w3c / csswg-drafts

CSS Working Group Editor Drafts
https://drafts.csswg.org/
Other
4.36k stars 640 forks source link

[css-highlight-api] Ensuring that the height of ::highlight and ::selection match #8363

Open fabiospampinato opened 1 year ago

fabiospampinato commented 1 year ago

In the following screenshot taken under Chrome@latest one can see that the height of the dark background set with a ::highlight doesn't match the height of the blue selection:

Screen Shot 2023-01-26 at 21 24 02

Reading the spec I can't figure out if this matches the spec or not.

It looks like a bug to me because it means that one can't quite use ::highlight as a way to render multiple selections, since the height of the two seems to be calculated differently, which seems undesirable.

Loirooriol commented 1 year ago

https://drafts.csswg.org/css-pseudo/#highlight-bounds

For text, the corresponding overlay must cover at least the entire em box and may extend further above/below the em box to the line box edges.

https://drafts.csswg.org/css-highlight-api/#painting

The painting of custom highlights is also handled identically to that of the built-in highlight pseudo-elements, as specified in CSS Pseudo-Elements 4 § 3.4 Area of a Highlight and CSS Pseudo-Elements 4 § 3.6 Painting the Highlight

I guess this allows some highlights to be taller than others, but it doesn't look great. CC @delan

delan commented 1 year ago

I agree. Filed impl bug: https://crbug.com/1411074

schenney-chromium commented 7 months ago

This is now https://crbug.com/1480139. The WPT test css/css-pseudo/active-selection-031.html fails in part due to the fact that chromium paints selection using a box that extends beyond the em box.

Should we desire to spec this, I would propose that "Custom Highlight background painting should match the overlay painted for selection."

Does anyone have any opinion on this?