Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[css-color-adjust-1] Define what happens to SVG in forced colors mode #3855

Closed
fantasai opened this issue Apr 19, 2019 · 9 comments
Closed

Comments

@fantasai
Copy link
Collaborator

It's not clear what should happen to SVG elements in forced colors mode. Do text content elements get backplates? Is anything else affected? What do we need to put in the spec to correctly handle SVG?

@fantasai fantasai added the css-color-adjust-1 Current Work label Apr 19, 2019
@fantasai
Copy link
Collaborator Author

Specced that <svg> elements get forced-color-adjust: none while <text> and <foreignObject> turn it back to auto for now. @AmeliaBR and @atanassov might have further comments on what should happen here...

@AmeliaBR
Copy link
Contributor

Setting forced-color-adjust: none on SVG elements by default would break any SVG that uses currentColor for accessibility purposes (to intentionally sync with any forced color changes). So that's a definite no-go.

That said, I wouldn't recommend that user agents directly adjust any colors on SVG other than for text, and they should only adjust text colors if they are adding in the glyph backplate effect to preserve contrast.

(Authors could of course use the media query & system colors to create a color scheme for data viz or icons that respects the user's palette while still going beyond what currentColor can do. See Eric Bailey's CSS-Tricks article for examples.)

@AmeliaBR
Copy link
Contributor

FYI, EdgeHTML currently doesn't do anything with SVG text when WHCM is on: no backplate, and no change to the fill color (unless the author is using fill: currentColor).

@AmeliaBR
Copy link
Contributor

To sum up my previous comment as a concrete recommendation:

  • Remove the current spec text defining UA stylesheet rules about forced-color-adjust and SVG elements.

  • Add an item to the list of Properties Affected by Forced Colors Mode, fill: currentColor !important; fill-opacity: 1 !important, but add a qualification that this should only apply for HTML elements and for SVG text elements (or descendants of text), and should only apply on SVG if the user agent is able to generate an opposing-color text backplate.

    The exact color of the backplate would as usual depend on the context — e.g., inside a <button>, where currentColor would be ButtonText, the backplate color would be ButtonFace.

@fantasai
Copy link
Collaborator Author

Setting forced-color-adjust: none on SVG elements by default would break any SVG that uses currentColor for accessibility purposes (to intentionally sync with any forced color changes). So that's a definite no-go.

Why would that break anything? It doesn't have any effect on <color> values.

@AmeliaBR
Copy link
Contributor

AmeliaBR commented May 21, 2019

Why would that break anything? It doesn't have any effect on <color> values.

It resets color and therefore currentColor & the ability of currentColor to sync according to the forced-color mode.

Currently, if I create an SVG icon and set it color: purple and fill: currentColor, the fill will change in high contrast mode to the WHCM text color or button color, depending on context. If you set forced-color-adjust: none on the same element, it would stay purple.

@kbabbitt
Copy link
Contributor

kbabbitt commented Aug 7, 2019

  • Add an item to the list of Properties Affected by Forced Colors Mode, fill: currentColor !important; fill-opacity: 1 !important, but add a qualification that this should only apply for HTML elements and for SVG text elements (or descendants of text), and should only apply on SVG if the user agent is able to generate an opposing-color text backplate.

+1 for fill-opacity: 1 !important (and stroke-opacity: 1 !important) being added for forced colors mode.

@alisonmaher
Copy link
Collaborator

I was hoping to re-address this issue, specifically regarding what should happen to SVG <text> in forced colors mode. After discussing this with @atanassov, there appear to be a couple concerns with setting forced-color-adjust: auto; for such elements:

  1. Adjusting the styles for SVG textual elements creates an inconsistent experience when the rest of the SVG element is not being styled for forced colors mode.
  2. More importantly, the backplate becomes difficult to define in this case. For example, what should the backplate look like for text on a path?

