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

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

Issue 2710213007: [NGLayout] Collapse margins before processing LayoutInline. (Closed)
Patch Set: git rebase-update Created 3 years, 10 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
« no previous file with comments | « third_party/WebKit/Source/core/layout/ng/ng_block_layout_algorithm.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 11912e2a52e184ed73a6eec9d479c343590f92cb..f73b2eee46d3fd99938b989e616dfaf316a78f71 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
@@ -45,9 +45,11 @@ class NGBlockLayoutAlgorithmTest
public:
NGBlockLayoutAlgorithmTest() {
RuntimeEnabledFeatures::setLayoutNGEnabled(true);
+ RuntimeEnabledFeatures::setLayoutNGInlineEnabled(true);
}
~NGBlockLayoutAlgorithmTest() {
RuntimeEnabledFeatures::setLayoutNGEnabled(false);
+ RuntimeEnabledFeatures::setLayoutNGInlineEnabled(false);
}
protected:
@@ -619,6 +621,37 @@ TEST_F(NGBlockLayoutAlgorithmTest, CollapsingMarginsCase5) {
EXPECT_THAT(horizontal_fragment->LeftOffset(), LayoutUnit(130));
}
+// Verifies that margins collapsing logic works with Layout Inline.
+TEST_F(NGBlockLayoutAlgorithmTest, CollapsingMarginsWithText) {
+ setBodyInnerHTML(R"HTML(
+ <!DOCTYPE html>
+ <style>
+ body {
+ margin: 10px;
+ }
+ p {
+ margin: 20px;
+ }
+ </style>
+ <p>Some text</p>
+ )HTML");
+ RefPtr<NGPhysicalBoxFragment> html_fragment;
+ std::tie(html_fragment, std::ignore) = RunBlockLayoutAlgorithmForElement(
+ document().getElementsByTagName("html")->item(0));
+
+ auto* body_fragment =
+ toNGPhysicalBoxFragment(html_fragment->Children()[0].get());
+ // 20 = std::max(body's margin, p's margin)
+ EXPECT_THAT(body_fragment->Offset(),
+ NGPhysicalOffset(LayoutUnit(10), LayoutUnit(20)));
+
+ auto* p_fragment =
+ toNGPhysicalBoxFragment(body_fragment->Children()[0].get());
+ // Collapsed margins with result = 0.
+ EXPECT_THAT(p_fragment->Offset(),
+ NGPhysicalOffset(LayoutUnit(20), LayoutUnit(0)));
+}
+
// Verifies that the margin strut of a child with a different writing mode does
// not get used in the collapsing margins calculation.
//
« no previous file with comments | « third_party/WebKit/Source/core/layout/ng/ng_block_layout_algorithm.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698