Title: [231487] trunk/Source/WebCore
Revision
231487
Author
[email protected]
Date
2018-05-08 09:31:04 -0700 (Tue, 08 May 2018)

Log Message

[LFC] Start using BlockMarginCollapse
https://bugs.webkit.org/show_bug.cgi?id=185424

Reviewed by Antti Koivisto.

BlockMarginCollapse could be all static.

* layout/blockformatting/BlockFormattingContext.cpp:
(WebCore::Layout::BlockFormattingContext::marginTop const):
(WebCore::Layout::BlockFormattingContext::marginBottom const):
* layout/blockformatting/BlockMarginCollapse.cpp:
(WebCore::Layout::isMarginTopCollapsedWithSibling):
(WebCore::Layout::isMarginBottomCollapsedWithSibling):
(WebCore::Layout::isMarginTopCollapsedWithParent):
(WebCore::Layout::isMarginBottomCollapsedWithParent):
(WebCore::Layout::collapsedMarginTopFromFirstChild):
(WebCore::Layout::collapsedMarginBottomFromLastChild):
(WebCore::Layout::nonCollapsedMarginTop):
(WebCore::Layout::nonCollapsedMarginBottom):
(WebCore::Layout::BlockMarginCollapse::marginTop):
(WebCore::Layout::BlockMarginCollapse::marginBottom):
(WebCore::Layout::BlockMarginCollapse::BlockMarginCollapse): Deleted.
(WebCore::Layout::BlockMarginCollapse::marginTop const): Deleted.
(WebCore::Layout::BlockMarginCollapse::marginBottom const): Deleted.
(WebCore::Layout::BlockMarginCollapse::isMarginTopCollapsedWithSibling const): Deleted.
(WebCore::Layout::BlockMarginCollapse::isMarginBottomCollapsedWithSibling const): Deleted.
(WebCore::Layout::BlockMarginCollapse::isMarginTopCollapsedWithParent const): Deleted.
(WebCore::Layout::BlockMarginCollapse::isMarginBottomCollapsedWithParent const): Deleted.
(WebCore::Layout::BlockMarginCollapse::nonCollapsedMarginTop const): Deleted.
(WebCore::Layout::BlockMarginCollapse::nonCollapsedMarginBottom const): Deleted.
(WebCore::Layout::BlockMarginCollapse::collapsedMarginTopFromFirstChild const): Deleted.
(WebCore::Layout::BlockMarginCollapse::collapsedMarginBottomFromLastChild const): Deleted.
(WebCore::Layout::BlockMarginCollapse::hasAdjoiningMarginTopAndBottom const): Deleted.
* layout/blockformatting/BlockMarginCollapse.h:

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (231486 => 231487)


--- trunk/Source/WebCore/ChangeLog	2018-05-08 16:26:54 UTC (rev 231486)
+++ trunk/Source/WebCore/ChangeLog	2018-05-08 16:31:04 UTC (rev 231487)
@@ -1,3 +1,40 @@
+2018-05-08  Zalan Bujtas  <[email protected]>
+
+        [LFC] Start using BlockMarginCollapse
+        https://bugs.webkit.org/show_bug.cgi?id=185424
+
+        Reviewed by Antti Koivisto.
+
+        BlockMarginCollapse could be all static.
+
+        * layout/blockformatting/BlockFormattingContext.cpp:
+        (WebCore::Layout::BlockFormattingContext::marginTop const):
+        (WebCore::Layout::BlockFormattingContext::marginBottom const):
+        * layout/blockformatting/BlockMarginCollapse.cpp:
+        (WebCore::Layout::isMarginTopCollapsedWithSibling):
+        (WebCore::Layout::isMarginBottomCollapsedWithSibling):
+        (WebCore::Layout::isMarginTopCollapsedWithParent):
+        (WebCore::Layout::isMarginBottomCollapsedWithParent):
+        (WebCore::Layout::collapsedMarginTopFromFirstChild):
+        (WebCore::Layout::collapsedMarginBottomFromLastChild):
+        (WebCore::Layout::nonCollapsedMarginTop):
+        (WebCore::Layout::nonCollapsedMarginBottom):
+        (WebCore::Layout::BlockMarginCollapse::marginTop):
+        (WebCore::Layout::BlockMarginCollapse::marginBottom):
+        (WebCore::Layout::BlockMarginCollapse::BlockMarginCollapse): Deleted.
+        (WebCore::Layout::BlockMarginCollapse::marginTop const): Deleted.
+        (WebCore::Layout::BlockMarginCollapse::marginBottom const): Deleted.
+        (WebCore::Layout::BlockMarginCollapse::isMarginTopCollapsedWithSibling const): Deleted.
+        (WebCore::Layout::BlockMarginCollapse::isMarginBottomCollapsedWithSibling const): Deleted.
+        (WebCore::Layout::BlockMarginCollapse::isMarginTopCollapsedWithParent const): Deleted.
+        (WebCore::Layout::BlockMarginCollapse::isMarginBottomCollapsedWithParent const): Deleted.
+        (WebCore::Layout::BlockMarginCollapse::nonCollapsedMarginTop const): Deleted.
+        (WebCore::Layout::BlockMarginCollapse::nonCollapsedMarginBottom const): Deleted.
+        (WebCore::Layout::BlockMarginCollapse::collapsedMarginTopFromFirstChild const): Deleted.
+        (WebCore::Layout::BlockMarginCollapse::collapsedMarginBottomFromLastChild const): Deleted.
+        (WebCore::Layout::BlockMarginCollapse::hasAdjoiningMarginTopAndBottom const): Deleted.
+        * layout/blockformatting/BlockMarginCollapse.h:
+
 2018-05-08  Youenn Fablet  <[email protected]>
 
         Allow WebResourceLoader to cancel a load served from a service worker

