Title: [233275] trunk/Source/WebCore
Revision
233275
Author
[email protected]
Date
2018-06-27 13:10:24 -0700 (Wed, 27 Jun 2018)

Log Message

[LFC] Do not collapse margin with the parent when element has border/padding.
https://bugs.webkit.org/show_bug.cgi?id=187114

Reviewed by Antti Koivisto.

* layout/blockformatting/BlockFormattingContext.cpp:
(WebCore::Layout::BlockFormattingContext::layout const):
* layout/blockformatting/BlockMarginCollapse.cpp:
(WebCore::Layout::isMarginTopCollapsedWithParent):
(WebCore::Layout::BlockFormattingContext::MarginCollapse::collapsedMarginTopFromFirstChild):
(WebCore::Layout::BlockFormattingContext::MarginCollapse::marginTop):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (233274 => 233275)


--- trunk/Source/WebCore/ChangeLog	2018-06-27 20:01:49 UTC (rev 233274)
+++ trunk/Source/WebCore/ChangeLog	2018-06-27 20:10:24 UTC (rev 233275)
@@ -1,3 +1,17 @@
+2018-06-27  Zalan Bujtas  <[email protected]>
+
+        [LFC] Do not collapse margin with the parent when element has border/padding.
+        https://bugs.webkit.org/show_bug.cgi?id=187114
+
+        Reviewed by Antti Koivisto.
+
+        * layout/blockformatting/BlockFormattingContext.cpp:
+        (WebCore::Layout::BlockFormattingContext::layout const):
+        * layout/blockformatting/BlockMarginCollapse.cpp:
+        (WebCore::Layout::isMarginTopCollapsedWithParent):
+        (WebCore::Layout::BlockFormattingContext::MarginCollapse::collapsedMarginTopFromFirstChild):
+        (WebCore::Layout::BlockFormattingContext::MarginCollapse::marginTop):
+
 2018-06-27  Simon Fraser  <[email protected]>
 
         Fix Windows build after r233268.

Modified: trunk/Source/WebCore/layout/blockformatting/BlockFormattingContext.cpp (233274 => 233275)


--- trunk/Source/WebCore/layout/blockformatting/BlockFormattingContext.cpp	2018-06-27 20:01:49 UTC (rev 233274)
+++ trunk/Source/WebCore/layout/blockformatting/BlockFormattingContext.cpp	2018-06-27 20:10:24 UTC (rev 233275)
@@ -84,7 +84,7 @@
                 // Since this box is a formatting context root, it takes care of its entire subtree.
                 break;
             }
-            
+
             LOG_WITH_STREAM(FormattingContextLayout, stream << "[Compute] -> [Position][Border][Padding][Width][Margin] -> for layoutBox(" << &layoutBox << ")");
             computeStaticPosition(layoutContext, layoutBox, displayBox);
             computeBorderAndPadding(layoutContext, layoutBox, displayBox);

Modified: trunk/Source/WebCore/layout/blockformatting/BlockMarginCollapse.cpp (233274 => 233275)


--- trunk/Source/WebCore/layout/blockformatting/BlockMarginCollapse.cpp	2018-06-27 20:01:49 UTC (rev 233274)
+++ trunk/Source/WebCore/layout/blockformatting/BlockMarginCollapse.cpp	2018-06-27 20:10:24 UTC (rev 233275)
@@ -78,7 +78,7 @@
     return layoutBox.style().bottom().isAuto();
 }
 
-static bool isMarginTopCollapsedWithParent(const Box& layoutBox)
+static bool isMarginTopCollapsedWithParent(const Box& layoutBox, const Display::Box& displayBox)
 {
     // The first inflow child could propagate its top margin to parent.
     // https://www.w3.org/TR/CSS21/box.html#collapsing-margins
@@ -99,13 +99,13 @@
         return false;
 
     // Margins of the root element's box do not collapse.
-    if (parent.isInitialContainingBlock())
+    if (layoutBox.isInitialContainingBlock())
         return false;
 
-    if (!parent.style().borderTop().nonZero())
+    if (displayBox.borderTop())
         return false;
 
-    if (!parent.style().paddingTop().isZero())
+    if (!displayBox.paddingTop())
         return false;
 
     return true;
@@ -118,7 +118,8 @@
         return 0;
 
     auto& firstInFlowChild = *downcast<Container>(layoutBox).firstInFlowChild();
-    if (!isMarginTopCollapsedWithParent(firstInFlowChild))
+    auto& fistInflowDisplayBox = *layoutContext.displayBoxForLayoutBox(firstInFlowChild);
+    if (!isMarginTopCollapsedWithParent(firstInFlowChild, fistInflowDisplayBox))
         return 0;
 
     // Collect collapsed margin top recursively.
@@ -161,7 +162,8 @@
         return 0;
 
     // TODO: take _hasAdjoiningMarginTopAndBottom() into account.
-    if (isMarginTopCollapsedWithParent(layoutBox))
+    auto& displayBox = *layoutContext.displayBoxForLayoutBox(layoutBox);
+    if (isMarginTopCollapsedWithParent(layoutBox, displayBox))
         return 0;
 
     // Floats and out of flow positioned boxes do not collapse their margins.
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to