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

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

Issue 2514693004: Revert of Remove redundant 'derived constraint space' setters from NGConstraintSpace (Closed)
Patch Set: Created 4 years, 1 month 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 unified diff | Download patch
OLDNEW
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
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 NGLogicalSize size(LayoutUnit(100), NGSizeIndefinite); 170 auto* space = ConstructConstraintSpace(
171 NGConstraintSpaceBuilder builder(HorizontalTopBottom); 171 HorizontalTopBottom, LTR,
172 builder.SetAvailableSize(size) 172 NGLogicalSize(LayoutUnit(100), NGSizeIndefinite));
173 .SetPercentageResolutionSize(size) 173 space->SetIsNewFormattingContext(true);
174 .SetIsNewFormattingContext(true);
175 auto* space = new NGConstraintSpace(HorizontalTopBottom, LTR,
176 builder.ToConstraintSpace());
177
178 NGPhysicalFragment* frag = RunBlockLayoutAlgorithm(space, div1); 174 NGPhysicalFragment* frag = RunBlockLayoutAlgorithm(space, div1);
179 175
180 EXPECT_TRUE(frag->MarginStrut().IsEmpty()); 176 EXPECT_TRUE(frag->MarginStrut().IsEmpty());
181 ASSERT_EQ(frag->Children().size(), 1UL); 177 ASSERT_EQ(frag->Children().size(), 1UL);
182 const NGPhysicalFragment* div2_fragment = 178 const NGPhysicalFragment* div2_fragment =
183 static_cast<const NGPhysicalFragment*>(frag->Children()[0].get()); 179 static_cast<const NGPhysicalFragment*>(frag->Children()[0].get());
184 EXPECT_EQ(NGMarginStrut({LayoutUnit(kDiv2MarginTop)}), 180 EXPECT_EQ(NGMarginStrut({LayoutUnit(kDiv2MarginTop)}),
185 div2_fragment->MarginStrut()); 181 div2_fragment->MarginStrut());
186 EXPECT_EQ(kDiv1MarginTop, div2_fragment->TopOffset()); 182 EXPECT_EQ(kDiv1MarginTop, div2_fragment->TopOffset());
187 } 183 }
(...skipping 576 matching lines...) Expand 10 before | Expand all | Expand 10 after
764 frag = RunBlockLayoutAlgorithm(space, div1); 760 frag = RunBlockLayoutAlgorithm(space, div1);
765 space = ConstructConstraintSpace( 761 space = ConstructConstraintSpace(
766 HorizontalTopBottom, LTR, 762 HorizontalTopBottom, LTR,
767 NGLogicalSize(LayoutUnit(kParentSize), LayoutUnit(kParentSize))); 763 NGLogicalSize(LayoutUnit(kParentSize), LayoutUnit(kParentSize)));
768 child3 = frag->Children()[2]; 764 child3 = frag->Children()[2];
769 EXPECT_EQ(kDiv1Size + kDiv2Size, child3->TopOffset()); 765 EXPECT_EQ(kDiv1Size + kDiv2Size, child3->TopOffset());
770 } 766 }
771 767
772 } // namespace 768 } // namespace
773 } // namespace blink 769 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698