Open fabiospampinato opened 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
I agree. Filed impl bug: https://crbug.com/1411074
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?
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:
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.