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

Consider changing specified behavior of <meta name=color-scheme> to match WebKit #7213

Closed
emilio opened this issue Oct 13, 2021 · 5 comments · Fixed by #7226
Closed

Consider changing specified behavior of <meta name=color-scheme> to match WebKit #7213

emilio opened this issue Oct 13, 2021 · 5 comments · Fixed by #7226
Labels
interop Implementations are not interoperable with each other normative change topic: rendering

Comments

@emilio
Copy link
Contributor

emilio commented Oct 13, 2021

https://html.spec.whatwg.org/#meta-color-scheme says:

If parsed is a valid CSS 'color-scheme' property value, then treat that value as a declaration of the CSS 'color-scheme' property on element's root, cascaded as a presentational hint, and return.

This does match what Chrome (Dev Edition at least) does, but doesn't match what Safari does, see test-case:

<!doctype html>
<meta name="color-scheme" content="dark">
<div style="color-scheme: initial"></div>
<pre><script>
  document.writeln(getComputedStyle(document.documentElement).colorScheme);
  document.writeln(getComputedStyle(document.querySelector("div")).colorScheme);
</script></pre>

I think the Safari behavior (which AFAICT is basically "changing the used value of color-scheme: normal") is slightly preferable, for two reasons:

  • It allows the initial keyword (which computes to normal) to behave as an author would expect (reverting to the meta-specified color-scheme). With the current definition, once an element sets color-scheme explicitly, the <meta> value is forever lost in that subtree.
  • It allows <meta name=color-scheme> to affect stuff that doesn't inherit from the root element (like ::backdrop).
  • It is less weird (I don't think we have precedent for a pres hint on an element based on a meta tag).

The CSS spec is down, but the normal definition says right now:

Indicates that the element doesn’t support color schemes at all, and so the element should be rendered with the browser’s default color scheme. (This is typically, tho not always, similar to light.)

I propose to remove the parenthetical, and perhaps change "browser's default color scheme" by "page's default color scheme". Then HTML would set the "page's default color-scheme" based on the meta tag's value.

This matches, I believe, what WebKit is doing, and seems to be a simpler model for how it should work, IMO. What do you think?

cc @lilles @hober @smfr @dholbert

@tabatkins
Copy link
Contributor

This seems fine to me, if impls are okay with it. It would mean moving the concept of the "browser default" color scheme here into HTML, to cover the case when meta color-scheme isn't specified.

@pxlcoder
Copy link

Hi @emilio,

I work on WebKit's color-scheme implementation, and can confirm that the behavior you described is what WebKit is doing.

I agree that WebKit's current behavior is preferable to the CSS spec, for all the reasons you mentioned.

@annevk annevk added interop Implementations are not interoperable with each other normative change topic: rendering labels Oct 13, 2021
@lilles
Copy link
Contributor

lilles commented Oct 14, 2021

IIUC, the effect of this change (apart from computed values via CSSOM) is that the used value for the color-scheme would be different for:

  • Setting color-scheme to normal or initial on an element
  • ::backdrop which is currently not affected by a color-scheme meta since it doesn't inherit the root element

I don't think that should be a back compat concern for Blink.

Color-scheme override probably needs some spec clarifications. In the case where we have:

<meta name="color-scheme" content="dark light">

All elements have color-scheme:normal as their computed values. And the spec says:

"If the element does not support that color scheme, the user agent must also auto-adjust other colors into this chosen color scheme"

If the computed value is normal, the element does not currently count as supporting the dark color scheme, but since normal is causing a used value of dark we should not auto-adjust any colors in that case. Otherwise, that would be a breaking change for Blink.

@emilio
Copy link
Contributor Author

emilio commented Oct 14, 2021

Right, I agree we shouldn't auto-adjust in that case. Seems everyone is ok with such a change? That's awesome :)

I can try to write PRs + tests then :)

emilio added a commit to emilio/html that referenced this issue Oct 15, 2021
emilio added a commit to emilio/csswg-drafts that referenced this issue Oct 15, 2021
emilio added a commit to emilio/csswg-drafts that referenced this issue Oct 15, 2021
This allows HTML to "set" the used value of the color-scheme property,
via a meta tag.

Part of whatwg/html#7213
Closes w3c#6726
emilio added a commit to emilio/html that referenced this issue Oct 15, 2021
@emilio
Copy link
Contributor Author

emilio commented Oct 15, 2021

I wrote some PRs:

If everyone is on board (specially @lilles / @tabatkins since Blink would be the one changing behavior) I can file a crbug (and hopefully get these merged).

emilio added a commit to emilio/csswg-drafts that referenced this issue Oct 15, 2021
This allows HTML to "set" the used value of the color-scheme property,
via a meta tag.

Part of whatwg/html#7213
Closes w3c#6726
emilio added a commit to emilio/html that referenced this issue Oct 15, 2021
emilio added a commit to emilio/html that referenced this issue Oct 16, 2021
emilio added a commit to w3c/csswg-drafts that referenced this issue Oct 16, 2021
This allows HTML to "set" the used value of the color-scheme property,
via a meta tag.

