OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "core/layout/ng/ng_block_layout_algorithm.h" | 5 #include "core/layout/ng/ng_block_layout_algorithm.h" |
6 | 6 |
7 #include "core/dom/NodeComputedStyle.h" | 7 #include "core/dom/NodeComputedStyle.h" |
8 #include "core/dom/TagCollection.h" | 8 #include "core/dom/TagCollection.h" |
9 #include "core/layout/LayoutTestHelper.h" | 9 #include "core/layout/LayoutTestHelper.h" |
10 #include "core/layout/ng/layout_ng_block_flow.h" | 10 #include "core/layout/ng/layout_ng_block_flow.h" |
11 #include "core/layout/ng/ng_block_break_token.h" | 11 #include "core/layout/ng/ng_block_break_token.h" |
12 #include "core/layout/ng/ng_block_node.h" | 12 #include "core/layout/ng/ng_block_node.h" |
13 #include "core/layout/ng/ng_constraint_space.h" | 13 #include "core/layout/ng/ng_constraint_space.h" |
14 #include "core/layout/ng/ng_constraint_space_builder.h" | 14 #include "core/layout/ng/ng_constraint_space_builder.h" |
15 #include "core/layout/ng/ng_floating_object.h" | 15 #include "core/layout/ng/ng_floating_object.h" |
16 #include "core/layout/ng/ng_length_utils.h" | 16 #include "core/layout/ng/ng_length_utils.h" |
17 #include "core/layout/ng/ng_physical_box_fragment.h" | 17 #include "core/layout/ng/ng_physical_box_fragment.h" |
18 #include "core/layout/ng/ng_physical_fragment.h" | 18 #include "core/layout/ng/ng_physical_fragment.h" |
19 #include "core/layout/ng/ng_units.h" | 19 #include "core/layout/ng/ng_units.h" |
20 #include "core/style/ComputedStyle.h" | 20 #include "core/style/ComputedStyle.h" |
21 #include "testing/gmock/include/gmock/gmock.h" | 21 #include "testing/gmock/include/gmock/gmock.h" |
22 #include "testing/gtest/include/gtest/gtest.h" | 22 #include "testing/gtest/include/gtest/gtest.h" |
23 | 23 |
24 namespace blink { | 24 namespace blink { |
25 namespace { | 25 namespace { |
26 | 26 |
27 using testing::ElementsAre; | 27 using testing::ElementsAre; |
28 using testing::Pointee; | 28 using testing::Pointee; |
29 | 29 |
30 NGConstraintSpace* ConstructConstraintSpace( | 30 RefPtr<NGConstraintSpace> ConstructConstraintSpace( |
31 NGWritingMode writing_mode, | 31 NGWritingMode writing_mode, |
32 TextDirection direction, | 32 TextDirection direction, |
33 NGLogicalSize size, | 33 NGLogicalSize size, |
34 bool shrink_to_fit = false, | 34 bool shrink_to_fit = false, |
35 LayoutUnit fragmentainer_space_available = LayoutUnit()) { | 35 LayoutUnit fragmentainer_space_available = LayoutUnit()) { |
36 NGFragmentationType block_fragmentation = | 36 NGFragmentationType block_fragmentation = |
37 fragmentainer_space_available != LayoutUnit() | 37 fragmentainer_space_available != LayoutUnit() |
38 ? NGFragmentationType::kFragmentColumn | 38 ? NGFragmentationType::kFragmentColumn |
39 : NGFragmentationType::kFragmentNone; | 39 : NGFragmentationType::kFragmentNone; |
40 | 40 |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
72 | 72 |
73 RefPtr<NGPhysicalBoxFragment> RunBlockLayoutAlgorithm( | 73 RefPtr<NGPhysicalBoxFragment> RunBlockLayoutAlgorithm( |
74 NGConstraintSpace* space, | 74 NGConstraintSpace* space, |
75 NGBlockNode* node) { | 75 NGBlockNode* node) { |
76 RefPtr<NGLayoutResult> result = | 76 RefPtr<NGLayoutResult> result = |
77 NGBlockLayoutAlgorithm(node, space).Layout(); | 77 NGBlockLayoutAlgorithm(node, space).Layout(); |
78 | 78 |
79 return toNGPhysicalBoxFragment(result->PhysicalFragment().get()); | 79 return toNGPhysicalBoxFragment(result->PhysicalFragment().get()); |
80 } | 80 } |
81 | 81 |
82 std::pair<RefPtr<NGPhysicalBoxFragment>, NGConstraintSpace*> | 82 std::pair<RefPtr<NGPhysicalBoxFragment>, RefPtr<NGConstraintSpace>> |
83 RunBlockLayoutAlgorithmForElement(Element* element) { | 83 RunBlockLayoutAlgorithmForElement(Element* element) { |
84 LayoutNGBlockFlow* block_flow = | 84 LayoutNGBlockFlow* block_flow = |
85 toLayoutNGBlockFlow(element->layoutObject()); | 85 toLayoutNGBlockFlow(element->layoutObject()); |
86 NGBlockNode* node = new NGBlockNode(block_flow); | 86 NGBlockNode* node = new NGBlockNode(block_flow); |
87 NGConstraintSpace* space = | 87 RefPtr<NGConstraintSpace> space = |
88 NGConstraintSpace::CreateFromLayoutObject(*block_flow); | 88 NGConstraintSpace::CreateFromLayoutObject(*block_flow); |
89 | 89 |
90 RefPtr<NGLayoutResult> result = | 90 RefPtr<NGLayoutResult> result = |
91 NGBlockLayoutAlgorithm(node, space).Layout(); | 91 NGBlockLayoutAlgorithm(node, space.get()).Layout(); |
92 return std::make_pair( | 92 return std::make_pair( |
93 toNGPhysicalBoxFragment(result->PhysicalFragment().get()), space); | 93 toNGPhysicalBoxFragment(result->PhysicalFragment().get()), space); |
94 } | 94 } |
95 | 95 |
96 MinAndMaxContentSizes RunComputeMinAndMax(NGBlockNode* node) { | 96 MinAndMaxContentSizes RunComputeMinAndMax(NGBlockNode* node) { |
97 // The constraint space is not used for min/max computation, but we need | 97 // The constraint space is not used for min/max computation, but we need |
98 // it to create the algorithm. | 98 // it to create the algorithm. |
99 NGConstraintSpace* space = | 99 RefPtr<NGConstraintSpace> space = |
100 ConstructConstraintSpace(kHorizontalTopBottom, TextDirection::kLtr, | 100 ConstructConstraintSpace(kHorizontalTopBottom, TextDirection::kLtr, |
101 NGLogicalSize(LayoutUnit(), LayoutUnit())); | 101 NGLogicalSize(LayoutUnit(), LayoutUnit())); |
102 | 102 |
103 NGBlockLayoutAlgorithm algorithm(node, space); | 103 NGBlockLayoutAlgorithm algorithm(node, space.get()); |
104 EXPECT_TRUE(algorithm.ComputeMinAndMaxContentSizes().has_value()); | 104 EXPECT_TRUE(algorithm.ComputeMinAndMaxContentSizes().has_value()); |
105 return *algorithm.ComputeMinAndMaxContentSizes(); | 105 return *algorithm.ComputeMinAndMaxContentSizes(); |
106 } | 106 } |
107 | 107 |
108 RefPtr<ComputedStyle> style_; | 108 RefPtr<ComputedStyle> style_; |
109 }; | 109 }; |
110 | 110 |
111 TEST_F(NGBlockLayoutAlgorithmTest, FixedSize) { | 111 TEST_F(NGBlockLayoutAlgorithmTest, FixedSize) { |
112 setBodyInnerHTML(R"HTML( | 112 setBodyInnerHTML(R"HTML( |
113 <div id="box" style="width:30px; height:40px"></div> | 113 <div id="box" style="width:30px; height:40px"></div> |
114 )HTML"); | 114 )HTML"); |
115 | 115 |
116 auto* space = ConstructConstraintSpace( | 116 RefPtr<NGConstraintSpace> space = ConstructConstraintSpace( |
117 kHorizontalTopBottom, TextDirection::kLtr, | 117 kHorizontalTopBottom, TextDirection::kLtr, |
118 NGLogicalSize(LayoutUnit(100), NGSizeIndefinite)); | 118 NGLogicalSize(LayoutUnit(100), NGSizeIndefinite)); |
119 | 119 |
120 auto* box = new NGBlockNode(getLayoutObjectByElementId("box")); | 120 auto* box = new NGBlockNode(getLayoutObjectByElementId("box")); |
121 | 121 |
122 RefPtr<NGPhysicalFragment> frag = RunBlockLayoutAlgorithm(space, box); | 122 RefPtr<NGPhysicalFragment> frag = RunBlockLayoutAlgorithm(space.get(), box); |
123 | 123 |
124 EXPECT_EQ(LayoutUnit(30), frag->Width()); | 124 EXPECT_EQ(LayoutUnit(30), frag->Width()); |
125 EXPECT_EQ(LayoutUnit(40), frag->Height()); | 125 EXPECT_EQ(LayoutUnit(40), frag->Height()); |
126 } | 126 } |
127 | 127 |
128 // Verifies that two children are laid out with the correct size and position. | 128 // Verifies that two children are laid out with the correct size and position. |
129 TEST_F(NGBlockLayoutAlgorithmTest, LayoutBlockChildren) { | 129 TEST_F(NGBlockLayoutAlgorithmTest, LayoutBlockChildren) { |
130 setBodyInnerHTML(R"HTML( | 130 setBodyInnerHTML(R"HTML( |
131 <div id="container" style="width: 30px"> | 131 <div id="container" style="width: 30px"> |
132 <div style="height: 20px"> | 132 <div style="height: 20px"> |
133 </div> | 133 </div> |
134 <div style="height: 30px; margin-top: 5px; margin-bottom: 20px"> | 134 <div style="height: 30px; margin-top: 5px; margin-bottom: 20px"> |
135 </div> | 135 </div> |
136 </div> | 136 </div> |
137 )HTML"); | 137 )HTML"); |
138 const int kWidth = 30; | 138 const int kWidth = 30; |
139 const int kHeight1 = 20; | 139 const int kHeight1 = 20; |
140 const int kHeight2 = 30; | 140 const int kHeight2 = 30; |
141 const int kMarginTop = 5; | 141 const int kMarginTop = 5; |
142 | 142 |
143 auto* container = new NGBlockNode(getLayoutObjectByElementId("container")); | 143 auto* container = new NGBlockNode(getLayoutObjectByElementId("container")); |
144 auto* space = ConstructConstraintSpace( | 144 RefPtr<NGConstraintSpace> space = ConstructConstraintSpace( |
145 kHorizontalTopBottom, TextDirection::kLtr, | 145 kHorizontalTopBottom, TextDirection::kLtr, |
146 NGLogicalSize(LayoutUnit(100), NGSizeIndefinite)); | 146 NGLogicalSize(LayoutUnit(100), NGSizeIndefinite)); |
147 | 147 |
148 RefPtr<NGPhysicalBoxFragment> frag = | 148 RefPtr<NGPhysicalBoxFragment> frag = |
149 RunBlockLayoutAlgorithm(space, container); | 149 RunBlockLayoutAlgorithm(space.get(), container); |
150 | 150 |
151 EXPECT_EQ(LayoutUnit(kWidth), frag->Width()); | 151 EXPECT_EQ(LayoutUnit(kWidth), frag->Width()); |
152 EXPECT_EQ(LayoutUnit(kHeight1 + kHeight2 + kMarginTop), frag->Height()); | 152 EXPECT_EQ(LayoutUnit(kHeight1 + kHeight2 + kMarginTop), frag->Height()); |
153 EXPECT_EQ(NGPhysicalFragment::kFragmentBox, frag->Type()); | 153 EXPECT_EQ(NGPhysicalFragment::kFragmentBox, frag->Type()); |
154 ASSERT_EQ(frag->Children().size(), 2UL); | 154 ASSERT_EQ(frag->Children().size(), 2UL); |
155 | 155 |
156 const NGPhysicalFragment* first_child_fragment = frag->Children()[0].get(); | 156 const NGPhysicalFragment* first_child_fragment = frag->Children()[0].get(); |
157 EXPECT_EQ(kHeight1, first_child_fragment->Height()); | 157 EXPECT_EQ(kHeight1, first_child_fragment->Height()); |
158 EXPECT_EQ(0, first_child_fragment->TopOffset()); | 158 EXPECT_EQ(0, first_child_fragment->TopOffset()); |
159 | 159 |
(...skipping 18 matching lines...) Expand all Loading... |
178 <div id="div1" style="writing-mode: vertical-lr;"> | 178 <div id="div1" style="writing-mode: vertical-lr;"> |
179 <div id="div2"> | 179 <div id="div2"> |
180 </div> | 180 </div> |
181 </div> | 181 </div> |
182 </div> | 182 </div> |
183 )HTML"); | 183 )HTML"); |
184 const int kHeight = 50; | 184 const int kHeight = 50; |
185 const int kMarginLeft = 100; | 185 const int kMarginLeft = 100; |
186 | 186 |
187 auto* container = new NGBlockNode(getLayoutObjectByElementId("container")); | 187 auto* container = new NGBlockNode(getLayoutObjectByElementId("container")); |
188 auto* space = | 188 RefPtr<NGConstraintSpace> space = |
189 ConstructConstraintSpace(kHorizontalTopBottom, TextDirection::kLtr, | 189 ConstructConstraintSpace(kHorizontalTopBottom, TextDirection::kLtr, |
190 NGLogicalSize(LayoutUnit(500), LayoutUnit(500))); | 190 NGLogicalSize(LayoutUnit(500), LayoutUnit(500))); |
191 RefPtr<NGPhysicalBoxFragment> frag = | 191 RefPtr<NGPhysicalBoxFragment> frag = |
192 RunBlockLayoutAlgorithm(space, container); | 192 RunBlockLayoutAlgorithm(space.get(), container); |
193 | 193 |
194 const NGPhysicalFragment* child = frag->Children()[0].get(); | 194 const NGPhysicalFragment* child = frag->Children()[0].get(); |
195 // DIV2 | 195 // DIV2 |
196 child = static_cast<const NGPhysicalBoxFragment*>(child)->Children()[0].get(); | 196 child = static_cast<const NGPhysicalBoxFragment*>(child)->Children()[0].get(); |
197 | 197 |
198 EXPECT_EQ(kHeight, child->Height()); | 198 EXPECT_EQ(kHeight, child->Height()); |
199 EXPECT_EQ(0, child->TopOffset()); | 199 EXPECT_EQ(0, child->TopOffset()); |
200 EXPECT_EQ(kMarginLeft, child->LeftOffset()); | 200 EXPECT_EQ(kMarginLeft, child->LeftOffset()); |
201 } | 201 } |
202 | 202 |
(...skipping 30 matching lines...) Expand all Loading... |
233 } | 233 } |
234 </style> | 234 </style> |
235 <div id='container'> | 235 <div id='container'> |
236 <div id='float-child-left'></div> | 236 <div id='float-child-left'></div> |
237 <div id='float-child-right'></div> | 237 <div id='float-child-right'></div> |
238 <div id='first-child'></div> | 238 <div id='first-child'></div> |
239 </div> | 239 </div> |
240 )HTML"); | 240 )HTML"); |
241 | 241 |
242 // ** Run LayoutNG algorithm ** | 242 // ** Run LayoutNG algorithm ** |
243 NGConstraintSpace* space; | 243 RefPtr<NGConstraintSpace> space; |
244 RefPtr<NGPhysicalBoxFragment> fragment; | 244 RefPtr<NGPhysicalBoxFragment> fragment; |
245 std::tie(fragment, space) = RunBlockLayoutAlgorithmForElement( | 245 std::tie(fragment, space) = RunBlockLayoutAlgorithmForElement( |
246 document().getElementsByTagName("html")->item(0)); | 246 document().getElementsByTagName("html")->item(0)); |
247 ASSERT_EQ(fragment->Children().size(), 1UL); | 247 ASSERT_EQ(fragment->Children().size(), 1UL); |
248 auto* body_fragment = toNGPhysicalBoxFragment(fragment->Children()[0].get()); | 248 auto* body_fragment = toNGPhysicalBoxFragment(fragment->Children()[0].get()); |
249 // 20 = max(first child's margin top, containers's margin top) | 249 // 20 = max(first child's margin top, containers's margin top) |
250 int body_top_offset = 20; | 250 int body_top_offset = 20; |
251 EXPECT_THAT(LayoutUnit(body_top_offset), body_fragment->TopOffset()); | 251 EXPECT_THAT(LayoutUnit(body_top_offset), body_fragment->TopOffset()); |
252 // 8 = body's margin | 252 // 8 = body's margin |
253 int body_left_offset = 8; | 253 int body_left_offset = 8; |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
352 <div id='float-between-nonempties'></div> | 352 <div id='float-between-nonempties'></div> |
353 <div id='second-child'> | 353 <div id='second-child'> |
354 <div id='float-top-align'></div> | 354 <div id='float-top-align'></div> |
355 <div id='empty3'></div> | 355 <div id='empty3'></div> |
356 <div id='empty4' style='margin-top: -30px'></div> | 356 <div id='empty4' style='margin-top: -30px'></div> |
357 </div> | 357 </div> |
358 <div id='empty5'></div> | 358 <div id='empty5'></div> |
359 )HTML"); | 359 )HTML"); |
360 | 360 |
361 // ** Run LayoutNG algorithm ** | 361 // ** Run LayoutNG algorithm ** |
362 NGConstraintSpace* space; | 362 RefPtr<NGConstraintSpace> space; |
363 RefPtr<NGPhysicalBoxFragment> fragment; | 363 RefPtr<NGPhysicalBoxFragment> fragment; |
364 std::tie(fragment, space) = RunBlockLayoutAlgorithmForElement( | 364 std::tie(fragment, space) = RunBlockLayoutAlgorithmForElement( |
365 document().getElementsByTagName("html")->item(0)); | 365 document().getElementsByTagName("html")->item(0)); |
366 | 366 |
367 auto* body_fragment = toNGPhysicalBoxFragment(fragment->Children()[0].get()); | 367 auto* body_fragment = toNGPhysicalBoxFragment(fragment->Children()[0].get()); |
368 // -7 = empty1's margin(-15) + body's margin(8) | 368 // -7 = empty1's margin(-15) + body's margin(8) |
369 int body_top_offset = -7; | 369 int body_top_offset = -7; |
370 EXPECT_THAT(LayoutUnit(body_top_offset), body_fragment->TopOffset()); | 370 EXPECT_THAT(LayoutUnit(body_top_offset), body_fragment->TopOffset()); |
371 int body_left_offset = 8; | 371 int body_left_offset = 8; |
372 EXPECT_THAT(LayoutUnit(body_top_offset), body_fragment->TopOffset()); | 372 EXPECT_THAT(LayoutUnit(body_top_offset), body_fragment->TopOffset()); |
(...skipping 304 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
677 <div id="div2">vertical</div> | 677 <div id="div2">vertical</div> |
678 </div> | 678 </div> |
679 <div id="div3"></div> | 679 <div id="div3"></div> |
680 </div> | 680 </div> |
681 )HTML"); | 681 )HTML"); |
682 const int kHeight = 60; | 682 const int kHeight = 60; |
683 const int kMarginBottom = 10; | 683 const int kMarginBottom = 10; |
684 const int kMarginTop = 40; | 684 const int kMarginTop = 40; |
685 | 685 |
686 auto* container = new NGBlockNode(getLayoutObjectByElementId("container")); | 686 auto* container = new NGBlockNode(getLayoutObjectByElementId("container")); |
687 auto* space = | 687 RefPtr<NGConstraintSpace> space = |
688 ConstructConstraintSpace(kHorizontalTopBottom, TextDirection::kLtr, | 688 ConstructConstraintSpace(kHorizontalTopBottom, TextDirection::kLtr, |
689 NGLogicalSize(LayoutUnit(500), LayoutUnit(500))); | 689 NGLogicalSize(LayoutUnit(500), LayoutUnit(500))); |
690 RefPtr<NGPhysicalBoxFragment> frag = | 690 RefPtr<NGPhysicalBoxFragment> frag = |
691 RunBlockLayoutAlgorithm(space, container); | 691 RunBlockLayoutAlgorithm(space.get(), container); |
692 | 692 |
693 ASSERT_EQ(frag->Children().size(), 2UL); | 693 ASSERT_EQ(frag->Children().size(), 2UL); |
694 | 694 |
695 const NGPhysicalFragment* child1 = frag->Children()[0].get(); | 695 const NGPhysicalFragment* child1 = frag->Children()[0].get(); |
696 EXPECT_EQ(0, child1->TopOffset()); | 696 EXPECT_EQ(0, child1->TopOffset()); |
697 EXPECT_EQ(kHeight, child1->Height()); | 697 EXPECT_EQ(kHeight, child1->Height()); |
698 | 698 |
699 const NGPhysicalFragment* child2 = frag->Children()[1].get(); | 699 const NGPhysicalFragment* child2 = frag->Children()[1].get(); |
700 EXPECT_EQ(kHeight + std::max(kMarginBottom, kMarginTop), child2->TopOffset()); | 700 EXPECT_EQ(kHeight + std::max(kMarginBottom, kMarginTop), child2->TopOffset()); |
701 } | 701 } |
(...skipping 23 matching lines...) Expand all Loading... |
725 const int kBorderRight = 2; | 725 const int kBorderRight = 2; |
726 const int kBorderBottom = 3; | 726 const int kBorderBottom = 3; |
727 const int kBorderLeft = 4; | 727 const int kBorderLeft = 4; |
728 const int kPaddingTop = 5; | 728 const int kPaddingTop = 5; |
729 const int kPaddingRight = 6; | 729 const int kPaddingRight = 6; |
730 const int kPaddingBottom = 7; | 730 const int kPaddingBottom = 7; |
731 const int kPaddingLeft = 8; | 731 const int kPaddingLeft = 8; |
732 | 732 |
733 auto* container = new NGBlockNode(getLayoutObjectByElementId("container")); | 733 auto* container = new NGBlockNode(getLayoutObjectByElementId("container")); |
734 | 734 |
735 auto* space = ConstructConstraintSpace( | 735 RefPtr<NGConstraintSpace> space = ConstructConstraintSpace( |
736 kHorizontalTopBottom, TextDirection::kLtr, | 736 kHorizontalTopBottom, TextDirection::kLtr, |
737 NGLogicalSize(LayoutUnit(1000), NGSizeIndefinite)); | 737 NGLogicalSize(LayoutUnit(1000), NGSizeIndefinite)); |
738 | 738 |
739 RefPtr<NGPhysicalBoxFragment> frag = | 739 RefPtr<NGPhysicalBoxFragment> frag = |
740 RunBlockLayoutAlgorithm(space, container); | 740 RunBlockLayoutAlgorithm(space.get(), container); |
741 | 741 |
742 ASSERT_EQ(frag->Children().size(), 1UL); | 742 ASSERT_EQ(frag->Children().size(), 1UL); |
743 | 743 |
744 // div1 | 744 // div1 |
745 const NGPhysicalFragment* child = frag->Children()[0].get(); | 745 const NGPhysicalFragment* child = frag->Children()[0].get(); |
746 EXPECT_EQ(kBorderLeft + kPaddingLeft + kWidth + kPaddingRight + kBorderRight, | 746 EXPECT_EQ(kBorderLeft + kPaddingLeft + kWidth + kPaddingRight + kBorderRight, |
747 child->Width()); | 747 child->Width()); |
748 EXPECT_EQ(kBorderTop + kPaddingTop + kHeight + kPaddingBottom + kBorderBottom, | 748 EXPECT_EQ(kBorderTop + kPaddingTop + kHeight + kPaddingBottom + kBorderBottom, |
749 child->Height()); | 749 child->Height()); |
750 | 750 |
(...skipping 11 matching lines...) Expand all Loading... |
762 setBodyInnerHTML(R"HTML( | 762 setBodyInnerHTML(R"HTML( |
763 <div id="container" style="width: 30px; padding-left: 10px"> | 763 <div id="container" style="width: 30px; padding-left: 10px"> |
764 <div id="div1" style="width: 40%"></div> | 764 <div id="div1" style="width: 40%"></div> |
765 </div> | 765 </div> |
766 )HTML"); | 766 )HTML"); |
767 const int kPaddingLeft = 10; | 767 const int kPaddingLeft = 10; |
768 const int kWidth = 30; | 768 const int kWidth = 30; |
769 | 769 |
770 auto* container = new NGBlockNode(getLayoutObjectByElementId("container")); | 770 auto* container = new NGBlockNode(getLayoutObjectByElementId("container")); |
771 | 771 |
772 auto* space = ConstructConstraintSpace( | 772 RefPtr<NGConstraintSpace> space = ConstructConstraintSpace( |
773 kHorizontalTopBottom, TextDirection::kLtr, | 773 kHorizontalTopBottom, TextDirection::kLtr, |
774 NGLogicalSize(LayoutUnit(100), NGSizeIndefinite)); | 774 NGLogicalSize(LayoutUnit(100), NGSizeIndefinite)); |
775 RefPtr<NGPhysicalBoxFragment> frag = | 775 RefPtr<NGPhysicalBoxFragment> frag = |
776 RunBlockLayoutAlgorithm(space, container); | 776 RunBlockLayoutAlgorithm(space.get(), container); |
777 | 777 |
778 EXPECT_EQ(LayoutUnit(kWidth + kPaddingLeft), frag->Width()); | 778 EXPECT_EQ(LayoutUnit(kWidth + kPaddingLeft), frag->Width()); |
779 EXPECT_EQ(NGPhysicalFragment::kFragmentBox, frag->Type()); | 779 EXPECT_EQ(NGPhysicalFragment::kFragmentBox, frag->Type()); |
780 ASSERT_EQ(frag->Children().size(), 1UL); | 780 ASSERT_EQ(frag->Children().size(), 1UL); |
781 | 781 |
782 const NGPhysicalFragment* child = frag->Children()[0].get(); | 782 const NGPhysicalFragment* child = frag->Children()[0].get(); |
783 EXPECT_EQ(LayoutUnit(12), child->Width()); | 783 EXPECT_EQ(LayoutUnit(12), child->Width()); |
784 } | 784 } |
785 | 785 |
786 // A very simple auto margin case. We rely on the tests in ng_length_utils_test | 786 // A very simple auto margin case. We rely on the tests in ng_length_utils_test |
787 // for the more complex cases; just make sure we handle auto at all here. | 787 // for the more complex cases; just make sure we handle auto at all here. |
788 TEST_F(NGBlockLayoutAlgorithmTest, AutoMargin) { | 788 TEST_F(NGBlockLayoutAlgorithmTest, AutoMargin) { |
789 setBodyInnerHTML(R"HTML( | 789 setBodyInnerHTML(R"HTML( |
790 <style> | 790 <style> |
791 #first { width: 10px; margin-left: auto; margin-right: auto; } | 791 #first { width: 10px; margin-left: auto; margin-right: auto; } |
792 </style> | 792 </style> |
793 <div id="container" style="width: 30px; padding-left: 10px"> | 793 <div id="container" style="width: 30px; padding-left: 10px"> |
794 <div id="first"> | 794 <div id="first"> |
795 </div> | 795 </div> |
796 </div> | 796 </div> |
797 )HTML"); | 797 )HTML"); |
798 const int kPaddingLeft = 10; | 798 const int kPaddingLeft = 10; |
799 const int kWidth = 30; | 799 const int kWidth = 30; |
800 const int kChildWidth = 10; | 800 const int kChildWidth = 10; |
801 | 801 |
802 auto* container = new NGBlockNode(getLayoutObjectByElementId("container")); | 802 auto* container = new NGBlockNode(getLayoutObjectByElementId("container")); |
803 | 803 |
804 auto* space = ConstructConstraintSpace( | 804 RefPtr<NGConstraintSpace> space = ConstructConstraintSpace( |
805 kHorizontalTopBottom, TextDirection::kLtr, | 805 kHorizontalTopBottom, TextDirection::kLtr, |
806 NGLogicalSize(LayoutUnit(100), NGSizeIndefinite)); | 806 NGLogicalSize(LayoutUnit(100), NGSizeIndefinite)); |
807 RefPtr<NGPhysicalBoxFragment> frag = | 807 RefPtr<NGPhysicalBoxFragment> frag = |
808 RunBlockLayoutAlgorithm(space, container); | 808 RunBlockLayoutAlgorithm(space.get(), container); |
809 | 809 |
810 EXPECT_EQ(LayoutUnit(kWidth + kPaddingLeft), frag->Width()); | 810 EXPECT_EQ(LayoutUnit(kWidth + kPaddingLeft), frag->Width()); |
811 EXPECT_EQ(NGPhysicalFragment::kFragmentBox, frag->Type()); | 811 EXPECT_EQ(NGPhysicalFragment::kFragmentBox, frag->Type()); |
812 EXPECT_EQ(LayoutUnit(kWidth + kPaddingLeft), frag->WidthOverflow()); | 812 EXPECT_EQ(LayoutUnit(kWidth + kPaddingLeft), frag->WidthOverflow()); |
813 ASSERT_EQ(1UL, frag->Children().size()); | 813 ASSERT_EQ(1UL, frag->Children().size()); |
814 | 814 |
815 const NGPhysicalFragment* child = frag->Children()[0].get(); | 815 const NGPhysicalFragment* child = frag->Children()[0].get(); |
816 EXPECT_EQ(LayoutUnit(kChildWidth), child->Width()); | 816 EXPECT_EQ(LayoutUnit(kChildWidth), child->Width()); |
817 EXPECT_EQ(LayoutUnit(kPaddingLeft + 10), child->LeftOffset()); | 817 EXPECT_EQ(LayoutUnit(kPaddingLeft + 10), child->LeftOffset()); |
818 EXPECT_EQ(LayoutUnit(0), child->TopOffset()); | 818 EXPECT_EQ(LayoutUnit(0), child->TopOffset()); |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
856 <div id='empty1'> | 856 <div id='empty1'> |
857 <div id='empty2'> | 857 <div id='empty2'> |
858 <div id='left-float'></div> | 858 <div id='left-float'></div> |
859 <div id='right-float'></div> | 859 <div id='right-float'></div> |
860 </div> | 860 </div> |
861 </div> | 861 </div> |
862 </div> | 862 </div> |
863 )HTML"); | 863 )HTML"); |
864 | 864 |
865 // ** Run LayoutNG algorithm ** | 865 // ** Run LayoutNG algorithm ** |
866 NGConstraintSpace* space; | 866 RefPtr<NGConstraintSpace> space; |
867 RefPtr<NGPhysicalBoxFragment> fragment; | 867 RefPtr<NGPhysicalBoxFragment> fragment; |
868 std::tie(fragment, space) = RunBlockLayoutAlgorithmForElement( | 868 std::tie(fragment, space) = RunBlockLayoutAlgorithmForElement( |
869 document().getElementsByTagName("html")->item(0)); | 869 document().getElementsByTagName("html")->item(0)); |
870 | 870 |
871 auto* body_fragment = toNGPhysicalBoxFragment(fragment->Children()[0].get()); | 871 auto* body_fragment = toNGPhysicalBoxFragment(fragment->Children()[0].get()); |
872 // 20 = std::max(empty1's margin, empty2's margin, body's margin) | 872 // 20 = std::max(empty1's margin, empty2's margin, body's margin) |
873 int body_top_offset = 20; | 873 int body_top_offset = 20; |
874 EXPECT_THAT(LayoutUnit(body_top_offset), body_fragment->TopOffset()); | 874 EXPECT_THAT(LayoutUnit(body_top_offset), body_fragment->TopOffset()); |
875 ASSERT_EQ(1UL, body_fragment->Children().size()); | 875 ASSERT_EQ(1UL, body_fragment->Children().size()); |
876 auto* container_fragment = | 876 auto* container_fragment = |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
989 <div id='container'> | 989 <div id='container'> |
990 <div id='left-float'></div> | 990 <div id='left-float'></div> |
991 <div id='left-wide-float'></div> | 991 <div id='left-wide-float'></div> |
992 <div id='regular'></div> | 992 <div id='regular'></div> |
993 <div id='right-float'></div> | 993 <div id='right-float'></div> |
994 <div id='left-float-with-margin'></div> | 994 <div id='left-float-with-margin'></div> |
995 </div> | 995 </div> |
996 )HTML"); | 996 )HTML"); |
997 | 997 |
998 // ** Run LayoutNG algorithm ** | 998 // ** Run LayoutNG algorithm ** |
999 NGConstraintSpace* space; | 999 RefPtr<NGConstraintSpace> space; |
1000 RefPtr<NGPhysicalBoxFragment> fragment; | 1000 RefPtr<NGPhysicalBoxFragment> fragment; |
1001 std::tie(fragment, space) = RunBlockLayoutAlgorithmForElement( | 1001 std::tie(fragment, space) = RunBlockLayoutAlgorithmForElement( |
1002 document().getElementsByTagName("html")->item(0)); | 1002 document().getElementsByTagName("html")->item(0)); |
1003 | 1003 |
1004 // ** Verify LayoutNG fragments and the list of positioned floats ** | 1004 // ** Verify LayoutNG fragments and the list of positioned floats ** |
1005 ASSERT_EQ(1UL, fragment->Children().size()); | 1005 ASSERT_EQ(1UL, fragment->Children().size()); |
1006 auto* body_fragment = toNGPhysicalBoxFragment(fragment->Children()[0].get()); | 1006 auto* body_fragment = toNGPhysicalBoxFragment(fragment->Children()[0].get()); |
1007 EXPECT_THAT(LayoutUnit(8), body_fragment->TopOffset()); | 1007 EXPECT_THAT(LayoutUnit(8), body_fragment->TopOffset()); |
1008 auto* container_fragment = | 1008 auto* container_fragment = |
1009 toNGPhysicalBoxFragment(body_fragment->Children()[0].get()); | 1009 toNGPhysicalBoxFragment(body_fragment->Children()[0].get()); |
(...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1270 setBodyInnerHTML(R"HTML( | 1270 setBodyInnerHTML(R"HTML( |
1271 <div id="container"> | 1271 <div id="container"> |
1272 <div id="first-child" style="width: 20px"></div> | 1272 <div id="first-child" style="width: 20px"></div> |
1273 <div id="second-child" style="width: 30px"></div> | 1273 <div id="second-child" style="width: 30px"></div> |
1274 </div> | 1274 </div> |
1275 )HTML"); | 1275 )HTML"); |
1276 const int kWidthChild2 = 30; | 1276 const int kWidthChild2 = 30; |
1277 | 1277 |
1278 auto* container = new NGBlockNode(getLayoutObjectByElementId("container")); | 1278 auto* container = new NGBlockNode(getLayoutObjectByElementId("container")); |
1279 | 1279 |
1280 auto* space = ConstructConstraintSpace( | 1280 RefPtr<NGConstraintSpace> space = ConstructConstraintSpace( |
1281 kHorizontalTopBottom, TextDirection::kLtr, | 1281 kHorizontalTopBottom, TextDirection::kLtr, |
1282 NGLogicalSize(LayoutUnit(100), NGSizeIndefinite), true); | 1282 NGLogicalSize(LayoutUnit(100), NGSizeIndefinite), true); |
1283 RefPtr<NGPhysicalFragment> frag = RunBlockLayoutAlgorithm(space, container); | 1283 RefPtr<NGPhysicalFragment> frag = |
| 1284 RunBlockLayoutAlgorithm(space.get(), container); |
1284 | 1285 |
1285 EXPECT_EQ(LayoutUnit(kWidthChild2), frag->Width()); | 1286 EXPECT_EQ(LayoutUnit(kWidthChild2), frag->Width()); |
1286 } | 1287 } |
1287 | 1288 |
1288 class FragmentChildIterator { | 1289 class FragmentChildIterator { |
1289 STACK_ALLOCATED(); | 1290 STACK_ALLOCATED(); |
1290 | 1291 |
1291 public: | 1292 public: |
1292 explicit FragmentChildIterator(const NGPhysicalBoxFragment* parent) { | 1293 explicit FragmentChildIterator(const NGPhysicalBoxFragment* parent) { |
1293 SetParent(parent); | 1294 SetParent(parent); |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1329 width: 210px; | 1330 width: 210px; |
1330 } | 1331 } |
1331 </style> | 1332 </style> |
1332 <div id="container"> | 1333 <div id="container"> |
1333 <div id="parent"> | 1334 <div id="parent"> |
1334 </div> | 1335 </div> |
1335 </div> | 1336 </div> |
1336 )HTML"); | 1337 )HTML"); |
1337 | 1338 |
1338 auto* container = new NGBlockNode(getLayoutObjectByElementId("container")); | 1339 auto* container = new NGBlockNode(getLayoutObjectByElementId("container")); |
1339 auto* space = ConstructConstraintSpace( | 1340 RefPtr<NGConstraintSpace> space = ConstructConstraintSpace( |
1340 kHorizontalTopBottom, TextDirection::kLtr, | 1341 kHorizontalTopBottom, TextDirection::kLtr, |
1341 NGLogicalSize(LayoutUnit(1000), NGSizeIndefinite)); | 1342 NGLogicalSize(LayoutUnit(1000), NGSizeIndefinite)); |
1342 RefPtr<const NGPhysicalBoxFragment> parent_fragment = | 1343 RefPtr<const NGPhysicalBoxFragment> parent_fragment = |
1343 RunBlockLayoutAlgorithm(space, container); | 1344 RunBlockLayoutAlgorithm(space.get(), container); |
1344 FragmentChildIterator iterator(parent_fragment.get()); | 1345 FragmentChildIterator iterator(parent_fragment.get()); |
1345 const auto* fragment = iterator.NextChild(); | 1346 const auto* fragment = iterator.NextChild(); |
1346 ASSERT_TRUE(fragment); | 1347 ASSERT_TRUE(fragment); |
1347 EXPECT_EQ(LayoutUnit(210), fragment->Width()); | 1348 EXPECT_EQ(LayoutUnit(210), fragment->Width()); |
1348 EXPECT_EQ(LayoutUnit(100), fragment->Height()); | 1349 EXPECT_EQ(LayoutUnit(100), fragment->Height()); |
1349 EXPECT_FALSE(iterator.NextChild()); | 1350 EXPECT_FALSE(iterator.NextChild()); |
1350 | 1351 |
1351 // There should be nothing inside the multicol container. | 1352 // There should be nothing inside the multicol container. |
1352 EXPECT_FALSE(FragmentChildIterator(fragment).NextChild()); | 1353 EXPECT_FALSE(FragmentChildIterator(fragment).NextChild()); |
1353 } | 1354 } |
(...skipping 10 matching lines...) Expand all Loading... |
1364 </style> | 1365 </style> |
1365 <div id="container"> | 1366 <div id="container"> |
1366 <div id="parent"> | 1367 <div id="parent"> |
1367 <div id="child"> | 1368 <div id="child"> |
1368 </div> | 1369 </div> |
1369 </div> | 1370 </div> |
1370 </div> | 1371 </div> |
1371 )HTML"); | 1372 )HTML"); |
1372 | 1373 |
1373 auto* container = new NGBlockNode(getLayoutObjectByElementId("container")); | 1374 auto* container = new NGBlockNode(getLayoutObjectByElementId("container")); |
1374 auto* space = ConstructConstraintSpace( | 1375 RefPtr<NGConstraintSpace> space = ConstructConstraintSpace( |
1375 kHorizontalTopBottom, TextDirection::kLtr, | 1376 kHorizontalTopBottom, TextDirection::kLtr, |
1376 NGLogicalSize(LayoutUnit(1000), NGSizeIndefinite)); | 1377 NGLogicalSize(LayoutUnit(1000), NGSizeIndefinite)); |
1377 RefPtr<const NGPhysicalBoxFragment> parent_fragment = | 1378 RefPtr<const NGPhysicalBoxFragment> parent_fragment = |
1378 RunBlockLayoutAlgorithm(space, container); | 1379 RunBlockLayoutAlgorithm(space.get(), container); |
1379 FragmentChildIterator iterator(parent_fragment.get()); | 1380 FragmentChildIterator iterator(parent_fragment.get()); |
1380 const auto* fragment = iterator.NextChild(); | 1381 const auto* fragment = iterator.NextChild(); |
1381 EXPECT_EQ(LayoutUnit(210), fragment->Width()); | 1382 EXPECT_EQ(LayoutUnit(210), fragment->Width()); |
1382 EXPECT_EQ(LayoutUnit(100), fragment->Height()); | 1383 EXPECT_EQ(LayoutUnit(100), fragment->Height()); |
1383 ASSERT_TRUE(fragment); | 1384 ASSERT_TRUE(fragment); |
1384 EXPECT_FALSE(iterator.NextChild()); | 1385 EXPECT_FALSE(iterator.NextChild()); |
1385 iterator.SetParent(fragment); | 1386 iterator.SetParent(fragment); |
1386 | 1387 |
1387 // #child fragment in first column | 1388 // #child fragment in first column |
1388 fragment = iterator.NextChild(); | 1389 fragment = iterator.NextChild(); |
(...skipping 21 matching lines...) Expand all Loading... |
1410 </style> | 1411 </style> |
1411 <div id="container"> | 1412 <div id="container"> |
1412 <div id="parent"> | 1413 <div id="parent"> |
1413 <div id="child" style="width: 60%; height: 100%"> | 1414 <div id="child" style="width: 60%; height: 100%"> |
1414 </div> | 1415 </div> |
1415 </div> | 1416 </div> |
1416 </div> | 1417 </div> |
1417 )HTML"); | 1418 )HTML"); |
1418 | 1419 |
1419 auto* container = new NGBlockNode(getLayoutObjectByElementId("container")); | 1420 auto* container = new NGBlockNode(getLayoutObjectByElementId("container")); |
1420 auto* space = ConstructConstraintSpace( | 1421 RefPtr<NGConstraintSpace> space = ConstructConstraintSpace( |
1421 kHorizontalTopBottom, TextDirection::kLtr, | 1422 kHorizontalTopBottom, TextDirection::kLtr, |
1422 NGLogicalSize(LayoutUnit(1000), NGSizeIndefinite)); | 1423 NGLogicalSize(LayoutUnit(1000), NGSizeIndefinite)); |
1423 RefPtr<const NGPhysicalBoxFragment> parent_fragment = | 1424 RefPtr<const NGPhysicalBoxFragment> parent_fragment = |
1424 RunBlockLayoutAlgorithm(space, container); | 1425 RunBlockLayoutAlgorithm(space.get(), container); |
1425 | 1426 |
1426 FragmentChildIterator iterator(parent_fragment.get()); | 1427 FragmentChildIterator iterator(parent_fragment.get()); |
1427 const auto* fragment = iterator.NextChild(); | 1428 const auto* fragment = iterator.NextChild(); |
1428 ASSERT_TRUE(fragment); | 1429 ASSERT_TRUE(fragment); |
1429 EXPECT_EQ(LayoutUnit(310), fragment->Width()); | 1430 EXPECT_EQ(LayoutUnit(310), fragment->Width()); |
1430 EXPECT_EQ(LayoutUnit(100), fragment->Height()); | 1431 EXPECT_EQ(LayoutUnit(100), fragment->Height()); |
1431 EXPECT_FALSE(iterator.NextChild()); | 1432 EXPECT_FALSE(iterator.NextChild()); |
1432 iterator.SetParent(fragment); | 1433 iterator.SetParent(fragment); |
1433 | 1434 |
1434 // #child fragment in first column | 1435 // #child fragment in first column |
(...skipping 21 matching lines...) Expand all Loading... |
1456 } | 1457 } |
1457 </style> | 1458 </style> |
1458 <div id="container"> | 1459 <div id="container"> |
1459 <div id="parent"> | 1460 <div id="parent"> |
1460 <div id="child" style="width: 75%; height: 150px"></div> | 1461 <div id="child" style="width: 75%; height: 150px"></div> |
1461 </div> | 1462 </div> |
1462 </div> | 1463 </div> |
1463 )HTML"); | 1464 )HTML"); |
1464 | 1465 |
1465 auto* container = new NGBlockNode(getLayoutObjectByElementId("container")); | 1466 auto* container = new NGBlockNode(getLayoutObjectByElementId("container")); |
1466 auto* space = ConstructConstraintSpace( | 1467 RefPtr<NGConstraintSpace> space = ConstructConstraintSpace( |
1467 kHorizontalTopBottom, TextDirection::kLtr, | 1468 kHorizontalTopBottom, TextDirection::kLtr, |
1468 NGLogicalSize(LayoutUnit(1000), NGSizeIndefinite)); | 1469 NGLogicalSize(LayoutUnit(1000), NGSizeIndefinite)); |
1469 RefPtr<const NGPhysicalBoxFragment> parent_fragment = | 1470 RefPtr<const NGPhysicalBoxFragment> parent_fragment = |
1470 RunBlockLayoutAlgorithm(space, container); | 1471 RunBlockLayoutAlgorithm(space.get(), container); |
1471 | 1472 |
1472 FragmentChildIterator iterator(parent_fragment.get()); | 1473 FragmentChildIterator iterator(parent_fragment.get()); |
1473 const auto* fragment = iterator.NextChild(); | 1474 const auto* fragment = iterator.NextChild(); |
1474 ASSERT_TRUE(fragment); | 1475 ASSERT_TRUE(fragment); |
1475 EXPECT_EQ(LayoutUnit(210), fragment->Width()); | 1476 EXPECT_EQ(LayoutUnit(210), fragment->Width()); |
1476 EXPECT_EQ(LayoutUnit(100), fragment->Height()); | 1477 EXPECT_EQ(LayoutUnit(100), fragment->Height()); |
1477 EXPECT_FALSE(iterator.NextChild()); | 1478 EXPECT_FALSE(iterator.NextChild()); |
1478 | 1479 |
1479 iterator.SetParent(fragment); | 1480 iterator.SetParent(fragment); |
1480 // #child fragment in first column | 1481 // #child fragment in first column |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1512 </style> | 1513 </style> |
1513 <div id="container"> | 1514 <div id="container"> |
1514 <div id="parent"> | 1515 <div id="parent"> |
1515 <div id="child" style="width: 75%; height: 250px;"> | 1516 <div id="child" style="width: 75%; height: 250px;"> |
1516 </div> | 1517 </div> |
1517 </div> | 1518 </div> |
1518 </div> | 1519 </div> |
1519 )HTML"); | 1520 )HTML"); |
1520 | 1521 |
1521 auto* container = new NGBlockNode(getLayoutObjectByElementId("container")); | 1522 auto* container = new NGBlockNode(getLayoutObjectByElementId("container")); |
1522 auto* space = ConstructConstraintSpace( | 1523 RefPtr<NGConstraintSpace> space = ConstructConstraintSpace( |
1523 kHorizontalTopBottom, TextDirection::kLtr, | 1524 kHorizontalTopBottom, TextDirection::kLtr, |
1524 NGLogicalSize(LayoutUnit(1000), NGSizeIndefinite)); | 1525 NGLogicalSize(LayoutUnit(1000), NGSizeIndefinite)); |
1525 RefPtr<const NGPhysicalBoxFragment> parent_fragment = | 1526 RefPtr<const NGPhysicalBoxFragment> parent_fragment = |
1526 RunBlockLayoutAlgorithm(space, container); | 1527 RunBlockLayoutAlgorithm(space.get(), container); |
1527 | 1528 |
1528 FragmentChildIterator iterator(parent_fragment.get()); | 1529 FragmentChildIterator iterator(parent_fragment.get()); |
1529 const auto* fragment = iterator.NextChild(); | 1530 const auto* fragment = iterator.NextChild(); |
1530 ASSERT_TRUE(fragment); | 1531 ASSERT_TRUE(fragment); |
1531 EXPECT_EQ(LayoutUnit(320), fragment->Width()); | 1532 EXPECT_EQ(LayoutUnit(320), fragment->Width()); |
1532 EXPECT_EQ(LayoutUnit(100), fragment->Height()); | 1533 EXPECT_EQ(LayoutUnit(100), fragment->Height()); |
1533 EXPECT_FALSE(iterator.NextChild()); | 1534 EXPECT_FALSE(iterator.NextChild()); |
1534 | 1535 |
1535 iterator.SetParent(fragment); | 1536 iterator.SetParent(fragment); |
1536 // #child fragment in first column | 1537 // #child fragment in first column |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1578 </style> | 1579 </style> |
1579 <div id="container"> | 1580 <div id="container"> |
1580 <div id="parent"> | 1581 <div id="parent"> |
1581 <div id="child" style="width: 1px; height: 250px;"> | 1582 <div id="child" style="width: 1px; height: 250px;"> |
1582 </div> | 1583 </div> |
1583 </div> | 1584 </div> |
1584 </div> | 1585 </div> |
1585 )HTML"); | 1586 )HTML"); |
1586 | 1587 |
1587 auto* container = new NGBlockNode(getLayoutObjectByElementId("container")); | 1588 auto* container = new NGBlockNode(getLayoutObjectByElementId("container")); |
1588 auto* space = ConstructConstraintSpace( | 1589 RefPtr<NGConstraintSpace> space = ConstructConstraintSpace( |
1589 kHorizontalTopBottom, TextDirection::kLtr, | 1590 kHorizontalTopBottom, TextDirection::kLtr, |
1590 NGLogicalSize(LayoutUnit(1000), NGSizeIndefinite)); | 1591 NGLogicalSize(LayoutUnit(1000), NGSizeIndefinite)); |
1591 RefPtr<const NGPhysicalBoxFragment> parent_fragment = | 1592 RefPtr<const NGPhysicalBoxFragment> parent_fragment = |
1592 RunBlockLayoutAlgorithm(space, container); | 1593 RunBlockLayoutAlgorithm(space.get(), container); |
1593 | 1594 |
1594 FragmentChildIterator iterator(parent_fragment.get()); | 1595 FragmentChildIterator iterator(parent_fragment.get()); |
1595 const auto* fragment = iterator.NextChild(); | 1596 const auto* fragment = iterator.NextChild(); |
1596 ASSERT_TRUE(fragment); | 1597 ASSERT_TRUE(fragment); |
1597 EXPECT_EQ(LayoutUnit(210), fragment->Width()); | 1598 EXPECT_EQ(LayoutUnit(210), fragment->Width()); |
1598 EXPECT_EQ(LayoutUnit(100), fragment->Height()); | 1599 EXPECT_EQ(LayoutUnit(100), fragment->Height()); |
1599 EXPECT_FALSE(iterator.NextChild()); | 1600 EXPECT_FALSE(iterator.NextChild()); |
1600 | 1601 |
1601 iterator.SetParent(fragment); | 1602 iterator.SetParent(fragment); |
1602 // #child fragment in first column | 1603 // #child fragment in first column |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1645 <div id="parent"> | 1646 <div id="parent"> |
1646 <div id="child1" style="width: 75%; height: 60px;"> | 1647 <div id="child1" style="width: 75%; height: 60px;"> |
1647 </div> | 1648 </div> |
1648 <div id="child2" style="width: 85%; height: 60px;"> | 1649 <div id="child2" style="width: 85%; height: 60px;"> |
1649 </div> | 1650 </div> |
1650 </div> | 1651 </div> |
1651 </div> | 1652 </div> |
1652 )HTML"); | 1653 )HTML"); |
1653 | 1654 |
1654 auto* container = new NGBlockNode(getLayoutObjectByElementId("container")); | 1655 auto* container = new NGBlockNode(getLayoutObjectByElementId("container")); |
1655 auto* space = ConstructConstraintSpace( | 1656 RefPtr<NGConstraintSpace> space = ConstructConstraintSpace( |
1656 kHorizontalTopBottom, TextDirection::kLtr, | 1657 kHorizontalTopBottom, TextDirection::kLtr, |
1657 NGLogicalSize(LayoutUnit(1000), NGSizeIndefinite)); | 1658 NGLogicalSize(LayoutUnit(1000), NGSizeIndefinite)); |
1658 RefPtr<const NGPhysicalBoxFragment> parent_fragment = | 1659 RefPtr<const NGPhysicalBoxFragment> parent_fragment = |
1659 RunBlockLayoutAlgorithm(space, container); | 1660 RunBlockLayoutAlgorithm(space.get(), container); |
1660 | 1661 |
1661 FragmentChildIterator iterator(parent_fragment.get()); | 1662 FragmentChildIterator iterator(parent_fragment.get()); |
1662 const auto* fragment = iterator.NextChild(); | 1663 const auto* fragment = iterator.NextChild(); |
1663 ASSERT_TRUE(fragment); | 1664 ASSERT_TRUE(fragment); |
1664 EXPECT_EQ(LayoutUnit(320), fragment->Width()); | 1665 EXPECT_EQ(LayoutUnit(320), fragment->Width()); |
1665 EXPECT_EQ(LayoutUnit(100), fragment->Height()); | 1666 EXPECT_EQ(LayoutUnit(100), fragment->Height()); |
1666 EXPECT_FALSE(iterator.NextChild()); | 1667 EXPECT_FALSE(iterator.NextChild()); |
1667 | 1668 |
1668 iterator.SetParent(fragment); | 1669 iterator.SetParent(fragment); |
1669 // #child1 fragment in first column | 1670 // #child1 fragment in first column |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1715 <div id="grandchild2" style="width: 40px; height: 20px;"> | 1716 <div id="grandchild2" style="width: 40px; height: 20px;"> |
1716 </div> | 1717 </div> |
1717 </div> | 1718 </div> |
1718 <div id="child2" style="width: 85%; height: 10px;"></div> | 1719 <div id="child2" style="width: 85%; height: 10px;"></div> |
1719 </div> | 1720 </div> |
1720 </div> | 1721 </div> |
1721 </div> | 1722 </div> |
1722 )HTML"); | 1723 )HTML"); |
1723 | 1724 |
1724 auto* container = new NGBlockNode(getLayoutObjectByElementId("container")); | 1725 auto* container = new NGBlockNode(getLayoutObjectByElementId("container")); |
1725 auto* space = ConstructConstraintSpace( | 1726 RefPtr<NGConstraintSpace> space = ConstructConstraintSpace( |
1726 kHorizontalTopBottom, TextDirection::kLtr, | 1727 kHorizontalTopBottom, TextDirection::kLtr, |
1727 NGLogicalSize(LayoutUnit(1000), NGSizeIndefinite)); | 1728 NGLogicalSize(LayoutUnit(1000), NGSizeIndefinite)); |
1728 RefPtr<const NGPhysicalBoxFragment> parent_fragment = | 1729 RefPtr<const NGPhysicalBoxFragment> parent_fragment = |
1729 RunBlockLayoutAlgorithm(space, container); | 1730 RunBlockLayoutAlgorithm(space.get(), container); |
1730 | 1731 |
1731 FragmentChildIterator iterator(parent_fragment.get()); | 1732 FragmentChildIterator iterator(parent_fragment.get()); |
1732 const auto* fragment = iterator.NextChild(); | 1733 const auto* fragment = iterator.NextChild(); |
1733 ASSERT_TRUE(fragment); | 1734 ASSERT_TRUE(fragment); |
1734 EXPECT_EQ(LayoutUnit(320), fragment->Width()); | 1735 EXPECT_EQ(LayoutUnit(320), fragment->Width()); |
1735 EXPECT_EQ(LayoutUnit(100), fragment->Height()); | 1736 EXPECT_EQ(LayoutUnit(100), fragment->Height()); |
1736 EXPECT_FALSE(iterator.NextChild()); | 1737 EXPECT_FALSE(iterator.NextChild()); |
1737 | 1738 |
1738 iterator.SetParent(fragment); | 1739 iterator.SetParent(fragment); |
1739 // #child1 fragment in first column | 1740 // #child1 fragment in first column |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1802 </style> | 1803 </style> |
1803 <div id="container"> | 1804 <div id="container"> |
1804 <div id="parent"> | 1805 <div id="parent"> |
1805 <div id="child" style="float: left; width: 75%; height: 100px;"> | 1806 <div id="child" style="float: left; width: 75%; height: 100px;"> |
1806 </div> | 1807 </div> |
1807 </div> | 1808 </div> |
1808 </div> | 1809 </div> |
1809 )HTML"); | 1810 )HTML"); |
1810 | 1811 |
1811 auto* container = new NGBlockNode(getLayoutObjectByElementId("container")); | 1812 auto* container = new NGBlockNode(getLayoutObjectByElementId("container")); |
1812 auto* space = ConstructConstraintSpace( | 1813 RefPtr<NGConstraintSpace> space = ConstructConstraintSpace( |
1813 kHorizontalTopBottom, TextDirection::kLtr, | 1814 kHorizontalTopBottom, TextDirection::kLtr, |
1814 NGLogicalSize(LayoutUnit(1000), NGSizeIndefinite)); | 1815 NGLogicalSize(LayoutUnit(1000), NGSizeIndefinite)); |
1815 RefPtr<const NGPhysicalBoxFragment> parent_fragment = | 1816 RefPtr<const NGPhysicalBoxFragment> parent_fragment = |
1816 RunBlockLayoutAlgorithm(space, container); | 1817 RunBlockLayoutAlgorithm(space.get(), container); |
1817 | 1818 |
1818 FragmentChildIterator iterator(parent_fragment.get()); | 1819 FragmentChildIterator iterator(parent_fragment.get()); |
1819 const auto* fragment = iterator.NextChild(); | 1820 const auto* fragment = iterator.NextChild(); |
1820 ASSERT_TRUE(fragment); | 1821 ASSERT_TRUE(fragment); |
1821 EXPECT_EQ(LayoutUnit(320), fragment->Width()); | 1822 EXPECT_EQ(LayoutUnit(320), fragment->Width()); |
1822 EXPECT_EQ(LayoutUnit(100), fragment->Height()); | 1823 EXPECT_EQ(LayoutUnit(100), fragment->Height()); |
1823 EXPECT_FALSE(iterator.NextChild()); | 1824 EXPECT_FALSE(iterator.NextChild()); |
1824 | 1825 |
1825 iterator.SetParent(fragment); | 1826 iterator.SetParent(fragment); |
1826 // #child fragment in first column | 1827 // #child fragment in first column |
(...skipping 24 matching lines...) Expand all Loading... |
1851 <div id="parent"> | 1852 <div id="parent"> |
1852 <div id="child1" style="float: left; width: 15%; height: 100px;"> | 1853 <div id="child1" style="float: left; width: 15%; height: 100px;"> |
1853 </div> | 1854 </div> |
1854 <div id="child2" style="float: right; width: 16%; height: 100px;"> | 1855 <div id="child2" style="float: right; width: 16%; height: 100px;"> |
1855 </div> | 1856 </div> |
1856 </div> | 1857 </div> |
1857 </div> | 1858 </div> |
1858 )HTML"); | 1859 )HTML"); |
1859 | 1860 |
1860 auto* container = new NGBlockNode(getLayoutObjectByElementId("container")); | 1861 auto* container = new NGBlockNode(getLayoutObjectByElementId("container")); |
1861 auto* space = ConstructConstraintSpace( | 1862 RefPtr<NGConstraintSpace> space = ConstructConstraintSpace( |
1862 kHorizontalTopBottom, TextDirection::kLtr, | 1863 kHorizontalTopBottom, TextDirection::kLtr, |
1863 NGLogicalSize(LayoutUnit(1000), NGSizeIndefinite)); | 1864 NGLogicalSize(LayoutUnit(1000), NGSizeIndefinite)); |
1864 RefPtr<const NGPhysicalBoxFragment> parent_fragment = | 1865 RefPtr<const NGPhysicalBoxFragment> parent_fragment = |
1865 RunBlockLayoutAlgorithm(space, container); | 1866 RunBlockLayoutAlgorithm(space.get(), container); |
1866 | 1867 |
1867 FragmentChildIterator iterator(parent_fragment.get()); | 1868 FragmentChildIterator iterator(parent_fragment.get()); |
1868 const auto* fragment = iterator.NextChild(); | 1869 const auto* fragment = iterator.NextChild(); |
1869 ASSERT_TRUE(fragment); | 1870 ASSERT_TRUE(fragment); |
1870 EXPECT_EQ(LayoutUnit(320), fragment->Width()); | 1871 EXPECT_EQ(LayoutUnit(320), fragment->Width()); |
1871 EXPECT_EQ(LayoutUnit(100), fragment->Height()); | 1872 EXPECT_EQ(LayoutUnit(100), fragment->Height()); |
1872 EXPECT_FALSE(iterator.NextChild()); | 1873 EXPECT_FALSE(iterator.NextChild()); |
1873 | 1874 |
1874 iterator.SetParent(fragment); | 1875 iterator.SetParent(fragment); |
1875 // #child1 fragment in first column | 1876 // #child1 fragment in first column |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1908 <div id="parent"> | 1909 <div id="parent"> |
1909 <div id="child1" style="float: left; width: 15%; height: 150px;"> | 1910 <div id="child1" style="float: left; width: 15%; height: 150px;"> |
1910 </div> | 1911 </div> |
1911 <div id="child2" style="float: right; width: 16%; height: 150px;"> | 1912 <div id="child2" style="float: right; width: 16%; height: 150px;"> |
1912 </div> | 1913 </div> |
1913 </div> | 1914 </div> |
1914 </div> | 1915 </div> |
1915 )HTML"); | 1916 )HTML"); |
1916 | 1917 |
1917 auto* container = new NGBlockNode(getLayoutObjectByElementId("container")); | 1918 auto* container = new NGBlockNode(getLayoutObjectByElementId("container")); |
1918 auto* space = ConstructConstraintSpace( | 1919 RefPtr<NGConstraintSpace> space = ConstructConstraintSpace( |
1919 kHorizontalTopBottom, TextDirection::kLtr, | 1920 kHorizontalTopBottom, TextDirection::kLtr, |
1920 NGLogicalSize(LayoutUnit(1000), NGSizeIndefinite)); | 1921 NGLogicalSize(LayoutUnit(1000), NGSizeIndefinite)); |
1921 RefPtr<const NGPhysicalBoxFragment> parent_fragment = | 1922 RefPtr<const NGPhysicalBoxFragment> parent_fragment = |
1922 RunBlockLayoutAlgorithm(space, container); | 1923 RunBlockLayoutAlgorithm(space.get(), container); |
1923 | 1924 |
1924 FragmentChildIterator iterator(parent_fragment.get()); | 1925 FragmentChildIterator iterator(parent_fragment.get()); |
1925 const auto* fragment = iterator.NextChild(); | 1926 const auto* fragment = iterator.NextChild(); |
1926 ASSERT_TRUE(fragment); | 1927 ASSERT_TRUE(fragment); |
1927 EXPECT_EQ(LayoutUnit(320), fragment->Width()); | 1928 EXPECT_EQ(LayoutUnit(320), fragment->Width()); |
1928 EXPECT_EQ(LayoutUnit(100), fragment->Height()); | 1929 EXPECT_EQ(LayoutUnit(100), fragment->Height()); |
1929 EXPECT_FALSE(iterator.NextChild()); | 1930 EXPECT_FALSE(iterator.NextChild()); |
1930 | 1931 |
1931 iterator.SetParent(fragment); | 1932 iterator.SetParent(fragment); |
1932 // #child1 fragment in first column | 1933 // #child1 fragment in first column |
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2113 height: 200px; | 2114 height: 200px; |
2114 } | 2115 } |
2115 </style> | 2116 </style> |
2116 <div id='container'></div> | 2117 <div id='container'></div> |
2117 )HTML"); | 2118 )HTML"); |
2118 | 2119 |
2119 LayoutUnit kFragmentainerSpaceAvailable(200); | 2120 LayoutUnit kFragmentainerSpaceAvailable(200); |
2120 | 2121 |
2121 NGBlockNode* node = new NGBlockNode( | 2122 NGBlockNode* node = new NGBlockNode( |
2122 toLayoutBlockFlow(getLayoutObjectByElementId("container"))); | 2123 toLayoutBlockFlow(getLayoutObjectByElementId("container"))); |
2123 auto* space = ConstructConstraintSpace( | 2124 RefPtr<NGConstraintSpace> space = ConstructConstraintSpace( |
2124 kHorizontalTopBottom, TextDirection::kLtr, | 2125 kHorizontalTopBottom, TextDirection::kLtr, |
2125 NGLogicalSize(LayoutUnit(1000), NGSizeIndefinite), false, | 2126 NGLogicalSize(LayoutUnit(1000), NGSizeIndefinite), false, |
2126 kFragmentainerSpaceAvailable); | 2127 kFragmentainerSpaceAvailable); |
2127 | 2128 |
2128 // We should only have one 150x200 fragment with no fragmentation. | 2129 // We should only have one 150x200 fragment with no fragmentation. |
2129 RefPtr<const NGPhysicalFragment> fragment = | 2130 RefPtr<const NGPhysicalFragment> fragment = |
2130 NGBlockLayoutAlgorithm(node, space).Layout()->PhysicalFragment(); | 2131 NGBlockLayoutAlgorithm(node, space.get()).Layout()->PhysicalFragment(); |
2131 EXPECT_EQ(NGPhysicalSize(LayoutUnit(150), LayoutUnit(200)), fragment->Size()); | 2132 EXPECT_EQ(NGPhysicalSize(LayoutUnit(150), LayoutUnit(200)), fragment->Size()); |
2132 ASSERT_TRUE(fragment->BreakToken()->IsFinished()); | 2133 ASSERT_TRUE(fragment->BreakToken()->IsFinished()); |
2133 } | 2134 } |
2134 | 2135 |
2135 // Tests that a block will fragment if it reaches the fragmentation line. | 2136 // Tests that a block will fragment if it reaches the fragmentation line. |
2136 TEST_F(NGBlockLayoutAlgorithmTest, SimpleFragmentation) { | 2137 TEST_F(NGBlockLayoutAlgorithmTest, SimpleFragmentation) { |
2137 setBodyInnerHTML(R"HTML( | 2138 setBodyInnerHTML(R"HTML( |
2138 <!DOCTYPE html> | 2139 <!DOCTYPE html> |
2139 <style> | 2140 <style> |
2140 #container { | 2141 #container { |
2141 width: 150px; | 2142 width: 150px; |
2142 height: 300px; | 2143 height: 300px; |
2143 } | 2144 } |
2144 </style> | 2145 </style> |
2145 <div id='container'></div> | 2146 <div id='container'></div> |
2146 )HTML"); | 2147 )HTML"); |
2147 | 2148 |
2148 LayoutUnit kFragmentainerSpaceAvailable(200); | 2149 LayoutUnit kFragmentainerSpaceAvailable(200); |
2149 | 2150 |
2150 NGBlockNode* node = new NGBlockNode( | 2151 NGBlockNode* node = new NGBlockNode( |
2151 toLayoutBlockFlow(getLayoutObjectByElementId("container"))); | 2152 toLayoutBlockFlow(getLayoutObjectByElementId("container"))); |
2152 auto* space = ConstructConstraintSpace( | 2153 RefPtr<NGConstraintSpace> space = ConstructConstraintSpace( |
2153 kHorizontalTopBottom, TextDirection::kLtr, | 2154 kHorizontalTopBottom, TextDirection::kLtr, |
2154 NGLogicalSize(LayoutUnit(1000), NGSizeIndefinite), false, | 2155 NGLogicalSize(LayoutUnit(1000), NGSizeIndefinite), false, |
2155 kFragmentainerSpaceAvailable); | 2156 kFragmentainerSpaceAvailable); |
2156 | 2157 |
2157 RefPtr<const NGPhysicalFragment> fragment = | 2158 RefPtr<const NGPhysicalFragment> fragment = |
2158 NGBlockLayoutAlgorithm(node, space).Layout()->PhysicalFragment(); | 2159 NGBlockLayoutAlgorithm(node, space.get()).Layout()->PhysicalFragment(); |
2159 EXPECT_EQ(NGPhysicalSize(LayoutUnit(150), LayoutUnit(200)), fragment->Size()); | 2160 EXPECT_EQ(NGPhysicalSize(LayoutUnit(150), LayoutUnit(200)), fragment->Size()); |
2160 ASSERT_FALSE(fragment->BreakToken()->IsFinished()); | 2161 ASSERT_FALSE(fragment->BreakToken()->IsFinished()); |
2161 | 2162 |
2162 fragment = NGBlockLayoutAlgorithm(node, space, | 2163 fragment = NGBlockLayoutAlgorithm(node, space.get(), |
2163 toNGBlockBreakToken(fragment->BreakToken())) | 2164 toNGBlockBreakToken(fragment->BreakToken())) |
2164 .Layout() | 2165 .Layout() |
2165 ->PhysicalFragment(); | 2166 ->PhysicalFragment(); |
2166 EXPECT_EQ(NGPhysicalSize(LayoutUnit(150), LayoutUnit(100)), fragment->Size()); | 2167 EXPECT_EQ(NGPhysicalSize(LayoutUnit(150), LayoutUnit(100)), fragment->Size()); |
2167 ASSERT_TRUE(fragment->BreakToken()->IsFinished()); | 2168 ASSERT_TRUE(fragment->BreakToken()->IsFinished()); |
2168 } | 2169 } |
2169 | 2170 |
2170 // Tests that children inside the same block formatting context fragment when | 2171 // Tests that children inside the same block formatting context fragment when |
2171 // reaching a fragmentation line. | 2172 // reaching a fragmentation line. |
2172 TEST_F(NGBlockLayoutAlgorithmTest, InnerChildrenFragmentation) { | 2173 TEST_F(NGBlockLayoutAlgorithmTest, InnerChildrenFragmentation) { |
(...skipping 16 matching lines...) Expand all Loading... |
2189 <div id='container'> | 2190 <div id='container'> |
2190 <div id='child1'></div> | 2191 <div id='child1'></div> |
2191 <div id='child2'></div> | 2192 <div id='child2'></div> |
2192 </div> | 2193 </div> |
2193 )HTML"); | 2194 )HTML"); |
2194 | 2195 |
2195 LayoutUnit kFragmentainerSpaceAvailable(200); | 2196 LayoutUnit kFragmentainerSpaceAvailable(200); |
2196 | 2197 |
2197 NGBlockNode* node = new NGBlockNode( | 2198 NGBlockNode* node = new NGBlockNode( |
2198 toLayoutBlockFlow(getLayoutObjectByElementId("container"))); | 2199 toLayoutBlockFlow(getLayoutObjectByElementId("container"))); |
2199 auto* space = ConstructConstraintSpace( | 2200 RefPtr<NGConstraintSpace> space = ConstructConstraintSpace( |
2200 kHorizontalTopBottom, TextDirection::kLtr, | 2201 kHorizontalTopBottom, TextDirection::kLtr, |
2201 NGLogicalSize(LayoutUnit(1000), NGSizeIndefinite), false, | 2202 NGLogicalSize(LayoutUnit(1000), NGSizeIndefinite), false, |
2202 kFragmentainerSpaceAvailable); | 2203 kFragmentainerSpaceAvailable); |
2203 | 2204 |
2204 RefPtr<const NGPhysicalFragment> fragment = | 2205 RefPtr<const NGPhysicalFragment> fragment = |
2205 NGBlockLayoutAlgorithm(node, space).Layout()->PhysicalFragment(); | 2206 NGBlockLayoutAlgorithm(node, space.get()).Layout()->PhysicalFragment(); |
2206 EXPECT_EQ(NGPhysicalSize(LayoutUnit(150), LayoutUnit(200)), fragment->Size()); | 2207 EXPECT_EQ(NGPhysicalSize(LayoutUnit(150), LayoutUnit(200)), fragment->Size()); |
2207 ASSERT_FALSE(fragment->BreakToken()->IsFinished()); | 2208 ASSERT_FALSE(fragment->BreakToken()->IsFinished()); |
2208 | 2209 |
2209 FragmentChildIterator iterator(toNGPhysicalBoxFragment(fragment.get())); | 2210 FragmentChildIterator iterator(toNGPhysicalBoxFragment(fragment.get())); |
2210 const NGPhysicalBoxFragment* child = iterator.NextChild(); | 2211 const NGPhysicalBoxFragment* child = iterator.NextChild(); |
2211 EXPECT_EQ(NGPhysicalSize(LayoutUnit(150), LayoutUnit(180)), child->Size()); | 2212 EXPECT_EQ(NGPhysicalSize(LayoutUnit(150), LayoutUnit(180)), child->Size()); |
2212 EXPECT_EQ(NGPhysicalOffset(LayoutUnit(0), LayoutUnit(20)), child->Offset()); | 2213 EXPECT_EQ(NGPhysicalOffset(LayoutUnit(0), LayoutUnit(20)), child->Offset()); |
2213 | 2214 |
2214 EXPECT_FALSE(iterator.NextChild()); | 2215 EXPECT_FALSE(iterator.NextChild()); |
2215 | 2216 |
2216 fragment = NGBlockLayoutAlgorithm(node, space, | 2217 fragment = NGBlockLayoutAlgorithm(node, space.get(), |
2217 toNGBlockBreakToken(fragment->BreakToken())) | 2218 toNGBlockBreakToken(fragment->BreakToken())) |
2218 .Layout() | 2219 .Layout() |
2219 ->PhysicalFragment(); | 2220 ->PhysicalFragment(); |
2220 EXPECT_EQ(NGPhysicalSize(LayoutUnit(150), LayoutUnit(140)), fragment->Size()); | 2221 EXPECT_EQ(NGPhysicalSize(LayoutUnit(150), LayoutUnit(140)), fragment->Size()); |
2221 ASSERT_TRUE(fragment->BreakToken()->IsFinished()); | 2222 ASSERT_TRUE(fragment->BreakToken()->IsFinished()); |
2222 | 2223 |
2223 iterator.SetParent(toNGPhysicalBoxFragment(fragment.get())); | 2224 iterator.SetParent(toNGPhysicalBoxFragment(fragment.get())); |
2224 child = iterator.NextChild(); | 2225 child = iterator.NextChild(); |
2225 EXPECT_EQ(NGPhysicalSize(LayoutUnit(150), LayoutUnit(20)), child->Size()); | 2226 EXPECT_EQ(NGPhysicalSize(LayoutUnit(150), LayoutUnit(20)), child->Size()); |
2226 EXPECT_EQ(NGPhysicalOffset(LayoutUnit(0), LayoutUnit(0)), child->Offset()); | 2227 EXPECT_EQ(NGPhysicalOffset(LayoutUnit(0), LayoutUnit(0)), child->Offset()); |
(...skipping 30 matching lines...) Expand all Loading... |
2257 <div id='container'> | 2258 <div id='container'> |
2258 <div id='child1'></div> | 2259 <div id='child1'></div> |
2259 <div id='child2'></div> | 2260 <div id='child2'></div> |
2260 </div> | 2261 </div> |
2261 )HTML"); | 2262 )HTML"); |
2262 | 2263 |
2263 LayoutUnit kFragmentainerSpaceAvailable(200); | 2264 LayoutUnit kFragmentainerSpaceAvailable(200); |
2264 | 2265 |
2265 NGBlockNode* node = new NGBlockNode( | 2266 NGBlockNode* node = new NGBlockNode( |
2266 toLayoutBlockFlow(getLayoutObjectByElementId("container"))); | 2267 toLayoutBlockFlow(getLayoutObjectByElementId("container"))); |
2267 auto* space = ConstructConstraintSpace( | 2268 RefPtr<NGConstraintSpace> space = ConstructConstraintSpace( |
2268 kHorizontalTopBottom, TextDirection::kLtr, | 2269 kHorizontalTopBottom, TextDirection::kLtr, |
2269 NGLogicalSize(LayoutUnit(1000), NGSizeIndefinite), false, | 2270 NGLogicalSize(LayoutUnit(1000), NGSizeIndefinite), false, |
2270 kFragmentainerSpaceAvailable); | 2271 kFragmentainerSpaceAvailable); |
2271 | 2272 |
2272 RefPtr<const NGPhysicalFragment> fragment = | 2273 RefPtr<const NGPhysicalFragment> fragment = |
2273 NGBlockLayoutAlgorithm(node, space).Layout()->PhysicalFragment(); | 2274 NGBlockLayoutAlgorithm(node, space.get()).Layout()->PhysicalFragment(); |
2274 EXPECT_EQ(NGPhysicalSize(LayoutUnit(150), LayoutUnit(200)), fragment->Size()); | 2275 EXPECT_EQ(NGPhysicalSize(LayoutUnit(150), LayoutUnit(200)), fragment->Size()); |
2275 ASSERT_FALSE(fragment->BreakToken()->IsFinished()); | 2276 ASSERT_FALSE(fragment->BreakToken()->IsFinished()); |
2276 | 2277 |
2277 FragmentChildIterator iterator(toNGPhysicalBoxFragment(fragment.get())); | 2278 FragmentChildIterator iterator(toNGPhysicalBoxFragment(fragment.get())); |
2278 const NGPhysicalBoxFragment* child = iterator.NextChild(); | 2279 const NGPhysicalBoxFragment* child = iterator.NextChild(); |
2279 EXPECT_EQ(NGPhysicalSize(LayoutUnit(150), LayoutUnit(180)), child->Size()); | 2280 EXPECT_EQ(NGPhysicalSize(LayoutUnit(150), LayoutUnit(180)), child->Size()); |
2280 EXPECT_EQ(NGPhysicalOffset(LayoutUnit(0), LayoutUnit(20)), child->Offset()); | 2281 EXPECT_EQ(NGPhysicalOffset(LayoutUnit(0), LayoutUnit(20)), child->Offset()); |
2281 | 2282 |
2282 EXPECT_FALSE(iterator.NextChild()); | 2283 EXPECT_FALSE(iterator.NextChild()); |
2283 | 2284 |
2284 fragment = NGBlockLayoutAlgorithm(node, space, | 2285 fragment = NGBlockLayoutAlgorithm(node, space.get(), |
2285 toNGBlockBreakToken(fragment->BreakToken())) | 2286 toNGBlockBreakToken(fragment->BreakToken())) |
2286 .Layout() | 2287 .Layout() |
2287 ->PhysicalFragment(); | 2288 ->PhysicalFragment(); |
2288 EXPECT_EQ(NGPhysicalSize(LayoutUnit(150), LayoutUnit(140)), fragment->Size()); | 2289 EXPECT_EQ(NGPhysicalSize(LayoutUnit(150), LayoutUnit(140)), fragment->Size()); |
2289 ASSERT_TRUE(fragment->BreakToken()->IsFinished()); | 2290 ASSERT_TRUE(fragment->BreakToken()->IsFinished()); |
2290 | 2291 |
2291 iterator.SetParent(toNGPhysicalBoxFragment(fragment.get())); | 2292 iterator.SetParent(toNGPhysicalBoxFragment(fragment.get())); |
2292 child = iterator.NextChild(); | 2293 child = iterator.NextChild(); |
2293 EXPECT_EQ(NGPhysicalSize(LayoutUnit(150), LayoutUnit(20)), child->Size()); | 2294 EXPECT_EQ(NGPhysicalSize(LayoutUnit(150), LayoutUnit(20)), child->Size()); |
2294 EXPECT_EQ(NGPhysicalOffset(LayoutUnit(0), LayoutUnit(0)), child->Offset()); | 2295 EXPECT_EQ(NGPhysicalOffset(LayoutUnit(0), LayoutUnit(0)), child->Offset()); |
(...skipping 28 matching lines...) Expand all Loading... |
2323 <div id='container'> | 2324 <div id='container'> |
2324 <div id='child1'></div> | 2325 <div id='child1'></div> |
2325 <div id='child2'></div> | 2326 <div id='child2'></div> |
2326 </div> | 2327 </div> |
2327 )HTML"); | 2328 )HTML"); |
2328 | 2329 |
2329 LayoutUnit kFragmentainerSpaceAvailable(200); | 2330 LayoutUnit kFragmentainerSpaceAvailable(200); |
2330 | 2331 |
2331 NGBlockNode* node = new NGBlockNode( | 2332 NGBlockNode* node = new NGBlockNode( |
2332 toLayoutBlockFlow(getLayoutObjectByElementId("container"))); | 2333 toLayoutBlockFlow(getLayoutObjectByElementId("container"))); |
2333 auto* space = ConstructConstraintSpace( | 2334 RefPtr<NGConstraintSpace> space = ConstructConstraintSpace( |
2334 kHorizontalTopBottom, TextDirection::kLtr, | 2335 kHorizontalTopBottom, TextDirection::kLtr, |
2335 NGLogicalSize(LayoutUnit(1000), NGSizeIndefinite), false, | 2336 NGLogicalSize(LayoutUnit(1000), NGSizeIndefinite), false, |
2336 kFragmentainerSpaceAvailable); | 2337 kFragmentainerSpaceAvailable); |
2337 | 2338 |
2338 RefPtr<const NGPhysicalFragment> fragment = | 2339 RefPtr<const NGPhysicalFragment> fragment = |
2339 NGBlockLayoutAlgorithm(node, space).Layout()->PhysicalFragment(); | 2340 NGBlockLayoutAlgorithm(node, space.get()).Layout()->PhysicalFragment(); |
2340 EXPECT_EQ(NGPhysicalSize(LayoutUnit(150), LayoutUnit(70)), fragment->Size()); | 2341 EXPECT_EQ(NGPhysicalSize(LayoutUnit(150), LayoutUnit(70)), fragment->Size()); |
2341 ASSERT_FALSE(fragment->BreakToken()->IsFinished()); | 2342 ASSERT_FALSE(fragment->BreakToken()->IsFinished()); |
2342 | 2343 |
2343 FragmentChildIterator iterator(toNGPhysicalBoxFragment(fragment.get())); | 2344 FragmentChildIterator iterator(toNGPhysicalBoxFragment(fragment.get())); |
2344 const NGPhysicalBoxFragment* child = iterator.NextChild(); | 2345 const NGPhysicalBoxFragment* child = iterator.NextChild(); |
2345 EXPECT_EQ(NGPhysicalSize(LayoutUnit(150), LayoutUnit(180)), child->Size()); | 2346 EXPECT_EQ(NGPhysicalSize(LayoutUnit(150), LayoutUnit(180)), child->Size()); |
2346 EXPECT_EQ(NGPhysicalOffset(LayoutUnit(0), LayoutUnit(20)), child->Offset()); | 2347 EXPECT_EQ(NGPhysicalOffset(LayoutUnit(0), LayoutUnit(20)), child->Offset()); |
2347 | 2348 |
2348 EXPECT_FALSE(iterator.NextChild()); | 2349 EXPECT_FALSE(iterator.NextChild()); |
2349 | 2350 |
2350 fragment = NGBlockLayoutAlgorithm(node, space, | 2351 fragment = NGBlockLayoutAlgorithm(node, space.get(), |
2351 toNGBlockBreakToken(fragment->BreakToken())) | 2352 toNGBlockBreakToken(fragment->BreakToken())) |
2352 .Layout() | 2353 .Layout() |
2353 ->PhysicalFragment(); | 2354 ->PhysicalFragment(); |
2354 EXPECT_EQ(NGPhysicalSize(LayoutUnit(150), LayoutUnit(0)), fragment->Size()); | 2355 EXPECT_EQ(NGPhysicalSize(LayoutUnit(150), LayoutUnit(0)), fragment->Size()); |
2355 ASSERT_TRUE(fragment->BreakToken()->IsFinished()); | 2356 ASSERT_TRUE(fragment->BreakToken()->IsFinished()); |
2356 | 2357 |
2357 iterator.SetParent(toNGPhysicalBoxFragment(fragment.get())); | 2358 iterator.SetParent(toNGPhysicalBoxFragment(fragment.get())); |
2358 child = iterator.NextChild(); | 2359 child = iterator.NextChild(); |
2359 EXPECT_EQ(NGPhysicalSize(LayoutUnit(150), LayoutUnit(20)), child->Size()); | 2360 EXPECT_EQ(NGPhysicalSize(LayoutUnit(150), LayoutUnit(20)), child->Size()); |
2360 EXPECT_EQ(NGPhysicalOffset(LayoutUnit(0), LayoutUnit(0)), child->Offset()); | 2361 EXPECT_EQ(NGPhysicalOffset(LayoutUnit(0), LayoutUnit(0)), child->Offset()); |
2361 | 2362 |
2362 child = iterator.NextChild(); | 2363 child = iterator.NextChild(); |
2363 EXPECT_EQ(NGPhysicalSize(LayoutUnit(150), LayoutUnit(100)), child->Size()); | 2364 EXPECT_EQ(NGPhysicalSize(LayoutUnit(150), LayoutUnit(100)), child->Size()); |
2364 EXPECT_EQ(NGPhysicalOffset(LayoutUnit(0), LayoutUnit(40)), child->Offset()); | 2365 EXPECT_EQ(NGPhysicalOffset(LayoutUnit(0), LayoutUnit(40)), child->Offset()); |
2365 | 2366 |
2366 EXPECT_FALSE(iterator.NextChild()); | 2367 EXPECT_FALSE(iterator.NextChild()); |
2367 } | 2368 } |
2368 | 2369 |
2369 } // namespace | 2370 } // namespace |
2370 } // namespace blink | 2371 } // namespace blink |
OLD | NEW |