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

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

Issue 2368153003: Compute margin block start for 1st block in LayoutNG root constraint space (Closed)
Patch Set: Get IsNewBfc from layout_box->createsNewFormattingContext() Created 4 years, 2 months 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_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"
11 #include "core/layout/ng/ng_units.h" 11 #include "core/layout/ng/ng_units.h"
12 #include "core/style/ComputedStyle.h" 12 #include "core/style/ComputedStyle.h"
13 #include "testing/gtest/include/gtest/gtest.h" 13 #include "testing/gtest/include/gtest/gtest.h"
14 14
15 namespace blink { 15 namespace blink {
16 namespace { 16 namespace {
17 17
18 class NGBlockLayoutAlgorithmTest : public ::testing::Test { 18 class NGBlockLayoutAlgorithmTest : public ::testing::Test {
19 protected: 19 protected:
20 void SetUp() override { style_ = ComputedStyle::create(); } 20 void SetUp() override { style_ = ComputedStyle::create(); }
21 21
22 NGPhysicalFragment* RunBlockLayoutAlgorithm(const NGConstraintSpace* space, 22 NGPhysicalFragment* RunBlockLayoutAlgorithm(NGConstraintSpace* space,
ikilpatrick 2016/09/29 00:18:11 can add const back in.
Gleb Lanbin 2016/09/29 17:11:15 Done.
23 NGBox* first_child) { 23 NGBox* first_child) {
24 NGBlockLayoutAlgorithm algorithm(style_, first_child); 24 NGBlockLayoutAlgorithm algorithm(style_, first_child);
25 NGPhysicalFragment* frag; 25 NGPhysicalFragment* frag;
26 while (!algorithm.Layout(space, &frag)) 26 while (!algorithm.Layout(space, &frag))
27 continue; 27 continue;
28 return frag; 28 return frag;
29 } 29 }
30 30
31 RefPtr<ComputedStyle> style_; 31 RefPtr<ComputedStyle> style_;
32 }; 32 };
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
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->SetIsNewBfc(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
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
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698