Commit c78c300c authored by Ana SollanoKim's avatar Ana SollanoKim Committed by Commit Bot

[LayoutNG] Make fieldset legends monolithic

Previously, we had made the legends fragment in the following change
https://chromium-review.googlesource.com/c/chromium/src/+/2090762. In
this other change
https://chromium-review.googlesource.com/c/chromium/src/+/2263353
we decided to not break borders for now. Because the legend is part of
the fieldset border, we now want to treat the legend as monolithic.

We still have logic for breaking the fieldset border, this will be
addressed in a follow up change.

Bug: 1097012
Change-Id: Iace252447063eb694c47fb9eea2a406ba2fe79d7
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2353354
Commit-Queue: Ana Sollano Kim <ansollan@microsoft.com>
Reviewed-by: default avatarAlison Maher <almaher@microsoft.com>
Reviewed-by: default avatarMorten Stenshorne <mstensho@chromium.org>
Cr-Commit-Position: refs/heads/master@{#798528}
parent 1bf739db
......@@ -146,24 +146,19 @@ scoped_refptr<const NGLayoutResult> NGFieldsetLayoutAlgorithm::Layout() {
}
NGBreakStatus NGFieldsetLayoutAlgorithm::LayoutChildren() {
scoped_refptr<const NGBlockBreakToken> legend_break_token;
scoped_refptr<const NGBlockBreakToken> content_break_token;
bool has_seen_all_children = false;
if (const auto* token = BreakToken()) {
const auto child_tokens = token->ChildBreakTokens();
if (wtf_size_t break_token_count = child_tokens.size()) {
DCHECK_LE(break_token_count, 2u);
for (wtf_size_t break_token_idx = 0; break_token_idx < break_token_count;
break_token_idx++) {
scoped_refptr<const NGBlockBreakToken> child_token =
To<NGBlockBreakToken>(child_tokens[break_token_idx]);
if (child_token && child_token->InputNode().IsRenderedLegend()) {
DCHECK_EQ(break_token_idx, 0u);
legend_break_token = child_token;
} else {
content_break_token = child_token;
}
scoped_refptr<const NGBlockBreakToken> child_token =
To<NGBlockBreakToken>(child_tokens[0]);
if (child_token) {
DCHECK(!child_token->InputNode().IsRenderedLegend());
content_break_token = child_token;
}
// There shouldn't be any additional break tokens.
DCHECK_EQ(child_tokens.size(), 1u);
}
if (token->HasSeenAllChildren()) {
container_builder_.SetHasSeenAllChildren();
......@@ -172,14 +167,8 @@ NGBreakStatus NGFieldsetLayoutAlgorithm::LayoutChildren() {
}
NGBlockNode legend = Node().GetRenderedLegend();
bool legend_needs_layout =
legend && (legend_break_token || !IsResumingLayout(BreakToken()));
if (legend_needs_layout) {
NGBreakStatus break_status = LayoutLegend(legend, legend_break_token);
if (break_status != NGBreakStatus::kContinue)
return break_status;
if (legend && !IsResumingLayout(BreakToken())) {
LayoutLegend(legend);
// The legend may eat from the available content box block size. Calculate
// the minimum block size needed to encompass the legend.
if (!Node().ShouldApplySizeContainment()) {
......@@ -231,11 +220,6 @@ NGBreakStatus NGFieldsetLayoutAlgorithm::LayoutChildren() {
// all live inside an anonymous child box of the fieldset container.
auto fieldset_content = Node().GetFieldsetContent();
if (fieldset_content && (content_break_token || !has_seen_all_children)) {
if (ConstraintSpace().HasBlockFragmentation() && legend_broke_ &&
IsFragmentainerOutOfSpace(ConstraintSpace().FragmentainerOffsetAtBfc() +
intrinsic_block_size_))
return NGBreakStatus::kContinue;
NGBreakStatus break_status =
LayoutFieldsetContent(fieldset_content, content_break_token,
adjusted_padding_box_size, !!legend);
......@@ -253,9 +237,7 @@ NGBreakStatus NGFieldsetLayoutAlgorithm::LayoutChildren() {
return NGBreakStatus::kContinue;
}
NGBreakStatus NGFieldsetLayoutAlgorithm::LayoutLegend(
NGBlockNode& legend,
scoped_refptr<const NGBlockBreakToken> legend_break_token) {
void NGFieldsetLayoutAlgorithm::LayoutLegend(NGBlockNode& legend) {
// Lay out the legend. While the fieldset container normally ignores its
// padding, the legend is laid out within what would have been the content
// box had the fieldset been a regular block with no weirdness.
......@@ -265,101 +247,47 @@ NGBreakStatus NGFieldsetLayoutAlgorithm::LayoutLegend(
legend.Style(), percentage_size.inline_size,
ConstraintSpace().GetWritingMode(), ConstraintSpace().Direction());
if (legend_break_token)
legend_margins.block_start = LayoutUnit();
scoped_refptr<const NGLayoutResult> result;
scoped_refptr<const NGLayoutResult> previous_result;
LayoutUnit block_offset;
do {
auto legend_space = CreateConstraintSpaceForLegend(
legend, ChildAvailableSize(), percentage_size, block_offset);
result = legend.Layout(legend_space, legend_break_token.get());
// TODO(layout-dev): Handle abortions caused by block fragmentation.
DCHECK_EQ(result->Status(), NGLayoutResult::kSuccess);
if (ConstraintSpace().HasBlockFragmentation()) {
NGBreakStatus break_status = BreakBeforeChildIfNeeded(
ConstraintSpace(), legend, *result.get(),
ConstraintSpace().FragmentainerOffsetAtBfc() + block_offset,
/*has_container_separation*/ false, &container_builder_);
if (break_status != NGBreakStatus::kContinue)
return break_status;
EBreakBetween break_after = JoinFragmentainerBreakValues(
result->FinalBreakAfter(), legend.Style().BreakAfter());
container_builder_.SetPreviousBreakAfter(break_after);
}
auto legend_space = CreateConstraintSpaceForLegend(
legend, ChildAvailableSize(), percentage_size);
scoped_refptr<const NGLayoutResult> result =
legend.Layout(legend_space, BreakToken());
const auto& physical_fragment = result->PhysicalFragment();
legend_broke_ = physical_fragment.BreakToken();
// We have already adjusted the legend block offset, no need to adjust
// again.
if (block_offset != LayoutUnit()) {
// If adjusting the block_offset caused the legend to break, revert back
// to the previous result.
if (legend_broke_) {
result = std::move(previous_result);
block_offset = LayoutUnit();
}
break;
}
LayoutUnit legend_border_box_block_size =
NGFragment(writing_mode_, physical_fragment).BlockSize();
LayoutUnit legend_margin_box_block_size =
legend_margins.block_start + legend_border_box_block_size;
// TODO(layout-dev): Handle abortions caused by block fragmentation.
DCHECK_EQ(result->Status(), NGLayoutResult::kSuccess);
LayoutUnit block_end_margin = legend_margins.block_end;
if (ConstraintSpace().HasKnownFragmentainerBlockSize()) {
block_end_margin = AdjustedMarginAfterFinalChildFragment(
ConstraintSpace(), legend_margin_box_block_size, block_end_margin);
}
legend_margin_box_block_size += block_end_margin;
LayoutUnit space_left = borders_.block_start - legend_border_box_block_size;
if (space_left > LayoutUnit()) {
// Don't adjust the block-start offset of the legend if the legend broke.
if (legend_break_token || legend_broke_)
break;
// https://html.spec.whatwg.org/C/#the-fieldset-and-legend-elements
// * The element is expected to be positioned in the block-flow direction
// such that its border box is centered over the border on the
// block-start side of the fieldset element.
block_offset += space_left / 2;
if (ConstraintSpace().HasBlockFragmentation()) {
// Save the previous result in case adjusting the block_offset causes
// the legend to break.
previous_result = std::move(result);
continue;
}
}
// If the border is smaller than the block end offset of the legend margin
// box, intrinsic_block_size_ should now be based on the the block end
// offset of the legend margin box instead of the border.
LayoutUnit legend_margin_end_offset = block_offset +
legend_margin_box_block_size -
legend_margins.block_start;
if (legend_margin_end_offset > borders_.block_start) {
intrinsic_block_size_ = legend_margin_end_offset;
is_legend_past_border_ = true;
// Don't adjust the block-start offset of the fragment border if it broke.
if (BreakToken() || (ConstraintSpace().HasKnownFragmentainerBlockSize() &&
legend_margin_end_offset >
ConstraintSpace().FragmentainerBlockSize()))
break;
// If the legend is larger than the width of the fieldset block-start
// border, the actual padding edge of the fieldset will be moved
// accordingly. This will be the block-start offset for the fieldset
// contents anonymous box.
borders_.block_start = legend_margin_end_offset;
}
break;
} while (true);
const auto& physical_fragment = result->PhysicalFragment();
LayoutUnit legend_border_box_block_size =
NGFragment(writing_mode_, physical_fragment).BlockSize();
LayoutUnit legend_margin_box_block_size = legend_margins.block_start +
legend_border_box_block_size +
legend_margins.block_end;
LayoutUnit space_left = borders_.block_start - legend_border_box_block_size;
if (space_left > LayoutUnit()) {
// https://html.spec.whatwg.org/C/#the-fieldset-and-legend-elements
// * The element is expected to be positioned in the block-flow direction
// such that its border box is centered over the border on the
// block-start side of the fieldset element.
block_offset += space_left / 2;
}
// If the border is smaller than the block end offset of the legend margin
// box, intrinsic_block_size_ should now be based on the the block end
// offset of the legend margin box instead of the border.
LayoutUnit legend_margin_end_offset =
block_offset + legend_margin_box_block_size - legend_margins.block_start;
if (legend_margin_end_offset > borders_.block_start) {
intrinsic_block_size_ = legend_margin_end_offset;
is_legend_past_border_ = true;
// If the legend is larger than the width of the fieldset block-start
// border, the actual padding edge of the fieldset will be moved
// accordingly. This will be the block-start offset for the fieldset
// contents anonymous box.
borders_.block_start = legend_margin_end_offset;
}
// If the margin box of the legend is at least as tall as the fieldset
// block-start border width, it will start at the block-start border edge
......@@ -375,7 +303,6 @@ NGBreakStatus NGFieldsetLayoutAlgorithm::LayoutLegend(
LogicalOffset legend_offset = {legend_inline_start, block_offset};
container_builder_.AddResult(*result, legend_offset);
return NGBreakStatus::kContinue;
}
LayoutUnit NGFieldsetLayoutAlgorithm::ComputeLegendInlineOffset(
......@@ -488,8 +415,7 @@ const NGConstraintSpace
NGFieldsetLayoutAlgorithm::CreateConstraintSpaceForLegend(
NGBlockNode legend,
LogicalSize available_size,
LogicalSize percentage_size,
LayoutUnit block_offset) {
LogicalSize percentage_size) {
NGConstraintSpaceBuilder builder(
ConstraintSpace(), legend.Style().GetWritingMode(), /* is_new_fc */ true);
SetOrthogonalFallbackInlineSizeIfNeeded(Style(), legend, &builder);
......@@ -498,12 +424,6 @@ NGFieldsetLayoutAlgorithm::CreateConstraintSpaceForLegend(
builder.SetPercentageResolutionSize(percentage_size);
builder.SetIsShrinkToFit(legend.Style().LogicalWidth().IsAuto());
builder.SetTextDirection(legend.Style().Direction());
if (ConstraintSpace().HasBlockFragmentation()) {
SetupSpaceBuilderForFragmentation(ConstraintSpace(), legend, block_offset,
&builder, /* is_new_fc */ true);
builder.SetEarlyBreakAppeal(container_builder_.BreakAppeal());
}
return builder.ToConstraintSpace();
}
......
......@@ -37,9 +37,7 @@ class CORE_EXPORT NGFieldsetLayoutAlgorithm
private:
NGBreakStatus LayoutChildren();
NGBreakStatus LayoutLegend(
NGBlockNode& legend,
scoped_refptr<const NGBlockBreakToken> legend_break_token);
void LayoutLegend(NGBlockNode& legend);
NGBreakStatus LayoutFieldsetContent(
NGBlockNode& fieldset_content,
scoped_refptr<const NGBlockBreakToken> content_break_token,
......@@ -49,13 +47,11 @@ class CORE_EXPORT NGFieldsetLayoutAlgorithm
const NGConstraintSpace CreateConstraintSpaceForLegend(
NGBlockNode legend,
LogicalSize available_size,
LogicalSize percentage_size,
LayoutUnit block_offset);
LogicalSize percentage_size);
const NGConstraintSpace CreateConstraintSpaceForFieldsetContent(
NGBlockNode fieldset_content,
LogicalSize padding_box_size,
LayoutUnit block_offset);
bool IsFragmentainerOutOfSpace(LayoutUnit block_offset) const;
const WritingMode writing_mode_;
......@@ -76,10 +72,6 @@ class CORE_EXPORT NGFieldsetLayoutAlgorithm
// fragments.
LayoutUnit consumed_border_block_start_;
// If true, this indicates that the legend broke during the current layout
// pass.
bool legend_broke_ = false;
// If true, the legend is taller than the block-start border, so that it
// sticks below it, allowing for a class C breakpoint [1] before any fieldset
// content.
......
......@@ -781,8 +781,8 @@ TEST_F(NGFieldsetLayoutAlgorithmTest, FieldsetContentFragmentation) {
EXPECT_EQ(expectation, dump);
}
// Tests that a fieldset with auto height will fragment when its legend reaches
// the fragmentation line.
// Tests that a fieldset with auto height will not fragment when its legend
// reaches the fragmentation line.
TEST_F(NGFieldsetLayoutAlgorithmTest, LegendFragmentationAutoHeight) {
SetBodyInnerHTML(R"HTML(
<style>
......@@ -811,20 +811,12 @@ TEST_F(NGFieldsetLayoutAlgorithmTest, LegendFragmentationAutoHeight) {
ASSERT_TRUE(fragment->BreakToken());
String dump = DumpFragmentTree(fragment.get());
// TODO(crbug.com/1097012): The height of the outermost fragment here should
// be 500, not 490, but the fragmentation machinery gets confused by the
// fieldset padding.
String expectation = R"DUMP(.:: LayoutNG Physical Fragment Tree ::.
offset:unplaced size:176x200
offset:13,0 size:50x200
)DUMP";
EXPECT_EQ(expectation, dump);
fragment = NGBaseLayoutAlgorithmTest::RunFieldsetLayoutAlgorithm(
node, space, fragment->BreakToken());
ASSERT_TRUE(fragment->BreakToken());
dump = DumpFragmentTree(fragment.get());
expectation = R"DUMP(.:: LayoutNG Physical Fragment Tree ::.
offset:unplaced size:176x200
offset:13,0 size:50x200
offset:unplaced size:176x490
offset:13,0 size:50x500
)DUMP";
EXPECT_EQ(expectation, dump);
......@@ -834,14 +826,13 @@ TEST_F(NGFieldsetLayoutAlgorithmTest, LegendFragmentationAutoHeight) {
dump = DumpFragmentTree(fragment.get());
expectation = R"DUMP(.:: LayoutNG Physical Fragment Tree ::.
offset:unplaced size:176x123
offset:13,0 size:50x100
offset:3,100 size:170x20
offset:unplaced size:176x23
offset:3,0 size:170x20
)DUMP";
EXPECT_EQ(expectation, dump);
}
// Tests that a fieldset with a set height will fragment when its legend
// Tests that a fieldset with a set height will not fragment when its legend
// reaches the fragmentation line. The used height should also be extended to
// encompass the legend.
TEST_F(NGFieldsetLayoutAlgorithmTest, LegendFragmentation) {
......@@ -872,20 +863,12 @@ TEST_F(NGFieldsetLayoutAlgorithmTest, LegendFragmentation) {
ASSERT_TRUE(fragment->BreakToken());
String dump = DumpFragmentTree(fragment.get());
// TODO(crbug.com/1097012): The height of the outermost fragment here should
// be 500, not 490, but the fragmentation machinery gets confused by the
// fieldset padding.
String expectation = R"DUMP(.:: LayoutNG Physical Fragment Tree ::.
offset:unplaced size:176x200
offset:13,0 size:50x200
)DUMP";
EXPECT_EQ(expectation, dump);
fragment = NGBaseLayoutAlgorithmTest::RunFieldsetLayoutAlgorithm(
node, space, fragment->BreakToken());
ASSERT_TRUE(fragment->BreakToken());
dump = DumpFragmentTree(fragment.get());
expectation = R"DUMP(.:: LayoutNG Physical Fragment Tree ::.
offset:unplaced size:176x200
offset:13,0 size:50x200
offset:unplaced size:176x490
offset:13,0 size:50x500
)DUMP";
EXPECT_EQ(expectation, dump);
......@@ -894,16 +877,19 @@ TEST_F(NGFieldsetLayoutAlgorithmTest, LegendFragmentation) {
ASSERT_FALSE(fragment->BreakToken());
dump = DumpFragmentTree(fragment.get());
// TODO(crbug.com/1097012): The height of the outermost fragment here should
// be 23, not 0, but the fragmentation machinery gets confused by the
// fieldset padding.
expectation = R"DUMP(.:: LayoutNG Physical Fragment Tree ::.
offset:unplaced size:176x123
offset:13,0 size:50x100
offset:3,100 size:170x20
offset:unplaced size:176x0
offset:3,0 size:170x20
)DUMP";
EXPECT_EQ(expectation, dump);
}
// Tests that a fieldset with auto height will fragment when its legend/content
// reaches the fragmentation line.
// Tests that a fieldset with auto height will not fragment when its legend
// reaches the fragmentation line. The content of the fieldset should fragment
// when it reaches the fragmentation line.
TEST_F(NGFieldsetLayoutAlgorithmTest, LegendAndContentFragmentationAutoHeight) {
SetBodyInnerHTML(R"HTML(
<style>
......@@ -936,36 +922,26 @@ TEST_F(NGFieldsetLayoutAlgorithmTest, LegendAndContentFragmentationAutoHeight) {
ASSERT_TRUE(fragment->BreakToken());
String dump = DumpFragmentTree(fragment.get());
// TODO(crbug.com/1097012): The height of the outermost fragment here should
// be 500, not 490, but the fragmentation machinery gets confused by the
// fieldset padding.
String expectation = R"DUMP(.:: LayoutNG Physical Fragment Tree ::.
offset:unplaced size:176x200
offset:13,0 size:50x200
offset:unplaced size:176x490
offset:13,0 size:50x500
)DUMP";
EXPECT_EQ(expectation, dump);
fragment = NGBaseLayoutAlgorithmTest::RunFieldsetLayoutAlgorithm(
node, space, fragment->BreakToken());
ASSERT_TRUE(fragment->BreakToken());
dump = DumpFragmentTree(fragment.get());
expectation = R"DUMP(.:: LayoutNG Physical Fragment Tree ::.
offset:unplaced size:176x200
offset:13,0 size:50x200
)DUMP";
EXPECT_EQ(expectation, dump);
fragment = NGBaseLayoutAlgorithmTest::RunFieldsetLayoutAlgorithm(
node, space, fragment->BreakToken());
ASSERT_TRUE(fragment->BreakToken());
dump = DumpFragmentTree(fragment.get());
// TODO(crbug.com/1097012): The height of the outermost fragment here should
// be 200, not 190, but the fragmentation machinery gets confused by the
// fieldset padding.
dump = DumpFragmentTree(fragment.get());
expectation = R"DUMP(.:: LayoutNG Physical Fragment Tree ::.
offset:unplaced size:176x190
offset:13,0 size:50x100
offset:3,100 size:170x100
offset:10,10 size:100x90
offset:3,0 size:170x200
offset:10,10 size:100x190
)DUMP";
EXPECT_EQ(expectation, dump);
......@@ -975,14 +951,15 @@ TEST_F(NGFieldsetLayoutAlgorithmTest, LegendAndContentFragmentationAutoHeight) {
dump = DumpFragmentTree(fragment.get());
expectation = R"DUMP(.:: LayoutNG Physical Fragment Tree ::.
offset:unplaced size:176x123
offset:3,0 size:170x120
offset:10,0 size:100x110
offset:unplaced size:176x23
offset:3,0 size:170x20
offset:10,0 size:100x10
)DUMP";
EXPECT_EQ(expectation, dump);
}
// Tests that a fieldset with a set height will fragment when its legend/content
// Tests that a fieldset with a set height will fragment when its legend reaches
// the fragmentation line. The content of the fieldset should fragment when it
// reaches the fragmentation line.
TEST_F(NGFieldsetLayoutAlgorithmTest, LegendAndContentFragmentation) {
SetBodyInnerHTML(R"HTML(
......@@ -1016,45 +993,34 @@ TEST_F(NGFieldsetLayoutAlgorithmTest, LegendAndContentFragmentation) {
ASSERT_TRUE(fragment->BreakToken());
String dump = DumpFragmentTree(fragment.get());
// TODO(crbug.com/1097012): The height of the outermost fragment here should
// be 500, not 490, but the fragmentation machinery gets confused by the
// fieldset padding.
String expectation = R"DUMP(.:: LayoutNG Physical Fragment Tree ::.
offset:unplaced size:176x200
offset:13,0 size:50x200
offset:unplaced size:176x490
offset:13,0 size:50x500
)DUMP";
EXPECT_EQ(expectation, dump);
fragment = NGBaseLayoutAlgorithmTest::RunFieldsetLayoutAlgorithm(
node, space, fragment->BreakToken());
ASSERT_TRUE(fragment->BreakToken());
dump = DumpFragmentTree(fragment.get());
expectation = R"DUMP(.:: LayoutNG Physical Fragment Tree ::.
offset:unplaced size:176x200
offset:13,0 size:50x200
)DUMP";
EXPECT_EQ(expectation, dump);
fragment = NGBaseLayoutAlgorithmTest::RunFieldsetLayoutAlgorithm(
node, space, fragment->BreakToken());
ASSERT_TRUE(fragment->BreakToken());
dump = DumpFragmentTree(fragment.get());
expectation = R"DUMP(.:: LayoutNG Physical Fragment Tree ::.
offset:unplaced size:176x123
offset:13,0 size:50x100
offset:3,100 size:170x20
offset:10,10 size:100x90
offset:unplaced size:176x0
offset:3,0 size:170x20
offset:10,10 size:100x190
)DUMP";
EXPECT_EQ(expectation, dump);
fragment = NGBaseLayoutAlgorithmTest::RunFieldsetLayoutAlgorithm(
node, space, fragment->BreakToken());
ASSERT_FALSE(fragment->BreakToken());
dump = DumpFragmentTree(fragment.get());
expectation = R"DUMP(.:: LayoutNG Physical Fragment Tree ::.
offset:unplaced size:176x0
offset:3,0 size:170x0
offset:10,0 size:100x110
offset:10,0 size:100x10
)DUMP";
EXPECT_EQ(expectation, dump);
}
......@@ -1070,7 +1036,7 @@ TEST_F(NGFieldsetLayoutAlgorithmTest, LegendFragmentationWithOverflow) {
<div style="width:55px; height:150px;"></div>
</legend>
<div style="width:44px; height:150px;"></div>
</div>
</fieldset>
)HTML");
LayoutUnit kFragmentainerSpaceAvailable(100);
......@@ -1089,7 +1055,7 @@ TEST_F(NGFieldsetLayoutAlgorithmTest, LegendFragmentationWithOverflow) {
String expectation = R"DUMP(.:: LayoutNG Physical Fragment Tree ::.
offset:unplaced size:1000x100
offset:0,0 size:55x30
offset:0,0 size:55x100
offset:0,0 size:55x150
offset:0,30 size:1000x70
offset:0,0 size:44x70
)DUMP";
......@@ -1102,8 +1068,6 @@ TEST_F(NGFieldsetLayoutAlgorithmTest, LegendFragmentationWithOverflow) {
dump = DumpFragmentTree(fragment.get());
expectation = R"DUMP(.:: LayoutNG Physical Fragment Tree ::.
offset:unplaced size:1000x80
offset:0,0 size:55x0
offset:0,0 size:55x50
offset:0,0 size:1000x80
offset:0,0 size:44x80
)DUMP";
......@@ -1195,28 +1159,16 @@ TEST_F(NGFieldsetLayoutAlgorithmTest, OverflowedLegend) {
scoped_refptr<const NGPhysicalBoxFragment> fragment =
NGBaseLayoutAlgorithmTest::RunFieldsetLayoutAlgorithm(node, space);
ASSERT_TRUE(fragment->BreakToken());
ASSERT_FALSE(fragment->BreakToken());
String dump = DumpFragmentTree(fragment.get());
String expectation = R"DUMP(.:: LayoutNG Physical Fragment Tree ::.
offset:unplaced size:100x100
offset:0,0 size:75x60
offset:0,0 size:50x100
offset:0,0 size:50x120
offset:0,120 size:40x20
offset:0,60 size:100x40
offset:0,0 size:85x10
)DUMP";
EXPECT_EQ(expectation, dump);
fragment = NGBaseLayoutAlgorithmTest::RunFieldsetLayoutAlgorithm(
node, space, fragment->BreakToken());
ASSERT_FALSE(fragment->BreakToken());
dump = DumpFragmentTree(fragment.get());
expectation = R"DUMP(.:: LayoutNG Physical Fragment Tree ::.
offset:unplaced size:100x0
offset:0,0 size:75x0
offset:0,0 size:50x20
offset:0,20 size:40x20
)DUMP";
EXPECT_EQ(expectation, dump);
}
......@@ -1258,7 +1210,7 @@ TEST_F(NGFieldsetLayoutAlgorithmTest, OverflowedFieldsetContent) {
String expectation = R"DUMP(.:: LayoutNG Physical Fragment Tree ::.
offset:unplaced size:100x100
offset:0,0 size:75x10
offset:0,0 size:50x100
offset:0,0 size:50x220
offset:0,10 size:100x90
offset:0,0 size:85x10
offset:0,10 size:65x10
......@@ -1273,8 +1225,6 @@ TEST_F(NGFieldsetLayoutAlgorithmTest, OverflowedFieldsetContent) {
dump = DumpFragmentTree(fragment.get());
expectation = R"DUMP(.:: LayoutNG Physical Fragment Tree ::.
offset:unplaced size:100x0
offset:0,0 size:75x0
offset:0,0 size:50x100
offset:0,0 size:100x0
offset:0,0 size:65x0
offset:0,0 size:51x100
......@@ -1288,8 +1238,6 @@ TEST_F(NGFieldsetLayoutAlgorithmTest, OverflowedFieldsetContent) {
dump = DumpFragmentTree(fragment.get());
expectation = R"DUMP(.:: LayoutNG Physical Fragment Tree ::.
offset:unplaced size:100x0
offset:0,0 size:75x0
offset:0,0 size:50x20
offset:0,0 size:100x0
offset:0,0 size:65x0
offset:0,0 size:51x40
......@@ -1442,8 +1390,10 @@ TEST_F(NGFieldsetLayoutAlgorithmTest, LegendBreakInsideAvoid) {
String dump = DumpFragmentTree(fragment.get());
String expectation = R"DUMP(.:: LayoutNG Physical Fragment Tree ::.
offset:unplaced size:1000x100
offset:unplaced size:1000x110
offset:0,0 size:20x50
offset:0,50 size:100x60
offset:0,0 size:10x60
)DUMP";
EXPECT_EQ(expectation, dump);
......@@ -1453,10 +1403,9 @@ TEST_F(NGFieldsetLayoutAlgorithmTest, LegendBreakInsideAvoid) {
dump = DumpFragmentTree(fragment.get());
expectation = R"DUMP(.:: LayoutNG Physical Fragment Tree ::.
offset:unplaced size:1000x60
offset:0,0 size:100x60
offset:0,0 size:10x60
offset:0,60 size:100x0
offset:unplaced size:1000x0
offset:0,0 size:100x0
offset:0,0 size:100x0
)DUMP";
EXPECT_EQ(expectation, dump);
}
......@@ -1530,7 +1479,7 @@ TEST_F(NGFieldsetLayoutAlgorithmTest, LegendBreakBeforeAvoid) {
<div id="container">
<div style="width:20px; height:90px;"></div>
<fieldset id="fieldset">
<legend id="legend" style="break-before:avoid; break-inside:avoid"></legend>
<legend id="legend" style="break-before:avoid;"></legend>
</fieldset>
</div>
)HTML");
......@@ -1549,8 +1498,10 @@ TEST_F(NGFieldsetLayoutAlgorithmTest, LegendBreakBeforeAvoid) {
String dump = DumpFragmentTree(fragment.get());
String expectation = R"DUMP(.:: LayoutNG Physical Fragment Tree ::.
offset:unplaced size:1000x100
offset:unplaced size:1000x125
offset:0,0 size:20x90
offset:0,90 size:120x35
offset:20,0 size:10x25
)DUMP";
EXPECT_EQ(expectation, dump);
......@@ -1560,10 +1511,9 @@ TEST_F(NGFieldsetLayoutAlgorithmTest, LegendBreakBeforeAvoid) {
dump = DumpFragmentTree(fragment.get());
expectation = R"DUMP(.:: LayoutNG Physical Fragment Tree ::.
offset:unplaced size:1000x45
offset:0,0 size:120x45
offset:20,0 size:10x25
offset:10,35 size:100x0
offset:unplaced size:1000x10
offset:0,0 size:120x10
offset:10,0 size:100x0
)DUMP";
EXPECT_EQ(expectation, dump);
}
......@@ -1659,6 +1609,8 @@ TEST_F(NGFieldsetLayoutAlgorithmTest, LegendBreakAfterAvoid) {
String expectation = R"DUMP(.:: LayoutNG Physical Fragment Tree ::.
offset:unplaced size:1000x100
offset:0,0 size:20x50
offset:0,50 size:100x50
offset:0,0 size:10x50
)DUMP";
EXPECT_EQ(expectation, dump);
......@@ -1668,10 +1620,9 @@ TEST_F(NGFieldsetLayoutAlgorithmTest, LegendBreakAfterAvoid) {
dump = DumpFragmentTree(fragment.get());
expectation = R"DUMP(.:: LayoutNG Physical Fragment Tree ::.
offset:unplaced size:1000x75
offset:0,0 size:100x75
offset:0,0 size:10x50
offset:0,50 size:100x25
offset:unplaced size:1000x25
offset:0,0 size:100x25
offset:0,0 size:100x25
offset:0,0 size:15x25
)DUMP";
EXPECT_EQ(expectation, dump);
......@@ -1710,8 +1661,11 @@ TEST_F(NGFieldsetLayoutAlgorithmTest, MarginBottomPastEndOfFragmentainer) {
ASSERT_TRUE(fragment->BreakToken());
String dump = DumpFragmentTree(fragment.get());
// TODO(crbug.com/1097012): The height of the outermost fragment here should
// be 100, not 110, but the fragmentation machinery gets confused
// and includes the margin bottom.
String expectation = R"DUMP(.:: LayoutNG Physical Fragment Tree ::.
offset:unplaced size:100x100
offset:unplaced size:100x110
offset:0,0 size:0x90
)DUMP";
EXPECT_EQ(expectation, dump);
......@@ -1763,7 +1717,7 @@ TEST_F(NGFieldsetLayoutAlgorithmTest, SmallLegendLargeBorderFragmentation) {
String dump = DumpFragmentTree(fragment.get());
String expectation = R"DUMP(.:: LayoutNG Physical Fragment Tree ::.
offset:unplaced size:220x60
offset:60,0 size:10x40
offset:60,5 size:10x50
)DUMP";
EXPECT_EQ(expectation, dump);
......@@ -1774,7 +1728,6 @@ TEST_F(NGFieldsetLayoutAlgorithmTest, SmallLegendLargeBorderFragmentation) {
dump = DumpFragmentTree(fragment.get());
expectation = R"DUMP(.:: LayoutNG Physical Fragment Tree ::.
offset:unplaced size:220x10
offset:60,0 size:10x10
offset:60,0 size:100x10
)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