Re: [csswg-drafts] [css-pseudo-4]: How should a selected spelling error be painted? (#2850)

To recap/clarify comments from the telcon:

I may have been misunderstanding the currently specified model for inheritance and `::selection` as defined in [Pseudo 4](https://drafts.csswg.org/css-pseudo-4/#highlight-cascade).

I understood the behavior as treating a selection as a sequence of separate pseudo-elements, one inside each element (or other pseudo) it overlaps. Each of those partial selections would then inherit from the base styles for that span of text. A selector like `p::selection` selects all the partial selection pseudo-elements inside the `p`, rather than selecting one pseudoelement that then has spans or other pseudos inside it. `em::selection` selects the partial selections inside the `em`, as does `p>em::selection` but the latter one wins out because it's a more specific selector.

So for real markup:

```html
<p>Unselected text selected text, <em>emphasized selected text, other emphasized text</em>.</p>
```

And a selection that covers "selected text, _emphasized selected text,_", you'd get an inheritance model of:

```html
<p>Unselected text <::s>selected text, </::s><em><::s>emphasized selected text,</::s> other emphasized text</em>.</p>
```

If that is the model used, then `color: currentColor` describes the behavior @fantasai wants (each span of text inside the selection taking the color it would be without the selection).
This is because each of those partial selections would inherit a different `color` value, and `color: currentColor` uses the inherited value, as defined in CSS Color [Level 3 (in the `currentColor` definition)](https://drafts.csswg.org/css-color-3/#currentcolor) or [Level 4 (in the "resolving color values" section)](https://drafts.csswg.org/css-color-4/#resolving-color-values).

But, now that I re-read the ["Cascading and Per-Element Highlight Styles"](https://drafts.csswg.org/css-pseudo-4/#highlight-cascade), I'm starting to doubt whether my mental model includes all the details in the spec:

> Each element draws its own active portions of the highlight overlays, which receives the styles specified by the corresponding highlight pseudo-element styles for which that element is the originating element. When multiple styles conflict, the winning style is determined by the cascade. When any supported property is not given a value by the cascade, it’s value is determined by inheritance from the corresponding highlight pseudo-element of its originating element’s parent element (regardless of whether that property is an inherited property).

Which is kind of hand-wavy language that doesn't match the normal inheritance rules, and never actually says that the highlight inherits from the local text span. So some additional hand-waving may still be required for `currentColor`.

-- 
GitHub Notification of comment by AmeliaBR
Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/2850#issuecomment-452936750 using your GitHub account

Received on Thursday, 10 January 2019 01:32:30 UTC