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

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

Issue 2346403002: [layoutng] Create correct constraint spaces for children (Closed)
Patch Set: fix assert failures Created 4 years, 3 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/core/layout/ng/ng_block_layout_algorithm_test.cc
diff --git a/third_party/WebKit/Source/core/layout/ng/ng_block_layout_algorithm_test.cc b/third_party/WebKit/Source/core/layout/ng/ng_block_layout_algorithm_test.cc
index a7755c88adc7fd546316456eea7a3294c18accb1..6014802c24e55065543eea66769f4baccb3e6833 100644
--- a/third_party/WebKit/Source/core/layout/ng/ng_block_layout_algorithm_test.cc
+++ b/third_party/WebKit/Source/core/layout/ng/ng_block_layout_algorithm_test.cc
@@ -402,5 +402,28 @@ TEST_F(NGBlockLayoutAlgorithmTest, BorderAndPadding) {
EXPECT_EQ(kBorderTop + kPaddingTop, child->TopOffset());
EXPECT_EQ(kBorderLeft + kPaddingLeft, child->LeftOffset());
}
+
+TEST_F(NGBlockLayoutAlgorithmTest, PercentageSize) {
+ const int kPaddingLeft = 10;
+ const int kWidth = 30;
+ style_->setWidth(Length(kWidth, Fixed));
+ style_->setPaddingLeft(Length(kPaddingLeft, Fixed));
+
+ RefPtr<ComputedStyle> first_style = ComputedStyle::create();
+ first_style->setWidth(Length(40, Percent));
+ NGBox* first_child = new NGBox(first_style.get());
+
+ auto* space =
+ new NGConstraintSpace(HorizontalTopBottom, LeftToRight,
+ NGLogicalSize(LayoutUnit(100), NGSizeIndefinite));
+ NGPhysicalFragment* frag = RunBlockLayoutAlgorithm(space, first_child);
+
+ EXPECT_EQ(frag->Width(), LayoutUnit(kWidth + kPaddingLeft));
+ EXPECT_EQ(frag->Type(), NGPhysicalFragmentBase::FragmentBox);
+ ASSERT_EQ(frag->Children().size(), 1UL);
+
+ const NGPhysicalFragmentBase* child = frag->Children()[0];
+ EXPECT_EQ(child->Width(), LayoutUnit(12));
+}
} // namespace
} // namespace blink

Powered by Google App Engine
This is Rietveld 408576698