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_physical_fragment.h" | 9 #include "core/layout/ng/ng_physical_fragment.h" |
10 #include "core/layout/ng/ng_length_utils.h" | 10 #include "core/layout/ng/ng_length_utils.h" |
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
150 // DIV2 | 150 // DIV2 |
151 RefPtr<ComputedStyle> div2_style = ComputedStyle::create(); | 151 RefPtr<ComputedStyle> div2_style = ComputedStyle::create(); |
152 div2_style->setMarginTop(Length(kDiv2MarginTop, Fixed)); | 152 div2_style->setMarginTop(Length(kDiv2MarginTop, Fixed)); |
153 NGBox* div2 = new NGBox(div2_style.get()); | 153 NGBox* div2 = new NGBox(div2_style.get()); |
154 | 154 |
155 div1->SetFirstChild(div2); | 155 div1->SetFirstChild(div2); |
156 | 156 |
157 auto* space = | 157 auto* space = |
158 new NGConstraintSpace(HorizontalTopBottom, LeftToRight, | 158 new NGConstraintSpace(HorizontalTopBottom, LeftToRight, |
159 NGLogicalSize(LayoutUnit(100), NGSizeIndefinite)); | 159 NGLogicalSize(LayoutUnit(100), NGSizeIndefinite)); |
| 160 space->SetIsNewFormattingContext(true); |
160 NGPhysicalFragment* frag = RunBlockLayoutAlgorithm(space, div1); | 161 NGPhysicalFragment* frag = RunBlockLayoutAlgorithm(space, div1); |
161 | 162 |
162 EXPECT_EQ(NGMarginStrut({LayoutUnit(kDiv1MarginTop)}), frag->MarginStrut()); | 163 EXPECT_EQ(NGMarginStrut({LayoutUnit(kDiv1MarginTop)}), frag->MarginStrut()); |
163 ASSERT_EQ(frag->Children().size(), 1UL); | 164 ASSERT_EQ(frag->Children().size(), 1UL); |
164 const NGPhysicalFragmentBase* div2_fragment = frag->Children()[0]; | 165 const NGPhysicalFragmentBase* div2_fragment = frag->Children()[0]; |
165 EXPECT_EQ(NGMarginStrut({LayoutUnit(kDiv2MarginTop)}), | 166 EXPECT_EQ(NGMarginStrut({LayoutUnit(kDiv2MarginTop)}), |
166 div2_fragment->MarginStrut()); | 167 div2_fragment->MarginStrut()); |
167 EXPECT_EQ(kDiv1MarginTop, div2_fragment->TopOffset()); | 168 EXPECT_EQ(kDiv1MarginTop, div2_fragment->TopOffset()); |
168 } | 169 } |
169 | 170 |
(...skipping 311 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
481 | 482 |
482 EXPECT_EQ(frag->Width(), LayoutUnit(kWidth + kPaddingLeft)); | 483 EXPECT_EQ(frag->Width(), LayoutUnit(kWidth + kPaddingLeft)); |
483 EXPECT_EQ(frag->Type(), NGPhysicalFragmentBase::FragmentBox); | 484 EXPECT_EQ(frag->Type(), NGPhysicalFragmentBase::FragmentBox); |
484 ASSERT_EQ(frag->Children().size(), 1UL); | 485 ASSERT_EQ(frag->Children().size(), 1UL); |
485 | 486 |
486 const NGPhysicalFragmentBase* child = frag->Children()[0]; | 487 const NGPhysicalFragmentBase* child = frag->Children()[0]; |
487 EXPECT_EQ(child->Width(), LayoutUnit(12)); | 488 EXPECT_EQ(child->Width(), LayoutUnit(12)); |
488 } | 489 } |
489 } // namespace | 490 } // namespace |
490 } // namespace blink | 491 } // namespace blink |
OLD | NEW |