w3c / csswg-drafts

CSS Working Group Editor Drafts
https://drafts.csswg.org/
Other
4.5k stars 666 forks source link

[css-color] [css-color-adjust] Make system colors fully resolve (but flag they were system colors) thus reversing the resolution of #3847 #6773

Closed emilio closed 2 years ago

emilio commented 3 years ago

In https://github.com/w3c/csswg-drafts/issues/3847 it was resolved that system colors would compute to themselves. The argument for that seems sensible (which is that color-scheme would be automatically honored for them while inheriting).

However I'm not so sure that's great behavior (plus there are still open issues from that change like https://github.com/w3c/csswg-drafts/issues/5780).

In particular, in order to guarantee contrast, you need to use system color pairs (the foreground and the background), such as:

div {
  background-color: Canvas;
  color: CanvasText;
}

If color-scheme changes, but the author doesn't specify a background, making system colors compute to themselves at computed-value time breaks contrast (rendered):

<!doctype html>
<style>
  :root { color-scheme: dark }
  span { color-scheme: light }
</style>
I'm dark, and <span>I'm light</span>

The span should be dark text over dark background per spec, since it inherits the initial color which is canvastext, which is undesirable.

That's clearly not how browsers are working today, which confuses me because I thought Chrome implemented this change.

I'd expect this test-case to render per spec the same as the following (rendered):

<!doctype html>
<style>
  :root { color-scheme: dark }
  span { color-scheme: light; color: CanvasText }
</style>
I'm dark, and <span>I'm light</span>

(which is clearly undesirable, and not what's going on).

Can you explain what's going on here @futhark / @andruud / @kbabbitt / @tabatkins?

cc @smfr

svgeesus commented 2 years ago
fantasai: The flag part is an internal impl detail; we just need to spec that these colors, even tho they resolve, need to stay as-is in forced colors mode. chris: suggested wording? fantasai: I can come up with some, yeah

I will wait for the suggested wording from @fantasai before publishing

fantasai commented 2 years ago

@svgeesus How about just:

However, such colors must not be altered by forced color mode.

?

emilio commented 2 years ago

I sent an update to the relevant WPT here: https://github.com/web-platform-tests/wpt/pull/34170

svgeesus commented 2 years ago

Closing as WPT now in sync, thanks @emilio