Skip to content

Commit 28b5323

Browse files
mstenshochromium-wpt-export-bot
authored andcommitted
Reland: Floats and out-of-flow objects may not be adjacent to anonymous blocks.
Floats and out-of-flow objects need to be true layout siblings of the inlines, or rendering will be wrong. This means that such objects should never be siblings of anonymous blocks, but rather inside them. This already works correctly for initial layout tree building, and also for many DOM manipulations. However, code was missing to satisfy this requirement if we removed a regular block that was a sibling of an anonymous block and either a float or out-of-flow positioned object. This even caused a crash triggered by ruby code, which ended up mixing inline and block children within the same container. That is not allowed. This happened in the MoveAllChildrenIncludingFloatsTo() call inside LayoutRubyBase::MoveBlockChildren(). Added a DCHECK to MoveAllChildrenIncludingFloatsTo() (which could fail prior to this fix); When moving children from one container to another, either both or none of the containers must have inline children. This is a reland of https://chromium-review.googlesource.com/1102690 with some modifications to avoid bug 853552. Bug: 852640 Change-Id: I0f8a0aa5523e8fe60c841164d25aad088f4b728f Reviewed-on: https://chromium-review.googlesource.com/1104900 Commit-Queue: Morten Stenshorne <[email protected]> Commit-Queue: Emil A Eklund <[email protected]> Reviewed-by: Emil A Eklund <[email protected]> Cr-Commit-Position: refs/heads/master@{#568196}
1 parent 79341a4 commit 28b5323

File tree

2 files changed

+44
-0
lines changed

2 files changed

+44
-0
lines changed
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<!DOCTYPE html>
2+
<title>Removing block between inline and float should put the two on the same line</title>
3+
<link rel="author" title="Morten Stenshorne" href="[email protected]">
4+
<link rel="help" href="https://www.w3.org/TR/CSS22/visuren.html#absolute-positioning" title="9.6 Absolute positioning">
5+
<link rel="match" href="../../reference/ref-filled-green-200px-square.html">
6+
<p>Test passes if there is a filled green square and <strong>no red</strong>.</p>
7+
<!-- This is a block with block children, so inlines need to be wrapped inside
8+
anonymous blocks. A float and out-of-flow positioned box is neutral here,
9+
in that it can either live among block children OR among inline
10+
children. If it is (or becomes) sibling of an inline child, though, it
11+
should be wrapped inside the same anonymous block as the inline, or layout
12+
will be wrong. -->
13+
<div style="width:200px; background:red;">
14+
<div style="height:50px; background:green;"></div>
15+
<div style="display:inline-block; vertical-align:top; width:100px; height:150px; background:green;"></div>
16+
<div id="removeMe" style="height:100px;"></div>
17+
<span style="position:absolute; width:100px; height:150px; background:green;"></span>
18+
</div>
19+
<script>
20+
document.body.offsetTop; // Trigger layout.
21+
document.getElementById("removeMe").style.display = "none";
22+
</script>
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<!DOCTYPE html>
2+
<title>Removing block between inline and float should put the two on the same line</title>
3+
<link rel="author" title="Morten Stenshorne" href="[email protected]">
4+
<link rel="help" href="https://www.w3.org/TR/CSS22/visuren.html#floats" title="9.5 Floats">
5+
<link rel="match" href="../../reference/ref-filled-green-200px-square.html">
6+
<p>Test passes if there is a filled green square and <strong>no red</strong>.</p>
7+
<!-- This is a block with block children, so inlines need to be wrapped inside
8+
anonymous blocks. A float and out-of-flow positioned box is neutral here,
9+
in that it can either live among block children OR among inline
10+
children. If it is (or becomes) sibling of an inline child, though, it
11+
should be wrapped inside the same anonymous block as the inline, or layout
12+
will be wrong. -->
13+
<div style="width:200px; background:red;">
14+
<div style="height:50px; background:green;"></div>
15+
<div style="display:inline-block; vertical-align:top; width:100px; height:150px; background:green;"></div>
16+
<div id="removeMe" style="height:100px;"></div>
17+
<div style="float:left; width:100px; height:150px; background:green;"></div>
18+
</div>
19+
<script>
20+
document.body.offsetTop; // Trigger layout.
21+
document.getElementById("removeMe").style.display = "none";
22+
</script>

0 commit comments

Comments
 (0)