Chromium Code Reviews| Index: third_party/WebKit/Source/core/layout/ng/ng_block_layout_algorithm_test.cc |
| diff --git a/third_party/WebKit/Source/core/layout/ng/ng_block_layout_algorithm_test.cc b/third_party/WebKit/Source/core/layout/ng/ng_block_layout_algorithm_test.cc |
| index 6ede938ace0283329e6282f20e186ca7b8049be7..36f9e033020c8efc93ef4dd8179b500b9fac3d4e 100644 |
| --- a/third_party/WebKit/Source/core/layout/ng/ng_block_layout_algorithm_test.cc |
| +++ b/third_party/WebKit/Source/core/layout/ng/ng_block_layout_algorithm_test.cc |
| @@ -41,6 +41,7 @@ NGConstraintSpace* ConstructConstraintSpace( |
| return NGConstraintSpaceBuilder(writing_mode) |
| .SetAvailableSize(size) |
| .SetPercentageResolutionSize(size) |
| + .SetInitialContainingBlockSize(size.ConvertToPhysical(writing_mode)) |
| .SetTextDirection(direction) |
| .SetIsShrinkToFit(shrink_to_fit) |
| .SetFragmentainerSpaceAvailable(fragmentainer_space_available) |
| @@ -71,12 +72,9 @@ class NGBlockLayoutAlgorithmTest |
| RefPtr<NGPhysicalBoxFragment> RunBlockLayoutAlgorithm( |
| NGConstraintSpace* space, |
| - NGBlockNode* first_child) { |
| - NGBlockNode* node = new NGBlockNode(style_.get()); |
| - node->SetFirstChild(first_child); |
| - |
| + NGBlockNode* block) { |
| RefPtr<NGLayoutResult> result = |
| - NGBlockLayoutAlgorithm(node, space).Layout(); |
| + NGBlockLayoutAlgorithm(block, space).Layout(); |
| return toNGPhysicalBoxFragment(result->PhysicalFragment().get()); |
| } |
| @@ -95,14 +93,12 @@ class NGBlockLayoutAlgorithmTest |
| toNGPhysicalBoxFragment(result->PhysicalFragment().get()), space); |
| } |
| - MinAndMaxContentSizes RunComputeMinAndMax(NGBlockNode* first_child) { |
| + MinAndMaxContentSizes RunComputeMinAndMax(NGBlockNode* node) { |
| // The constraint space is not used for min/max computation, but we need |
| // it to create the algorithm. |
| NGConstraintSpace* space = |
| ConstructConstraintSpace(kHorizontalTopBottom, TextDirection::kLtr, |
| NGLogicalSize(LayoutUnit(), LayoutUnit())); |
| - NGBlockNode* node = new NGBlockNode(style_.get()); |
| - node->SetFirstChild(first_child); |
|
Gleb Lanbin
2017/03/01 19:47:44
can you update the description because it doesn't
atotic
2017/03/01 20:20:38
done
|
| NGBlockLayoutAlgorithm algorithm(node, space); |
| EXPECT_TRUE(algorithm.ComputeMinAndMaxContentSizes().has_value()); |
| @@ -113,13 +109,17 @@ class NGBlockLayoutAlgorithmTest |
| }; |
| TEST_F(NGBlockLayoutAlgorithmTest, FixedSize) { |
| - style_->setWidth(Length(30, Fixed)); |
| - style_->setHeight(Length(40, Fixed)); |
| + setBodyInnerHTML(R"HTML( |
| + <div id="box" style="width:30px; height:40px"></div> |
| + )HTML"); |
| auto* space = ConstructConstraintSpace( |
| kHorizontalTopBottom, TextDirection::kLtr, |
| NGLogicalSize(LayoutUnit(100), NGSizeIndefinite)); |
| - RefPtr<NGPhysicalFragment> frag = RunBlockLayoutAlgorithm(space, nullptr); |
| + |
| + auto* box = new NGBlockNode(getLayoutObjectByElementId("box")); |
| + |
| + RefPtr<NGPhysicalFragment> frag = RunBlockLayoutAlgorithm(space, box); |
| EXPECT_EQ(LayoutUnit(30), frag->Width()); |
| EXPECT_EQ(LayoutUnit(40), frag->Height()); |
| @@ -127,30 +127,27 @@ TEST_F(NGBlockLayoutAlgorithmTest, FixedSize) { |
| // Verifies that two children are laid out with the correct size and position. |
| TEST_F(NGBlockLayoutAlgorithmTest, LayoutBlockChildren) { |
| + setBodyInnerHTML(R"HTML( |
| + <div id="container" style="width: 30px"> |
| + <div id="first_child" style="height: 20px"> |
|
Gleb Lanbin
2017/03/01 19:47:44
ids: first_child, second_child etc. are not used a
atotic
2017/03/01 20:20:38
done
|
| + </div> |
| + <div id="second_child" |
| + style="height: 30px;margin-top: 5px;margin-bottom: 20px"> |
|
Gleb Lanbin
2017/03/01 19:47:44
please follow https://google.github.io/styleguide/
atotic
2017/03/01 20:20:38
done.
|
| + </div> |
| + </div> |
| + )HTML"); |
| const int kWidth = 30; |
| const int kHeight1 = 20; |
| const int kHeight2 = 30; |
| const int kMarginTop = 5; |
| - const int kMarginBottom = 20; |
| - style_->setWidth(Length(kWidth, Fixed)); |
| - |
| - RefPtr<ComputedStyle> first_style = ComputedStyle::create(); |
| - first_style->setHeight(Length(kHeight1, Fixed)); |
| - NGBlockNode* first_child = new NGBlockNode(first_style.get()); |
| - |
| - RefPtr<ComputedStyle> second_style = ComputedStyle::create(); |
| - second_style->setHeight(Length(kHeight2, Fixed)); |
| - second_style->setMarginTop(Length(kMarginTop, Fixed)); |
| - second_style->setMarginBottom(Length(kMarginBottom, Fixed)); |
| - NGBlockNode* second_child = new NGBlockNode(second_style.get()); |
| - |
| - first_child->SetNextSibling(second_child); |
| + auto* container = new NGBlockNode(getLayoutObjectByElementId("container")); |
| auto* space = ConstructConstraintSpace( |
| kHorizontalTopBottom, TextDirection::kLtr, |
| NGLogicalSize(LayoutUnit(100), NGSizeIndefinite)); |
| + |
| RefPtr<NGPhysicalBoxFragment> frag = |
| - RunBlockLayoutAlgorithm(space, first_child); |
| + RunBlockLayoutAlgorithm(space, container); |
| EXPECT_EQ(LayoutUnit(kWidth), frag->Width()); |
| EXPECT_EQ(LayoutUnit(kHeight1 + kHeight2 + kMarginTop), frag->Height()); |
| @@ -168,35 +165,26 @@ TEST_F(NGBlockLayoutAlgorithmTest, LayoutBlockChildren) { |
| // Verifies that a child is laid out correctly if it's writing mode is different |
| // from the parent's one. |
| -// |
| -// Test case's HTML representation: |
| -// <div style="writing-mode: vertical-lr;"> |
| -// <div style="width:50px; |
| -// height: 50px; margin-left: 100px; |
| -// writing-mode: horizontal-tb;"></div> |
| -// </div> |
| TEST_F(NGBlockLayoutAlgorithmTest, LayoutBlockChildrenWithWritingMode) { |
| - const int kWidth = 50; |
| + setBodyInnerHTML(R"HTML( |
| + <div id="container"> |
| + <div id="div1" style="writing-mode: vertical-lr;"> |
| + <div id="div2" style="width: 50px; |
|
Gleb Lanbin
2017/03/01 19:47:44
the style definition takes more than 3 lines? move
atotic
2017/03/01 20:20:39
done
|
| + height: 50px; margin-left: 100px; |
| + writing-mode: horizontal-tb;"> |
| + </div> |
| + </div> |
| + </div> |
| + )HTML"); |
| const int kHeight = 50; |
| const int kMarginLeft = 100; |
| - RefPtr<ComputedStyle> div1_style = ComputedStyle::create(); |
| - div1_style->setWritingMode(WritingMode::kVerticalLr); |
| - NGBlockNode* div1 = new NGBlockNode(div1_style.get()); |
| - |
| - RefPtr<ComputedStyle> div2_style = ComputedStyle::create(); |
| - div2_style->setHeight(Length(kHeight, Fixed)); |
| - div2_style->setWidth(Length(kWidth, Fixed)); |
| - div1_style->setWritingMode(WritingMode::kHorizontalTb); |
| - div2_style->setMarginLeft(Length(kMarginLeft, Fixed)); |
| - NGBlockNode* div2 = new NGBlockNode(div2_style.get()); |
| - |
| - div1->SetFirstChild(div2); |
| - |
| + auto* container = new NGBlockNode(getLayoutObjectByElementId("container")); |
| auto* space = |
| ConstructConstraintSpace(kHorizontalTopBottom, TextDirection::kLtr, |
| NGLogicalSize(LayoutUnit(500), LayoutUnit(500))); |
| - RefPtr<NGPhysicalBoxFragment> frag = RunBlockLayoutAlgorithm(space, div1); |
| + RefPtr<NGPhysicalBoxFragment> frag = |
| + RunBlockLayoutAlgorithm(space, container); |
| const NGPhysicalFragment* child = frag->Children()[0].get(); |
| // DIV2 |
| @@ -665,55 +653,37 @@ TEST_F(NGBlockLayoutAlgorithmTest, CollapsingMarginsWithText) { |
| // Verifies that the margin strut of a child with a different writing mode does |
| // not get used in the collapsing margins calculation. |
| // |
| -// Test case's HTML representation: |
| -// <style> |
| -// #div1 { margin-bottom: 10px; height: 60px; writing-mode: vertical-rl; } |
| -// #div2 { margin-left: -20px; width: 10px; } |
| -// #div3 { margin-top: 40px; height: 60px; } |
| -// </style> |
| -// <div id="div1"> |
| -// <div id="div2">vertical</div> |
| -// </div> |
| -// <div id="div3"></div> |
| // TODO(glebl): Disabled for now. Follow-up with kojii@ on |
| // https://software.hixie.ch/utilities/js/live-dom-viewer/?saved=4844 |
| TEST_F(NGBlockLayoutAlgorithmTest, DISABLED_CollapsingMarginsCase6) { |
| + setBodyInnerHTML(R"HTML( |
| + <style> |
| + #div1 { |
| + margin-bottom: 10px; |
| + width: 10px; |
| + height: 60px; |
| + writing-mode: vertical-rl; |
| + } |
| + #div2 { margin-left: -20px; width: 10px; } |
| + #div3 { margin-top: 40px; height: 60px; } |
| + </style> |
| + <div id="container" style="width:500px;height:500px"> |
| + <div id="div1"> |
| + <div id="div2">vertical</div> |
| + </div> |
| + <div id="div3"></div> |
| + </div> |
| + )HTML"); |
| const int kHeight = 60; |
| - const int kWidth = 10; |
| const int kMarginBottom = 10; |
| - const int kMarginLeft = -20; |
| const int kMarginTop = 40; |
| - style_->setWidth(Length(500, Fixed)); |
| - style_->setHeight(Length(500, Fixed)); |
| - |
| - // DIV1 |
| - RefPtr<ComputedStyle> div1_style = ComputedStyle::create(); |
| - div1_style->setWidth(Length(kWidth, Fixed)); |
| - div1_style->setHeight(Length(kHeight, Fixed)); |
| - div1_style->setWritingMode(WritingMode::kVerticalRl); |
| - div1_style->setMarginBottom(Length(kMarginBottom, Fixed)); |
| - NGBlockNode* div1 = new NGBlockNode(div1_style.get()); |
| - |
| - // DIV2 |
| - RefPtr<ComputedStyle> div2_style = ComputedStyle::create(); |
| - div2_style->setWidth(Length(kWidth, Fixed)); |
| - div2_style->setMarginLeft(Length(kMarginLeft, Fixed)); |
| - NGBlockNode* div2 = new NGBlockNode(div2_style.get()); |
| - |
| - // DIV3 |
| - RefPtr<ComputedStyle> div3_style = ComputedStyle::create(); |
| - div3_style->setHeight(Length(kHeight, Fixed)); |
| - div3_style->setMarginTop(Length(kMarginTop, Fixed)); |
| - NGBlockNode* div3 = new NGBlockNode(div3_style.get()); |
| - |
| - div1->SetFirstChild(div2); |
| - div1->SetNextSibling(div3); |
| - |
| + auto* container = new NGBlockNode(getLayoutObjectByElementId("container")); |
| auto* space = |
| ConstructConstraintSpace(kHorizontalTopBottom, TextDirection::kLtr, |
| NGLogicalSize(LayoutUnit(500), LayoutUnit(500))); |
| - RefPtr<NGPhysicalBoxFragment> frag = RunBlockLayoutAlgorithm(space, div1); |
| + RefPtr<NGPhysicalBoxFragment> frag = |
| + RunBlockLayoutAlgorithm(space, container); |
| ASSERT_EQ(frag->Children().size(), 2UL); |
| @@ -727,17 +697,23 @@ TEST_F(NGBlockLayoutAlgorithmTest, DISABLED_CollapsingMarginsCase6) { |
| // Verifies that a box's size includes its borders and padding, and that |
| // children are positioned inside the content box. |
| -// |
| -// Test case's HTML representation: |
| -// <style> |
| -// #div1 { width:100px; height:100px; } |
| -// #div1 { border-style:solid; border-width:1px 2px 3px 4px; } |
| -// #div1 { padding:5px 6px 7px 8px; } |
| -// </style> |
| -// <div id="div1"> |
| -// <div id="div2"></div> |
| -// </div> |
| TEST_F(NGBlockLayoutAlgorithmTest, BorderAndPadding) { |
| + setBodyInnerHTML(R"HTML( |
| + <style> |
| + #div1 { |
| + width: 100px; |
| + height: 100px; |
| + border-style: solid; |
| + border-width: 1px 2px 3px 4px; |
| + padding: 5px 6px 7px 8px; |
| + } |
| + </style> |
| + <div id="container"> |
| + <div id="div1"> |
| + <div id="div2"></div> |
| + </div> |
| + </div> |
| + )HTML"); |
| const int kWidth = 100; |
| const int kHeight = 100; |
| const int kBorderTop = 1; |
| @@ -748,35 +724,15 @@ TEST_F(NGBlockLayoutAlgorithmTest, BorderAndPadding) { |
| const int kPaddingRight = 6; |
| const int kPaddingBottom = 7; |
| const int kPaddingLeft = 8; |
| - RefPtr<ComputedStyle> div1_style = ComputedStyle::create(); |
| - div1_style->setWidth(Length(kWidth, Fixed)); |
| - div1_style->setHeight(Length(kHeight, Fixed)); |
| - |
| - div1_style->setBorderTopWidth(kBorderTop); |
| - div1_style->setBorderTopStyle(BorderStyleSolid); |
| - div1_style->setBorderRightWidth(kBorderRight); |
| - div1_style->setBorderRightStyle(BorderStyleSolid); |
| - div1_style->setBorderBottomWidth(kBorderBottom); |
| - div1_style->setBorderBottomStyle(BorderStyleSolid); |
| - div1_style->setBorderLeftWidth(kBorderLeft); |
| - div1_style->setBorderLeftStyle(BorderStyleSolid); |
| - |
| - div1_style->setPaddingTop(Length(kPaddingTop, Fixed)); |
| - div1_style->setPaddingRight(Length(kPaddingRight, Fixed)); |
| - div1_style->setPaddingBottom(Length(kPaddingBottom, Fixed)); |
| - div1_style->setPaddingLeft(Length(kPaddingLeft, Fixed)); |
| - NGBlockNode* div1 = new NGBlockNode(div1_style.get()); |
| - |
| - RefPtr<ComputedStyle> div2_style = ComputedStyle::create(); |
| - NGBlockNode* div2 = new NGBlockNode(div2_style.get()); |
| - |
| - div1->SetFirstChild(div2); |
| + auto* container = new NGBlockNode(getLayoutObjectByElementId("container")); |
| auto* space = ConstructConstraintSpace( |
| kHorizontalTopBottom, TextDirection::kLtr, |
| NGLogicalSize(LayoutUnit(1000), NGSizeIndefinite)); |
| - RefPtr<NGPhysicalBoxFragment> frag = RunBlockLayoutAlgorithm(space, div1); |
| + |
| + RefPtr<NGPhysicalBoxFragment> frag = |
| + RunBlockLayoutAlgorithm(space, container); |
| ASSERT_EQ(frag->Children().size(), 1UL); |
| @@ -798,20 +754,21 @@ TEST_F(NGBlockLayoutAlgorithmTest, BorderAndPadding) { |
| } |
| TEST_F(NGBlockLayoutAlgorithmTest, PercentageResolutionSize) { |
| + setBodyInnerHTML(R"HTML( |
| + <div id="container" style="width: 30px; padding-left: 10px"> |
| + <div id="div1" style="width: 40%"></div> |
| + </div> |
| + )HTML"); |
| const int kPaddingLeft = 10; |
| const int kWidth = 30; |
| - style_->setWidth(Length(kWidth, Fixed)); |
| - style_->setPaddingLeft(Length(kPaddingLeft, Fixed)); |
| - RefPtr<ComputedStyle> first_style = ComputedStyle::create(); |
| - first_style->setWidth(Length(40, Percent)); |
| - NGBlockNode* first_child = new NGBlockNode(first_style.get()); |
| + auto* container = new NGBlockNode(getLayoutObjectByElementId("container")); |
| auto* space = ConstructConstraintSpace( |
| kHorizontalTopBottom, TextDirection::kLtr, |
| NGLogicalSize(LayoutUnit(100), NGSizeIndefinite)); |
| RefPtr<NGPhysicalBoxFragment> frag = |
| - RunBlockLayoutAlgorithm(space, first_child); |
| + RunBlockLayoutAlgorithm(space, container); |
| EXPECT_EQ(LayoutUnit(kWidth + kPaddingLeft), frag->Width()); |
| EXPECT_EQ(NGPhysicalFragment::kFragmentBox, frag->Type()); |
| @@ -824,23 +781,26 @@ TEST_F(NGBlockLayoutAlgorithmTest, PercentageResolutionSize) { |
| // A very simple auto margin case. We rely on the tests in ng_length_utils_test |
| // for the more complex cases; just make sure we handle auto at all here. |
| TEST_F(NGBlockLayoutAlgorithmTest, AutoMargin) { |
| + setBodyInnerHTML(R"HTML( |
| + <style> |
| + #first { width: 10px; margin-left: auto; margin-right: auto; } |
| + </style> |
| + <div id="container" style="width: 30px; padding-left: 10px"> |
| + <div id="first"> |
| + </div> |
| + </div> |
| + )HTML"); |
| const int kPaddingLeft = 10; |
| const int kWidth = 30; |
| - style_->setWidth(Length(kWidth, Fixed)); |
| - style_->setPaddingLeft(Length(kPaddingLeft, Fixed)); |
| - |
| - RefPtr<ComputedStyle> first_style = ComputedStyle::create(); |
| const int kChildWidth = 10; |
| - first_style->setWidth(Length(kChildWidth, Fixed)); |
| - first_style->setMarginLeft(Length(Auto)); |
| - first_style->setMarginRight(Length(Auto)); |
| - NGBlockNode* first_child = new NGBlockNode(first_style.get()); |
| + |
| + auto* container = new NGBlockNode(getLayoutObjectByElementId("container")); |
| auto* space = ConstructConstraintSpace( |
| kHorizontalTopBottom, TextDirection::kLtr, |
| NGLogicalSize(LayoutUnit(100), NGSizeIndefinite)); |
| RefPtr<NGPhysicalBoxFragment> frag = |
| - RunBlockLayoutAlgorithm(space, first_child); |
| + RunBlockLayoutAlgorithm(space, container); |
| EXPECT_EQ(LayoutUnit(kWidth + kPaddingLeft), frag->Width()); |
| EXPECT_EQ(NGPhysicalFragment::kFragmentBox, frag->Type()); |
| @@ -1284,49 +1244,40 @@ TEST_F(NGBlockLayoutAlgorithmTest, PositionFragmentsWithClear) { |
| // Verifies that we compute the right min and max-content size. |
| TEST_F(NGBlockLayoutAlgorithmTest, ComputeMinMaxContent) { |
| - const int kWidth = 50; |
| - const int kWidthChild1 = 20; |
| + setBodyInnerHTML(R"HTML( |
| + <div id="container" style="width: 50px"> |
| + <div id="first_child" style="width: 20px"></div> |
| + <div id="second_child" style="width: 30px"></div> |
| + </div> |
| + )HTML"); |
| + |
| const int kWidthChild2 = 30; |
| - // This should have no impact on the min/max content size. |
| - style_->setWidth(Length(kWidth, Fixed)); |
| + auto* container = new NGBlockNode(getLayoutObjectByElementId("container")); |
| - RefPtr<ComputedStyle> first_style = ComputedStyle::create(); |
| - first_style->setWidth(Length(kWidthChild1, Fixed)); |
| - NGBlockNode* first_child = new NGBlockNode(first_style.get()); |
| - |
| - RefPtr<ComputedStyle> second_style = ComputedStyle::create(); |
| - second_style->setWidth(Length(kWidthChild2, Fixed)); |
| - NGBlockNode* second_child = new NGBlockNode(second_style.get()); |
| - |
| - first_child->SetNextSibling(second_child); |
| - |
| - MinAndMaxContentSizes sizes = RunComputeMinAndMax(first_child); |
| + MinAndMaxContentSizes sizes = RunComputeMinAndMax(container); |
| EXPECT_EQ(kWidthChild2, sizes.min_content); |
| EXPECT_EQ(kWidthChild2, sizes.max_content); |
| } |
| // Tests that we correctly handle shrink-to-fit |
| TEST_F(NGBlockLayoutAlgorithmTest, ShrinkToFit) { |
| - const int kWidthChild1 = 20; |
| + setBodyInnerHTML(R"HTML( |
| + <div id="container"> |
| + <div id="first_child" style="width: 20px"></div> |
| + <div id="second_child" style="width: 30px"></div> |
| + </div> |
| + )HTML"); |
| const int kWidthChild2 = 30; |
| - RefPtr<ComputedStyle> first_style = ComputedStyle::create(); |
| - first_style->setWidth(Length(kWidthChild1, Fixed)); |
| - NGBlockNode* first_child = new NGBlockNode(first_style.get()); |
| - |
| - RefPtr<ComputedStyle> second_style = ComputedStyle::create(); |
| - second_style->setWidth(Length(kWidthChild2, Fixed)); |
| - NGBlockNode* second_child = new NGBlockNode(second_style.get()); |
| - |
| - first_child->SetNextSibling(second_child); |
| + auto* container = new NGBlockNode(getLayoutObjectByElementId("container")); |
| auto* space = ConstructConstraintSpace( |
| kHorizontalTopBottom, TextDirection::kLtr, |
| NGLogicalSize(LayoutUnit(100), NGSizeIndefinite), true); |
| - RefPtr<NGPhysicalFragment> frag = RunBlockLayoutAlgorithm(space, first_child); |
| + RefPtr<NGPhysicalFragment> frag = RunBlockLayoutAlgorithm(space, container); |
| - EXPECT_EQ(LayoutUnit(30), frag->Width()); |
| + EXPECT_EQ(LayoutUnit(kWidthChild2), frag->Width()); |
| } |
| class FragmentChildIterator { |
| @@ -1360,27 +1311,31 @@ class FragmentChildIterator { |
| unsigned index_; |
| }; |
| -// Test case's HTML representation: |
| -// <div id="parent" style="columns:2; column-fill:auto; column-gap:10px; |
| -// width:210px; height:100px;"> |
| -// </div> |
| // TODO(glebl): reenable multicol after new margin collapsing/floats algorithm |
| // is checked in. |
| TEST_F(NGBlockLayoutAlgorithmTest, DISABLED_EmptyMulticol) { |
| - // parent |
| - RefPtr<ComputedStyle> parent_style = ComputedStyle::create(); |
| - parent_style->setColumnCount(2); |
| - parent_style->setColumnFill(ColumnFillAuto); |
| - parent_style->setColumnGap(10); |
| - parent_style->setHeight(Length(100, Fixed)); |
| - parent_style->setWidth(Length(210, Fixed)); |
| - NGBlockNode* parent = new NGBlockNode(parent_style.get()); |
| + setBodyInnerHTML(R"HTML( |
| + <style> |
| + #parent { |
| + column-count: 2; |
| + column-fill: auto; |
| + column-gap: 10px; |
| + height: 100px; |
| + width: 210px; |
| + } |
| + </style> |
| + <div id="container"> |
| + <div id="parent"> |
| + </div> |
| + </div> |
| + )HTML"); |
| + auto* container = new NGBlockNode(getLayoutObjectByElementId("container")); |
| auto* space = ConstructConstraintSpace( |
| kHorizontalTopBottom, TextDirection::kLtr, |
| NGLogicalSize(LayoutUnit(1000), NGSizeIndefinite)); |
| RefPtr<const NGPhysicalBoxFragment> parent_fragment = |
| - RunBlockLayoutAlgorithm(space, parent); |
| + RunBlockLayoutAlgorithm(space, container); |
| FragmentChildIterator iterator(parent_fragment.get()); |
| const auto* fragment = iterator.NextChild(); |
| ASSERT_TRUE(fragment); |
| @@ -1392,34 +1347,30 @@ TEST_F(NGBlockLayoutAlgorithmTest, DISABLED_EmptyMulticol) { |
| EXPECT_FALSE(FragmentChildIterator(fragment).NextChild()); |
| } |
| -// Test case's HTML representation: |
| -// <div id="parent" style="columns:2; column-fill:auto; column-gap:10px; |
| -// width:210px; height:100px;"> |
| -// <div id="child"></div> |
| -// </div> |
| // TODO(glebl): reenable multicol after new margin collapsing/floats algorithm |
| // is checked in. |
| TEST_F(NGBlockLayoutAlgorithmTest, DISABLED_EmptyBlock) { |
| - // parent |
| - RefPtr<ComputedStyle> parent_style = ComputedStyle::create(); |
| - parent_style->setColumnCount(2); |
| - parent_style->setColumnFill(ColumnFillAuto); |
| - parent_style->setColumnGap(10); |
| - parent_style->setHeight(Length(100, Fixed)); |
| - parent_style->setWidth(Length(210, Fixed)); |
| - NGBlockNode* parent = new NGBlockNode(parent_style.get()); |
| - |
| - // child |
| - RefPtr<ComputedStyle> child_style = ComputedStyle::create(); |
| - NGBlockNode* child = new NGBlockNode(child_style.get()); |
| - |
| - parent->SetFirstChild(child); |
| + setBodyInnerHTML(R"HTML( |
| + <style> |
| + #parent { |
| + height: 100px; |
| + width: 210px; |
| + } |
| + </style> |
| + <div id="container"> |
| + <div id="parent"> |
| + <div id="child"> |
| + </div> |
| + </div> |
| + </div> |
| + )HTML"); |
| + auto* container = new NGBlockNode(getLayoutObjectByElementId("container")); |
| auto* space = ConstructConstraintSpace( |
| kHorizontalTopBottom, TextDirection::kLtr, |
| NGLogicalSize(LayoutUnit(1000), NGSizeIndefinite)); |
| RefPtr<const NGPhysicalBoxFragment> parent_fragment = |
| - RunBlockLayoutAlgorithm(space, parent); |
| + RunBlockLayoutAlgorithm(space, container); |
| FragmentChildIterator iterator(parent_fragment.get()); |
| const auto* fragment = iterator.NextChild(); |
| EXPECT_EQ(LayoutUnit(210), fragment->Width()); |
| @@ -1439,36 +1390,33 @@ TEST_F(NGBlockLayoutAlgorithmTest, DISABLED_EmptyBlock) { |
| EXPECT_FALSE(iterator.NextChild()); |
| } |
| -// Test case's HTML representation: |
| -// <div id="parent" style="columns:2; column-fill:auto; column-gap:10px; |
| -// width:310px; height:100px;"> |
| -// <div id="child" style="width:60%; height:100px;"></div> |
| -// </div> |
| // TODO(glebl): reenable multicol after new margin collapsing/floats algorithm |
| // is checked in. |
| TEST_F(NGBlockLayoutAlgorithmTest, DISABLED_BlockInOneColumn) { |
| - // parent |
| - RefPtr<ComputedStyle> parent_style = ComputedStyle::create(); |
| - parent_style->setColumnCount(2); |
| - parent_style->setColumnFill(ColumnFillAuto); |
| - parent_style->setColumnGap(10); |
| - parent_style->setHeight(Length(100, Fixed)); |
| - parent_style->setWidth(Length(310, Fixed)); |
| - NGBlockNode* parent = new NGBlockNode(parent_style.get()); |
| - |
| - // child |
| - RefPtr<ComputedStyle> child_style = ComputedStyle::create(); |
| - child_style->setWidth(Length(60, Percent)); |
| - child_style->setHeight(Length(100, Fixed)); |
| - NGBlockNode* child = new NGBlockNode(child_style.get()); |
| - |
| - parent->SetFirstChild(child); |
| + setBodyInnerHTML(R"HTML( |
| + <style> |
| + #parent { |
| + column-count: 2; |
| + column-fill: auto; |
| + column-gap: 10px; |
| + height: 100px; |
| + width: 310px; |
| + } |
| + </style> |
| + <div id="container"> |
| + <div id="parent"> |
| + <div id="child" style="width: 60%; height: 100%"> |
| + </div> |
| + </div> |
| + </div> |
| + )HTML"); |
| + auto* container = new NGBlockNode(getLayoutObjectByElementId("container")); |
| auto* space = ConstructConstraintSpace( |
| kHorizontalTopBottom, TextDirection::kLtr, |
| NGLogicalSize(LayoutUnit(1000), NGSizeIndefinite)); |
| RefPtr<const NGPhysicalBoxFragment> parent_fragment = |
| - RunBlockLayoutAlgorithm(space, parent); |
| + RunBlockLayoutAlgorithm(space, container); |
| FragmentChildIterator iterator(parent_fragment.get()); |
| const auto* fragment = iterator.NextChild(); |
| @@ -1489,36 +1437,32 @@ TEST_F(NGBlockLayoutAlgorithmTest, DISABLED_BlockInOneColumn) { |
| EXPECT_FALSE(iterator.NextChild()); |
| } |
| -// Test case's HTML representation: |
| -// <div id="parent" style="columns:2; column-fill:auto; column-gap:10px; |
| -// width:210px; height:100px;"> |
| -// <div id="child" style="width:75%; height:150px;"></div> |
| -// </div> |
| // TODO(glebl): reenable multicol after new margin collapsing/floats algorithm |
| // is checked in. |
| TEST_F(NGBlockLayoutAlgorithmTest, DISABLED_BlockInTwoColumns) { |
| - // parent |
| - RefPtr<ComputedStyle> parent_style = ComputedStyle::create(); |
| - parent_style->setColumnCount(2); |
| - parent_style->setColumnFill(ColumnFillAuto); |
| - parent_style->setColumnGap(10); |
| - parent_style->setHeight(Length(100, Fixed)); |
| - parent_style->setWidth(Length(210, Fixed)); |
| - NGBlockNode* parent = new NGBlockNode(parent_style.get()); |
| - |
| - // child |
| - RefPtr<ComputedStyle> child_style = ComputedStyle::create(); |
| - child_style->setWidth(Length(75, Percent)); |
| - child_style->setHeight(Length(150, Fixed)); |
| - NGBlockNode* child = new NGBlockNode(child_style.get()); |
| - |
| - parent->SetFirstChild(child); |
| + setBodyInnerHTML(R"HTML( |
| + <style> |
| + #parent { |
| + column-count: 2; |
| + column-fill: auto; |
| + column-gap: 10px; |
| + height: 100px; |
| + width: 20px; |
| + } |
| + </style> |
| + <div id="container"> |
| + <div id="parent"> |
| + <div id="child" style="width: 75%; height: 150px"></div> |
| + </div> |
| + </div> |
| + )HTML"); |
| + auto* container = new NGBlockNode(getLayoutObjectByElementId("container")); |
| auto* space = ConstructConstraintSpace( |
| kHorizontalTopBottom, TextDirection::kLtr, |
| NGLogicalSize(LayoutUnit(1000), NGSizeIndefinite)); |
| RefPtr<const NGPhysicalBoxFragment> parent_fragment = |
| - RunBlockLayoutAlgorithm(space, parent); |
| + RunBlockLayoutAlgorithm(space, container); |
| FragmentChildIterator iterator(parent_fragment.get()); |
| const auto* fragment = iterator.NextChild(); |
| @@ -1548,36 +1492,33 @@ TEST_F(NGBlockLayoutAlgorithmTest, DISABLED_BlockInTwoColumns) { |
| EXPECT_FALSE(iterator.NextChild()); |
| } |
| -// Test case's HTML representation: |
| -// <div id="parent" style="columns:3; column-fill:auto; column-gap:10px; |
| -// width:320px; height:100px;"> |
| -// <div id="child" style="width:75%; height:250px;"></div> |
| -// </div> |
| // TODO(glebl): reenable multicol after new margin collapsing/floats algorithm |
| // is checked in. |
| TEST_F(NGBlockLayoutAlgorithmTest, DISABLED_BlockInThreeColumns) { |
| - // parent |
| - RefPtr<ComputedStyle> parent_style = ComputedStyle::create(); |
| - parent_style->setColumnCount(3); |
| - parent_style->setColumnFill(ColumnFillAuto); |
| - parent_style->setColumnGap(10); |
| - parent_style->setHeight(Length(100, Fixed)); |
| - parent_style->setWidth(Length(320, Fixed)); |
| - NGBlockNode* parent = new NGBlockNode(parent_style.get()); |
| - |
| - // child |
| - RefPtr<ComputedStyle> child_style = ComputedStyle::create(); |
| - child_style->setWidth(Length(75, Percent)); |
| - child_style->setHeight(Length(250, Fixed)); |
| - NGBlockNode* child = new NGBlockNode(child_style.get()); |
| - |
| - parent->SetFirstChild(child); |
| + setBodyInnerHTML(R"HTML( |
| + <style> |
| + #parent { |
| + column-count: 3; |
| + column-fill: auto; |
| + column-gap: 10px; |
| + height: 100px; |
| + width: 320px; |
| + } |
| + </style> |
| + <div id="container"> |
| + <div id="parent"> |
| + <div id="child" style="width: 75%; height: 250px;"> |
| + </div> |
| + </div> |
| + </div> |
| + )HTML"); |
| + auto* container = new NGBlockNode(getLayoutObjectByElementId("container")); |
| auto* space = ConstructConstraintSpace( |
| kHorizontalTopBottom, TextDirection::kLtr, |
| NGLogicalSize(LayoutUnit(1000), NGSizeIndefinite)); |
| RefPtr<const NGPhysicalBoxFragment> parent_fragment = |
| - RunBlockLayoutAlgorithm(space, parent); |
| + RunBlockLayoutAlgorithm(space, container); |
| FragmentChildIterator iterator(parent_fragment.get()); |
| const auto* fragment = iterator.NextChild(); |
| @@ -1616,37 +1557,34 @@ TEST_F(NGBlockLayoutAlgorithmTest, DISABLED_BlockInThreeColumns) { |
| EXPECT_FALSE(iterator.NextChild()); |
| } |
| -// Test case's HTML representation: |
| -// <div id="parent" style="columns:2; column-fill:auto; column-gap:10px; |
| -// width:210px; height:100px;"> |
| -// <div id="child" style="width:1px; height:250px;"></div> |
| -// </div> |
| // TODO(glebl): reenable multicol after new margin collapsing/floats algorithm |
| // is checked in. |
| TEST_F(NGBlockLayoutAlgorithmTest, |
| DISABLED_ActualColumnCountGreaterThanSpecified) { |
| - // parent |
| - RefPtr<ComputedStyle> parent_style = ComputedStyle::create(); |
| - parent_style->setColumnCount(2); |
| - parent_style->setColumnFill(ColumnFillAuto); |
| - parent_style->setColumnGap(10); |
| - parent_style->setHeight(Length(100, Fixed)); |
| - parent_style->setWidth(Length(210, Fixed)); |
| - NGBlockNode* parent = new NGBlockNode(parent_style.get()); |
| - |
| - // child |
| - RefPtr<ComputedStyle> child_style = ComputedStyle::create(); |
| - child_style->setWidth(Length(1, Fixed)); |
| - child_style->setHeight(Length(250, Fixed)); |
| - NGBlockNode* child = new NGBlockNode(child_style.get()); |
| - |
| - parent->SetFirstChild(child); |
| + setBodyInnerHTML(R"HTML( |
| + <style> |
| + #parent { |
| + column-count: 2; |
| + column-fill: auto; |
| + column-gap: 10px; |
| + height: 100px; |
| + width: 210px; |
| + } |
| + </style> |
| + <div id="container"> |
| + <div id="parent"> |
| + <div id="child" style="width: 1px; height: 250px;"> |
| + </div> |
| + </div> |
| + </div> |
| + )HTML"); |
| + auto* container = new NGBlockNode(getLayoutObjectByElementId("container")); |
| auto* space = ConstructConstraintSpace( |
| kHorizontalTopBottom, TextDirection::kLtr, |
| NGLogicalSize(LayoutUnit(1000), NGSizeIndefinite)); |
| RefPtr<const NGPhysicalBoxFragment> parent_fragment = |
| - RunBlockLayoutAlgorithm(space, parent); |
| + RunBlockLayoutAlgorithm(space, container); |
| FragmentChildIterator iterator(parent_fragment.get()); |
| const auto* fragment = iterator.NextChild(); |
| @@ -1685,44 +1623,35 @@ TEST_F(NGBlockLayoutAlgorithmTest, |
| EXPECT_FALSE(iterator.NextChild()); |
| } |
| -// Test case's HTML representation: |
| -// <div id="parent" style="columns:3; column-fill:auto; column-gap:10px; |
| -// width:320px; height:100px;"> |
| -// <div id="child1" style="width:75%; height:60px;"></div> |
| -// <div id="child2" style="width:85%; height:60px;"></div> |
| -// </div> |
| // TODO(glebl): reenable multicol after new margin collapsing/floats algorithm |
| // is checked in. |
| TEST_F(NGBlockLayoutAlgorithmTest, DISABLED_TwoBlocksInTwoColumns) { |
| - // parent |
| - RefPtr<ComputedStyle> parent_style = ComputedStyle::create(); |
| - parent_style->setColumnCount(3); |
| - parent_style->setColumnFill(ColumnFillAuto); |
| - parent_style->setColumnGap(10); |
| - parent_style->setHeight(Length(100, Fixed)); |
| - parent_style->setWidth(Length(320, Fixed)); |
| - NGBlockNode* parent = new NGBlockNode(parent_style.get()); |
| - |
| - // child1 |
| - RefPtr<ComputedStyle> child1_style = ComputedStyle::create(); |
| - child1_style->setWidth(Length(75, Percent)); |
| - child1_style->setHeight(Length(60, Fixed)); |
| - NGBlockNode* child1 = new NGBlockNode(child1_style.get()); |
| - |
| - // child2 |
| - RefPtr<ComputedStyle> child2_style = ComputedStyle::create(); |
| - child2_style->setWidth(Length(85, Percent)); |
| - child2_style->setHeight(Length(60, Fixed)); |
| - NGBlockNode* child2 = new NGBlockNode(child2_style.get()); |
| - |
| - parent->SetFirstChild(child1); |
| - child1->SetNextSibling(child2); |
| + setBodyInnerHTML(R"HTML( |
| + <style> |
| + #parent { |
| + column-count: 3; |
| + column-fill: auto; |
| + column-gap: 10px; |
| + height: 100px; |
| + width: 320px; |
| + } |
| + </style> |
| + <div id="container"> |
| + <div id="parent"> |
| + <div id="child1" style="width: 75%; height: 60px;"> |
| + </div> |
| + <div id="child2" style="width: 85%; height: 60px;"> |
| + </div> |
| + </div> |
| + </div> |
| + )HTML"); |
| + auto* container = new NGBlockNode(getLayoutObjectByElementId("container")); |
| auto* space = ConstructConstraintSpace( |
| kHorizontalTopBottom, TextDirection::kLtr, |
| NGLogicalSize(LayoutUnit(1000), NGSizeIndefinite)); |
| RefPtr<const NGPhysicalBoxFragment> parent_fragment = |
| - RunBlockLayoutAlgorithm(space, parent); |
| + RunBlockLayoutAlgorithm(space, container); |
| FragmentChildIterator iterator(parent_fragment.get()); |
| const auto* fragment = iterator.NextChild(); |
| @@ -1760,61 +1689,39 @@ TEST_F(NGBlockLayoutAlgorithmTest, DISABLED_TwoBlocksInTwoColumns) { |
| EXPECT_FALSE(iterator.NextChild()); |
| } |
| -// Test case's HTML representation: |
| -// <div id="parent" style="columns:3; column-fill:auto; column-gap:10px; |
| -// width:320px; height:100px;"> |
| -// <div id="child1" style="width:75%; height:60px;"> |
| -// <div id="grandchild1" style="width:50px; height:120px;"></div> |
| -// <div id="grandchild2" style="width:40px; height:20px;"></div> |
| -// </div> |
| -// <div id="child2" style="width:85%; height:10px;"></div> |
| -// </div> |
| // TODO(glebl): reenable multicol after new margin collapsing/floats algorithm |
| // is checked in. |
| TEST_F(NGBlockLayoutAlgorithmTest, DISABLED_OverflowedBlock) { |
| - // parent |
| - RefPtr<ComputedStyle> parent_style = ComputedStyle::create(); |
| - parent_style->setColumnCount(3); |
| - parent_style->setColumnFill(ColumnFillAuto); |
| - parent_style->setColumnGap(10); |
| - parent_style->setHeight(Length(100, Fixed)); |
| - parent_style->setWidth(Length(320, Fixed)); |
| - NGBlockNode* parent = new NGBlockNode(parent_style.get()); |
| - |
| - // child1 |
| - RefPtr<ComputedStyle> child1_style = ComputedStyle::create(); |
| - child1_style->setWidth(Length(75, Percent)); |
| - child1_style->setHeight(Length(60, Fixed)); |
| - NGBlockNode* child1 = new NGBlockNode(child1_style.get()); |
| - |
| - // grandchild1 |
| - RefPtr<ComputedStyle> grandchild1_style = ComputedStyle::create(); |
| - grandchild1_style->setWidth(Length(50, Fixed)); |
| - grandchild1_style->setHeight(Length(120, Fixed)); |
| - NGBlockNode* grandchild1 = new NGBlockNode(grandchild1_style.get()); |
| - |
| - // grandchild2 |
| - RefPtr<ComputedStyle> grandchild2_style = ComputedStyle::create(); |
| - grandchild2_style->setWidth(Length(40, Fixed)); |
| - grandchild2_style->setHeight(Length(20, Fixed)); |
| - NGBlockNode* grandchild2 = new NGBlockNode(grandchild2_style.get()); |
| - |
| - // child2 |
| - RefPtr<ComputedStyle> child2_style = ComputedStyle::create(); |
| - child2_style->setWidth(Length(85, Percent)); |
| - child2_style->setHeight(Length(10, Fixed)); |
| - NGBlockNode* child2 = new NGBlockNode(child2_style.get()); |
| - |
| - parent->SetFirstChild(child1); |
| - child1->SetNextSibling(child2); |
| - child1->SetFirstChild(grandchild1); |
| - grandchild1->SetNextSibling(grandchild2); |
| + setBodyInnerHTML(R"HTML( |
| + <style> |
| + #parent { |
| + column-count: 2; |
| + column-fill: auto; |
| + column-gap: 10px; |
| + height: 100px; |
| + width: 320px; |
| + } |
| + </style> |
| + <div id="container"> |
| + <div id="parent"> |
| + <div id="child1" style="width: 75%; height: 60px;"> |
| + <div id="grandchild1" style="width: 50px; height: 120px;"> |
| + </div> |
| + <div id="grandchild2" style="width: 40px; height: 20px;"> |
| + </div> |
| + </div> |
| + <div id="child2" style="width: 85%; height: 10px;"></div> |
| + </div> |
| + </div> |
| + </div> |
| + )HTML"); |
| + auto* container = new NGBlockNode(getLayoutObjectByElementId("container")); |
| auto* space = ConstructConstraintSpace( |
| kHorizontalTopBottom, TextDirection::kLtr, |
| NGLogicalSize(LayoutUnit(1000), NGSizeIndefinite)); |
| RefPtr<const NGPhysicalBoxFragment> parent_fragment = |
| - RunBlockLayoutAlgorithm(space, parent); |
| + RunBlockLayoutAlgorithm(space, container); |
| FragmentChildIterator iterator(parent_fragment.get()); |
| const auto* fragment = iterator.NextChild(); |
| @@ -1875,37 +1782,33 @@ TEST_F(NGBlockLayoutAlgorithmTest, DISABLED_OverflowedBlock) { |
| EXPECT_FALSE(iterator.NextChild()); |
| } |
| -// Test case's HTML representation: |
| -// <div id="parent" style="columns:3; column-fill:auto; column-gap:10px; |
| -// width:320px; height:100px;"> |
| -// <div id="child" style="float:left; width:75%; height:100px;"></div> |
| -// </div> |
| // TODO(glebl): reenable multicol after new margin collapsing/floats algorithm |
| // is checked in. |
| TEST_F(NGBlockLayoutAlgorithmTest, DISABLED_FloatInOneColumn) { |
| - // parent |
| - RefPtr<ComputedStyle> parent_style = ComputedStyle::create(); |
| - parent_style->setColumnCount(3); |
| - parent_style->setColumnFill(ColumnFillAuto); |
| - parent_style->setColumnGap(10); |
| - parent_style->setHeight(Length(100, Fixed)); |
| - parent_style->setWidth(Length(320, Fixed)); |
| - NGBlockNode* parent = new NGBlockNode(parent_style.get()); |
| - |
| - // child |
| - RefPtr<ComputedStyle> child_style = ComputedStyle::create(); |
| - child_style->setFloating(EFloat::kLeft); |
| - child_style->setWidth(Length(75, Percent)); |
| - child_style->setHeight(Length(100, Fixed)); |
| - NGBlockNode* child = new NGBlockNode(child_style.get()); |
| - |
| - parent->SetFirstChild(child); |
| + setBodyInnerHTML(R"HTML( |
| + <style> |
| + #parent { |
| + column-count: 3; |
| + column-fill: auto; |
| + column-gap: 10px; |
| + height: 100px; |
| + width: 320px; |
| + } |
| + </style> |
| + <div id="container"> |
| + <div id="parent"> |
| + <div id="child" style="float: left; width: 75%; height: 100px;"> |
| + </div> |
| + </div> |
| + </div> |
| + )HTML"); |
| + auto* container = new NGBlockNode(getLayoutObjectByElementId("container")); |
| auto* space = ConstructConstraintSpace( |
| kHorizontalTopBottom, TextDirection::kLtr, |
| NGLogicalSize(LayoutUnit(1000), NGSizeIndefinite)); |
| RefPtr<const NGPhysicalBoxFragment> parent_fragment = |
| - RunBlockLayoutAlgorithm(space, parent); |
| + RunBlockLayoutAlgorithm(space, container); |
| FragmentChildIterator iterator(parent_fragment.get()); |
| const auto* fragment = iterator.NextChild(); |
| @@ -1926,46 +1829,35 @@ TEST_F(NGBlockLayoutAlgorithmTest, DISABLED_FloatInOneColumn) { |
| EXPECT_FALSE(iterator.NextChild()); |
| } |
| -// Test case's HTML representation: |
| -// <div id="parent" style="columns:3; column-fill:auto; column-gap:10px; |
| -// width:320px; height:100px;"> |
| -// <div id="child1" style="float:left; width:15%; height:100px;"></div> |
| -// <div id="child2" style="float:right; width:16%; height:100px;"></div> |
| -// </div> |
| // TODO(glebl): reenable multicol after new margin collapsing/floats algorithm |
| // is checked in. |
| TEST_F(NGBlockLayoutAlgorithmTest, DISABLED_TwoFloatsInOneColumn) { |
| - // parent |
| - RefPtr<ComputedStyle> parent_style = ComputedStyle::create(); |
| - parent_style->setColumnCount(3); |
| - parent_style->setColumnFill(ColumnFillAuto); |
| - parent_style->setColumnGap(10); |
| - parent_style->setHeight(Length(100, Fixed)); |
| - parent_style->setWidth(Length(320, Fixed)); |
| - NGBlockNode* parent = new NGBlockNode(parent_style.get()); |
| - |
| - // child1 |
| - RefPtr<ComputedStyle> child1_style = ComputedStyle::create(); |
| - child1_style->setFloating(EFloat::kLeft); |
| - child1_style->setWidth(Length(15, Percent)); |
| - child1_style->setHeight(Length(100, Fixed)); |
| - NGBlockNode* child1 = new NGBlockNode(child1_style.get()); |
| - |
| - // child2 |
| - RefPtr<ComputedStyle> child2_style = ComputedStyle::create(); |
| - child2_style->setFloating(EFloat::kRight); |
| - child2_style->setWidth(Length(16, Percent)); |
| - child2_style->setHeight(Length(100, Fixed)); |
| - NGBlockNode* child2 = new NGBlockNode(child2_style.get()); |
| - |
| - parent->SetFirstChild(child1); |
| - child1->SetNextSibling(child2); |
| + setBodyInnerHTML(R"HTML( |
| + <style> |
| + #parent { |
| + column-count: 3; |
| + column-fill: auto; |
| + column-gap: 10px; |
| + width: 320px; |
| + height: 100px; |
| + } |
| + </style> |
| + <div id="container"> |
| + <div id="parent"> |
| + <div id="child1" style="float: left; width: 15%; height: 100px;"> |
| + </div> |
| + <div id="child2" style="float: right; width: 16%; height: 100px;"> |
| + </div> |
| + </div> |
| + </div> |
| + )HTML"); |
| + auto* container = new NGBlockNode(getLayoutObjectByElementId("container")); |
| auto* space = ConstructConstraintSpace( |
| kHorizontalTopBottom, TextDirection::kLtr, |
| NGLogicalSize(LayoutUnit(1000), NGSizeIndefinite)); |
| RefPtr<const NGPhysicalBoxFragment> parent_fragment = |
| - RunBlockLayoutAlgorithm(space, parent); |
| + RunBlockLayoutAlgorithm(space, container); |
| FragmentChildIterator iterator(parent_fragment.get()); |
| const auto* fragment = iterator.NextChild(); |
| @@ -1994,46 +1886,35 @@ TEST_F(NGBlockLayoutAlgorithmTest, DISABLED_TwoFloatsInOneColumn) { |
| EXPECT_FALSE(iterator.NextChild()); |
| } |
| -// Test case's HTML representation: |
| -// <div id="parent" style="columns:3; column-fill:auto; column-gap:10px; |
| -// width:320px; height:100px;"> |
| -// <div id="child1" style="float:left; width:15%; height:150px;"></div> |
| -// <div id="child2" style="float:right; width:16%; height:150px;"></div> |
| -// </div> |
| // TODO(glebl): reenable multicol after new margin collapsing/floats algorithm |
| // is checked in. |
| TEST_F(NGBlockLayoutAlgorithmTest, DISABLED_TwoFloatsInTwoColumns) { |
| - // parent |
| - RefPtr<ComputedStyle> parent_style = ComputedStyle::create(); |
| - parent_style->setColumnCount(3); |
| - parent_style->setColumnFill(ColumnFillAuto); |
| - parent_style->setColumnGap(10); |
| - parent_style->setHeight(Length(100, Fixed)); |
| - parent_style->setWidth(Length(320, Fixed)); |
| - NGBlockNode* parent = new NGBlockNode(parent_style.get()); |
| - |
| - // child1 |
| - RefPtr<ComputedStyle> child1_style = ComputedStyle::create(); |
| - child1_style->setFloating(EFloat::kLeft); |
| - child1_style->setWidth(Length(15, Percent)); |
| - child1_style->setHeight(Length(150, Fixed)); |
| - NGBlockNode* child1 = new NGBlockNode(child1_style.get()); |
| - |
| - // child2 |
| - RefPtr<ComputedStyle> child2_style = ComputedStyle::create(); |
| - child2_style->setFloating(EFloat::kRight); |
| - child2_style->setWidth(Length(16, Percent)); |
| - child2_style->setHeight(Length(150, Fixed)); |
| - NGBlockNode* child2 = new NGBlockNode(child2_style.get()); |
| - |
| - parent->SetFirstChild(child1); |
| - child1->SetNextSibling(child2); |
| + setBodyInnerHTML(R"HTML( |
| + <style> |
| + #parent { |
| + column-count: 3; |
| + column-fill: auto; |
| + column-gap: 10px; |
| + width: 320px; |
| + height: 100px; |
| + } |
| + </style> |
| + <div id="container"> |
| + <div id="parent"> |
| + <div id="child1" style="float: left; width: 15%; height: 150px;"> |
| + </div> |
| + <div id="child2" style="float: right; width: 16%; height: 150px;"> |
| + </div> |
| + </div> |
| + </div> |
| + )HTML"); |
| + auto* container = new NGBlockNode(getLayoutObjectByElementId("container")); |
| auto* space = ConstructConstraintSpace( |
| kHorizontalTopBottom, TextDirection::kLtr, |
| NGLogicalSize(LayoutUnit(1000), NGSizeIndefinite)); |
| RefPtr<const NGPhysicalBoxFragment> parent_fragment = |
| - RunBlockLayoutAlgorithm(space, parent); |
| + RunBlockLayoutAlgorithm(space, container); |
| FragmentChildIterator iterator(parent_fragment.get()); |
| const auto* fragment = iterator.NextChild(); |