NEW 274790
REGRESSION (268128@main): Floating elements can be split across columns
https://bugs.webkit.org/show_bug.cgi?id=274790
Summary REGRESSION (268128@main): Floating elements can be split across columns
Brad Andalman
Reported 2024-05-28 11:29:33 PDT
Created attachment 471529 [details] HTML that shows a drop cap split across two columns We use “float: left” and a large font-size to implement drop caps. Recently, we’ve noticed that these drop caps can sometimes be split across a column, which looks quite bad. I’ve attached some HTML that exhibits the bug in Safari 17.5. I’ll also attach a screenshot that shows the failure in Safari, contrasted with Chrome, which renders it correctly. This bug also appears in Safari Technology Preview Release 195, but does *not* appear in Safari 17.2.1. So, this appears to be a relatively recent regression.
Attachments
HTML that shows a drop cap split across two columns (1.60 KB, text/html)
2024-05-28 11:29 PDT, Brad Andalman
no flags
Render of the HTML in Safari 17.5 and Chrome (379.42 KB, image/png)
2024-05-28 11:30 PDT, Brad Andalman
no flags
HTML for same underlying bug, but different appearance (1.69 KB, text/html)
2024-05-31 12:16 PDT, Brad Andalman
no flags
Rendering of new HTML in Safari 17.5 and Chrome (456.73 KB, image/png)
2024-05-31 12:17 PDT, Brad Andalman
no flags
Rendering of new HTML in Safari 17.2.1 (155.82 KB, image/png)
2024-05-31 12:20 PDT, Brad Andalman
no flags
Bad layout in second column due to widows (1.81 KB, text/html)
2024-06-03 12:18 PDT, Brad Andalman
no flags
Rendering of bad layout due to widows in Safari 17.5 (312.80 KB, image/png)
2024-06-03 12:19 PDT, Brad Andalman
no flags
Screenshot of Apple Books 7.1 on Sequoia showing split drop cap (906.35 KB, image/png)
2024-10-30 16:34 PDT, Brad Andalman
no flags
Brad Andalman
Comment 1 2024-05-28 11:30:33 PDT
Created attachment 471530 [details] Render of the HTML in Safari 17.5 and Chrome
Radar WebKit Bug Importer
Comment 2 2024-05-28 11:52:00 PDT
Karl Dubost
Comment 3 2024-05-28 22:49:43 PDT
Brad, Thanks a lot for the testcase. Very useful. I can confirm this is a regresssion. I'm starting a regression testing.
Karl Dubost
Comment 4 2024-05-28 23:22:23 PDT
Brad Andalman
Comment 5 2024-05-31 12:16:03 PDT
Created attachment 471557 [details] HTML for same underlying bug, but different appearance I’m attaching new HTML that looks like the same underlying bug. This HTML is almost the same, but 1) uses a more “reasonable” line-height and 2) changes the column height slightly. When you open this in Safari 17.5, the drop cap appears entirely in the first column, but there is still an incorrect space in the second column (presumably where WebKit layout thinks the drop cap should appear). I’ll attach screenshots shortly.
Brad Andalman
Comment 6 2024-05-31 12:17:27 PDT
Created attachment 471558 [details] Rendering of new HTML in Safari 17.5 and Chrome Here is a comparison of Safari 17.5 and Chrome. I’ve highlighted the incorrect behavior in Safari. And you can see that, in Chrome, the drop cap fits in the first column and doesn’t affect the second column.
Brad Andalman
Comment 7 2024-05-31 12:20:09 PDT
Created attachment 471559 [details] Rendering of new HTML in Safari 17.2.1 In this screenshot, you can see the old behavior in Safari. It’s preferable to the current behavior, but this version of Safari deems the drop cap too large to fit in the first column and moves it to the second. It feels like the Chrome behavior is correct (though the old Safari behavior seems justifiable).
Brad Andalman
Comment 8 2024-05-31 12:27:15 PDT
Since this regression is a big deal for our application, we were wondering if there is a way to detect this bug and workaround it (until a real fix is available). Is there any way you can tell me how the height for the drop cap is calculated currently (in this broken state)? For instance, I tried getting the bounding rect of the span that contains the drop cap, but that doesn’t equal the height of the letter. I’ve tried to figure out the height by using some combination font-metrics and font-size, but I haven’t figured it out exactly yet (and am worried that might be going down the wrong path). Any advice would be much appreciated!
Karl Dubost
Comment 9 2024-06-02 18:28:00 PDT
I don't think there's an easy way to detect this unfortunately. :(
Brad Andalman
Comment 10 2024-06-03 12:14:09 PDT
I was afraid you might say that! Oh well. I also found another case (involving widows) that seems related to this bug. To be sure, I’ll attach some example HTML shortly.
Brad Andalman
Comment 11 2024-06-03 12:18:48 PDT
Created attachment 471580 [details] Bad layout in second column due to widows If you comment out the “widows: 5” CSS in the attached HTML, you can see that two lines fit below the drop cap. With that “widows: 5”, though, those two lines move to the second column. And while there are five lines in the second column now, the inset due to the (phantom) drop cap persists. In Safari 17.2.1 (and in Chrome), that drop-cap indentation doesn’t appear.
Brad Andalman
Comment 12 2024-06-03 12:19:37 PDT
Created attachment 471581 [details] Rendering of bad layout due to widows in Safari 17.5
Karl Dubost
Comment 13 2024-06-03 22:59:04 PDT
Thanks a lot for all the test cases. That will help to solve the issue.
Antti Koivisto
Comment 14 2024-06-04 08:23:09 PDT
The issue in first case appears to be paint, not layout. Overflowing content wrongly paints in the first column while clipping in the second but everything is in a right place.
Antti Koivisto
Comment 15 2024-06-10 23:32:47 PDT
Basically this used to avoid visual split because the layout was wrong. We pushed the first line on second column down so there was no overflow. Now we have correct layout but the overflowing part shows up on the previous page.
Brad Andalman
Comment 16 2024-06-12 15:05:16 PDT
Thanks for taking a look at the first case (https://bug-274790-attachments.webkit.org/attachment.cgi?id=471529). Since that failure is due to an issue with paint, should I file a separate bug? Because the second issue (https://bug-274790-attachments.webkit.org/attachment.cgi?id=471557) feels like it might actually be a layout issue. Lastly, the third issue (https://bug-274790-attachments.webkit.org/attachment.cgi?id=471580) — the one related to widows — must also be different. It’s now fixed in Safari Technology Preview, while the other two cases are not. Apologies for lumping these three cases together. From my perspective, they certainly appeared to be related!
Antti Koivisto
Comment 17 2024-06-18 01:39:12 PDT
I think we can keep them here for now until I figure out how to handle this.
Brad Andalman
Comment 18 2024-10-30 16:29:22 PDT
Comment on attachment 471580 [details] Bad layout in second column due to widows Marking this obsolete, as this no longer happens in Safari 18.1.
Brad Andalman
Comment 19 2024-10-30 16:29:37 PDT
Comment on attachment 471581 [details] Rendering of bad layout due to widows in Safari 17.5 Marking this obsolete, as this no longer happens in Safari 18.1.
Brad Andalman
Comment 20 2024-10-30 16:33:57 PDT
I obsoleted two attachments, since the case they were hightlighting (see comment #11) no longer occurs in Safari 18.1. However, the issue with the split drop cap still persists in Safari 18.1. You can even see it in Apple Books (version 7.1) on Sequoia 15.1. This does not happen on Ventura, in Apple Books 5.2.
Brad Andalman
Comment 21 2024-10-30 16:34:57 PDT
Created attachment 473090 [details] Screenshot of Apple Books 7.1 on Sequoia showing split drop cap
Note You need to log in before you can comment on or make changes to this bug.