Bug 219087 - ::first-letter styles cause Range clientRect miscalculations
Summary: ::first-letter styles cause Range clientRect miscalculations
Status: NEW
Alias: None
Product: WebKit
Classification: Unclassified
Component: Layout and Rendering (show other bugs)
Version: Safari Technology Preview
Hardware: All All
: P2 Minor
Assignee: Nobody
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2020-11-18 07:32 PST by Joseph Pearson
Modified: 2022-09-22 14:45 PDT (History)
7 users (show)

See Also:


Attachments
Example showing expected result and miscalcs (2.91 KB, text/html)
2020-11-18 07:32 PST, Joseph Pearson
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Joseph Pearson 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.
Comment 1 Smoley 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).
Comment 2 Radar WebKit Bug Importer 2020-11-18 10:47:53 PST
<rdar://problem/71546397>
Comment 3 Ahmad Saleem 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!