Considering this, I would suggest that we do not apply forced colors to SVG <text>, and only apply forced-color-adjust: auto; to <foreignObject> SVG elements.

@css-meeting-bot
Copy link
Member

The CSS Working Group just discussed [css-color-adjust-1] Define what happens to SVG in forced colors mode, and agreed to the following:

  • RESOLVED: Accept proposed definition
The full IRC log of that discussion <dael> Topic: [css-color-adjust-1] Define what happens to SVG in forced colors mode
<dael> github: https://github.com//issues/3855
<dael> Rossen_: I can introduce this
<dael> Rossen_: This issue defined how forced colors supposed to effect SVG. Previous resolution was that forced colors should apply to text element and foreign object element. foriegn object makes sense b/c switching to HTML and all forced color rules apply
<dael> Rossen_: Additonal complication and prop change is what seemed reasonable to expect text element effected by force colors but in effect when text gets forced color applied in addition a background plate should be rendered so overall contrast ratio is as defined through system. THis proved to be ineffective and counter intutive for svg
<dael> Rossen_: A few cases where this might make sense but in general since no svg elements except these are effected by forced colors overall effect becomes incongruent. prop revert including font
<dael> Rossen_: Computing backplate on a path is hard to define and deterimental. You either get bounding box is is more then necessary or you do per glyph which is bad
<dael> Rossen_: Prop: exclude text elemented of svg from being effected by force colors
<dael> chris: Agree, makes most sense
<dael> AmeliaBR: sgtm
<dael> AmeliaBR: Example in spec may be useful about using MQ to make SVG work with high contrast. Default it's best not tot ry and do too much
<dael> AmeliaBR: Do we need to call out foreign object or do colors naturally apply to content inside? Do we need ot add colors to the foreign object itself or enough content inside has the rules if it's html
<dael> fantasai: We should set force color adjust none on SVG root and switch to auto on foreign object
<dael> chris: agree [missed]
<AmeliaBR> +1 to fantasai's solution
<dael> chris: You don't want color value set outside inheriting in. Need to be explicitly set on foreign object
<fantasai> which is what's posted in the issue at https://github.com//issues/3855#issuecomment-485023552 :)
<dael> Rossen_: That's the impl we landed on. +1 to fantasai
<dael> Rossen_: Other suggestions or objections for that resolution?
<dael> RESOLVED: Accept proposed definition

atanassov added a commit that referenced this issue Feb 15, 2020
[css-color-adjust-1] Don't force colors on SVG text by default #3855
chromium-wpt-export-bot pushed a commit to web-platform-tests/wpt that referenced this issue Feb 18, 2020
As per the following spec resolution, SVG text no longer should be
adjusted in forced colors mode by default.
w3c/csswg-drafts#3855

Bug: 970285
Change-Id: I11a785f64ca6f7e7840b17d6b59d4ce9b9f8b4e1
chromium-wpt-export-bot pushed a commit to web-platform-tests/wpt that referenced this issue Feb 19, 2020
As per the following spec resolution, SVG text no longer should be
adjusted in forced colors mode by default.
w3c/csswg-drafts#3855

Bug: 970285
Change-Id: I11a785f64ca6f7e7840b17d6b59d4ce9b9f8b4e1
chromium-wpt-export-bot pushed a commit to web-platform-tests/wpt that referenced this issue Feb 19, 2020
As per the following spec resolution, SVG text no longer should be
adjusted in forced colors mode by default.
w3c/csswg-drafts#3855

Bug: 970285
Change-Id: I11a785f64ca6f7e7840b17d6b59d4ce9b9f8b4e1
chromium-wpt-export-bot pushed a commit to web-platform-tests/wpt that referenced this issue Feb 20, 2020
As per the following spec resolution, SVG text no longer should be
adjusted in forced colors mode by default.
w3c/csswg-drafts#3855

