Intent to Ship: CSS Color Adjust: 'only' keyword for color-scheme

118 views
Skip to first unread message

Rune Lillesveen

unread,
Oct 27, 2021, 10:10:14 AM10/27/21
to blink-dev

Contact emails

fut...@chromium.org

Specification

https://drafts.csswg.org/css-color-adjust/#color-scheme-prop

Summary

The 'only' keyword has been re-added to the specification for color-scheme as a way of per-element opt-out of color-scheme override like forced darkening.

Previously, both declarations below would force the div element into color-scheme dark and apply forced darkening. With this change, the second declaration would opt-out of forced darkening and keep the used color-scheme 'light'.

div { color-scheme: light } div { color-scheme: only light } will keep the color-scheme for the element light and opt-out of forced darkening.


This feature is already enabled as part of an original trial in M96: https://chromestatus.com/features/5672533924773888



Blink component

Blink>CSS

TAG review

N/A Change to existing API already covered by CSS spec

TAG review status

Not applicable

Risks



Interoperability and Compatibility

Low risk: WebView has shipped forced darkening. This change means content loaded in WebViews may opt out of forced darkening with "color-scheme: only light;" where it previously would see 'only' as an unrecognized color-scheme and for 'light' into 'dark'. Low risk: Making 'only' a recognized keyword instead of a color-scheme means the parser will no longer accept multiple instances of 'only' in the same declaration, so declarations like this will be dropped: div { color-scheme: only only dark } WebKit already recognized 'only' as an opt-out of forced darkening keyword.



