Title: [238930] trunk/Source/WebCore
Revision
238930
Author
[email protected]
Date
2018-12-06 07:21:48 -0800 (Thu, 06 Dec 2018)

Log Message

[LFC][BFC][MarginCollapsing] Add MarginCollapse::establishesBlockFormattingContext
https://bugs.webkit.org/show_bug.cgi?id=192297

Reviewed by Antti Koivisto.

WebKit treats the document element renderer as a block formatting context root.

* layout/blockformatting/BlockMarginCollapse.cpp:
(WebCore::Layout::establishesBlockFormattingContext):
(WebCore::Layout::BlockFormattingContext::Geometry::MarginCollapse::isMarginTopCollapsedWithParent):
(WebCore::Layout::BlockFormattingContext::Geometry::MarginCollapse::isMarginBottomCollapsedWithParent):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (238929 => 238930)


--- trunk/Source/WebCore/ChangeLog	2018-12-06 13:07:46 UTC (rev 238929)
+++ trunk/Source/WebCore/ChangeLog	2018-12-06 15:21:48 UTC (rev 238930)
@@ -1,3 +1,17 @@
+2018-12-06  Zalan Bujtas  <[email protected]>
+
+        [LFC][BFC][MarginCollapsing] Add MarginCollapse::establishesBlockFormattingContext
+        https://bugs.webkit.org/show_bug.cgi?id=192297
+
+        Reviewed by Antti Koivisto.
+
+        WebKit treats the document element renderer as a block formatting context root.
+
+        * layout/blockformatting/BlockMarginCollapse.cpp:
+        (WebCore::Layout::establishesBlockFormattingContext):
+        (WebCore::Layout::BlockFormattingContext::Geometry::MarginCollapse::isMarginTopCollapsedWithParent):
+        (WebCore::Layout::BlockFormattingContext::Geometry::MarginCollapse::isMarginBottomCollapsedWithParent):
+
 2018-12-06  Carlos Eduardo Ramalho  <[email protected]>
 
         [GStreamer] -DENABLE_VIDEO=ON -DENABLE_OPENGL=OFF still tries to build GstreamerGL

Modified: trunk/Source/WebCore/layout/blockformatting/BlockMarginCollapse.cpp (238929 => 238930)


--- trunk/Source/WebCore/layout/blockformatting/BlockMarginCollapse.cpp	2018-12-06 13:07:46 UTC (rev 238929)
+++ trunk/Source/WebCore/layout/blockformatting/BlockMarginCollapse.cpp	2018-12-06 15:21:48 UTC (rev 238930)
@@ -69,6 +69,15 @@
     return hasPadding(layoutBox.style().paddingAfter());
 }
 
+static bool establishesBlockFormattingContext(const Box& layoutBox)
+{
+    // WebKit treats the document element renderer as a block formatting context root. It probably only impacts margin collapsing, so let's not do
+    // a layout wide quirk on this for now.
+    if (layoutBox.isDocumentBox())
+        return true;
+    return layoutBox.establishesBlockFormattingContext();
+}
+
 static LayoutUnit marginValue(LayoutUnit currentMarginValue, LayoutUnit candidateMarginValue)
 {
     if (!candidateMarginValue)
@@ -131,16 +140,11 @@
     if (layoutBox.previousInFlowSibling())
         return false;
 
-    // We never margin collapse the initial containing block.
-    ASSERT(layoutBox.parent());
     auto& parent = *layoutBox.parent();
-    if (parent.establishesBlockFormattingContext())
+    // Margins of elements that establish new block formatting contexts do not collapse with their in-flow children
+    if (establishesBlockFormattingContext(parent))
         return false;
 
-    // Margins of the root element's box do not collapse.
-    if (parent.isDocumentBox() || parent.isInitialContainingBlock())
-        return false;
-
     if (hasBorderBefore(parent))
         return false;
 
@@ -308,20 +312,15 @@
     if (isMarginBottomCollapsedThrough(layoutBox))
         return false;
 
-    // We never margin collapse the initial containing block.
-    ASSERT(layoutBox.parent());
-    auto& parent = *layoutBox.parent();
     // Only the last inlflow child collapses with parent.
     if (layoutBox.nextInFlowSibling())
         return false;
 
-    if (parent.establishesBlockFormattingContext())
+    auto& parent = *layoutBox.parent();
+    // Margins of elements that establish new block formatting contexts do not collapse with their in-flow children
+    if (establishesBlockFormattingContext(parent))
         return false;
 
-    // Margins of the root element's box do not collapse.
-    if (parent.isDocumentBox() || parent.isInitialContainingBlock())
-        return false;
-
     if (hasBorderBefore(parent))
         return false;
 
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to