Modified: trunk/Source/WebCore/layout/blockformatting/BlockFormattingContext.cpp (231486 => 231487)


--- trunk/Source/WebCore/layout/blockformatting/BlockFormattingContext.cpp	2018-05-08 16:26:54 UTC (rev 231486)
+++ trunk/Source/WebCore/layout/blockformatting/BlockFormattingContext.cpp	2018-05-08 16:31:04 UTC (rev 231487)
@@ -29,6 +29,7 @@
 #if ENABLE(LAYOUT_FORMATTING_CONTEXT)
 
 #include "BlockFormattingState.h"
+#include "BlockMarginCollapse.h"
 #include "DisplayBox.h"
 #include "FloatingContext.h"
 #include "FloatingState.h"
@@ -150,14 +151,14 @@
 {
 }
 
-LayoutUnit BlockFormattingContext::marginTop(const Box&) const
+LayoutUnit BlockFormattingContext::marginTop(const Box& layoutBox) const
 {
-    return 0;
+    return BlockMarginCollapse::marginTop(layoutBox);
 }
 
-LayoutUnit BlockFormattingContext::marginBottom(const Box&) const
+LayoutUnit BlockFormattingContext::marginBottom(const Box& layoutBox) const
 {
-    return 0;
+    return BlockMarginCollapse::marginBottom(layoutBox);
 }
 
 }

Modified: trunk/Source/WebCore/layout/blockformatting/BlockMarginCollapse.cpp (231486 => 231487)


--- trunk/Source/WebCore/layout/blockformatting/BlockMarginCollapse.cpp	2018-05-08 16:26:54 UTC (rev 231486)
+++ trunk/Source/WebCore/layout/blockformatting/BlockMarginCollapse.cpp	2018-05-08 16:31:04 UTC (rev 231487)
@@ -55,56 +55,8 @@
     return currentMarginValue + candidateMarginValue;
 }
 