Part of whatwg/html#7213
Closes #6726
domenic pushed a commit that referenced this issue Oct 18, 2021
dandclark pushed a commit to dandclark/html that referenced this issue Dec 4, 2021
chromium-wpt-export-bot pushed a commit to web-platform-tests/wpt that referenced this issue Mar 30, 2022
The HTML specification changed to use the meta color-scheme as a page's
supported color schemes instead of presentation style for the root
element. This means the color-scheme meta no longer affects the
computed for an initial value root element, but still affects the used
color-scheme the same way as before.

There is one used value change, and that is when resetting the
color-scheme to "normal" down the tree, which now follows the meta
element instead of resolving to a "light" color-scheme.

We now align with Gecko and Safari.

See the whatwg issue[1] for a discussion.

[1] whatwg/html#7213

Bug: 1260617
Change-Id: Ic72a2dead75257650f8d99cc5f30f13b7005ea41
chromium-wpt-export-bot pushed a commit to web-platform-tests/wpt that referenced this issue Mar 30, 2022
The HTML specification changed to use the meta color-scheme as a page's
supported color schemes instead of presentation style for the root
element. This means the color-scheme meta no longer affects the
computed for an initial value root element, but still affects the used
color-scheme the same way as before.

There is one used value change, and that is when resetting the
color-scheme to "normal" down the tree, which now follows the meta
element instead of resolving to a "light" color-scheme.

We now align with Gecko and Safari.

See the whatwg issue[1] for a discussion.

[1] whatwg/html#7213

Bug: 1260617
Change-Id: Ic72a2dead75257650f8d99cc5f30f13b7005ea41
chromium-wpt-export-bot pushed a commit to web-platform-tests/wpt that referenced this issue Mar 31, 2022
The HTML specification changed to use the meta color-scheme as a page's
supported color schemes instead of presentation style for the root
element. This means the color-scheme meta no longer affects the
computed for an initial value root element, but still affects the used
color-scheme the same way as before.

There is one used value change, and that is when resetting the
color-scheme to "normal" down the tree, which now follows the meta
element instead of resolving to a "light" color-scheme.

We now align with Gecko and Safari.

See the whatwg issue[1] for a discussion.

[1] whatwg/html#7213

Bug: 1260617
Change-Id: Ic72a2dead75257650f8d99cc5f30f13b7005ea41
chromium-wpt-export-bot pushed a commit to web-platform-tests/wpt that referenced this issue Mar 31, 2022
The HTML specification changed to use the meta color-scheme as a page's
supported color schemes instead of presentation style for the root
element. This means the color-scheme meta no longer affects the
computed for an initial value root element, but still affects the used
color-scheme the same way as before.

There is one used value change, and that is when resetting the
color-scheme to "normal" down the tree, which now follows the meta
element instead of resolving to a "light" color-scheme.

We now align with Gecko and Safari.

See the whatwg issue[1] for a discussion.

[1] whatwg/html#7213

Bug: 1260617
Change-Id: Ic72a2dead75257650f8d99cc5f30f13b7005ea41
chromium-wpt-export-bot pushed a commit to web-platform-tests/wpt that referenced this issue Mar 31, 2022
The HTML specification changed to use the meta color-scheme as a page's
supported color schemes instead of presentation style for the root
element. This means the color-scheme meta no longer affects the
computed for an initial value root element, but still affects the used
color-scheme the same way as before.

There is one used value change, and that is when resetting the
color-scheme to "normal" down the tree, which now follows the meta
element instead of resolving to a "light" color-scheme.

We now align with Gecko and Safari.

See the whatwg issue[1] for a discussion.

[1] whatwg/html#7213

Bug: 1260617
Change-Id: Ic72a2dead75257650f8d99cc5f30f13b7005ea41
aarongable pushed a commit to chromium/chromium that referenced this issue Mar 31, 2022
The HTML specification changed to use the meta color-scheme as a page's
supported color schemes instead of presentation style for the root
element. This means the color-scheme meta no longer affects the
computed for an initial value root element, but still affects the used
color-scheme the same way as before.

There is one used value change, and that is when resetting the
color-scheme to "normal" down the tree, which now follows the meta
element instead of resolving to a "light" color-scheme.

We now align with Gecko and Safari.

See the whatwg issue[1] for a discussion.

[1] whatwg/html#7213

