Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(824)

Unified Diff: third_party/WebKit/Source/core/layout/ng/ng_block_layout_algorithm_test.cc

Issue 2725773002: Remove NGBlockNode constructor, SetFirstChild, SetNextSibling methods (Closed)
Patch Set: Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/layout/ng/ng_block_node.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..b185322891e3582d67ac602dfb3d7da8a50b214f 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);
ikilpatrick 2017/03/01 17:32:46 can we also remove/make private SetFirstChild now
atotic 2017/03/01 18:57:12 done. SetFirstChild/SetNextSibling are gone
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"));
ikilpatrick 2017/03/01 17:32:46 auto* box = ....
atotic 2017/03/01 18:57:13 done
+
+ 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">
+ </div>
+ <div id="second_child"
+ style="height:30px;margin-top:5px;margin-bottom:20px">
+ </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"));
ikilpatrick 2017/03/01 17:32:46 auto* (and elsewhere).
atotic 2017/03/01 18:57:13 done
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());
@@ -176,27 +173,25 @@ TEST_F(NGBlockLayoutAlgorithmTest, LayoutBlockChildren) {
// 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;
+ 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
@@ -666,54 +661,41 @@ TEST_F(NGBlockLayoutAlgorithmTest, CollapsingMarginsWithText) {
// 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>
+// <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; }
Gleb Lanbin 2017/03/01 17:25:22 this shouldn't be longer than 80 symbols.
atotic 2017/03/01 18:57:12 done
+ #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);
@@ -738,6 +720,18 @@ TEST_F(NGBlockLayoutAlgorithmTest, DISABLED_CollapsingMarginsCase6) {
// <div id="div2"></div>
// </div>
TEST_F(NGBlockLayoutAlgorithmTest, BorderAndPadding) {
+ setBodyInnerHTML(R"HTML(
+ <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="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 +742,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 +772,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 +799,22 @@ 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(
+ <div id="container" style="width:30px;padding-left:10px">
+ <div id="first" style="width:10px;margin-left:auto;margin-right:auto"></div>
Gleb Lanbin 2017/03/01 17:25:22 same here.
atotic 2017/03/01 18:57:13 done
+ </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 +1258,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 {
@@ -1367,20 +1332,20 @@ class FragmentChildIterator {
// 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(
+ <div id="container">
+ <div id="parent" style="column-count: 2; column-fill: auto;
+ column-gap: 10px; height: 100px; width: 210px;">
+ </div>
+ </div>
+ )HTML");
+ auto container = new NGBlockNode(getLayoutObjectByElementId("container"));
Gleb Lanbin 2017/03/01 17:25:22 auto* ? here and below.
atotic 2017/03/01 18:57:13 done
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);
@@ -1400,26 +1365,21 @@ TEST_F(NGBlockLayoutAlgorithmTest, DISABLED_EmptyMulticol) {
// 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(
+ <div id="container">
+ <div id="parent" style="column-count: 2; column-fill: auto;
+ column-gap: 10px; height: 100px; width: 210px;">
+ <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());
@@ -1447,28 +1407,22 @@ TEST_F(NGBlockLayoutAlgorithmTest, DISABLED_EmptyBlock) {
// 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(
+ <div id="container">
+ <div id="parent" style="column-count: 2; column-fill: auto;
+ column-gap: 10px; height: 100px; width: 310px;">
+ <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();
@@ -1497,28 +1451,21 @@ TEST_F(NGBlockLayoutAlgorithmTest, DISABLED_BlockInOneColumn) {
// 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(
+ <div id="container">
+ <div id="parent" style="column-count: 2; column-fill: auto;
Gleb Lanbin 2017/03/01 17:25:22 can you move the style definition to <style> ? and
atotic 2017/03/01 18:57:12 done for long style defs.
+ column-gap: 10px; height: 100px; width: 210px;">
+ <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();
@@ -1556,28 +1503,22 @@ TEST_F(NGBlockLayoutAlgorithmTest, DISABLED_BlockInTwoColumns) {
// 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(
+ <div id="container">
+ <div id="parent" style="column-count: 3; column-fill: auto;
+ column-gap: 10px; height: 100px; width: 320px;">
+ <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();
@@ -1625,28 +1566,22 @@ TEST_F(NGBlockLayoutAlgorithmTest, DISABLED_BlockInThreeColumns) {
// 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(
+ <div id="container">
+ <div id="parent" style="column-count: 2; column-fill: auto;
+ column-gap: 10px; height: 100px; width: 210px;">
+ <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();
@@ -1694,35 +1629,24 @@ TEST_F(NGBlockLayoutAlgorithmTest,
// 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(
+ <div id="container">
+ <div id="parent" style="column-count: 3; column-fill: auto;
+ column-gap: 10px; height: 100px; width: 320px;">
+ <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();
@@ -1763,58 +1687,37 @@ TEST_F(NGBlockLayoutAlgorithmTest, DISABLED_TwoBlocksInTwoColumns) {
// 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 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(
+ <div id="container">
+ <div id="parent" style="column-count: 2; column-fill: auto;
+ column-gap: 10px; height: 100px; width: 320px;">
+ <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();
@@ -1883,29 +1786,22 @@ TEST_F(NGBlockLayoutAlgorithmTest, DISABLED_OverflowedBlock) {
// 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(
+ <div id="container">
+ <div id="parent" style="columns:3; column-fill:auto; column-gap:10px;
+ width:320px; height:100px;">
Gleb Lanbin 2017/03/01 17:25:22 wrong indentation and please move it to <style>
atotic 2017/03/01 18:57:12 done
+ <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();
@@ -1935,37 +1831,24 @@ TEST_F(NGBlockLayoutAlgorithmTest, DISABLED_FloatInOneColumn) {
// 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(
+ <div id="container">
+ <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>
+ </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();
@@ -2003,37 +1886,24 @@ TEST_F(NGBlockLayoutAlgorithmTest, DISABLED_TwoFloatsInOneColumn) {
// 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(
+ <div id="container">
+ <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>
+ </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();
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/layout/ng/ng_block_node.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698