Request for position: CSS highlight inheritance (css-pseudo #highlight-cascade)
I’m seeking WebKit’s position on the “Cascading and Per-Element Highlight Styles” section of css-pseudo-4 [0]. Most impls (with the sole exception of Presto) have historically not propagated highlight styles through the element tree. This has meant that only the global ::selection selector (*::selection) worked intuitively, and made it awkward to style the highlights on some subset of elements. Authors had to repeat each selector with a “*” descendant, and ensure that “overriding” rules win the cascade. For example, to highlight content under p.foo in yellow, but content under <em> anywhere in the document in cyan, one might: p.foo::selection, p.foo *::selection { background-color: yellow; } em:not(#specificity)::selection, em:not(#specificity) *::selection { background-color: cyan; } The spec gives highlights an inheritance-based processing model, where all properties (inherited or otherwise) default to the value on the parent’s highlight. Note that the spec’s processing model is no longer cascade-based, as of w3c/csswg-drafts#2474 [1]. We believe the compat risk is minimal, because the new model won’t break existing content with global ::selection rules, nor will it break rules that use the cascade to build an ersatz “propagation” like the example above. As far as we can tell, only content that relies on descendants of a highlight-styled element being reset to initial styles should be affected. [0] https://drafts.csswg.org/css-pseudo-4/#highlight-cascade [1] https://github.com/w3c/csswg-drafts/issues/2474 Cheers, Delan Azabani Igalia // web platform
On 2021-07-01 10:22, Delan Azabani wrote:
I’m seeking WebKit’s position on the “Cascading and Per-Element Highlight Styles” section of css-pseudo-4 [0].
Just following up on this. Any thoughts? Note that there’s a new compat risk scenario that I wasn’t previously aware of (<https://github.com/w3c/csswg-drafts/issues/6774>), so there are actually two kinds of content that might be adversely affected: 1. content somehow relying on descendants being reset to initial ::selection styles (and not using universal ::selection rules) 2. content relying on combining one highlight color explicitly set on ::selection with another defaulted from the originating element
participants (1)
-
Delan Azabani