-BlockMarginCollapse::BlockMarginCollapse()
+static bool isMarginTopCollapsedWithSibling(const Box& layoutBox)
 {
-}
-
-LayoutUnit BlockMarginCollapse::marginTop(const Box& layoutBox) const
-{
-    if (layoutBox.isAnonymous())
-        return 0;
-    
-    // TODO: take _hasAdjoiningMarginTopAndBottom() into account.
-    if (isMarginTopCollapsedWithParent(layoutBox))
-        return 0;
-    
-    // Floats and out of flow positioned boxes do not collapse their margins.
-    if (!isMarginTopCollapsedWithSibling(layoutBox))
-        return nonCollapsedMarginTop(layoutBox);
-    
-    // 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.
-    auto* previousInFlowSibling = layoutBox.previousInFlowSibling();
-    if (!previousInFlowSibling)
-        return nonCollapsedMarginTop(layoutBox);
-
-    auto previousSiblingMarginBottom = nonCollapsedMarginBottom(*previousInFlowSibling);
-    auto marginTop = nonCollapsedMarginTop(layoutBox);
-    return marginValue(marginTop, previousSiblingMarginBottom);
-}
-
-LayoutUnit BlockMarginCollapse::marginBottom(const Box& layoutBox) const
-{
-    if (layoutBox.isAnonymous())
-        return 0;
-
-    // TODO: take _hasAdjoiningMarginTopAndBottom() into account.
-    if (isMarginBottomCollapsedWithParent(layoutBox))
-        return 0;
-
-    // Floats and out of flow positioned boxes do not collapse their margins.
-    if (!isMarginBottomCollapsedWithSibling(layoutBox))
-        return nonCollapsedMarginBottom(layoutBox);
-    
-    // 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 (layoutBox.nextInFlowSibling())
-        return 0;
-    return nonCollapsedMarginBottom(layoutBox);
-}
-
-bool BlockMarginCollapse::isMarginTopCollapsedWithSibling(const Box& layoutBox) const
-{
     if (layoutBox.isFloatingPositioned())
         return false;
 
@@ -116,7 +68,7 @@
     return layoutBox.style().top().isAuto();
 }
 
-bool BlockMarginCollapse::isMarginBottomCollapsedWithSibling(const Box& layoutBox) const
+static bool isMarginBottomCollapsedWithSibling(const Box& layoutBox)
 {
     if (layoutBox.isFloatingPositioned())
         return false;
@@ -129,7 +81,7 @@
     return layoutBox.style().bottom().isAuto();
 }
 
-bool BlockMarginCollapse::isMarginTopCollapsedWithParent(const Box& layoutBox) const
+static bool isMarginTopCollapsedWithParent(const Box& layoutBox)
 {
     // The first inflow child could propagate its top margin to parent.
     // https://www.w3.org/TR/CSS21/box.html#collapsing-margins
@@ -162,7 +114,7 @@
     return true;
 }
 
-bool BlockMarginCollapse::isMarginBottomCollapsedWithParent(const Box& layoutBox) const
+static bool isMarginBottomCollapsedWithParent(const Box& layoutBox)
 {
     // last inflow box to parent.
     // https://www.w3.org/TR/CSS21/box.html#collapsing-margins
@@ -198,20 +150,8 @@
     return true;
 }
 
-LayoutUnit BlockMarginCollapse::nonCollapsedMarginTop(const Box& layoutBox) const
+static LayoutUnit collapsedMarginTopFromFirstChild(const Box& layoutBox)
 {
-    // Non collapsed margin top includes collapsed margin from inflow first child.
-    return marginValue(layoutBox.style().marginTop().value(), collapsedMarginTopFromFirstChild(layoutBox));
-}
-
-LayoutUnit BlockMarginCollapse::nonCollapsedMarginBottom(const Box& layoutBox) const
-{
-    // Non collapsed margin bottom includes collapsed margin from inflow last child.
-    return marginValue(layoutBox.style().marginBottom().value(), collapsedMarginBottomFromLastChild(layoutBox));
-}
-
-LayoutUnit BlockMarginCollapse::collapsedMarginTopFromFirstChild(const Box& layoutBox) const
-{
     // Check if the first child collapses its margin top.
     if (!is<Container>(layoutBox) || !downcast<Container>(layoutBox).hasInFlowChild())
         return 0;
@@ -224,7 +164,7 @@
     return marginValue(firstInFlowChild.style().marginTop().value(), collapsedMarginTopFromFirstChild(firstInFlowChild));
 }
 
-LayoutUnit BlockMarginCollapse::collapsedMarginBottomFromLastChild(const Box& layoutBox) const
+static LayoutUnit collapsedMarginBottomFromLastChild(const Box& layoutBox)
 {
     // Check if the last child propagates its margin bottom.
     if (!is<Container>(layoutBox) || !downcast<Container>(layoutBox).hasInFlowChild())
@@ -238,8 +178,20 @@
     return marginValue(lastInFlowChild.style().marginBottom().value(), collapsedMarginBottomFromLastChild(lastInFlowChild));
 }
 
