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 576 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
760 frag = RunBlockLayoutAlgorithm(space, div1); | 764 frag = RunBlockLayoutAlgorithm(space, div1); |
761 space = ConstructConstraintSpace( | 765 space = ConstructConstraintSpace( |
762 HorizontalTopBottom, LTR, | 766 HorizontalTopBottom, LTR, |
763 NGLogicalSize(LayoutUnit(kParentSize), LayoutUnit(kParentSize))); | 767 NGLogicalSize(LayoutUnit(kParentSize), LayoutUnit(kParentSize))); |
764 child3 = frag->Children()[2]; | 768 child3 = frag->Children()[2]; |
765 EXPECT_EQ(kDiv1Size + kDiv2Size, child3->TopOffset()); | 769 EXPECT_EQ(kDiv1Size + kDiv2Size, child3->TopOffset()); |
766 } | 770 } |
767 | 771 |
768 } // namespace | 772 } // namespace |
769 } // namespace blink | 773 } // namespace blink |
OLD | NEW |