Skip to content

Commit

Permalink
[css-color-adjust-1] Per WG resolution, add forced-color-adjust:prese…
Browse files Browse the repository at this point in the history
…rve-parent-color. Fixes #6310
  • Loading branch information
tabatkins committed Jun 16, 2021
1 parent 207dd1e commit 93a3db4
Showing 1 changed file with 27 additions and 3 deletions.
30 changes: 27 additions & 3 deletions css-color-adjust-1/Overview.bs
Original file line number Diff line number Diff line change
Expand Up @@ -559,7 +559,7 @@ Opting Out of a Forced Color Palette: the 'forced-color-adjust' property {#force

<pre class=propdef>
Name: forced-color-adjust
Value: auto | none
Value: auto | none | preserve-parent-color
Initial: auto
Applies to: all elements and text
Inherited: yes
Expand Down Expand Up @@ -587,14 +587,31 @@ Opting Out of a Forced Color Palette: the 'forced-color-adjust' property {#force
and need to make changes to the UA’s default adjustments
to provide a more appropriate user experience
for those elements.

: <dfn>preserve-parent-color</dfn>
:: In [=forced colors mode=],
if the 'color' property inherits from its parent
(i.e. there is no [=cascaded value=]
or the [=cascaded value=] is ''currentColor'', ''inherit'',
or another keyword that inherits from the parent),
then it computes to the [=used value|used=] color of its parent’s 'color' value.

In all other respects, behaves the same as ''none''.

Note: This value is intended solely to get a reasonable behavior
from embedded SVG elements that expect to receive the outer document's text color
(and stay consistent with adjustments from [=forced colors mode=]),
while otherwise defaulting SVGs
to preserving their exact colors,
as [=forced colors mode=] can't generally be usefully applied to illustrations.
</dl>

In order to not break SVG content,
UAs are expected to add the following rules to their UA style sheet:

<pre>
<pre highlight=css>
@namespace "http://www.w3.org/2000/svg";
svg|svg { forced-color-adjust: none; }
svg|svg { forced-color-adjust: preserve-parent-color; }
svg|foreignObject { forced-color-adjust: auto; }
</pre>

Expand Down Expand Up @@ -758,6 +775,13 @@ Changes {#changes}
<a href="https://github.com/w3c/csswg-drafts/issues/5987">Issue 5987</a>)
* Renamed 'color-adjust' to 'print-color-adjust', and re-added 'color-adjust' as an alias/shorthand.
(<a href="https://github.com/w3c/csswg-drafts/issues/3880">Issue 3880</a>)
* Added the ''preserve-parent-color'' keyword to 'forced-color-adjust'
and adjusted the stylesheet to use it,
to preserve the general "don't mess with SVG colors" behavior
without breaking use-cases like SVG icons
that want to use the inherited text color
<em>after</em> [=forced colors mode=] has taken effect.
(<a href="https://github.com/w3c/csswg-drafts/issues/6310">Issue 6310</a>)

Changes since the <a href="https://www.w3.org/TR/2020/WD-css-color-adjust-1-20200402/">2 April 2020 Working Draft</a>:

Expand Down

0 comments on commit 93a3db4

Please sign in to comment.