Commit dd4c10b0 authored by Morten Stenshorne's avatar Morten Stenshorne Committed by Commit Bot

[LayoutNG] Report unbreakable block-size for non-block-containers.

We need to report unbreakable block-size from the column layout
algorithm, in cases where we have nested column balancing.

Set up the fragment builder to be block-fragmented when inside a nested
multicol that performs the initial column balancing pass, so that
spanners report unbreakability (happens automatically via
NGBoxFragmentBuilder::AddResult(), when set up correctly).

When we fall back to legacy layout, we also need to set up the builder
so that we report unbreakable block-size rather than space shortage
(those two share data storage). We don't actually have to report any
size, though, (0 is fine) since this is always monolithic content, which
is taken care of by the parent algorithm (BreakBeforeChildIfNeeded() in
NGBlockLayoutAlgorithm).

Bug: 829028, 1013716
Change-Id: Ib507cbedbacf2ed05c1db5a58f7738c070f3ab79
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1859786Reviewed-by: default avatarIan Kilpatrick <ikilpatrick@chromium.org>
Commit-Queue: Morten Stenshorne <mstensho@chromium.org>
Cr-Commit-Position: refs/heads/master@{#705533}
parent e9a890e3
...@@ -1180,6 +1180,20 @@ scoped_refptr<const NGLayoutResult> NGBlockNode::RunLegacyLayout( ...@@ -1180,6 +1180,20 @@ scoped_refptr<const NGLayoutResult> NGBlockNode::RunLegacyLayout(
builder.SetInitialFragmentGeometry(fragment_geometry); builder.SetInitialFragmentGeometry(fragment_geometry);
builder.SetIsLegacyLayoutRoot(); builder.SetIsLegacyLayoutRoot();
// If we're block-fragmented, we can only handle monolithic content, since
// the two block fragmentation machineries (NG and legacy) cannot cooperate.
DCHECK(!constraint_space.HasBlockFragmentation() || IsMonolithic());
if (constraint_space.IsInitialColumnBalancingPass()) {
// In the initial column balancing pass we need to provide the tallest
// unbreakable block-size. However, since the content is monolithic,
// that's already handled by the parent algorithm (so we don't need to
// propagate anything here). We still have to tell the builder that we're
// in this layout pass, though, so that the layout result is set up
// correctly.
builder.SetIsInitialColumnBalancingPass();
}
CopyBaselinesFromLegacyLayout(constraint_space, &builder); CopyBaselinesFromLegacyLayout(constraint_space, &builder);
layout_result = builder.ToBoxFragment(); layout_result = builder.ToBoxFragment();
......
...@@ -117,8 +117,11 @@ scoped_refptr<const NGLayoutResult> NGColumnLayoutAlgorithm::Layout() { ...@@ -117,8 +117,11 @@ scoped_refptr<const NGLayoutResult> NGColumnLayoutAlgorithm::Layout() {
is_constrained_by_outer_fragmentation_context_ = is_constrained_by_outer_fragmentation_context_ =
ConstraintSpace().HasKnownFragmentainerBlockSize(); ConstraintSpace().HasKnownFragmentainerBlockSize();
if (is_constrained_by_outer_fragmentation_context_) if (ConstraintSpace().HasBlockFragmentation()) {
container_builder_.SetHasBlockFragmentation(); container_builder_.SetHasBlockFragmentation();
if (ConstraintSpace().IsInitialColumnBalancingPass())
container_builder_.SetIsInitialColumnBalancingPass();
}
container_builder_.SetIsBlockFragmentationContextRoot(); container_builder_.SetIsBlockFragmentationContextRoot();
...@@ -661,6 +664,14 @@ LayoutUnit NGColumnLayoutAlgorithm::CalculateBalancedColumnBlockSize( ...@@ -661,6 +664,14 @@ LayoutUnit NGColumnLayoutAlgorithm::CalculateBalancedColumnBlockSize(
content_runs[index].implicit_breaks_assumed_count++; content_runs[index].implicit_breaks_assumed_count++;
} }
if (ConstraintSpace().IsInitialColumnBalancingPass()) {
// Nested column balancing. Our outer fragmentation context is in its
// initial balancing pass, so it also wants to know the largest unbreakable
// block-size.
container_builder_.PropagateTallestUnbreakableBlockSize(
tallest_unbreakable_block_size);
}
// We now have an estimated minimal block-size for the columns. Roughly // We now have an estimated minimal block-size for the columns. Roughly
// speaking, this is the block-size that the columns will need if we are // speaking, this is the block-size that the columns will need if we are
// allowed to break freely at any offset. This is normally not the case, // allowed to break freely at any offset. This is normally not the case,
......
...@@ -2826,6 +2826,72 @@ TEST_F(NGColumnLayoutAlgorithmTest, ColumnBalancingSingleLine) { ...@@ -2826,6 +2826,72 @@ TEST_F(NGColumnLayoutAlgorithmTest, ColumnBalancingSingleLine) {
EXPECT_EQ(expectation, dump); EXPECT_EQ(expectation, dump);
} }
TEST_F(NGColumnLayoutAlgorithmTest, ColumnBalancingSingleLineInNested) {
SetBodyInnerHTML(R"HTML(
<style>
#parent {
columns: 3;
column-gap: 10px;
width: 320px;
line-height: 20px;
}
</style>
<div id="container">
<div id="parent">
<div style="columns:2; column-gap:10px;">
<br>
</div>
</div>
</div>
)HTML");
String dump = DumpFragmentTree(GetElementById("container"));
String expectation = R"DUMP(.:: LayoutNG Physical Fragment Tree ::.
offset:unplaced size:1000x20
offset:0,0 size:320x20
offset:0,0 size:100x20
offset:0,0 size:100x20
offset:0,0 size:45x20
offset:0,0 size:0x20
offset:0,9 size:0x1
)DUMP";
EXPECT_EQ(expectation, dump);
}
TEST_F(NGColumnLayoutAlgorithmTest, ColumnBalancingSingleLineInNestedSpanner) {
SetBodyInnerHTML(R"HTML(
<style>
#parent {
columns: 3;
column-gap: 10px;
width: 320px;
line-height: 20px;
}
</style>
<div id="container">
<div id="parent">
<div style="columns:2;">
<div style="column-span:all;">
<br>
</div>
</div>
</div>
</div>
)HTML");
String dump = DumpFragmentTree(GetElementById("container"));
String expectation = R"DUMP(.:: LayoutNG Physical Fragment Tree ::.
offset:unplaced size:1000x20
offset:0,0 size:320x20
offset:0,0 size:100x20
offset:0,0 size:100x20
offset:0,0 size:100x20
offset:0,0 size:0x20
offset:0,9 size:0x1
)DUMP";
EXPECT_EQ(expectation, dump);
}
TEST_F(NGColumnLayoutAlgorithmTest, ColumnBalancingOverflow) { TEST_F(NGColumnLayoutAlgorithmTest, ColumnBalancingOverflow) {
SetBodyInnerHTML(R"HTML( SetBodyInnerHTML(R"HTML(
<style> <style>
......
...@@ -1163,13 +1163,11 @@ crbug.com/591099 virtual/layout_ng_experimental/fast/multicol/nested-auto-height ...@@ -1163,13 +1163,11 @@ crbug.com/591099 virtual/layout_ng_experimental/fast/multicol/nested-auto-height
crbug.com/591099 virtual/layout_ng_experimental/fast/multicol/nested-auto-height.html [ Failure ] crbug.com/591099 virtual/layout_ng_experimental/fast/multicol/nested-auto-height.html [ Failure ]
crbug.com/591099 virtual/layout_ng_experimental/fast/multicol/nested-auto-height-short-first-row.html [ Failure ] crbug.com/591099 virtual/layout_ng_experimental/fast/multicol/nested-auto-height-short-first-row.html [ Failure ]
crbug.com/829028 virtual/layout_ng_experimental/fast/multicol/nested-balanced-inner-column-count-1-with-forced-break.html [ Failure ] crbug.com/829028 virtual/layout_ng_experimental/fast/multicol/nested-balanced-inner-column-count-1-with-forced-break.html [ Failure ]
crbug.com/829028 virtual/layout_ng_experimental/fast/multicol/nested-balanced-inner-column-count-1-with-forced-break-2.html [ Failure ]
crbug.com/591099 virtual/layout_ng_experimental/fast/multicol/nested-balanced-inner-with-many-breaks-2.html [ Failure ] crbug.com/591099 virtual/layout_ng_experimental/fast/multicol/nested-balanced-inner-with-many-breaks-2.html [ Failure ]
crbug.com/591099 virtual/layout_ng_experimental/fast/multicol/nested-balanced-inner-with-many-breaks.html [ Failure ] crbug.com/591099 virtual/layout_ng_experimental/fast/multicol/nested-balanced-inner-with-many-breaks.html [ Failure ]
crbug.com/591099 virtual/layout_ng_experimental/fast/multicol/nested-balanced-with-strut-before-first-line.html [ Failure ] crbug.com/591099 virtual/layout_ng_experimental/fast/multicol/nested-balanced-with-strut-before-first-line.html [ Failure ]
crbug.com/591099 virtual/layout_ng_experimental/fast/multicol/nested-columns.html [ Failure ] crbug.com/591099 virtual/layout_ng_experimental/fast/multicol/nested-columns.html [ Failure ]
crbug.com/591099 virtual/layout_ng_experimental/fast/multicol/nested-fixed-height-with-struts.html [ Failure ] crbug.com/591099 virtual/layout_ng_experimental/fast/multicol/nested-fixed-height-with-struts.html [ Failure ]
crbug.com/591099 virtual/layout_ng_experimental/fast/multicol/nested-one-line-in-inner.html [ Failure ]
crbug.com/591099 virtual/layout_ng_experimental/fast/multicol/nested-outer-fixed-height.html [ Failure ] crbug.com/591099 virtual/layout_ng_experimental/fast/multicol/nested-outer-fixed-height.html [ Failure ]
crbug.com/591099 virtual/layout_ng_experimental/fast/multicol/nested-short-first-row-extra-tall-line.html [ Failure ] crbug.com/591099 virtual/layout_ng_experimental/fast/multicol/nested-short-first-row-extra-tall-line.html [ Failure ]
crbug.com/591099 virtual/layout_ng_experimental/fast/multicol/nested-short-first-row-unsplittable-block.html [ Failure ] crbug.com/591099 virtual/layout_ng_experimental/fast/multicol/nested-short-first-row-unsplittable-block.html [ Failure ]
......
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