Bug: 1260617
Change-Id: Ic72a2dead75257650f8d99cc5f30f13b7005ea41
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3560051
Reviewed-by: Anders Hartvoll Ruud <[email protected]>
Commit-Queue: Rune Lillesveen <[email protected]>
Cr-Commit-Position: refs/heads/main@{#987452}
chromium-wpt-export-bot pushed a commit to web-platform-tests/wpt that referenced this issue Mar 31, 2022
The HTML specification changed to use the meta color-scheme as a page's
supported color schemes instead of presentation style for the root
element. This means the color-scheme meta no longer affects the
computed for an initial value root element, but still affects the used
color-scheme the same way as before.

There is one used value change, and that is when resetting the
color-scheme to "normal" down the tree, which now follows the meta
element instead of resolving to a "light" color-scheme.

We now align with Gecko and Safari.

See the whatwg issue[1] for a discussion.

[1] whatwg/html#7213

Bug: 1260617
Change-Id: Ic72a2dead75257650f8d99cc5f30f13b7005ea41
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3560051
Reviewed-by: Anders Hartvoll Ruud <[email protected]>
Commit-Queue: Rune Lillesveen <[email protected]>
Cr-Commit-Position: refs/heads/main@{#987452}
chromium-wpt-export-bot pushed a commit to web-platform-tests/wpt that referenced this issue Mar 31, 2022
The HTML specification changed to use the meta color-scheme as a page's
supported color schemes instead of presentation style for the root
element. This means the color-scheme meta no longer affects the
computed for an initial value root element, but still affects the used
color-scheme the same way as before.

There is one used value change, and that is when resetting the
color-scheme to "normal" down the tree, which now follows the meta
element instead of resolving to a "light" color-scheme.

We now align with Gecko and Safari.

See the whatwg issue[1] for a discussion.

[1] whatwg/html#7213

Bug: 1260617
Change-Id: Ic72a2dead75257650f8d99cc5f30f13b7005ea41
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3560051
Reviewed-by: Anders Hartvoll Ruud <[email protected]>
Commit-Queue: Rune Lillesveen <[email protected]>
Cr-Commit-Position: refs/heads/main@{#987452}
moz-v2v-gh pushed a commit to mozilla/gecko-dev that referenced this issue Apr 11, 2022
… schemes, a=testonly

Automatic update from web-platform-tests
Make color-scheme meta affect all normal schemes

The HTML specification changed to use the meta color-scheme as a page's
supported color schemes instead of presentation style for the root
element. This means the color-scheme meta no longer affects the
computed for an initial value root element, but still affects the used
color-scheme the same way as before.

There is one used value change, and that is when resetting the
color-scheme to "normal" down the tree, which now follows the meta
element instead of resolving to a "light" color-scheme.

We now align with Gecko and Safari.

See the whatwg issue[1] for a discussion.

[1] whatwg/html#7213

Bug: 1260617
Change-Id: Ic72a2dead75257650f8d99cc5f30f13b7005ea41
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3560051
Reviewed-by: Anders Hartvoll Ruud <[email protected]>
Commit-Queue: Rune Lillesveen <[email protected]>
Cr-Commit-Position: refs/heads/main@{#987452}

--

wpt-commits: 2ffd24a48587d98f03f7f33faa8875ec888035e0
wpt-pr: 33416
jamienicol pushed a commit to jamienicol/gecko that referenced this issue Apr 14, 2022
… schemes, a=testonly

Automatic update from web-platform-tests
Make color-scheme meta affect all normal schemes

The HTML specification changed to use the meta color-scheme as a page's
supported color schemes instead of presentation style for the root
element. This means the color-scheme meta no longer affects the
computed for an initial value root element, but still affects the used
color-scheme the same way as before.

There is one used value change, and that is when resetting the
color-scheme to "normal" down the tree, which now follows the meta
element instead of resolving to a "light" color-scheme.

We now align with Gecko and Safari.

See the whatwg issue[1] for a discussion.

[1] whatwg/html#7213

Bug: 1260617
Change-Id: Ic72a2dead75257650f8d99cc5f30f13b7005ea41
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3560051
Reviewed-by: Anders Hartvoll Ruud <[email protected]>
Commit-Queue: Rune Lillesveen <[email protected]>
Cr-Commit-Position: refs/heads/main@{#987452}

--

wpt-commits: 2ffd24a48587d98f03f7f33faa8875ec888035e0
wpt-pr: 33416
mfreed7 pushed a commit to mfreed7/html that referenced this issue Jun 3, 2022
mjfroman pushed a commit to mjfroman/moz-libwebrtc-third-party that referenced this issue Oct 14, 2022
The HTML specification changed to use the meta color-scheme as a page's
supported color schemes instead of presentation style for the root
element. This means the color-scheme meta no longer affects the
computed for an initial value root element, but still affects the used
color-scheme the same way as before.

There is one used value change, and that is when resetting the
color-scheme to "normal" down the tree, which now follows the meta
element instead of resolving to a "light" color-scheme.

We now align with Gecko and Safari.

See the whatwg issue[1] for a discussion.

[1] whatwg/html#7213

Bug: 1260617
Change-Id: Ic72a2dead75257650f8d99cc5f30f13b7005ea41
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3560051
Reviewed-by: Anders Hartvoll Ruud <[email protected]>
Commit-Queue: Rune Lillesveen <[email protected]>
Cr-Commit-Position: refs/heads/main@{#987452}
NOKEYCHECK=True
GitOrigin-RevId: 0d60d42899d1eee9b1118700755bc85ae9376476
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
interop Implementations are not interoperable with each other normative change topic: rendering
Development

Successfully merging a pull request may close this issue.

5 participants