-bool BlockMarginCollapse::hasAdjoiningMarginTopAndBottom(const Box&) const
+static LayoutUnit nonCollapsedMarginTop(const Box& layoutBox)
 {
+    // Non collapsed margin top includes collapsed margin from inflow first child.
+    return marginValue(layoutBox.style().marginTop().value(), collapsedMarginTopFromFirstChild(layoutBox));
+}
+
+static LayoutUnit nonCollapsedMarginBottom(const Box& layoutBox)
+{
+    // Non collapsed margin bottom includes collapsed margin from inflow last child.
+    return marginValue(layoutBox.style().marginBottom().value(), collapsedMarginBottomFromLastChild(layoutBox));
+}
+
+/*static bool hasAdjoiningMarginTopAndBottom(const Box&)
+{
     // Two margins are adjoining if and only if:
     // 1. both belong to in-flow block-level boxes that participate in the same block formatting context
     // 2. no line boxes, no clearance, no padding and no border separate them (Note that certain zero-height line boxes (see 9.4.2) are ignored for this purpose.)
@@ -251,8 +203,52 @@
     //        zero or 'auto' computed 'height', and no in-flow children
     // A collapsed margin is considered adjoining to another margin if any of its component margins is adjoining to that margin.
     return false;
+}*/
+
+LayoutUnit BlockMarginCollapse::marginTop(const Box& layoutBox)
+{
+    if (layoutBox.isAnonymous())
+        return 0;
+
+    // TODO: take _hasAdjoiningMarginTopAndBottom() into account.
+    if (isMarginTopCollapsedWithParent(layoutBox))
+        return 0;
+
+    // Floats and out of flow positioned boxes do not collapse their margins.
+    if (!isMarginTopCollapsedWithSibling(layoutBox))
+        return nonCollapsedMarginTop(layoutBox);
+
+    // 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.
+    auto* previousInFlowSibling = layoutBox.previousInFlowSibling();
+    if (!previousInFlowSibling)
+        return nonCollapsedMarginTop(layoutBox);
+
+    auto previousSiblingMarginBottom = nonCollapsedMarginBottom(*previousInFlowSibling);
+    auto marginTop = nonCollapsedMarginTop(layoutBox);
+    return marginValue(marginTop, previousSiblingMarginBottom);
 }
 
+LayoutUnit BlockMarginCollapse::marginBottom(const Box& layoutBox)
+{
+    if (layoutBox.isAnonymous())
+        return 0;
+
+    // TODO: take _hasAdjoiningMarginTopAndBottom() into account.
+    if (isMarginBottomCollapsedWithParent(layoutBox))
+        return 0;
+
+    // Floats and out of flow positioned boxes do not collapse their margins.
+    if (!isMarginBottomCollapsedWithSibling(layoutBox))
+        return nonCollapsedMarginBottom(layoutBox);
+
+    // 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 (layoutBox.nextInFlowSibling())
+        return 0;
+    return nonCollapsedMarginBottom(layoutBox);
 }
+
 }
+}
 #endif

Modified: trunk/Source/WebCore/layout/blockformatting/BlockMarginCollapse.h (231486 => 231487)


--- trunk/Source/WebCore/layout/blockformatting/BlockMarginCollapse.h	2018-05-08 16:26:54 UTC (rev 231486)
+++ trunk/Source/WebCore/layout/blockformatting/BlockMarginCollapse.h	2018-05-08 16:31:04 UTC (rev 231487)
@@ -40,23 +40,8 @@
 class BlockMarginCollapse {
     WTF_MAKE_ISO_ALLOCATED(BlockMarginCollapse);
 public:
-    BlockMarginCollapse();
-
-    LayoutUnit marginTop(const Box&) const;
-    LayoutUnit marginBottom(const Box&) const;
-
-private:
-    bool isMarginTopCollapsedWithSibling(const Box&) const;
-    bool isMarginBottomCollapsedWithSibling(const Box&) const;
-    bool isMarginTopCollapsedWithParent(const Box&) const;
-    bool isMarginBottomCollapsedWithParent(const Box&) const;
-
-    LayoutUnit nonCollapsedMarginTop(const Box&) const;
-    LayoutUnit nonCollapsedMarginBottom(const Box&) const;
-    LayoutUnit collapsedMarginTopFromFirstChild(const Box&) const;
-    LayoutUnit collapsedMarginBottomFromLastChild(const Box&) const;
-
-    bool hasAdjoiningMarginTopAndBottom(const Box&) const;
+    static LayoutUnit marginTop(const Box&);
+    static LayoutUnit marginBottom(const Box&);
 };
 
 }
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to