Bug 212505 - A floating figure’s margin can affect subsequent/previous columns [Multicolumn]
Summary: A floating figure’s margin can affect subsequent/previous columns [Multicolumn]
Status: NEW
Alias: None
Product: WebKit
Classification: Unclassified
Component: Layout and Rendering (show other bugs)
Version: Safari 18
Hardware: Mac macOS 15
: P2 Normal
Assignee: Nobody
URL:
Keywords: BrowserCompat, InRadar
Depends on:
Blocks:
 
Reported: 2020-05-28 18:08 PDT by Brad Andalman
Modified: 2024-08-08 15:51 PDT (History)
5 users (show)

See Also:


Attachments
HTML that shows margin on a figure in one column improperly affecting the next (4.43 KB, text/html)
2020-05-28 18:08 PDT, Brad Andalman
no flags Details
test case (4.75 KB, text/html)
2022-07-11 22:17 PDT, Karl Dubost
no flags Details
Rendering in Safari, firefox, chrome (318.82 KB, image/png)
2022-07-11 22:31 PDT, Karl Dubost
no flags Details
quirky test case (4.87 KB, text/html)
2022-07-12 15:21 PDT, Brad Andalman
no flags Details
standard test case (4.91 KB, text/html)
2022-07-12 15:21 PDT, Brad Andalman
no flags Details
Safari vs Chrome Layout with Guides (592.01 KB, image/png)
2022-07-12 15:24 PDT, Brad Andalman
no flags Details
HTML showing figure improperly affecting next column [Quirks] (2.44 KB, text/html)
2023-09-19 09:49 PDT, Brad Andalman
no flags Details
HTML showing figure improperly affecting next column [Standard] (2.46 KB, text/html)
2023-09-19 09:52 PDT, Brad Andalman
no flags Details
HTML showing incorrect gap at top of column (after floating figure) (1.80 KB, text/html)
2024-08-08 13:52 PDT, Brad Andalman
no flags Details
HTML showing incorrect gap at bottom of column (after floating figure) (2.09 KB, text/html)
2024-08-08 13:53 PDT, Brad Andalman
no flags Details
Screenshot comparing Safari and Chrome (top gap) (442.12 KB, image/png)
2024-08-08 13:53 PDT, Brad Andalman
no flags Details
Screenshot comparing Safari and Chrome (bottom gap) (499.28 KB, image/png)
2024-08-08 13:54 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 2020-05-28 18:08:49 PDT
Created attachment 400534 [details]
HTML that shows margin on a figure in one column improperly affecting the next

I have a figure that exactly reaches the bottom of a column. Even though the figure is entirely contained within a single column, margin-bottom on this figure affects the subsequent column. If I adjust the margin-top of the figure so that the bottom of the image no longer reaches the bottom of the column, then the margin-bottom behaves as I'd expect, and doesn't affect the subsequent column.
Comment 1 Radar WebKit Bug Importer 2020-06-01 17:44:34 PDT
<rdar://problem/63851666>
Comment 2 Karl Dubost 2022-07-11 22:17:13 PDT
Created attachment 460803 [details]
test case

Slightly modifying the test so it can be tested on any browsers, and not just webkit browsers.
Comment 3 Karl Dubost 2022-07-11 22:31:53 PDT
Created attachment 460804 [details]
Rendering in Safari, firefox, chrome

Rendering in 

Safari Technology Preview 16.0
Firefox Nightly 104.0a1
Google Chrome Canary 105.0.5174.0


Both Chrome and Firefox are pushing the image to the next column

I wonder if we can reduce a bit more the test.
Comment 4 Karl Dubost 2022-07-11 23:06:36 PDT
I tried to reproduce with a little animation to see if there was a pattern in between browsers, but the issue disappears when I do that. 

https://codepen.io/webcompat/pen/poLEzJR
Comment 5 Brad Andalman 2022-07-12 15:21:01 PDT
Actually, in Safari, the new "test case" attachment moves the image to the next column as well (as it does in Chrome and Firefox).

This is because the "test case" attachment doesn't just remove the "-webkit" prefixes from a few properties, but adds other things as well. In particular, it adds "<!DOCTYPE html>" at the beginning, which causes the browser to use Standards mode (as opposed to Quirks mode). This is why we see different behavior between the first attachment and the second. And this is likely why Karl couldn't repro in his animation.

In Quirks mode, when the image reaches the bottom of a column (exactly), then the margin-bottom affects the next column. I will add another attachment ("quirky test case") that illustrates this, and doesn't use properties with "-webkit" prefixes. If you change the figure's margin-top from 15px to 14px in this example, you'll see that the margin-bottom no longer affects the next column (as in my original report).

The behavior in Standards mode is different. In Standards mode, the figure will *never* reach the very bottom of the column. I will add another attachment ("standard test case") that shows this. In that example, if you change the figure's margin-top from 11px to 12px, then the image will move to the next column. I think the fact that the figure can't ever reach the very bottom of the column is another bug. The figure's margin-top should be able to be 15px without it being forced to the next column.

