Created attachment 468331 [details] Test case reduction When a custom selection background color is specified in a ::selection pseudo-element CSS rule, there are scenarios in which child nodes of the affected node are not painted with the expected custom color. One such scenario occurs when top-level "anonymous" text abuts a top-level paragraph block. The attached reduction.html exhibits the bug using this scenario. To reproduce: 1. Open attached reduction.html in Safari on Mac. 2. Select all. Expected: The entirety of the top line of rendered text should be painted with the custom selection color. Actual: Only the text portion of the line is painted with the custom color, and the right gap is painted with the default selection background color.
Created attachment 468332 [details] Proposed patch to address the bug
The root of the problem is that anonymous nodes do not consult their ancestors when determining the appropriate background color. The attached patch offers one solution to the bug, in which the RenderElement::selectionBackgroundColor method is amended such that if the element is anonymous, it consults the first non-anonymous ancestor in order instead. I will work on a test case for this but I wanted to get the core bug logged as a baseline.
Created attachment 468333 [details] Proposed test case for the bug
Created attachment 468334 [details] Proposed test case expected png result
Pull request: https://github.com/WebKit/WebKit/pull/19541
<rdar://problem/117796745>
Committed 271129@main (76bb9606ee1b): <https://commits.webkit.org/271129@main> Reviewed commits have been landed. Closing PR #19541 and removing active labels.