| 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 d705cc192048352d17f2781fb42e10e5ea5c986c..9d697ddc71bfa28c771d1136192b53d3a974c353 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
|
| @@ -583,59 +583,79 @@ TEST_F(NGBlockLayoutAlgorithmTest, AutoMargin) {
|
| EXPECT_EQ(LayoutUnit(0), child->TopOffset());
|
| }
|
|
|
| -// Verifies that 2 Left/Right float fragments are correctly positioned by the
|
| +// Verifies that 3 Left/Right float fragments are correctly positioned by the
|
| // algorithm.
|
| //
|
| // Test case's HTML representation:
|
| // <div id="parent" style="width: 200px; height: 200px;">
|
| // <div style="float:left; width: 30px; height: 30px;
|
| -// margin: 15px;"/> <!-- DIV1 -->
|
| -// <div style="float:right; width: 30px; height: 30px;"/> <!-- DIV2 -->
|
| +// margin-top: 10px;"/> <!-- DIV1 -->
|
| +// <div style="float:right; width: 50px; height: 50px;"/> <!-- DIV2 -->
|
| +// <div style="float:left; width: 120px; height: 120px;
|
| +// margin-left: 30px;"/> <!-- DIV3 -->
|
| // </div>
|
| //
|
| // Expected:
|
| // - Left float(DIV1) is positioned at the left.
|
| // - Right float(DIV2) is positioned at the right.
|
| +// - Left float(DIV3) is positioned at the left below DIV2.
|
| TEST_F(NGBlockLayoutAlgorithmTest, PositionFloatFragments) {
|
| - const int kDiv1Margin = 10;
|
| + const int kDiv1TopMargin = 10;
|
| const int kParentSize = 200;
|
| - const int kSmallDivSize = 30;
|
| + const int kDiv1Size = 30;
|
| + const int kDiv2Size = 50;
|
| + const int kDiv3Size = kParentSize - kDiv1Size - kDiv2Size;
|
| + const int kDiv3LeftMargin = kDiv1Size;
|
| +
|
| + style_->setHeight(Length(kParentSize, Fixed));
|
| + style_->setWidth(Length(kParentSize, Fixed));
|
|
|
| // DIV1
|
| RefPtr<ComputedStyle> div1_style = ComputedStyle::create();
|
| - div1_style->setWidth(Length(kSmallDivSize, Fixed));
|
| - div1_style->setHeight(Length(kSmallDivSize, Fixed));
|
| + div1_style->setWidth(Length(kDiv1Size, Fixed));
|
| + div1_style->setHeight(Length(kDiv1Size, Fixed));
|
| div1_style->setFloating(EFloat::Left);
|
| - div1_style->setMarginBottom(Length(kDiv1Margin, Fixed));
|
| - div1_style->setMarginTop(Length(kDiv1Margin, Fixed));
|
| - div1_style->setMarginLeft(Length(kDiv1Margin, Fixed));
|
| - div1_style->setMarginRight(Length(kDiv1Margin, Fixed));
|
| + div1_style->setMarginTop(Length(kDiv1TopMargin, Fixed));
|
| NGBox* div1 = new NGBox(div1_style.get());
|
|
|
| // DIV2
|
| RefPtr<ComputedStyle> div2_style = ComputedStyle::create();
|
| - div2_style->setWidth(Length(kSmallDivSize, Fixed));
|
| - div2_style->setHeight(Length(kSmallDivSize, Fixed));
|
| + div2_style->setWidth(Length(kDiv2Size, Fixed));
|
| + div2_style->setHeight(Length(kDiv2Size, Fixed));
|
| div2_style->setFloating(EFloat::Right);
|
| NGBox* div2 = new NGBox(div2_style.get());
|
|
|
| + // DIV3
|
| + RefPtr<ComputedStyle> div3_style = ComputedStyle::create();
|
| + div3_style->setWidth(Length(kDiv3Size, Fixed));
|
| + div3_style->setHeight(Length(kDiv3Size, Fixed));
|
| + div3_style->setMarginLeft(Length(kDiv3LeftMargin, Fixed));
|
| + div3_style->setFloating(EFloat::Left);
|
| + NGBox* div3 = new NGBox(div3_style.get());
|
| +
|
| div1->SetNextSibling(div2);
|
| + div2->SetNextSibling(div3);
|
|
|
| auto* space = new NGConstraintSpace(
|
| HorizontalTopBottom, LeftToRight,
|
| NGLogicalSize(LayoutUnit(kParentSize), LayoutUnit(kParentSize)));
|
| NGPhysicalFragment* frag = RunBlockLayoutAlgorithm(space, div1);
|
| - ASSERT_EQ(frag->Children().size(), 2UL);
|
| + ASSERT_EQ(frag->Children().size(), 3UL);
|
|
|
| - // div1
|
| + // DIV1
|
| const NGPhysicalFragmentBase* child1 = frag->Children()[0];
|
| - EXPECT_EQ(kDiv1Margin, child1->TopOffset());
|
| - EXPECT_EQ(kDiv1Margin, child1->LeftOffset());
|
| + EXPECT_EQ(kDiv1TopMargin, child1->TopOffset());
|
| + EXPECT_EQ(0, child1->LeftOffset());
|
|
|
| - // div2
|
| + // DIV2
|
| const NGPhysicalFragmentBase* child2 = frag->Children()[1];
|
| EXPECT_EQ(0, child2->TopOffset());
|
| - EXPECT_EQ(kParentSize - kSmallDivSize, child2->LeftOffset());
|
| + EXPECT_EQ(kParentSize - kDiv2Size, child2->LeftOffset());
|
| +
|
| + // DIV3
|
| + const NGPhysicalFragmentBase* child3 = frag->Children()[2];
|
| + EXPECT_EQ(kDiv2Size, child3->TopOffset());
|
| + EXPECT_EQ(kDiv3LeftMargin, child3->LeftOffset());
|
| }
|
| } // namespace
|
| } // namespace blink
|
|
|