RESOLVED FIXED263658
Selection gaps are not painted with the expected Selection pseudoelement color
https://bugs.webkit.org/show_bug.cgi?id=263658
Summary Selection gaps are not painted with the expected Selection pseudoelement color
Daniel Jalkut
Reported 2023-10-25 08:05:21 PDT
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.
Attachments
Test case reduction (134 bytes, text/html)
2023-10-25 08:05 PDT, Daniel Jalkut
no flags
Proposed patch to address the bug (1.13 KB, patch)
2023-10-25 08:08 PDT, Daniel Jalkut
no flags
Proposed test case for the bug (334 bytes, text/html)
2023-10-25 08:55 PDT, Daniel Jalkut
no flags
Proposed test case expected png result (25.98 KB, image/png)
2023-10-25 08:55 PDT, Daniel Jalkut
no flags
Daniel Jalkut
Comment 1 2023-10-25 08:08:27 PDT
Created attachment 468332 [details] Proposed patch to address the bug
Daniel Jalkut
Comment 2 2023-10-25 08:08:46 PDT
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.
Daniel Jalkut
Comment 3 2023-10-25 08:55:17 PDT
Created attachment 468333 [details] Proposed test case for the bug
Daniel Jalkut
Comment 4 2023-10-25 08:55:53 PDT
Created attachment 468334 [details] Proposed test case expected png result
Daniel Jalkut
Comment 5 2023-10-25 09:03:18 PDT
Radar WebKit Bug Importer
Comment 6 2023-11-01 08:06:14 PDT
EWS
Comment 7 2023-11-26 23:15:44 PST
Committed 271129@main (76bb9606ee1b): <https://commits.webkit.org/271129@main> Reviewed commits have been landed. Closing PR #19541 and removing active labels.
Note You need to log in before you can comment on or make changes to this bug.