Title: [233304] trunk/Source/WebCore
Revision
233304
Author
[email protected]
Date
2018-06-28 07:35:13 -0700 (Thu, 28 Jun 2018)

Log Message

[LFC] The margin bottom of the document element does not collapse with its last inflow child's bottom margin.
https://bugs.webkit.org/show_bug.cgi?id=187135

Reviewed by Antti Koivisto.

* layout/blockformatting/BlockFormattingContext.h:
* layout/blockformatting/BlockFormattingContextGeometry.cpp:
(WebCore::Layout::BlockFormattingContext::Geometry::inFlowNonReplacedHeightAndMargin):
* layout/blockformatting/BlockMarginCollapse.cpp:
(WebCore::Layout::BlockFormattingContext::MarginCollapse::marginBottom):
(WebCore::Layout::BlockFormattingContext::MarginCollapse::isMarginBottomCollapsedWithParent):
(WebCore::Layout::BlockFormattingContext::MarginCollapse::collapsedMarginBottomFromLastChild):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (233303 => 233304)


--- trunk/Source/WebCore/ChangeLog	2018-06-28 08:02:29 UTC (rev 233303)
+++ trunk/Source/WebCore/ChangeLog	2018-06-28 14:35:13 UTC (rev 233304)
@@ -1,3 +1,18 @@
+2018-06-28  Zalan Bujtas  <[email protected]>
+
+        [LFC] The margin bottom of the document element does not collapse with its last inflow child's bottom margin.
+        https://bugs.webkit.org/show_bug.cgi?id=187135
+
+        Reviewed by Antti Koivisto.
+
+        * layout/blockformatting/BlockFormattingContext.h:
+        * layout/blockformatting/BlockFormattingContextGeometry.cpp:
+        (WebCore::Layout::BlockFormattingContext::Geometry::inFlowNonReplacedHeightAndMargin):
+        * layout/blockformatting/BlockMarginCollapse.cpp:
+        (WebCore::Layout::BlockFormattingContext::MarginCollapse::marginBottom):
+        (WebCore::Layout::BlockFormattingContext::MarginCollapse::isMarginBottomCollapsedWithParent):
+        (WebCore::Layout::BlockFormattingContext::MarginCollapse::collapsedMarginBottomFromLastChild):
+
 2018-06-28  Dirk Schulze  <[email protected]>
 
         [css-masking] Update clip-path box mapping to unified box

Modified: trunk/Source/WebCore/layout/blockformatting/BlockFormattingContext.h (233303 => 233304)


--- trunk/Source/WebCore/layout/blockformatting/BlockFormattingContext.h	2018-06-28 08:02:29 UTC (rev 233303)
+++ trunk/Source/WebCore/layout/blockformatting/BlockFormattingContext.h	2018-06-28 14:35:13 UTC (rev 233304)
@@ -83,7 +83,7 @@
         static LayoutUnit marginTop(const LayoutContext&, const Box&);
         static LayoutUnit marginBottom(const LayoutContext&, const Box&);
 
-        static bool isMarginBottomCollapsedWithParent(const Box&);
+        static bool isMarginBottomCollapsedWithParent(const LayoutContext&, const Box&);
         static bool isMarginTopCollapsedWithParentMarginBottom(const Box&);
     
     private:

Modified: trunk/Source/WebCore/layout/blockformatting/BlockFormattingContextGeometry.cpp (233303 => 233304)


--- trunk/Source/WebCore/layout/blockformatting/BlockFormattingContextGeometry.cpp	2018-06-28 08:02:29 UTC (rev 233303)
+++ trunk/Source/WebCore/layout/blockformatting/BlockFormattingContextGeometry.cpp	2018-06-28 14:35:13 UTC (rev 233304)
@@ -99,7 +99,7 @@
         // 2. the bottom edge of the bottom (possibly collapsed) margin of its last in-flow child, if the child's bottom margin...
         auto* lastInFlowChild = downcast<Container>(layoutBox).lastInFlowChild();
         ASSERT(lastInFlowChild);
-        if (!MarginCollapse::isMarginBottomCollapsedWithParent(*lastInFlowChild)) {
+        if (!MarginCollapse::isMarginBottomCollapsedWithParent(layoutContext, *lastInFlowChild)) {
             auto* lastInFlowDisplayBox = layoutContext.displayBoxForLayoutBox(*lastInFlowChild);
             ASSERT(lastInFlowDisplayBox);
             return { lastInFlowDisplayBox->bottom() + lastInFlowDisplayBox->marginBottom() - borderAndPaddingTop, nonCollapsedMargin, collapsedMargin };

Modified: trunk/Source/WebCore/layout/blockformatting/BlockMarginCollapse.cpp (233303 => 233304)


--- trunk/Source/WebCore/layout/blockformatting/BlockMarginCollapse.cpp	2018-06-28 08:02:29 UTC (rev 233303)
+++ trunk/Source/WebCore/layout/blockformatting/BlockMarginCollapse.cpp	2018-06-28 14:35:13 UTC (rev 233304)
@@ -186,7 +186,7 @@
         return 0;
 
     // TODO: take _hasAdjoiningMarginTopAndBottom() into account.
-    if (BlockFormattingContext::MarginCollapse::isMarginBottomCollapsedWithParent(layoutBox))
+    if (BlockFormattingContext::MarginCollapse::isMarginBottomCollapsedWithParent(layoutContext, layoutBox))
         return 0;
 
     // Floats and out of flow positioned boxes do not collapse their margins.
@@ -200,7 +200,7 @@
     return nonCollapsedMarginBottom(layoutContext, layoutBox);
 }
 
-bool BlockFormattingContext::MarginCollapse::isMarginBottomCollapsedWithParent(const Box& layoutBox)
+bool BlockFormattingContext::MarginCollapse::isMarginBottomCollapsedWithParent(const LayoutContext& layoutContext, const Box& layoutBox)
 {
     // last inflow box to parent.
     // https://www.w3.org/TR/CSS21/box.html#collapsing-margins
@@ -221,13 +221,14 @@
         return false;
 
     // Margins of the root element's box do not collapse.
-    if (parent.isInitialContainingBlock())
+    if (parent.isDocumentBox() || parent.isInitialContainingBlock())
         return false;
 
-    if (!parent.style().borderTop().nonZero())
+    auto& parentDisplayBox = *layoutContext.displayBoxForLayoutBox(parent);
+    if (parentDisplayBox.borderTop())
         return false;
 
-    if (!parent.style().paddingTop().isZero())
+    if (parentDisplayBox.paddingTop())
         return false;
 
     if (!parent.style().height().isAuto())
@@ -248,7 +249,7 @@
         return 0;
 
     auto& lastInFlowChild = *downcast<Container>(layoutBox).lastInFlowChild();
-    if (!isMarginBottomCollapsedWithParent(lastInFlowChild))
+    if (!isMarginBottomCollapsedWithParent(layoutContext, lastInFlowChild))
         return 0;
 
     // Collect collapsed margin bottom recursively.
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to