Commit 61745d3d authored by Alison Maher's avatar Alison Maher Committed by Commit Bot

[LayoutNG] Offset of proxy fragments after spanner

When we were adding new proxy fragments directly after a spanner,
we were computing the wrong offset for these new fragmentainers.
This change fixes this by looking at the offset of the spanner when
determining the offset of proxy fragments in this case.

Bug: 1079031
Change-Id: I34a6358f9bc1b1d630d72bb268f3ae79edcdff00
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2422424
Commit-Queue: Alison Maher <almaher@microsoft.com>
Reviewed-by: default avatarMorten Stenshorne <mstensho@chromium.org>
Cr-Commit-Position: refs/heads/master@{#809460}
parent 231f9838
...@@ -1094,20 +1094,34 @@ void NGOutOfFlowLayoutPart::AddOOFResultsToFragmentainer( ...@@ -1094,20 +1094,34 @@ void NGOutOfFlowLayoutPart::AddOOFResultsToFragmentainer(
} }
if (is_new_fragment) { if (is_new_fragment) {
// Calculate the column inline progression in order to calculate the inline LogicalOffset offset;
// offset of any newly added column fragments. if (index != num_children - 1 && !container_builder_->Children()[index + 1]
if (column_inline_progression_ == kIndefiniteSize) { .fragment->IsFragmentainerBox()) {
LayoutUnit available_size = // If we are a new fragment and are separated from other columns by a
container_builder_->ChildAvailableSize().inline_size; // spanner, compute the correct column offset to use.
const ComputedStyle& style = container_builder_->Style(); const auto& spanner = container_builder_->Children()[index + 1];
LayoutUnit column_inline_size = DCHECK(spanner.fragment->IsColumnSpanAll());
ResolveUsedColumnInlineSize(available_size, style);
column_inline_progression_ = offset = spanner.offset;
column_inline_size + ResolveUsedColumnGap(available_size, style); LogicalSize spanner_size = spanner.fragment->Size().ConvertToLogical(
container_builder_->Style().GetWritingMode());
// TODO(almaher): Include trailing spanner margin.
offset.block_offset += spanner_size.block_size;
} else {
// Calculate the column inline progression in order to calculate the
// inline offset of any newly added column fragments.
if (column_inline_progression_ == kIndefiniteSize) {
LayoutUnit available_size =
container_builder_->ChildAvailableSize().inline_size;
const ComputedStyle& style = container_builder_->Style();
LayoutUnit column_inline_size =
ResolveUsedColumnInlineSize(available_size, style);
column_inline_progression_ =
column_inline_size + ResolveUsedColumnGap(available_size, style);
}
offset = fragmentainer.offset;
offset.inline_offset += column_inline_progression_;
} }
LogicalOffset offset = fragmentainer.offset;
offset.inline_offset += column_inline_progression_;
container_builder_->AddChild(algorithm.Layout()->PhysicalFragment(), container_builder_->AddChild(algorithm.Layout()->PhysicalFragment(),
offset); offset);
} else { } else {
......
...@@ -966,8 +966,6 @@ TEST_F(NGOutOfFlowLayoutPartTest, ...@@ -966,8 +966,6 @@ TEST_F(NGOutOfFlowLayoutPartTest,
// TODO(1079031): With top set to 0px, the abspos should start in the first // TODO(1079031): With top set to 0px, the abspos should start in the first
// column with an offset of (0,0). // column with an offset of (0,0).
// TODO(1079031): The offsets of the columns following the spanner are
// incorrect. (The first should start at (0,10)).
String expectation = R"DUMP(.:: LayoutNG Physical Fragment Tree ::. String expectation = R"DUMP(.:: LayoutNG Physical Fragment Tree ::.
offset:unplaced size:1000x40 offset:unplaced size:1000x40
offset:0,0 size:1000x40 offset:0,0 size:1000x40
...@@ -981,13 +979,13 @@ TEST_F(NGOutOfFlowLayoutPartTest, ...@@ -981,13 +979,13 @@ TEST_F(NGOutOfFlowLayoutPartTest,
offset:0,10 size:1000x0 offset:0,10 size:1000x0
offset:0,10 size:1000x0 offset:0,10 size:1000x0
offset:0,10 size:1000x0 offset:0,10 size:1000x0
offset:1016,0 size:492x30 offset:0,10 size:492x30
offset:0,0 size:5x30 offset:0,0 size:5x30
offset:1524,0 size:492x30 offset:508,10 size:492x30
offset:0,0 size:5x30 offset:0,0 size:5x30
offset:2032,0 size:492x30 offset:1016,10 size:492x30
offset:0,0 size:5x30 offset:0,0 size:5x30
offset:2540,0 size:492x30 offset:1524,10 size:492x30
offset:0,0 size:5x20 offset:0,0 size:5x20
)DUMP"; )DUMP";
EXPECT_EQ(expectation, dump); EXPECT_EQ(expectation, dump);
...@@ -1026,8 +1024,6 @@ TEST_F(NGOutOfFlowLayoutPartTest, ...@@ -1026,8 +1024,6 @@ TEST_F(NGOutOfFlowLayoutPartTest,
// TODO(1079031): With top set to 25px, the abspos should start in the third // TODO(1079031): With top set to 25px, the abspos should start in the third
// column with an offset of (0,5). // column with an offset of (0,5).
// TODO(1079031): The offsets of the columns following the spanner are
// incorrect. (The first should start at (0,10)).
String expectation = R"DUMP(.:: LayoutNG Physical Fragment Tree ::. String expectation = R"DUMP(.:: LayoutNG Physical Fragment Tree ::.
offset:unplaced size:1000x40 offset:unplaced size:1000x40
offset:0,0 size:1000x40 offset:0,0 size:1000x40
...@@ -1038,11 +1034,11 @@ TEST_F(NGOutOfFlowLayoutPartTest, ...@@ -1038,11 +1034,11 @@ TEST_F(NGOutOfFlowLayoutPartTest,
offset:0,0 size:30x10 offset:0,0 size:30x10
offset:0,0 size:30x10 offset:0,0 size:30x10
offset:0,10 size:1000x0 offset:0,10 size:1000x0
offset:1016,0 size:492x30 offset:0,10 size:492x30
offset:0,15 size:5x15 offset:0,15 size:5x15
offset:1524,0 size:492x30 offset:508,10 size:492x30
offset:0,0 size:5x30 offset:0,0 size:5x30
offset:2032,0 size:492x30 offset:1016,10 size:492x30
offset:0,0 size:5x5 offset:0,0 size:5x5
)DUMP"; )DUMP";
EXPECT_EQ(expectation, dump); EXPECT_EQ(expectation, dump);
...@@ -1088,12 +1084,12 @@ TEST_F(NGOutOfFlowLayoutPartTest, ...@@ -1088,12 +1084,12 @@ TEST_F(NGOutOfFlowLayoutPartTest,
offset:0,0 size:1000x0 offset:0,0 size:1000x0
offset:0,0 size:1000x0 offset:0,0 size:1000x0
offset:0,0 size:1000x0 offset:0,0 size:1000x0
offset:0,0 size:492x1
offset:0,0 size:5x1
offset:508,0 size:492x1 offset:508,0 size:492x1
offset:0,0 size:5x1 offset:0,0 size:5x1
offset:1016,0 size:492x1 offset:1016,0 size:492x1
offset:0,0 size:5x1 offset:0,0 size:5x1
offset:1524,0 size:492x1
offset:0,0 size:5x1
)DUMP"; )DUMP";
EXPECT_EQ(expectation, dump); EXPECT_EQ(expectation, dump);
} }
...@@ -1136,14 +1132,14 @@ TEST_F(NGOutOfFlowLayoutPartTest, AbsposFragWithSpannerAndNewEmptyColumns) { ...@@ -1136,14 +1132,14 @@ TEST_F(NGOutOfFlowLayoutPartTest, AbsposFragWithSpannerAndNewEmptyColumns) {
offset:0,0 size:1000x0 offset:0,0 size:1000x0
offset:0,0 size:1000x0 offset:0,0 size:1000x0
offset:0,0 size:1000x0 offset:0,0 size:1000x0
offset:0,0 size:492x40
offset:508,0 size:492x40 offset:508,0 size:492x40
offset:1016,0 size:492x40
offset:0,39 size:5x1 offset:0,39 size:5x1
offset:1016,0 size:492x40
offset:0,0 size:5x40
offset:1524,0 size:492x40 offset:1524,0 size:492x40
offset:0,0 size:5x40 offset:0,0 size:5x40
offset:2032,0 size:492x40 offset:2032,0 size:492x40
offset:0,0 size:5x40
offset:2540,0 size:492x40
offset:0,0 size:5x39 offset:0,0 size:5x39
)DUMP"; )DUMP";
EXPECT_EQ(expectation, dump); EXPECT_EQ(expectation, dump);
......
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