Branch: refs/heads/main
Home: https://github.com/WebKit/WebKit
Commit: c6e90cd950732f7d48f3f65320261418486fe61d
https://github.com/WebKit/WebKit/commit/c6e90cd950732f7d48f3f65320261418486fe61d
Author: Alan Baradlay <[email protected]>
Date: 2026-04-15 (Wed, 15 Apr 2026)
Changed paths:
A
LayoutTests/imported/w3c/web-platform-tests/css/CSS2/normal-flow/margin-collapse-min-height-001-expected.html
A
LayoutTests/imported/w3c/web-platform-tests/css/CSS2/normal-flow/margin-collapse-min-height-001-ref.html
A
LayoutTests/imported/w3c/web-platform-tests/css/CSS2/normal-flow/margin-collapse-min-height-001.html
A
LayoutTests/imported/w3c/web-platform-tests/css/CSS2/normal-flow/margin-collapse-min-height-002-expected.html
A
LayoutTests/imported/w3c/web-platform-tests/css/CSS2/normal-flow/margin-collapse-min-height-002-ref.html
A
LayoutTests/imported/w3c/web-platform-tests/css/CSS2/normal-flow/margin-collapse-min-height-002.html
A
LayoutTests/imported/w3c/web-platform-tests/css/CSS2/normal-flow/margin-collapse-min-height-003-expected.html
A
LayoutTests/imported/w3c/web-platform-tests/css/CSS2/normal-flow/margin-collapse-min-height-003-ref.html
A
LayoutTests/imported/w3c/web-platform-tests/css/CSS2/normal-flow/margin-collapse-min-height-003.html
M Source/WebCore/rendering/RenderBlockFlow.cpp
Log Message:
-----------
Margin of last element bleeding out of the parent with min-height
https://bugs.webkit.org/show_bug.cgi?id=278381
<rdar://problem/134356544>
Reviewed by Antti Koivisto.
Consider the following:
<style>
.parent { min-height: 100px; }
.child { margin-bottom: 550px; height: 30px; }
</style>
<div class="parent">
<div class="child"></div>
</div>
<div class="footer"></div>
Child is 30px tall, margin-bottom 550px, parent has min-height 20px.
Pass 1 (height: auto): The child's 550px margin collapses through the parent.
The parent's auto height (derived from content height) is 30px (the
child's border edge).
The 550px becomes the parent's own after-margin.
Pass 2 (min-height): 30px > 20px -> min-height doesn't kick in.
Height stays 30px.
The 550px margin is still on the parent, pushing the footer to 30px +
550px = 580px.
That's the "margin collapses through" case -- min-height (20px) is less than
content (30px), so it has no effect.
.parent (30px)
___________________
| .child (30px) |
|___________________|
<-- 550px margin collapses through
___________________
| .footer |
|___________________|
Now if we change min-height to 100px:
Pass 1 (height: auto): Same -- margin collapses through, auto height = 30px,
550px becomes parent's after-margin.
Pass 2 (min-height): 30px < 100px -> height raised to 100px.
Now height is no longer auto -- the collapse is retroactively undone.
The 550px is no longer the parent's after-margin. Footer sits at 100px
+ 0 = 100px.
The 550px margin is trapped inside the 100px parent -- it occupies the
70px of empty space below the 30px child, and the remaining 480px overflows
"invisibly".
.parent (100px via min-height)
___________________
| .child (30px) |
| |
| (550px margin |
| trapped inside) |
|___________________|
___________________
| .footer |
|___________________|
WebKit was missing this second step. After updateLogicalHeight()
raised the height to min-height, the propagated margin values from
setCollapsedBottomMargin() were left untouched - so the child's
550px margin was still sitting on the parent as its after-margin,
pushing the footer down.
The fix: after updateLogicalHeight(), if min-height increased the
height, reset the parent's after-margin back to just its own margin-after.
The child's margin stays trapped inside the now-taller parent.
* Source/WebCore/rendering/RenderBlockFlow.cpp:
(WebCore::RenderBlockFlow::layoutBlock):
Canonical link: https://commits.webkit.org/311274@main
To unsubscribe from these emails, change your notification settings at
https://github.com/WebKit/WebKit/settings/notifications