Bug: 970285
Change-Id: I11a785f64ca6f7e7840b17d6b59d4ce9b9f8b4e1
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2055431
Reviewed-by: Rune Lillesveen <futhark@chromium.org>
Commit-Queue: Alison Maher <almaher@microsoft.com>
Cr-Commit-Position: refs/heads/master@{#743163}
chromium-wpt-export-bot pushed a commit to web-platform-tests/wpt that referenced this issue Feb 20, 2020
As per the following spec resolution, SVG text no longer should be
adjusted in forced colors mode by default.
w3c/csswg-drafts#3855

Bug: 970285
Change-Id: I11a785f64ca6f7e7840b17d6b59d4ce9b9f8b4e1
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2055431
Reviewed-by: Rune Lillesveen <futhark@chromium.org>
Commit-Queue: Alison Maher <almaher@microsoft.com>
Cr-Commit-Position: refs/heads/master@{#743163}
pull bot pushed a commit to FreddyZeng/chromium that referenced this issue Feb 20, 2020
As per the following spec resolution, SVG text no longer should be
adjusted in forced colors mode by default.
w3c/csswg-drafts#3855

Bug: 970285
Change-Id: I11a785f64ca6f7e7840b17d6b59d4ce9b9f8b4e1
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2055431
Reviewed-by: Rune Lillesveen <futhark@chromium.org>
Commit-Queue: Alison Maher <almaher@microsoft.com>
Cr-Commit-Position: refs/heads/master@{#743163}
xeonchen pushed a commit to xeonchen/gecko that referenced this issue Feb 24, 2020
…ode, a=testonly

Automatic update from web-platform-tests
Don't adjust SVG text in forced colors mode

As per the following spec resolution, SVG text no longer should be
adjusted in forced colors mode by default.
w3c/csswg-drafts#3855

Bug: 970285
Change-Id: I11a785f64ca6f7e7840b17d6b59d4ce9b9f8b4e1
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2055431
Reviewed-by: Rune Lillesveen <futhark@chromium.org>
Commit-Queue: Alison Maher <almaher@microsoft.com>
Cr-Commit-Position: refs/heads/master@{#743163}

--

wpt-commits: ae1a412839f35155c7b697bcc022e8d2d094dc34
wpt-pr: 21846
gecko-dev-updater pushed a commit to marco-c/gecko-dev-comments-removed that referenced this issue Feb 25, 2020
…ode, a=testonly

Automatic update from web-platform-tests
Don't adjust SVG text in forced colors mode

As per the following spec resolution, SVG text no longer should be
adjusted in forced colors mode by default.
w3c/csswg-drafts#3855

Bug: 970285
Change-Id: I11a785f64ca6f7e7840b17d6b59d4ce9b9f8b4e1
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2055431
Reviewed-by: Rune Lillesveen <futharkchromium.org>
Commit-Queue: Alison Maher <almahermicrosoft.com>
Cr-Commit-Position: refs/heads/master{#743163}

--

wpt-commits: ae1a412839f35155c7b697bcc022e8d2d094dc34
wpt-pr: 21846

UltraBlame original commit: 0dd994bc04aafb09a3f7c66795f774f06bd3cd2d
moz-v2v-gh pushed a commit to mozilla/gecko-dev that referenced this issue Feb 25, 2020
…ode, a=testonly

Automatic update from web-platform-tests
Don't adjust SVG text in forced colors mode

As per the following spec resolution, SVG text no longer should be
adjusted in forced colors mode by default.
w3c/csswg-drafts#3855

Bug: 970285
Change-Id: I11a785f64ca6f7e7840b17d6b59d4ce9b9f8b4e1
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2055431
Reviewed-by: Rune Lillesveen <futhark@chromium.org>
Commit-Queue: Alison Maher <almaher@microsoft.com>
Cr-Commit-Position: refs/heads/master@{#743163}

--

wpt-commits: ae1a412839f35155c7b697bcc022e8d2d094dc34
wpt-pr: 21846
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants