Open emilio opened 2 years ago
This area is complex and I would like to avoid adding special-cases to the svg embedding case. It would be ideal if we could resolve the differences between svg and iframe embedding too.
For backwards compatibility (e.g., pages would become unreadable with a black background), we cannot let color-scheme
default to the preferred color scheme, so maybe it is best to disentangle the prefers-color-scheme
media query and color-scheme
? For example, color-scheme
could just control browser UX (described here), and prefers-color-scheme
could just return the OS dark mode setting or other user-set value. In this model, there are no differences between content in iframes vs svg. Embedded svg content with prefers-color-scheme
media queries would match the global setting.
The CSS Working Group just discussed Propagated preferred-color-scheme on SVG images
, and agreed to the following:
RESOLVED: do what Emilio said
RESOLVED: for the purposes of propagating prefers-color-scheme to the embedded page, if `color-scheme` is `normal` and there's no `color-scheme` meta tag, the propagated scheme is the preferred color-scheme of the embedder document
In https://github.com/w3c/csswg-drafts/issues/7213 we resolved for the preferred color-scheme for SVG images to be context dependent.
However what "context dependent" means can be a bit fuzzy. The way I implemented it in Firefox is using the used color-scheme.
That's usually fine, but for pages which don't use the
color-scheme
property or meta-tag it is a subtle behavior change, because all the SVG images become light (rather than the previous behavior, which is using the OS preferred color-scheme).@progers mentioned that they have data that indicates that usage of the
prefers-color-scheme
media query is much higher than the color-scheme property / meta tag, and we've seen one case of breakage already: https://bugzilla.mozilla.org/show_bug.cgi?id=1779874I think it'd be better to deal with this case a bit more subtly. Proposed behavior:
color-scheme
property or meta tag, then use that color-scheme to propagate to SVG images.prefers-color-scheme
matches), rather than the "used color scheme" which would be light.I think this makes sense because we're propagating a preference, rather than the used-color-scheme (so propagating the parent page preference for the normal case makes sense). For our internal use cases in Firefox it didn't quite matter because all internal pages support both light and dark mode.
I think this would be similarly-sensible behavior, and a bit more backwards-compatible. It means that we need to provide that extra definition ("effective color-scheme preference" or something?) on the spec.
Thoughts? cc @lilles @progers @smfr @tabatkins