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

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

Issue 2399963002: [layoutng] margin: auto support (Closed)
Patch Set: one more test now passes! 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 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 f990e21ef24ee384a109d902f17226be17b2f1c8..3e5ac597d38cda4ed920eb792fd785e0a4ee5966 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
@@ -488,5 +488,36 @@ TEST_F(NGBlockLayoutAlgorithmTest, PercentageSize) {
const NGPhysicalFragmentBase* child = frag->Children()[0];
EXPECT_EQ(child->Width(), LayoutUnit(12));
}
+
+// A very simple auto margin case. We rely on the tests in ng_length_utils_test
+// for the more complex cases; just make sure we handle auto at all here.
+TEST_F(NGBlockLayoutAlgorithmTest, AutoMargin) {
+ const int kPaddingLeft = 10;
+ const int kWidth = 30;
+ style_->setWidth(Length(kWidth, Fixed));
+ style_->setPaddingLeft(Length(kPaddingLeft, Fixed));
+
+ RefPtr<ComputedStyle> first_style = ComputedStyle::create();
+ const int kChildWidth = 10;
+ first_style->setWidth(Length(kChildWidth, Fixed));
+ first_style->setMarginLeft(Length(Auto));
+ first_style->setMarginRight(Length(Auto));
+ 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(LayoutUnit(kWidth + kPaddingLeft), frag->Width());
+ EXPECT_EQ(NGPhysicalFragmentBase::FragmentBox, frag->Type());
+ EXPECT_EQ(LayoutUnit(kWidth + kPaddingLeft), frag->WidthOverflow());
+ ASSERT_EQ(1UL, frag->Children().size());
+
+ const NGPhysicalFragmentBase* child = frag->Children()[0];
+ EXPECT_EQ(LayoutUnit(kChildWidth), child->Width());
+ EXPECT_EQ(LayoutUnit(kPaddingLeft + 10), child->LeftOffset());
+ EXPECT_EQ(LayoutUnit(0), child->TopOffset());
+}
} // namespace
} // namespace blink

Powered by Google App Engine
This is Rietveld 408576698