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/layout/ng/ng_box.h" | 7 #include "core/layout/ng/ng_box.h" |
8 #include "core/layout/ng/ng_constraint_space.h" | 8 #include "core/layout/ng/ng_constraint_space.h" |
9 #include "core/layout/ng/ng_constraint_space_builder.h" | 9 #include "core/layout/ng/ng_constraint_space_builder.h" |
10 #include "core/layout/ng/ng_physical_fragment_base.h" | 10 #include "core/layout/ng/ng_physical_fragment_base.h" |
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
160 div1_style->setMarginTop(Length(kDiv1MarginTop, Fixed)); | 160 div1_style->setMarginTop(Length(kDiv1MarginTop, Fixed)); |
161 NGBox* div1 = new NGBox(div1_style.get()); | 161 NGBox* div1 = new NGBox(div1_style.get()); |
162 | 162 |
163 // DIV2 | 163 // DIV2 |
164 RefPtr<ComputedStyle> div2_style = ComputedStyle::create(); | 164 RefPtr<ComputedStyle> div2_style = ComputedStyle::create(); |
165 div2_style->setMarginTop(Length(kDiv2MarginTop, Fixed)); | 165 div2_style->setMarginTop(Length(kDiv2MarginTop, Fixed)); |
166 NGBox* div2 = new NGBox(div2_style.get()); | 166 NGBox* div2 = new NGBox(div2_style.get()); |
167 | 167 |
168 div1->SetFirstChild(div2); | 168 div1->SetFirstChild(div2); |
169 | 169 |
170 auto* space = ConstructConstraintSpace( | 170 NGLogicalSize size(LayoutUnit(100), NGSizeIndefinite); |
171 HorizontalTopBottom, LTR, | 171 NGConstraintSpaceBuilder builder(HorizontalTopBottom); |
172 NGLogicalSize(LayoutUnit(100), NGSizeIndefinite)); | 172 builder.SetAvailableSize(size) |
173 space->SetIsNewFormattingContext(true); | 173 .SetPercentageResolutionSize(size) |
| 174 .SetIsNewFormattingContext(true); |
| 175 auto* space = new NGConstraintSpace(HorizontalTopBottom, LTR, |
| 176 builder.ToConstraintSpace()); |
| 177 |
174 NGPhysicalFragment* frag = RunBlockLayoutAlgorithm(space, div1); | 178 NGPhysicalFragment* frag = RunBlockLayoutAlgorithm(space, div1); |
175 | 179 |
176 EXPECT_TRUE(frag->MarginStrut().IsEmpty()); | 180 EXPECT_TRUE(frag->MarginStrut().IsEmpty()); |
177 ASSERT_EQ(frag->Children().size(), 1UL); | 181 ASSERT_EQ(frag->Children().size(), 1UL); |
178 const NGPhysicalFragment* div2_fragment = | 182 const NGPhysicalFragment* div2_fragment = |
179 static_cast<const NGPhysicalFragment*>(frag->Children()[0].get()); | 183 static_cast<const NGPhysicalFragment*>(frag->Children()[0].get()); |
180 EXPECT_EQ(NGMarginStrut({LayoutUnit(kDiv2MarginTop)}), | 184 EXPECT_EQ(NGMarginStrut({LayoutUnit(kDiv2MarginTop)}), |
181 div2_fragment->MarginStrut()); | 185 div2_fragment->MarginStrut()); |
182 EXPECT_EQ(kDiv1MarginTop, div2_fragment->TopOffset()); | 186 EXPECT_EQ(kDiv1MarginTop, div2_fragment->TopOffset()); |
183 } | 187 } |
(...skipping 496 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
680 EXPECT_EQ(kDiv2Size, child3->TopOffset()); | 684 EXPECT_EQ(kDiv2Size, child3->TopOffset()); |
681 EXPECT_EQ(kParentLeftPadding + kParentSize - kDiv3Size, child3->LeftOffset()); | 685 EXPECT_EQ(kParentLeftPadding + kParentSize - kDiv3Size, child3->LeftOffset()); |
682 | 686 |
683 // DIV4 | 687 // DIV4 |
684 const NGPhysicalFragmentBase* child4 = frag->Children()[3]; | 688 const NGPhysicalFragmentBase* child4 = frag->Children()[3]; |
685 EXPECT_EQ(kDiv2Size + kDiv3Size, child4->TopOffset()); | 689 EXPECT_EQ(kDiv2Size + kDiv3Size, child4->TopOffset()); |
686 EXPECT_EQ(kParentLeftPadding + kDiv4LeftMargin, child4->LeftOffset()); | 690 EXPECT_EQ(kParentLeftPadding + kDiv4LeftMargin, child4->LeftOffset()); |
687 } | 691 } |
688 } // namespace | 692 } // namespace |
689 } // namespace blink | 693 } // namespace blink |
OLD | NEW |