Skip to content

Commit 93a3db4

Browse files
committed
[css-color-adjust-1] Per WG resolution, add forced-color-adjust:preserve-parent-color. Fixes w3c#6310
1 parent 207dd1e commit 93a3db4

File tree

1 file changed

+27
-3
lines changed

1 file changed

+27
-3
lines changed

css-color-adjust-1/Overview.bs

+27-3
Original file line numberDiff line numberDiff line change
@@ -559,7 +559,7 @@ Opting Out of a Forced Color Palette: the 'forced-color-adjust' property {#force
559559

560560
<pre class=propdef>
561561
Name: forced-color-adjust
562-
Value: auto | none
562+
Value: auto | none | preserve-parent-color
563563
Initial: auto
564564
Applies to: all elements and text
565565
Inherited: yes
@@ -587,14 +587,31 @@ Opting Out of a Forced Color Palette: the 'forced-color-adjust' property {#force
587587
and need to make changes to the UA’s default adjustments
588588
to provide a more appropriate user experience
589589
for those elements.
590+
591+
: <dfn>preserve-parent-color</dfn>
592+
:: In [=forced colors mode=],
593+
if the 'color' property inherits from its parent
594+
(i.e. there is no [=cascaded value=]
595+
or the [=cascaded value=] is ''currentColor'', ''inherit'',
596+
or another keyword that inherits from the parent),
597+
then it computes to the [=used value|used=] color of its parent’s 'color' value.
598+
599+
In all other respects, behaves the same as ''none''.
600+
601+
Note: This value is intended solely to get a reasonable behavior
602+
from embedded SVG elements that expect to receive the outer document's text color
603+
(and stay consistent with adjustments from [=forced colors mode=]),
604+
while otherwise defaulting SVGs
605+
to preserving their exact colors,
606+
as [=forced colors mode=] can't generally be usefully applied to illustrations.
590607
</dl>
591608

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

595-
<pre>
612+
<pre highlight=css>
596613
@namespace "http://www.w3.org/2000/svg";
597-
svg|svg { forced-color-adjust: none; }
614+
svg|svg { forced-color-adjust: preserve-parent-color; }
598615
svg|foreignObject { forced-color-adjust: auto; }
599616
</pre>
600617

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

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

0 commit comments

Comments
 (0)