RESOLVED FIXED308175
REGRESSION (303091@main): getClientRects() can include rects with no width and height
https://bugs.webkit.org/show_bug.cgi?id=308175
Summary REGRESSION (303091@main): getClientRects() can include rects with no width an...
Brad Andalman
Reported 2026-02-18 15:55:15 PST
Created attachment 478401 [details] HTML that exhibits the bug We make use of a slightly complicated method to "float" a text box. Sometimes this floating text box can affect a paragraph that splits across two columns in a multi-column view. When that happens, Safari Technology Preview 237 has different behavior than the released version of Safari. In order to inspect the position of the lines in each paragraph, we use a <span> element to contain the paragraph text. Then, we can call getClientRects() on that containing span. Prior to STP 237, each returned rect would represent a line in the paragraph (this is very useful, and is also how Chrome and Firefox behave). With STP 237, getClientRects() can include a rect with a width and height of 0. This seems broken, even though it doesn't seem to affect the text layout in my test. I'm attaching HTML that illustrates this problem. It contains JS so that, if it finds a rect with a width and height of 0, it will add a background color of "pink" to some text. Otherwise, the background for that text will be green.
Attachments
HTML that exhibits the bug (2.76 KB, text/html)
2026-02-18 15:55 PST, Brad Andalman
no flags
Screenshot showing the bug in STP 237 (and not in the released version of Safari) (378.36 KB, image/png)
2026-02-18 15:56 PST, Brad Andalman
no flags
rendering in safari, firefox, chrome (135.35 KB, image/png)
2026-02-18 23:59 PST, Karl Dubost
no flags
Patch (4.32 KB, patch)
2026-02-19 14:50 PST, alan
no flags
[fast-cq]Patch (4.96 KB, patch)
2026-02-19 15:58 PST, alan
no flags
Brad Andalman
Comment 1 2026-02-18 15:56:40 PST
Created attachment 478402 [details] Screenshot showing the bug in STP 237 (and not in the released version of Safari)
Radar WebKit Bug Importer
Comment 2 2026-02-18 17:16:16 PST
Karl Dubost
Comment 3 2026-02-18 23:59:12 PST
Created attachment 478406 [details] rendering in safari, firefox, chrome Thanks for the bug report and the testcase ! Rendering in Safari Technology Preview 236 21625.1.1.19.1 Firefox Nightly 149.0a1 14926.2.4 Google Chrome Canary 147.0.7694.0 7694.0
Karl Dubost
Comment 4 2026-02-19 00:01:46 PST
<span id="lorem-span">…</span> has a unknown size. not even displayed as 0x0 in the Web inspector.
alan
Comment 5 2026-02-19 14:26:59 PST
(In reply to Karl Dubost from comment #4) > <span id="lorem-span">…</span> has a unknown size. not even displayed as 0x0 > in the Web inspector. Such inline boxes do not normally show their size as they are prone to fragmentation e.g <span>first line <br>second line</span>
alan
Comment 6 2026-02-19 14:50:49 PST
alan
Comment 7 2026-02-19 15:58:05 PST
Created attachment 478410 [details] [fast-cq]Patch
EWS
Comment 8 2026-02-20 08:13:28 PST
Committed 307916@main (d02501613445): <https://commits.webkit.org/307916@main> All reviewed patches have been landed. Closing bug and clearing flags on attachment 478410 [details].
EWS
Comment 9 2026-02-27 19:23:44 PST
Committed 305413.375@safari-7624-branch (da629230e759): <https://commits.webkit.org/305413.375@safari-7624-branch> Reviewed commits have been landed. Closing PR #4572 and removing active labels.
Note You need to log in before you can comment on or make changes to this bug.