RESOLVED FIXED219087
::first-letter styles cause Range clientRect miscalculations
https://bugs.webkit.org/show_bug.cgi?id=219087
Summary ::first-letter styles cause Range clientRect miscalculations
Joseph Pearson
Reported 2020-11-18 07:32:28 PST
Created attachment 414449 [details] Example showing expected result and miscalcs If an element has a ::first-letter style rule, creating a Range within that element and measuring its client rectangles (Range#getClientRects or Range#getBoundingClientRects) will produce incorrect dimensions. The range itself is fine: Range#toString() shows that the correct characters have been selected. But the resulting rectangles are wrong, at least on the x axis (left, width). Note that *any* ::first-letter declaration on the element produces the bug, even if the styles are not layout-affecting, and even if they're invalid style values. See a quick reduction in the attached file. I don't think this is a new bug — I have observed it for years, but only got around to the reduction today.
Attachments
Example showing expected result and miscalcs (2.91 KB, text/html)
2020-11-18 07:32 PST, Joseph Pearson
no flags
Patch (7.63 KB, patch)
2026-04-11 13:38 PDT, alan
no flags
[fast-cq]Patch (7.71 KB, patch)
2026-04-11 15:58 PDT, alan
no flags
Smoley
Comment 1 2020-11-18 10:47:43 PST
Thanks for filing. I can reproduce this with the test case on Safari 13.1.3 as well as STP 115 (14.1).
Radar WebKit Bug Importer
Comment 2 2020-11-18 10:47:53 PST
Ahmad Saleem
Comment 3 2022-09-22 14:45:46 PDT
I am able to reproduce this bug in Safari Technology Preview 154 using attached test case and both Example 2 and 3 doe snot highlight "troublemakers" like Expected Results while both Firefox Nightly 107 and Chrome Canary 108 show expected results in all cases / example. Thanks!
alan
Comment 4 2026-04-11 13:38:10 PDT
alan
Comment 5 2026-04-11 13:39:36 PDT
Let's see if this works without https://github.com/WebKit/WebKit/pull/62142
alan
Comment 6 2026-04-11 15:58:09 PDT
Created attachment 479024 [details] [fast-cq]Patch
EWS
Comment 7 2026-04-13 07:13:44 PDT
Committed 311085@main (625c8663227c): <https://commits.webkit.org/311085@main> All reviewed patches have been landed. Closing bug and clearing flags on attachment 479024 [details].
Note You need to log in before you can comment on or make changes to this bug.