In both Chrome and Firefox, the behavior is the same in both Quirks and Standards modes. However, since the text layout is different (see attached "Safari vs Chrome Layout with Guides"), the image will reach the very bottom of the column when the figure's margin-top is only 11px, and switch when margin-top is changed to 12px. This is the same inflection point as the "standard test case" in Safari — is that a coincidence?

In short, there's a Safari bug in either mode. In Quirks mode, the margin-bottom affects the next column when it shouldn't; in Standards mode, the figure won't ever reach the bottom of the column.
Comment 6 Brad Andalman 2022-07-12 15:21:42 PDT
Created attachment 460831 [details]
quirky test case
Comment 7 Brad Andalman 2022-07-12 15:21:59 PDT
Created attachment 460832 [details]
standard test case
Comment 8 Brad Andalman 2022-07-12 15:24:45 PDT
Created attachment 460833 [details]
Safari vs Chrome Layout with Guides

This screenshot shows Safari (in the back) and Chrome (front). The top and bottom guides show that the columns are the same height. The middle guide shows the baseline of the last line of text, which is lower in Chrome than in Safari.
Comment 9 Karl Dubost 2022-07-12 16:15:09 PDT
Ah! I didn't realize you were expecting Quirks mode. 
Is there a specific website breaking because of this?
Comment 10 Brad Andalman 2022-07-12 16:18:12 PDT
Our application, Vellum, relies on Quirks mode (for historic reasons).
Comment 11 Karl Dubost 2022-07-12 16:24:05 PDT
Also thanks a lot for the test cases and explanations. This is useful.
Comment 12 Brad Andalman 2022-07-12 16:31:39 PDT
My pleasure!

Also, please let me know if you think that I should submit these (related) bugs separately:
1) Image does not reach the bottom of the column in Standards mode
2) Column text layout is different when compared to Chrome/Firefox
Comment 13 Karl Dubost 2022-07-12 16:35:22 PDT
Yes always better to have separate bugs for different type of issues.
Comment 14 Brad Andalman 2022-07-13 12:08:54 PDT
Looks like the text layout issue I referred to above ("Column text layout is different when compared to Chrome/Firefox") is covered by this webkit bug: 
https://bugs.webkit.org/show_bug.cgi?id=225695

And I've filed a bug for the (related?) issue where the "image does not reach the bottom of the column in Standards mode":
https://bugs.webkit.org/show_bug.cgi?id=242708
Comment 15 Brad Andalman 2023-09-19 09:49:29 PDT
Created attachment 467758 [details]
HTML showing figure improperly affecting next column [Quirks]

I just filed a similar – though not identical? - bug here:
https://bugs.webkit.org/show_bug.cgi?id=261752

When creating the HTML for that bug, I made this repro case a tiny bit simpler. Namely, I reduced the column count and made the math easier. In this simpler case, in quirks mode, we still see that the margin-bottom on the <figure> improperly affects the next column.
Comment 16 Brad Andalman 2023-09-19 09:52:49 PDT
Created attachment 467759 [details]
HTML showing figure improperly affecting next column [Standard]

When creating the HTML for a similar bug (https://bugs.webkit.org/show_bug.cgi?id=261752), I made this repro case a tiny bit simpler. Namely, I reduced the column count and made the math easier. In this simpler case, in standards mode, even though there is enough space for the image, it get moved to the next column.

This is different than the original attachment where – likely because the math is different – the image doesn’t actually reach the bottom of the column (even though it should).
Comment 17 Brad Andalman 2024-08-08 13:44:20 PDT
We are still hitting this issue, so I wanted to update this bug.

In particular, I’m removing “QuirksMode” from the Summary, since I worry that that is a distraction. I don’t believe that’s relevant, and I will be submitting two more attachments that illustrate this issue.
Comment 18 Brad Andalman 2024-08-08 13:52:36 PDT
Created attachment 472084 [details]
HTML showing incorrect gap at top of column (after floating figure)
Comment 19 Brad Andalman 2024-08-08 13:53:10 PDT
Created attachment 472085 [details]
HTML showing incorrect gap at bottom of column (after floating figure)
Comment 20 Brad Andalman 2024-08-08 13:53:58 PDT
Created attachment 472086 [details]
Screenshot comparing Safari and Chrome (top gap)
Comment 21 Brad Andalman 2024-08-08 13:54:33 PDT
Created attachment 472087 [details]
Screenshot comparing Safari and Chrome (bottom gap)
Comment 22 Brad Andalman 2024-08-08 13:57:41 PDT
I’ve added two more HTML attachments and two more screenshots that illustrate the incorrect behavior in Safari (vs correct behavior in Chrome).
Comment 23 Brad Andalman 2024-08-08 15:51:01 PDT
Tested in Safari 18.0 (20619.1.18.11.1) on Sequoia 15.0 Beta (24A5279h), and the bug still manifests.