Gecko: In development (https://bugzilla.mozilla.org/show_bug.cgi?id=1576289) Development of the color-scheme property in progress. At least blocker issues are being fixed.

WebKit: Shipped/Shipping

Web developers: No signals


Debuggability

The existing property and the new keyword should automatically be supported in devtools. There is possibly a need for force dark / color-scheme override debugging support in devtools, but that is out of scope for this minor change.



Is this feature fully tested by web-platform-tests?

Yes

Changes made to tests under https://wpt.fyi/results/css/css-color-adjust/parsing to account for spec changes for 'only'.

Web platform tests do not support running with color-scheme overrides. A couple of Blink-specific rendering tests have been added to run under virtual/dark-mode-*

Flag name

CSSColorSchemeOnly (Blink runtime flag)

Requires code in //chrome?

False

Tracking bug

https://crbug.com/1224806

Estimated milestones

DevTrial on desktop96
DevTrial on android96
DevTrial on Webview96


Link to entry on the Chrome Platform Status

https://chromestatus.com/feature/5157621012103168

This intent message was generated by Chrome Platform Status.

--
Rune Lillesveen

Rune Lillesveen

unread,
Oct 27, 2021, 10:12:23 AM10/27/21
to blink-dev
On Wed, Oct 27, 2021 at 4:09 PM Rune Lillesveen <fut...@chromium.org> wrote:

Debuggability

The existing property and the new keyword should automatically be supported in devtools. There is possibly a need for force dark / color-scheme override debugging support in devtools, but that is out of scope for this minor change.


Manuel Rego Casasnovas

unread,
Oct 28, 2021, 6:11:55 AM10/28/21
to Rune Lillesveen, blink-dev
Hi,

Some comments inline.

On 27/10/2021 16:09, Rune Lillesveen wrote:
> Summary
>
> The 'only' keyword has been re-added to the specification for
> color-scheme as a way of per-element opt-out of color-scheme override
> like forced darkening.

I guess this is the CSSWG discussion about re-adding it:
https://github.com/w3c/csswg-drafts/issues/5089

> Previously, both declarations below would force the div element into
> color-scheme dark and apply forced darkening. With this change, the
> second declaration would opt-out of forced darkening and keep the used
> color-scheme 'light'.
>
> div { color-scheme: light } div { color-scheme: only light } will keep
> the color-scheme for the element light and opt-out of forced darkening.

Let me clarify this comment, this is happening when we're in forced
darkening, am I right?
First I read it too quickly and "color-scheme: light" forcing the DIV
into color-scheme dark was weird.

> This feature is already enabled as part of an original trial in M96:
> https://chromestatus.com/features/5672533924773888
> <https://chromestatus.com/features/5672533924773888>

Do we have any results to comment from the origin trial? Or it was
mostly for auto dark mode and this was just a small bit of it?

> Gecko: In development
> (https://bugzilla.mozilla.org/show_bug.cgi?id=1576289
> <https://bugzilla.mozilla.org/show_bug.cgi?id=1576289>) Development of
> the color-scheme property in progress. At least blocker issues are being
> fixed.

Not sure if this is in development, as there seems to be not recent
activity on the bug; but they indeed look interested in implementing
color-scheme property. Do we have any feedback from Mozilla about this
"only" keyword?

Cheers,
Rego

Rune Lillesveen

unread,
Oct 28, 2021, 7:14:19 AM10/28/21
to Manuel Rego Casasnovas, Peter Beverloo, Emilio Cobos Álvarez, blink-dev
On Thu, Oct 28, 2021 at 12:11 PM Manuel Rego Casasnovas <re...@igalia.com> wrote:
Hi,

Some comments inline.

On 27/10/2021 16:09, Rune Lillesveen wrote:
>         Summary
>
> The 'only' keyword has been re-added to the specification for
> color-scheme as a way of per-element opt-out of color-scheme override
> like forced darkening.

I guess this is the CSSWG discussion about re-adding it:
https://github.com/w3c/csswg-drafts/issues/5089

Correct.

> Previously, both declarations below would force the div element into
> color-scheme dark and apply forced darkening. With this change, the
> second declaration would opt-out of forced darkening and keep the used
> color-scheme 'light'.
>
> div { color-scheme: light } div { color-scheme: only light } will keep
> the color-scheme for the element light and opt-out of forced darkening.

Let me clarify this comment, this is happening when we're in forced
darkening, am I right?
First I read it too quickly and "color-scheme: light" forcing the DIV
into color-scheme dark was weird.
 
Correct, when we're in forced darkening, or color-scheme override which is the term used by the specification.

> This feature is already enabled as part of an original trial in M96:
> https://chromestatus.com/features/5672533924773888
> <https://chromestatus.com/features/5672533924773888>

Do we have any results to comment from the origin trial? Or it was
mostly for auto dark mode and this was just a small bit of it?

That was mostly for auto dark mode, but Peter can confirm.

> Gecko: In development
> (https://bugzilla.mozilla.org/show_bug.cgi?id=1576289
> <https://bugzilla.mozilla.org/show_bug.cgi?id=1576289>) Development of
> the color-scheme property in progress. At least blocker issues are being
> fixed.

Not sure if this is in development, as there seems to be not recent
activity on the bug; but they indeed look interested in implementing
color-scheme property. Do we have any feedback from Mozilla about this
"only" keyword?

Emilio (added) has been fixing blocker issues, fixing tests, doing spec changes for <meta name="color-scheme=">, etc, which I took as a signal of Mozilla working on it.

--
Rune Lillesveen

Emilio Cobos Álvarez

unread,
Oct 29, 2021, 3:09:24 PM10/29/21
to Rune Lillesveen, Manuel Rego Casasnovas, Peter Beverloo, blink-dev
Yeah, indeed. I guess my only question about the only keyword is whether
it'd be applicable to printing as well.

In particular, Chrome right now respects <meta name=color-scheme
content=dark> while printing, but it might be reasonable for UAs to
force it to light in that case, in order to save ink...

I guess `only` could also serve as a hint for the UA to not do such
thing... But then again we already have a way to opt out of similar
adjustments with `color-adjust: exact`. Was extending / expanding the
scope of the `color-adjust` property for this, instead of adding an
`only` value to `color-scheme` considered?

-- Emilio

> --
> Rune Lillesveen
>
> --
> You received this message because you are subscribed to the Google
> Groups "blink-dev" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to blink-dev+...@chromium.org
> <mailto:blink-dev+...@chromium.org>.
> To view this discussion on the web visit
> https://groups.google.com/a/chromium.org/d/msgid/blink-dev/CACuPfeTAFoyWbcQxnnHqhGcUWoZyOrBtfc%2BjcgnUVESnoSyPYw%40mail.gmail.com <https://groups.google.com/a/chromium.org/d/msgid/blink-dev/CACuPfeTAFoyWbcQxnnHqhGcUWoZyOrBtfc%2BjcgnUVESnoSyPYw%40mail.gmail.com?utm_medium=email&utm_source=footer>.

Daniel Bratell

unread,
Nov 4, 2021, 2:49:57 PM11/4/21
to Emilio Cobos Álvarez, Rune Lillesveen, Manuel Rego Casasnovas, Peter Beverloo, blink-dev
LGTM1

/Daniel

Manuel Rego Casasnovas

unread,
Nov 4, 2021, 3:19:38 PM11/4/21
to Daniel Bratell, Emilio Cobos Álvarez, Rune Lillesveen, Peter Beverloo, blink-dev
LGTM2, it's nice we're catching up with WebKit.

I still miss the whole picture in the spec with all the properties and
different values: https://drafts.csswg.org/css-color-adjust/
Maybe a good explainer for the whole thing would be welcomed.

Cheers,
Rego

Chris Harrelson

unread,
Nov 4, 2021, 3:20:07 PM11/4/21
to Manuel Rego Casasnovas, Daniel Bratell, Emilio Cobos Álvarez, Rune Lillesveen, Peter Beverloo, blink-dev
LGTM3

To unsubscribe from this group and stop receiving emails from it, send an email to blink-dev+...@chromium.org.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/blink-dev/e80ef8af-d68e-52ea-5238-773739cccb78%40igalia.com.

Rune Lillesveen

unread,
Nov 10, 2021, 8:54:30 AM11/10/21
to Emilio Cobos Álvarez, Manuel Rego Casasnovas, Peter Beverloo, blink-dev
I don't know. I wasn't aware of color-adjust actually.

Some considerations:

- WebKit already shipping 'only' as an opt-out for color-scheme override
- We already have a separate opt-out mechanism for forced color adjust as well: https://drafts.csswg.org/css-color-adjust-1/#forced-color-adjust-prop

--
Rune Lillesveen

Rune Lillesveen

unread,
Nov 10, 2021, 9:05:14 AM11/10/21
to Emilio Cobos Álvarez, Manuel Rego Casasnovas, Peter Beverloo, blink-dev
I see that the color-adjust shorthand is marked as deprecated in the draft. I guess the alternative to 'only' would be to have a separate 'color-scheme-color-adjust' property, then?

--
Rune Lillesveen

Reply all
Reply to author
Forward
0 new messages