Closed delan closed 2 years ago
(summary for meeting)
color:currentColor is always a special case. Normally it means the same thing as color:inherit, but for highlights, it means “the next highlight pseudo-element layer below”. The two questions here are: [see description]
The CSS Working Group just discussed highlights and color:currentcolor
.
So at least for gCS
, probably the simple answer is not having other highlights into account, so we always return consistent styles, I believe. I still don't think currentColor
behaving oddly is great though.
Thanks @emilio, so if I understand you correctly, color:currentColor (as currently specified) would be the originating element’s ‘color’ in gCS, because we pretend that no other highlights are active? I can see this working better than @frivoal’s suggestion of using the color of the first highlighted character/replaced, because it avoids the problems of nothing being highlighted or ::selection/::target-text leaking ::{spelling,grammar}-error.
My only question then would be whether it’s ok to make gCS(highlights) be so “hypothetical” and different from reality? I don’t really mind, but I also have never really used gCS that often, so I don’t know.
As for making color:currentColor equivalent to color:inherit for highlights (like it is for non-highlight styles), I guess there are two ways we can do that. One is to drop the functionality that color:currentColor provides, and the other is what I think you said on IRC, change highlight inheritance so we inherit (all?) from the next active highlight layer below.
If you mean the first, maybe @fantasai or @frivoal can comment on the intent behind color:currentColor, and whether we really need it (or can provide it some other way). If the second, can you elaborate on how we would do that while also being able to inherit styles from the same highlight in the parent?
The language about currentColor
in CSS Pseudo is odd indeed and makes currentColor
even more complex than it already is.
(As an aside, why is CSS Pseudo 4 linking to CSS Color 3 for the color definitions?)
If you mean the first, maybe @fantasai or @frivoal can comment on the intent behind color:currentColor, and whether we really need it (or can provide it some other way).
I remembered the use case this was important for btw! With ::spelling-error and ::grammar-error, typical styles are to add a red or green squiggly line without changing the background or foreground color. The former is trivial (initial/transparent), but the latter needs some way of grabbing the ‘color’ that would have been used prior to the highlight, otherwise every misspelled word would become initial/black (#6779).
The language about
currentColor
in CSS Pseudo is odd indeed and makescurrentColor
even more complex than it already is.
I agree, though I fear this might end up being the least complicated way to solve that problem.
(As an aside, why is CSS Pseudo 4 linking to CSS Color 3 for the color definitions?)
No idea personally… I’m not yet familiar with our conventions around spec levels. Should we link to level 4 or 5?
The CSS Working Group just discussed Highlights and currentcolor
, and agreed to the following:
RESOLVED: 'color: currentColor' on a highlight takes the next *active* highlight color, so that text is drawn as if highlight weren't taking effect
RESOLVED: getComptuedStyle() with a highlight pseudo takes color as if that highlight applied and no other highlight applied
https://drafts.csswg.org/css-pseudo-4/#highlight-text
When we choose the “next highlight pseudo-element layer below”, do we consider only the layers that are actively highlighting the content in question? I think it makes sense to do so, in order for color:currentColor to effectively mean “highlighting with this pseudo doesn’t change the foreground color”. Otherwise, color:currentColor on ::selection always yields ::target-text’s default foreground color, even when that’s irrelevant to the content.
If so, what is the result of
getComputedStyle(..., "::selection").color
? The problem is that we need the resolved value, which would be indeterminate for a highlight with color:currentColor. Even if the active highlights were the same throughout the whole originating element, giving us a single unambiguous answer, we can only expose that answer if it didn’t come from ::spelling-error or ::grammar-error (#highlight-security).(cc @mrego, @frivoal)