Re: [csswg-drafts] [css-pseudo] highlights and color:currentColor (#6818)

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`

<details><summary>The full IRC log of that discussion</summary>
&lt;fantasai> Topic: Highlights and currentcolor<br>
&lt;fantasai> delan: Started discussing this issue last week, but only got partway through<br>
&lt;fantasai> delan: about special case of setting 'color: currentColor'<br>
&lt;fantasai> delan: outside of highlights, it means 'color: inherit'<br>
&lt;fantasai> delan: for highlights, actually means something else<br>
&lt;fantasai> delan: there were 2 questions originally, now 3<br>
&lt;fantasai> delan: 1st question, double-checking, spec says when setting to currentColor, do we want to grab color from next highlight layer below regardless, or only active highlight layers<br>
&lt;fantasai> delan: fantasai said it only makes sense to use active highlight layer, and I think everyone agrees on that<br>
&lt;fantasai> florian: I'm a little unsure, agree with that assessment, but discussion last time suggested maybe there was a whole different way to think about this<br>
&lt;fantasai> delan: that's the 3rd question, whether this is the right way to solve the problem that it solves<br>
&lt;fantasai> delan: 2nd question is, if it is the next active highlight specifically, then what happens when you getComputedStyle?<br>
&lt;fantasai> delan: getComputedStyle needs to return resolved colors, so has to return an actual color<br>
&lt;TabAtkins> q+<br>
&lt;fantasai> delan: if you have an element with multiple underlying colors, what do you do<br>
&lt;fantasai> delan: currntly a few ideas on how to address that<br>
&lt;fantasai> delan: 3rd question, which emilio brought up, this exceptional behavior of currentColor for highlights is odd and complicated<br>
&lt;fantasai> delan: wondering if this was the right way to solve the problem, or if better way to solve the problem<br>
&lt;fantasai> delan: To clarify, best example of a use case for this, is the spelling and grammar error pseudo-elements<br>
&lt;fantasai> delan: a typical styling for that would be to add a red or green squiggly line to the text<br>
&lt;fantasai> delan: but you're just adding the decoration, you don't want to change the color of the text<br>
&lt;fantasai> delan: if you spell a word, still want to have the same text color<br>
&lt;cpn> s/cpn/chcunningham/<br>
&lt;fantasai> delan: but given way highlight painting works, if we didn't have this rule for currentColor, then there would be no way to highlight something without changing the color to 'initial' (black)<br>
&lt;fantasai> delan: it's complicated and an odd exception, but we need some solution to this problem<br>
&lt;fantasai> florian: one extra bit, suggestion last time is that this might be similar to ::first-line<br>
&lt;fantasai> florian: we don't redefine how currentColor works, we redefine what inherits from what<br>
&lt;fantasai> florian: if you set currentColor on first line, it'll get its color from ::first line<br>
&lt;emilio> q+<br>
&lt;Rossen_> ack TabAtkins<br>
&lt;fantasai> TabAtkins: I'm not certain about best way to handle property itself, but for purpose of getComputedStyle I think it's reasonable to say "pretend it's not selected at all", so just get underlying style<br>
&lt;delan> q+<br>
&lt;fantasai> TabAtkins: that seems the most straightforward, and doesn't leak info about spelling/grammar errors<br>
&lt;TabAtkins> scribe+ TabAtkins<br>
&lt;florian> q+ to ask clarification from Tab<br>
&lt;Rossen_> ack fantasai<br>
&lt;TabAtkins> fantasai: WE also have to consider that when you set the - we have paired cascading, and it sets to "the color it would have already been" it sets the background, so this behavior needs to represent that as well<br>
&lt;Rossen_> ack emilio<br>
&lt;fantasai> emilio: does this really only apply to currentCOlor? seems applies to inherited properties applied to highlights<br>
&lt;fantasai> emilio: maybe color is the only one atm<br>
&lt;fantasai> emilio: seems you'd have the same problem with text-fill and other things<br>
&lt;fantasai> emilio: so, in general, I think the right fix would be inheritance, but that might be annoying to implement<br>
&lt;Rossen_> q?<br>
&lt;Rossen_> ack delan<br>
&lt;fantasai> delan: Tab, is it true that you mean same thing as emilio, wrt Q2, my understanding is that if you ask for getComputedStyle for ::selection, we pretend everything is selected and no other highlights apply<br>
&lt;fantasai> TabAtkins: no opinion on pretending selected or pretending not selected, defer to impl on that question<br>
&lt;fantasai> TabAtkins: but ignoring any other highlights is the important bit<br>
&lt;fantasai> delan: sounds like a straightforward solution to that, I agree<br>
&lt;fantasai> delan: wrt Q3, inheritance and possible parallels with ::first-line<br>
&lt;fantasai> delan: I'm not that fresh on ::first-line and ::first-letter<br>
&lt;fantasai> delan: can someone explain how it would work for us to sometimes inherit from another highlight (grab color from ancestor highlight) while still inheriting within this inheritance tree for ???<br>
&lt;Rossen_> q?<br>
&lt;florian> q-<br>
&lt;fantasai> emilio: I think that's the hard part<br>
&lt;astearns> github: https://github.com/w3c/csswg-drafts/issues/6818<br>
&lt;fantasai> emilio: My selection styles inherit from my parent selection styles<br>
&lt;Rossen_> q?<br>
&lt;fantasai> emilio: E.g. selection style inherits from other highlight which inherits from regular text which inherits from parent selection style<br>
&lt;fantasai> delan: ...<br>
&lt;fantasai> delan: ::target-text inherits from ::selection style??<br>
&lt;fantasai> emilio: whichever order we decide on...<br>
&lt;fantasai> emilio: for simplicity, say we have ::selection and ::spelling-error<br>
&lt;fantasai> emilio: say ::selection inherits from ::spelling-error, and ::spelling-error inherits from parent ::spelling-error<br>
&lt;fantasai> emilio: I think that would get you the right behavior<br>
&lt;Rossen_> q?<br>
&lt;TabAtkins> fantasai: It would not, because if ::selection inherits from ::spelling-error, and that inherits from parent ::spelling-error, it'll never inherit from the parent selection<br>
&lt;fantasai> emilio: ::spelling-error inherits from ::selection<br>
&lt;TabAtkins> fantasai: Why would spelling-error inerit from selection?<br>
&lt;fantasai> emilio: ::spelling-error inherits from ::selection<br>
&lt;fantasai> fantasai: that doesn't work<br>
&lt;TabAtkins> fantasai: can you give me an example of the zigzag?<br>
&lt;TabAtkins> fantasai: there's two pseudos - selection paints over spelling-error - what's the inheritance chain?<br>
&lt;fantasai> delan: So you go in a zigzag, our ::selection inherits from our ::spelling error, and our ::spelling-error inherits from our parent's ::selection, which inherits from parent's ::spelling-error, etc.<br>
&lt;TabAtkins> child selection -> child spelling error -> parent selection -> parent spelling-error<br>
&lt;fantasai> fantasai: Why would it make sense for ::spelling-error to inherit from parent's ::selection?<br>
&lt;TabAtkins> fantasai: Why would it make sense for spelling error to inherit from the parent's selection?<br>
&lt;fantasai> emilio: I guess it doesn't quite...<br>
&lt;fantasai> delan: when you jump back in the zigzag, you have a lower layer inheriting from a higher layer<br>
&lt;fantasai> delan: it's hard for me to imagine this<br>
&lt;TabAtkins> fantasai: imagine spelling was red, seleciton was blue<br>
&lt;TabAtkins> fantasai: you highlight some things<br>
&lt;Rossen_> q?<br>
&lt;TabAtkins> fantasai: the zigzag means you'll get red text when you highlight, if the parent has an spelling error<br>
&lt;tantek> This (special inheritance across pseudo-elements) seems confusing enough to the WG that I can't imagine authors actually coming up with a predictive mental model for what is going on.<br>
&lt;TabAtkins> fantasai: seems weird<br>
&lt;fantasai> Rossen_: Seems work to do here, need to decide if we are going to rethink through inheritance or to tweak existing model<br>
&lt;delan> q+<br>
&lt;fantasai> delan: This is a valid conversation, about solving via other mechanism<br>
&lt;fantasai> delan: but wondering if we can resolve Q1 and Q2, based on assumption that things work the way specified now using currentColor<br>
&lt;fantasai> delan: and later if we want to solve a different way, we can do that?<br>
&lt;fantasai> Rossen_: Makes sense to me<br>
&lt;florian> q+<br>
&lt;dbaron> I *think* one of he goals here is that which of grammar-error/spelling-error/target-text/selection's styles wins does *not* depend on which elements are associated with the selectors (and how they nest), but rather on a spec-defined order of the pseudos.<br>
&lt;Rossen_> ack florian<br>
&lt;delan> q+<br>
&lt;fantasai> florian: I support doing this. Earlier Tab suggested that you put either everything selected or nothing is, suggest assuming everything because otherwise no point in querying ::selection<br>
&lt;Rossen_> ack delan<br>
&lt;fantasai> delan: I thought question was between nothing or pretending that just the pseudo you asked for<br>
&lt;fantasai> florian: that's the one<br>
&lt;fantasai> florian: answering that just the pseudo you asked for is everywhere and nothing else<br>
&lt;fantasai> florian: It's not useful to assume no highlights at all<br>
&lt;fantasai> emilio: I think that's the current behavior<br>
&lt;fantasai> emilio: I'm moderately sure that querying ::selection will get you the ::selection styles<br>
&lt;fantasai> delan: pretendign everything else not selected also solves, what happens if ::selection leaks a color from ::spelling-error or ::grammar-error, which we made it forbidden for privacy reasons so this solves that problem<br>
&lt;fantasai> emilio: it's also simpler, fixes privacy leak<br>
&lt;fantasai> florian: alternative we mentioned last time was to fragment things, and answer question about first one, but overkill for no good reason<br>
&lt;fantasai> delan: don't think anyone needs that answer<br>
&lt;fantasai> florian: if we really needed that answer, we'd need an API to reply on each individual fragment<br>
&lt;fantasai_> delan: For Q1, proposing that we say that when you say 'color: currentColor' on a highlight pseudo, you grab the next active highlight's color<br>
&lt;fantasai_> delan: so that color is as if this highlight wasn't applying<br>
&lt;fantasai_> emilio: ...<br>
&lt;fantasai_> fantasai_: currentColor computes to itself<br>
&lt;fantasai_> emilio: except in 'color' property<br>
&lt;fantasai_> emilio: I'll double-check<br>
&lt;fantasai_> emilio: anyway, seems fine<br>
&lt;fantasai_> RESOLVED: 'color: currentColor' on a highlight takes the next *active* highlight color, so that text is drawn as if highlight weren't taking effect<br>
&lt;fantasai_> scribe+<br>
&lt;fantasai_> delan: For Q2, when you call getComputedStyle() with a highlight pseudo, the color of the result should behave as if the pseudo you passed in is highlighted, but all other highlight pseudos are not highlighting<br>
&lt;fantasai_> delan: we pretend<br>
&lt;florian> +1<br>
&lt;fantasai_> RESOLVED: getComptuedStyle() with a highlight pseudo takes color as if that highlight applied and no other highlight applied<br>
&lt;fantasai_> Rossen: we'll take Q3 back to the issue<br>
</details>


-- 
GitHub Notification of comment by css-meeting-bot
Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/6818#issuecomment-995033957 using your GitHub account


-- 
Sent via github-notify-ml as configured in https://github.com/w3c/github-notify-ml-config

Received on Wednesday, 15 December 2021 18:02:45 UTC