Bug 274790 - REGRESSION (268128@main): Floating elements can be split across columns
Summary: REGRESSION (268128@main): Floating elements can be split across columns
Status: NEW
Alias: None
Product: WebKit
Classification: Unclassified
Component: Layout and Rendering (show other bugs)
Version: Safari 17
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Antti Koivisto
URL:
Keywords: InRadar
Depends on: 261683
Blocks:
  Show dependency treegraph
 
Reported: 2024-05-28 11:29 PDT by Brad Andalman
Modified: 2024-10-30 16:34 PDT (History)
8 users (show)

See Also:


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 Details
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 Details
HTML for same underlying bug, but different appearance (1.69 KB, text/html)
2024-05-31 12:16 PDT, Brad Andalman
no flags Details
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 Details
Rendering of new HTML in Safari 17.2.1 (155.82 KB, image/png)
2024-05-31 12:20 PDT, Brad Andalman
no flags Details
Bad layout in second column due to widows (1.81 KB, text/html)
2024-06-03 12:18 PDT, Brad Andalman
no flags Details
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 Details
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 Details

Note You need to log in before you can comment on or make changes to this bug.
Description Brad Andalman 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.
Comment 1 Brad Andalman 2024-05-28 11:30:33 PDT
Created attachment 471530 [details]
Render of the HTML in Safari 17.5 and Chrome
Comment 2 Radar WebKit Bug Importer 2024-05-28 11:52:00 PDT
<rdar://problem/128881044>
Comment 3 Karl Dubost 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.
Comment 4 Karl Dubost 2024-05-28 23:22:23 PDT
This has been regressed by bug 261683
https://github.com/WebKit/WebKit/commit/c28da984b5ca8fb4bf7941f1b932dd6dd92c0724
Comment 5 Brad Andalman 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.
Comment 6 Brad Andalman 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.
Comment 7 Brad Andalman 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).
Comment 8 Brad Andalman 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!
Comment 9 Karl Dubost 2024-06-02 18:28:00 PDT
I don't think there's an easy way to detect this unfortunately. :(
Comment 10 Brad Andalman 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.
Comment 11 Brad Andalman 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.
Comment 12 Brad Andalman 2024-06-03 12:19:37 PDT
Created attachment 471581 [details]
Rendering of bad layout due to widows in Safari 17.5
Comment 13 Karl Dubost 2024-06-03 22:59:04 PDT
Thanks a lot for all the test cases. That will help to solve the issue.
Comment 14 Antti Koivisto 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.
Comment 15 Antti Koivisto 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.
Comment 16 Brad Andalman 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!
Comment 17 Antti Koivisto 2024-06-18 01:39:12 PDT
I think we can keep them here for now until I figure out how to handle this.
Comment 18 Brad Andalman 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.
Comment 19 Brad Andalman 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.
Comment 20 Brad Andalman 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.
Comment 21 Brad Andalman 2024-10-30 16:34:57 PDT
Created attachment 473090 [details]
Screenshot of Apple Books 7.1 on Sequoia showing split drop cap