Commit 2df15e26 authored by Alison Maher's avatar Alison Maher Committed by Commit Bot

[LayoutNG] Pass the column block offset to NGOutOfFlowLayoutPart

When determining the column block size of a new proxy fragment that
is added directly after a spanning fragment, we need to know the
current column block offset.

Bug: 1079031
Change-Id: Ibc03d753e927da3b02399d27e986132c4f4833e0
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2365355
Commit-Queue: Alison Maher <almaher@microsoft.com>
Reviewed-by: default avatarMorten Stenshorne <mstensho@chromium.org>
Cr-Commit-Position: refs/heads/master@{#803672}
parent bb91d09d
...@@ -226,6 +226,16 @@ class CORE_EXPORT NGBoxFragmentBuilder final ...@@ -226,6 +226,16 @@ class CORE_EXPORT NGBoxFragmentBuilder final
// building now. // building now.
void SetConsumedBlockSize(LayoutUnit size) { consumed_block_size_ = size; } void SetConsumedBlockSize(LayoutUnit size) { consumed_block_size_ = size; }
// Set how much of the column block-size we've used so far. This will be used
// to determine the block-size of any new columns added by descendant
// out-of-flow positioned elements.
void SetBlockOffsetForAdditionalColumns(LayoutUnit size) {
block_offset_for_additional_columns_ = size;
}
LayoutUnit BlockOffsetForAdditionalColumns() const {
return block_offset_for_additional_columns_;
}
void SetSequenceNumber(unsigned sequence_number) { void SetSequenceNumber(unsigned sequence_number) {
sequence_number_ = sequence_number; sequence_number_ = sequence_number;
} }
...@@ -542,6 +552,7 @@ class CORE_EXPORT NGBoxFragmentBuilder final ...@@ -542,6 +552,7 @@ class CORE_EXPORT NGBoxFragmentBuilder final
bool is_math_fraction_ = false; bool is_math_fraction_ = false;
bool is_at_block_end_ = false; bool is_at_block_end_ = false;
LayoutUnit consumed_block_size_; LayoutUnit consumed_block_size_;
LayoutUnit block_offset_for_additional_columns_;
unsigned sequence_number_ = 0; unsigned sequence_number_ = 0;
LayoutUnit minimal_space_shortage_ = LayoutUnit::Max(); LayoutUnit minimal_space_shortage_ = LayoutUnit::Max();
......
...@@ -294,6 +294,8 @@ scoped_refptr<const NGLayoutResult> NGColumnLayoutAlgorithm::Layout() { ...@@ -294,6 +294,8 @@ scoped_refptr<const NGLayoutResult> NGColumnLayoutAlgorithm::Layout() {
container_builder_.SetFragmentsTotalBlockSize(previously_consumed_block_size + container_builder_.SetFragmentsTotalBlockSize(previously_consumed_block_size +
block_size); block_size);
container_builder_.SetIntrinsicBlockSize(intrinsic_block_size_); container_builder_.SetIntrinsicBlockSize(intrinsic_block_size_);
container_builder_.SetBlockOffsetForAdditionalColumns(
CurrentContentBlockOffset());
if (ConstraintSpace().HasBlockFragmentation()) { if (ConstraintSpace().HasBlockFragmentation()) {
// In addition to establishing one, we're nested inside another // In addition to establishing one, we're nested inside another
......
...@@ -1152,9 +1152,10 @@ const NGConstraintSpace& NGOutOfFlowLayoutPart::GetFragmentainerConstraintSpace( ...@@ -1152,9 +1152,10 @@ const NGConstraintSpace& NGOutOfFlowLayoutPart::GetFragmentainerConstraintSpace(
original_column_block_size_ != kIndefiniteSize && original_column_block_size_ != kIndefiniteSize &&
!container_builder_->Children()[index + 1] !container_builder_->Children()[index + 1]
.fragment->IsFragmentainerBox()) { .fragment->IsFragmentainerBox()) {
// TODO(almaher): Should we take the consumed column block size into column_size.block_size =
// account? original_column_block_size_ -
column_size.block_size = original_column_block_size_; container_builder_->BlockOffsetForAdditionalColumns();
column_size.block_size = column_size.block_size.ClampNegativeToZero();
} }
// TODO(bebeaudr): Need to handle different fragmentation types. It won't // TODO(bebeaudr): Need to handle different fragmentation types. It won't
...@@ -1227,9 +1228,10 @@ void NGOutOfFlowLayoutPart::ComputeStartFragmentIndexAndRelativeOffset( ...@@ -1227,9 +1228,10 @@ void NGOutOfFlowLayoutPart::ComputeStartFragmentIndexAndRelativeOffset(
if (original_column_block_size_ != kIndefiniteSize && if (original_column_block_size_ != kIndefiniteSize &&
!container_builder_->Children()[child_index - 1] !container_builder_->Children()[child_index - 1]
.fragment->IsFragmentainerBox()) { .fragment->IsFragmentainerBox()) {
// TODO(almaher): Should we take the consumed column block size into fragmentainer_block_size =
// account? original_column_block_size_ -
fragmentainer_block_size = original_column_block_size_; container_builder_->BlockOffsetForAdditionalColumns();
fragmentainer_block_size = fragmentainer_block_size.ClampNegativeToZero();
} }
wtf_size_t additional_fragment_count = wtf_size_t additional_fragment_count =
......
...@@ -966,6 +966,8 @@ TEST_F(NGOutOfFlowLayoutPartTest, ...@@ -966,6 +966,8 @@ 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
...@@ -979,12 +981,69 @@ TEST_F(NGOutOfFlowLayoutPartTest, ...@@ -979,12 +981,69 @@ 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:492x40 offset:1016,0 size:492x30
offset:0,0 size:5x40 offset:0,0 size:5x30
offset:1524,0 size:492x40 offset:1524,0 size:492x30
offset:0,0 size:5x40 offset:0,0 size:5x30
offset:2032,0 size:492x40 offset:2032,0 size:492x30
offset:0,0 size:5x30
offset:2540,0 size:492x30
offset:0,0 size:5x20
)DUMP";
EXPECT_EQ(expectation, dump);
}
// Tests that new column fragments are added correctly if a positioned node
// fragments beyond the last fragmentainer in a context directly after a
// spanner.
TEST_F(NGOutOfFlowLayoutPartTest,
PositionedFragmentationWithNewColumnsAfterSpanner) {
SetBodyInnerHTML(
R"HTML(
<style>
#multicol {
column-count:2; column-fill:auto; column-gap:16px; height:40px;
}
.rel {
position: relative; width:30px;
}
.abs {
position:absolute; width:5px; height:50px; top:25px;
}
.content { height:20px; }
</style>
<div id="container">
<div id="multicol">
<div class="rel">
<div class="content"></div>
<div class="abs"></div>
</div>
<div style="column-span:all;"></div>
</div>
</div>
)HTML");
String dump = DumpFragmentTree(GetElementById("container"));
// TODO(1079031): With top set to 25px, the abspos should start in the third
// 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 ::.
offset:unplaced size:1000x40
offset:0,0 size:1000x40
offset:0,0 size:492x10
offset:0,0 size:30x10
offset:0,0 size:30x10
offset:508,0 size:492x10
offset:0,0 size:30x10
offset:0,0 size:30x10
offset:0,10 size:1000x0
offset:1016,0 size:492x30
offset:0,15 size:5x15
offset:1524,0 size:492x30
offset:0,0 size:5x30 offset:0,0 size:5x30
offset:2032,0 size:492x30
offset:0,0 size:5x5
)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