Title: [239331] trunk/Source/WebCore
Revision
239331
Author
[email protected]
Date
2018-12-18 07:23:47 -0800 (Tue, 18 Dec 2018)

Log Message

[LFC][BFC][MarginCollapsing] Expand marginAfterCollapsesWithNextSibling and marginBeforeCollapsesWithPreviousSibling collapsing logic
https://bugs.webkit.org/show_bug.cgi?id=192791

Reviewed by Antti Koivisto.

* layout/blockformatting/BlockMarginCollapse.cpp:
(WebCore::Layout::BlockFormattingContext::Geometry::MarginCollapse::marginBeforeCollapsesWithPreviousSibling):
(WebCore::Layout::BlockFormattingContext::Geometry::MarginCollapse::marginAfterCollapsesWithNextSibling):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (239330 => 239331)


--- trunk/Source/WebCore/ChangeLog	2018-12-18 15:19:21 UTC (rev 239330)
+++ trunk/Source/WebCore/ChangeLog	2018-12-18 15:23:47 UTC (rev 239331)
@@ -1,5 +1,16 @@
 2018-12-18  Zalan Bujtas  <[email protected]>
 
+        [LFC][BFC][MarginCollapsing] Expand marginAfterCollapsesWithNextSibling and marginBeforeCollapsesWithPreviousSibling collapsing logic
+        https://bugs.webkit.org/show_bug.cgi?id=192791
+
+        Reviewed by Antti Koivisto.
+
+        * layout/blockformatting/BlockMarginCollapse.cpp:
+        (WebCore::Layout::BlockFormattingContext::Geometry::MarginCollapse::marginBeforeCollapsesWithPreviousSibling):
+        (WebCore::Layout::BlockFormattingContext::Geometry::MarginCollapse::marginAfterCollapsesWithNextSibling):
+
+2018-12-18  Zalan Bujtas  <[email protected]>
+
         [LFC][BFC][MarginCollapsing] Expand marginAfterCollapsesWithParentMarginAfter and marginBeforeCollapsesWithParentMarginBefore collapsing logic
         https://bugs.webkit.org/show_bug.cgi?id=192787
 

Modified: trunk/Source/WebCore/layout/blockformatting/BlockMarginCollapse.cpp (239330 => 239331)


--- trunk/Source/WebCore/layout/blockformatting/BlockMarginCollapse.cpp	2018-12-18 15:19:21 UTC (rev 239330)
+++ trunk/Source/WebCore/layout/blockformatting/BlockMarginCollapse.cpp	2018-12-18 15:23:47 UTC (rev 239331)
@@ -290,15 +290,30 @@
 {
     ASSERT(layoutBox.isBlockLevelBox());
 
-    if (layoutBox.isFloatingPositioned())
+    if (!layoutBox.previousInFlowSibling())
         return false;
 
-    if (!layoutBox.isPositioned() || layoutBox.isInFlowPositioned())
-        return true;
+    auto& previousInFlowSibling = *layoutBox.previousInFlowSibling();
 
-    // Out of flow positioned.
-    ASSERT(layoutBox.isOutOfFlowPositioned());
-    return layoutBox.style().top().isAuto();
+    // Margins between a floated box and any other box do not collapse.
+    if (layoutBox.isFloatingPositioned() || previousInFlowSibling.isFloatingPositioned())
+        return false;
+
+    // Margins of absolutely positioned boxes do not collapse.
+    if ((layoutBox.isOutOfFlowPositioned() && !layoutBox.style().top().isAuto())
+        || (previousInFlowSibling.isOutOfFlowPositioned() && !previousInFlowSibling.style().bottom().isAuto()))
+        return false;
+
+    // Margins of inline-block boxes do not collapse.
+    if (layoutBox.isInlineBlockBox() || previousInFlowSibling.isInlineBlockBox())
+        return false;
+
+    // The bottom margin of an in-flow block-level element always collapses with the top margin of
+    // its next in-flow block-level sibling, unless that sibling has clearance.
+    if (hasClearance(layoutBox))
+        return false;
+
+    return true;
 }
 
 bool BlockFormattingContext::Geometry::MarginCollapse::marginAfterCollapsesWithNextSibling(const Box& layoutBox)
@@ -305,15 +320,10 @@
 {
     ASSERT(layoutBox.isBlockLevelBox());
 
-    if (layoutBox.isFloatingPositioned())
+    if (!layoutBox.nextInFlowSibling())
         return false;
 
-    if (!layoutBox.isPositioned() || layoutBox.isInFlowPositioned())
-        return true;
-
-    // Out of flow positioned.
-    ASSERT(layoutBox.isOutOfFlowPositioned());
-    return layoutBox.style().bottom().isAuto();
+    return marginBeforeCollapsesWithPreviousSibling(*layoutBox.nextInFlowSibling());
 }
 
 bool BlockFormattingContext::Geometry::MarginCollapse::marginsCollapseThrough(const Box& layoutBox)
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to