Skip to content

Commit

Permalink
[LayoutNG] Mild cleanup and bugfixing of end margin strut handling.
Browse files Browse the repository at this point in the history
Also some more documentation.

Tried to make the various situations a bit clearer, with documentation
and code. And shared code for layout abortion.

The code used to call MaybeUpdateFragmentBfcOffset() quite
unconditionally based on an *end* offset inside the block. I found it
confusing to use an end offset as a BFC start offset. The code was
correct, though, since MaybeUpdateFragmentBfcOffset() wouldn't do
anything if the BFC offset was already known (which would be the case
if had children with actual size, for instance, making for a strange
BFC offset in that case). We'll now only call
MaybeUpdateFragmentBfcOffset() if BFC offset is unknown.
That's the only time end_bfc_block_offset can actually be used as a BFC
start offset.

Fixed one bug, though: A block with explicit height:0 ate the input
margin, rather than letting it collapse through and propagate to
subsequent layout input nodes. The intention of the code was just to get
rid of the last child margin, since height was non-auto. Now we check if
we have a BFC offset before doing so. If we have BFC offset, it means
that no input margins should collapse through. And if we DON'T have a
BFC offset, leave the margins alone for subsequent layout input nodes.
Otherwise we'd just lose them.

The old layout test that now passes is actually because of this (dog ate
BODY top margin), but that probably wasn't too obvious, so I added a
dedicated WPT test for it.

Cq-Include-Trybots: master.tryserver.chromium.linux:linux_layout_tests_layout_ng
Change-Id: Iec8cea316015c6d36ef6bab9acbe826513222b1d
  • Loading branch information
mstensho authored and chromium-wpt-export-bot committed Feb 7, 2018
1 parent 04c852b commit 50651bb
Showing 1 changed file with 12 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<!DOCTYPE html>
<title>Collapse bottom margin from previous sibling through zero height block to next sibling</title>
<link rel="author" title="Morten Stenshorne" href="mstensho@chromium.org">
<link rel="help" href="https://www.w3.org/TR/CSS22/box.html#collapsing-margins" title="8.3.1 Collapsing margins">
<link rel="match" href="../../reference/ref-filled-green-200px-square.html">
<p>Test passes if there is a filled green square and <strong>no red</strong>.</p>
<div style="overflow:hidden; width:200px; height:400px; background:green;">
<div style="margin-bottom:200px;"></div>
<div style="height:0;"></div>
<div style="height:200px; margin-top:100px; background:white;"></div>
<div style="height:200px; background:red;"></div>
</div>

0 comments on commit 50651bb

Please sign in to comment.