Commit dca8306c authored by Alison Maher's avatar Alison Maher Committed by Commit Bot

[LayoutNG] Add forced breakpoint tests

Break-before, break-after, and break-inside don't apply to absolute
positioned elements, so we don't need to add any special handling for
these when fragmenting OOF positioned elements. This change adds tests
to ensure that these forced breaks don't apply to abspos elements, as
expected, but do still apply to the children of abspos elements.

Bug: 1079031
Change-Id: Iaee4dfa67244e1999f659978c7cb3bbfce55ad8d
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2327818
Commit-Queue: Alison Maher <almaher@microsoft.com>
Reviewed-by: default avatarMorten Stenshorne <mstensho@chromium.org>
Cr-Commit-Position: refs/heads/master@{#795544}
parent 4db0a23f
......@@ -317,5 +317,253 @@ TEST_F(NGOutOfFlowLayoutPartTest, PositionedFragmentationWithNewEmptyColumns) {
EXPECT_EQ(expectation, dump);
}
// Break-inside does not apply to absolute positioned elements.
TEST_F(NGOutOfFlowLayoutPartTest, BreakInsideAvoid) {
SetBodyInnerHTML(
R"HTML(
<style>
#multicol {
column-count:2; column-fill:auto; column-gap:16px; height:40px;
}
.rel {
position: relative;
}
.abs {
position:absolute; break-inside:avoid;
}
</style>
<div id="container">
<div id="multicol">
<div style="width:20px; height:10px;"></div>
<div class="rel" style="width:30px;">
<div class="abs" style="width:40px; height:40px;"></div>
</div>
</div>
</div>
)HTML");
String dump = DumpFragmentTree(GetElementById("container"));
// TODO(bebeaudr): The abspos should have an offset of (0,10), and
// break into a second column, ignoring "break-inside:avoid".
String expectation = R"DUMP(.:: LayoutNG Physical Fragment Tree ::.
offset:unplaced size:1000x40
offset:0,0 size:1000x40
offset:0,0 size:492x40
offset:0,0 size:20x10
offset:0,10 size:30x0
offset:0,0 size:40x40
)DUMP";
EXPECT_EQ(expectation, dump);
}
// Break-before does not apply to absolute positioned elements.
TEST_F(NGOutOfFlowLayoutPartTest, BreakBeforeColumn) {
SetBodyInnerHTML(
R"HTML(
<style>
#multicol {
column-count:2; column-fill:auto; column-gap:16px; height:40px;
}
.rel {
position: relative;
}
.abs {
position:absolute; break-before:column;
}
</style>
<div id="container">
<div id="multicol">
<div style="width:10px; height:30px;"></div>
<div class="rel" style="width:30px;">
<div class="abs" style="width:40px; height:30px;"></div>
</div>
</div>
</div>
)HTML");
String dump = DumpFragmentTree(GetElementById("container"));
// TODO(bebeaudr): The abspos should have an offset of (0,30) in the first
// column, ignoring "break-before:column", and break into a second column.
String expectation = R"DUMP(.:: LayoutNG Physical Fragment Tree ::.
offset:unplaced size:1000x40
offset:0,0 size:1000x40
offset:0,0 size:492x40
offset:0,0 size:10x30
offset:0,30 size:30x0
offset:0,0 size:40x30
)DUMP";
EXPECT_EQ(expectation, dump);
}
// Break-after does not apply to absolute positioned elements.
TEST_F(NGOutOfFlowLayoutPartTest, BreakAfterColumn) {
SetBodyInnerHTML(
R"HTML(
<style>
#multicol {
column-count:2; column-fill:auto; column-gap:16px; height:40px;
}
.rel {
position: relative;
}
.abs {
position:absolute; break-after:column;
}
</style>
<div id="container">
<div id="multicol">
<div style="width:10px; height:20px;"></div>
<div class="rel" style="width:30px; height:10px;">
<div class="abs" style="width:40px; height:10px;"></div>
</div>
<div style="width:20px; height:10px;"></div>
</div>
</div>
)HTML");
String dump = DumpFragmentTree(GetElementById("container"));
// TODO(bebeaudr): The abspos should have an offset of (0,20).
String expectation = R"DUMP(.:: LayoutNG Physical Fragment Tree ::.
offset:unplaced size:1000x40
offset:0,0 size:1000x40
offset:0,0 size:492x40
offset:0,0 size:10x20
offset:0,20 size:30x10
offset:0,30 size:20x10
offset:0,0 size:40x10
)DUMP";
EXPECT_EQ(expectation, dump);
}
// Break-inside should still apply to children of absolute positioned elements.
TEST_F(NGOutOfFlowLayoutPartTest, ChildBreakInsideAvoid) {
SetBodyInnerHTML(
R"HTML(
<style>
#multicol {
column-count:2; column-fill:auto; column-gap:16px; height:100px;
}
.rel {
position: relative;
}
.abs {
position:absolute;
}
</style>
<div id="container">
<div id="multicol">
<div class="rel" style="width:30px;">
<div class="abs" style="width:40px; height:150px;">
<div style="width:15px; height:50px;"></div>
<div style="break-inside:avoid; width:20px; height:100px;"></div>
</div>
</div>
</div>
</div>
)HTML");
String dump = DumpFragmentTree(GetElementById("container"));
String expectation = R"DUMP(.:: LayoutNG Physical Fragment Tree ::.
offset:unplaced size:1000x100
offset:0,0 size:1000x100
offset:0,0 size:492x100
offset:0,0 size:30x0
offset:0,0 size:40x100
offset:0,0 size:15x50
offset:508,0 size:492x100
offset:0,0 size:40x50
offset:0,0 size:20x100
)DUMP";
EXPECT_EQ(expectation, dump);
}
// Break-before should still apply to children of absolute positioned elements.
TEST_F(NGOutOfFlowLayoutPartTest, ChildBreakBeforeAvoid) {
SetBodyInnerHTML(
R"HTML(
<style>
#multicol {
column-count:2; column-fill:auto; column-gap:16px; height:100px;
}
.rel {
position: relative;
}
.abs {
position:absolute;
}
</style>
<div id="container">
<div id="multicol">
<div class="rel" style="width:30px;">
<div class="abs" style="width:40px; height:150px;">
<div style="width:15px; height:50px;"></div>
<div style="width:20px; height:50px;"></div>
<div style="break-before:avoid; width:10px; height:20px;"></div>
</div>
</div>
</div>
</div>
)HTML");
String dump = DumpFragmentTree(GetElementById("container"));
String expectation = R"DUMP(.:: LayoutNG Physical Fragment Tree ::.
offset:unplaced size:1000x100
offset:0,0 size:1000x100
offset:0,0 size:492x100
offset:0,0 size:30x0
offset:0,0 size:40x100
offset:0,0 size:15x50
offset:508,0 size:492x100
offset:0,0 size:40x50
offset:0,0 size:20x50
offset:0,50 size:10x20
)DUMP";
EXPECT_EQ(expectation, dump);
}
// Break-after should still apply to children of absolute positioned elements.
TEST_F(NGOutOfFlowLayoutPartTest, ChildBreakAfterAvoid) {
SetBodyInnerHTML(
R"HTML(
<style>
#multicol {
column-count:2; column-fill:auto; column-gap:16px; height:100px;
}
.rel {
position: relative;
}
.abs {
position:absolute;
}
</style>
<div id="container">
<div id="multicol">
<div class="rel" style="width:30px;">
<div class="abs" style="width:40px; height:150px;">
<div style="width:15px; height:50px;"></div>
<div style="break-after:avoid; width:20px; height:50px;"></div>
<div style="width:10px; height:20px;"></div>
</div>
</div>
</div>
</div>
)HTML");
String dump = DumpFragmentTree(GetElementById("container"));
String expectation = R"DUMP(.:: LayoutNG Physical Fragment Tree ::.
offset:unplaced size:1000x100
offset:0,0 size:1000x100
offset:0,0 size:492x100
offset:0,0 size:30x0
offset:0,0 size:40x100
offset:0,0 size:15x50
offset:508,0 size:492x100
offset:0,0 size:40x50
offset:0,0 size:20x50
offset:0,50 size:10x20
)DUMP";
EXPECT_EQ(expectation, dump);
}
} // namespace
} // namespace blink
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment