Bug 219087

Summary: ::first-letter styles cause Range clientRect miscalculations
Product: WebKit Reporter: Joseph Pearson <j>
Component: Layout and RenderingAssignee: Nobody <webkit-unassigned>
Status: NEW    
Severity: Minor CC: ahmad.saleem792, bfulgham, simon.fraser, smoley, webkit-bug-importer, wenson_hsieh, zalan
Priority: P2 Keywords: InRadar
Version: Safari Technology Preview   
Hardware: All   
OS: All   
See Also: https://bugs.webkit.org/show_bug.cgi?id=43830
Attachments:
Description Flags
Example showing expected result and miscalcs none

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
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!
Note You need to log in before you can comment on or make changes to this bug.