[LFC][BFC] Move MarginCollapse class under BlockFormattingContext::Geometry
authorzalan@apple.com <zalan@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 5 Sep 2018 14:42:45 +0000 (14:42 +0000)
committerzalan@apple.com <zalan@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 5 Sep 2018 14:42:45 +0000 (14:42 +0000)
https://bugs.webkit.org/show_bug.cgi?id=189296

Reviewed by Antti Koivisto.

Margin collapsing is part of geometry after all.

* layout/blockformatting/BlockFormattingContext.cpp:
(WebCore::Layout::BlockFormattingContext::computeEstimatedMarginTop const):
* layout/blockformatting/BlockFormattingContext.h:
* layout/blockformatting/BlockFormattingContextGeometry.cpp:
(WebCore::Layout::BlockFormattingContext::Geometry::estimatedMarginTop):
* layout/blockformatting/BlockMarginCollapse.cpp:
(WebCore::Layout::BlockFormattingContext::Geometry::MarginCollapse::collapsedMarginTopFromFirstChild):
(WebCore::Layout::BlockFormattingContext::Geometry::MarginCollapse::nonCollapsedMarginTop):
(WebCore::Layout::BlockFormattingContext::Geometry::MarginCollapse::computedNonCollapsedMarginTop):
(WebCore::Layout::BlockFormattingContext::Geometry::MarginCollapse::computedNonCollapsedMarginBottom):
(WebCore::Layout::BlockFormattingContext::Geometry::MarginCollapse::marginTop):
(WebCore::Layout::BlockFormattingContext::Geometry::MarginCollapse::marginBottom):
(WebCore::Layout::BlockFormattingContext::Geometry::MarginCollapse::isMarginBottomCollapsedWithParent):
(WebCore::Layout::BlockFormattingContext::Geometry::MarginCollapse::isMarginTopCollapsedWithParentMarginBottom):
(WebCore::Layout::BlockFormattingContext::Geometry::MarginCollapse::collapsedMarginBottomFromLastChild):
(WebCore::Layout::BlockFormattingContext::Geometry::MarginCollapse::nonCollapsedMarginBottom):
(WebCore::Layout::BlockFormattingContext::MarginCollapse::collapsedMarginTopFromFirstChild): Deleted.
(WebCore::Layout::BlockFormattingContext::MarginCollapse::nonCollapsedMarginTop): Deleted.
(WebCore::Layout::BlockFormattingContext::MarginCollapse::computedNonCollapsedMarginTop): Deleted.
(WebCore::Layout::BlockFormattingContext::MarginCollapse::computedNonCollapsedMarginBottom): Deleted.
(WebCore::Layout::BlockFormattingContext::MarginCollapse::marginTop): Deleted.
(WebCore::Layout::BlockFormattingContext::MarginCollapse::marginBottom): Deleted.
(WebCore::Layout::BlockFormattingContext::MarginCollapse::isMarginBottomCollapsedWithParent): Deleted.
(WebCore::Layout::BlockFormattingContext::MarginCollapse::isMarginTopCollapsedWithParentMarginBottom): Deleted.
(WebCore::Layout::BlockFormattingContext::MarginCollapse::collapsedMarginBottomFromLastChild): Deleted.
(WebCore::Layout::BlockFormattingContext::MarginCollapse::nonCollapsedMarginBottom): Deleted.
(WebCore::Layout::BlockFormattingContext::MarginCollapse::estimatedMarginTop): Deleted.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@235668 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebCore/ChangeLog
Source/WebCore/layout/blockformatting/BlockFormattingContext.cpp
Source/WebCore/layout/blockformatting/BlockFormattingContext.h
Source/WebCore/layout/blockformatting/BlockFormattingContextGeometry.cpp
Source/WebCore/layout/blockformatting/BlockMarginCollapse.cpp

index f730c49..ae7107b 100644 (file)
@@ -1,3 +1,40 @@
+2018-09-05  Zalan Bujtas <zalan@apple.com>
+
+        [LFC][BFC] Move MarginCollapse class under BlockFormattingContext::Geometry
+        https://bugs.webkit.org/show_bug.cgi?id=189296
+
+        Reviewed by Antti Koivisto.
+
+        Margin collapsing is part of geometry after all.
+
+        * layout/blockformatting/BlockFormattingContext.cpp:
+        (WebCore::Layout::BlockFormattingContext::computeEstimatedMarginTop const):
+        * layout/blockformatting/BlockFormattingContext.h:
+        * layout/blockformatting/BlockFormattingContextGeometry.cpp:
+        (WebCore::Layout::BlockFormattingContext::Geometry::estimatedMarginTop):
+        * layout/blockformatting/BlockMarginCollapse.cpp:
+        (WebCore::Layout::BlockFormattingContext::Geometry::MarginCollapse::collapsedMarginTopFromFirstChild):
+        (WebCore::Layout::BlockFormattingContext::Geometry::MarginCollapse::nonCollapsedMarginTop):
+        (WebCore::Layout::BlockFormattingContext::Geometry::MarginCollapse::computedNonCollapsedMarginTop):
+        (WebCore::Layout::BlockFormattingContext::Geometry::MarginCollapse::computedNonCollapsedMarginBottom):
+        (WebCore::Layout::BlockFormattingContext::Geometry::MarginCollapse::marginTop):
+        (WebCore::Layout::BlockFormattingContext::Geometry::MarginCollapse::marginBottom):
+        (WebCore::Layout::BlockFormattingContext::Geometry::MarginCollapse::isMarginBottomCollapsedWithParent):
+        (WebCore::Layout::BlockFormattingContext::Geometry::MarginCollapse::isMarginTopCollapsedWithParentMarginBottom):
+        (WebCore::Layout::BlockFormattingContext::Geometry::MarginCollapse::collapsedMarginBottomFromLastChild):
+        (WebCore::Layout::BlockFormattingContext::Geometry::MarginCollapse::nonCollapsedMarginBottom):
+        (WebCore::Layout::BlockFormattingContext::MarginCollapse::collapsedMarginTopFromFirstChild): Deleted.
+        (WebCore::Layout::BlockFormattingContext::MarginCollapse::nonCollapsedMarginTop): Deleted.
+        (WebCore::Layout::BlockFormattingContext::MarginCollapse::computedNonCollapsedMarginTop): Deleted.
+        (WebCore::Layout::BlockFormattingContext::MarginCollapse::computedNonCollapsedMarginBottom): Deleted.
+        (WebCore::Layout::BlockFormattingContext::MarginCollapse::marginTop): Deleted.
+        (WebCore::Layout::BlockFormattingContext::MarginCollapse::marginBottom): Deleted.
+        (WebCore::Layout::BlockFormattingContext::MarginCollapse::isMarginBottomCollapsedWithParent): Deleted.
+        (WebCore::Layout::BlockFormattingContext::MarginCollapse::isMarginTopCollapsedWithParentMarginBottom): Deleted.
+        (WebCore::Layout::BlockFormattingContext::MarginCollapse::collapsedMarginBottomFromLastChild): Deleted.
+        (WebCore::Layout::BlockFormattingContext::MarginCollapse::nonCollapsedMarginBottom): Deleted.
+        (WebCore::Layout::BlockFormattingContext::MarginCollapse::estimatedMarginTop): Deleted.
+
 2018-09-04  Zalan Bujtas  <zalan@apple.com>
 
         [LFC] Make BlockFormattingContext::Geometry a subclass of FormattingContext::Geometry
index 172145b..b9640e8 100644 (file)
@@ -165,7 +165,7 @@ void BlockFormattingContext::computeStaticPosition(LayoutContext& layoutContext,
 
 void BlockFormattingContext::computeEstimatedMarginTop(LayoutContext& layoutContext, const Box& layoutBox, Display::Box& displayBox) const
 {
-    auto estimatedMarginTop = MarginCollapse::estimatedMarginTop(layoutContext, layoutBox);
+    auto estimatedMarginTop = Geometry::estimatedMarginTop(layoutContext, layoutBox);
     displayBox.setEstimatedMarginTop(estimatedMarginTop);
     displayBox.moveVertically(estimatedMarginTop);
 }
index 2f42060..a1ae7e2 100644 (file)
@@ -78,32 +78,33 @@ private:
         static bool instrinsicWidthConstraintsNeedChildrenWidth(const Box&);
         static InstrinsicWidthConstraints instrinsicWidthConstraints(LayoutContext&, const Box&);
 
-    private:
-        static HeightAndMargin inFlowNonReplacedHeightAndMargin(LayoutContext&, const Box&);
-        static WidthAndMargin inFlowNonReplacedWidthAndMargin(LayoutContext&, const Box&, std::optional<LayoutUnit> precomputedWidth = std::nullopt);
-        static WidthAndMargin inFlowReplacedWidthAndMargin(LayoutContext&, const Box&);
-        static Position staticPositionForOutOfFlowPositioned(const LayoutContext&, const Box&);
-    };
-    
-    // This class implements margin collapsing for block formatting context.
-    class MarginCollapse {
-    public:
-        static LayoutUnit marginTop(const LayoutContext&, const Box&);
         static LayoutUnit estimatedMarginTop(const LayoutContext&, const Box&);
-        static LayoutUnit marginBottom(const LayoutContext&, const Box&);
 
-        static bool isMarginBottomCollapsedWithParent(const LayoutContext&, const Box&);
-        static bool isMarginTopCollapsedWithParentMarginBottom(const Box&);
-    
     private:
-        static LayoutUnit collapsedMarginBottomFromLastChild(const LayoutContext&, const Box&);
-        static LayoutUnit nonCollapsedMarginBottom(const LayoutContext&, const Box&);
+        // This class implements margin collapsing for block formatting context.
+        class MarginCollapse {
+        public:
+            static LayoutUnit marginTop(const LayoutContext&, const Box&);
+            static LayoutUnit marginBottom(const LayoutContext&, const Box&);
 
-        static LayoutUnit computedNonCollapsedMarginTop(const LayoutContext&, const Box&);
-        static LayoutUnit computedNonCollapsedMarginBottom(const LayoutContext&, const Box&);
+            static bool isMarginBottomCollapsedWithParent(const LayoutContext&, const Box&);
+            static bool isMarginTopCollapsedWithParentMarginBottom(const Box&);
 
-        static LayoutUnit collapsedMarginTopFromFirstChild(const LayoutContext&, const Box&);
-        static LayoutUnit nonCollapsedMarginTop(const LayoutContext&, const Box&);
+        private:
+            static LayoutUnit collapsedMarginBottomFromLastChild(const LayoutContext&, const Box&);
+            static LayoutUnit nonCollapsedMarginBottom(const LayoutContext&, const Box&);
+
+            static LayoutUnit computedNonCollapsedMarginTop(const LayoutContext&, const Box&);
+            static LayoutUnit computedNonCollapsedMarginBottom(const LayoutContext&, const Box&);
+
+            static LayoutUnit collapsedMarginTopFromFirstChild(const LayoutContext&, const Box&);
+            static LayoutUnit nonCollapsedMarginTop(const LayoutContext&, const Box&);
+        };
+
+        static HeightAndMargin inFlowNonReplacedHeightAndMargin(LayoutContext&, const Box&);
+        static WidthAndMargin inFlowNonReplacedWidthAndMargin(LayoutContext&, const Box&, std::optional<LayoutUnit> precomputedWidth = std::nullopt);
+        static WidthAndMargin inFlowReplacedWidthAndMargin(LayoutContext&, const Box&);
+        static Position staticPositionForOutOfFlowPositioned(const LayoutContext&, const Box&);
     };
 };
 
index 4337342..cf3678f 100644 (file)
@@ -454,6 +454,19 @@ FormattingContext::InstrinsicWidthConstraints BlockFormattingContext::Geometry::
     return { minimumIntrinsicWidth, maximumIntrinsicWidth };
 }
 
+LayoutUnit BlockFormattingContext::Geometry::estimatedMarginTop(const LayoutContext& layoutContext, const Box& layoutBox)
+{
+    ASSERT(layoutBox.isBlockLevelBox());
+    // Can't estimate vertical margins for out of flow boxes (and we shouldn't need to do it for float boxes).
+    ASSERT(layoutBox.isInFlow());
+    // Can't cross block formatting context boundary.
+    ASSERT(!layoutBox.establishesBlockFormattingContext());
+
+    // Let's just use the normal path for now.
+    return MarginCollapse::marginTop(layoutContext, layoutBox);
+}
+
+
 }
 }
 
index d2dd6ca..5faa711 100644 (file)
@@ -144,7 +144,7 @@ static bool isMarginBottomCollapsedThrough(const LayoutContext& layoutContext, c
     return true;
 }
 
-LayoutUnit BlockFormattingContext::MarginCollapse::collapsedMarginTopFromFirstChild(const LayoutContext& layoutContext, const Box& layoutBox)
+LayoutUnit BlockFormattingContext::Geometry::MarginCollapse::collapsedMarginTopFromFirstChild(const LayoutContext& layoutContext, const Box& layoutBox)
 {
     ASSERT(layoutBox.isBlockLevelBox());
 
@@ -164,7 +164,7 @@ LayoutUnit BlockFormattingContext::MarginCollapse::collapsedMarginTopFromFirstCh
     return marginValue(computedNonCollapsedMarginTop(layoutContext, firstInFlowChild), collapsedMarginTopFromFirstChild(layoutContext, firstInFlowChild));
 }
 
-LayoutUnit BlockFormattingContext::MarginCollapse::nonCollapsedMarginTop(const LayoutContext& layoutContext, const Box& layoutBox)
+LayoutUnit BlockFormattingContext::Geometry::MarginCollapse::nonCollapsedMarginTop(const LayoutContext& layoutContext, const Box& layoutBox)
 {
     ASSERT(layoutBox.isBlockLevelBox());
 
@@ -186,21 +186,21 @@ LayoutUnit BlockFormattingContext::MarginCollapse::nonCollapsedMarginTop(const L
     // A collapsed margin is considered adjoining to another margin if any of its component margins is adjoining to that margin.
     return false;
 }*/
-LayoutUnit BlockFormattingContext::MarginCollapse::computedNonCollapsedMarginTop(const LayoutContext& layoutContext, const Box& layoutBox)
+LayoutUnit BlockFormattingContext::Geometry::MarginCollapse::computedNonCollapsedMarginTop(const LayoutContext& layoutContext, const Box& layoutBox)
 {
     ASSERT(layoutBox.isBlockLevelBox());
 
-    return FormattingContext::Geometry::computedNonCollapsedVerticalMarginValue(layoutContext, layoutBox).top;
+    return computedNonCollapsedVerticalMarginValue(layoutContext, layoutBox).top;
 }
 
-LayoutUnit BlockFormattingContext::MarginCollapse::computedNonCollapsedMarginBottom(const LayoutContext& layoutContext, const Box& layoutBox)
+LayoutUnit BlockFormattingContext::Geometry::MarginCollapse::computedNonCollapsedMarginBottom(const LayoutContext& layoutContext, const Box& layoutBox)
 {
     ASSERT(layoutBox.isBlockLevelBox());
 
-    return FormattingContext::Geometry::computedNonCollapsedVerticalMarginValue(layoutContext, layoutBox).bottom;
+    return computedNonCollapsedVerticalMarginValue(layoutContext, layoutBox).bottom;
 }
 
-LayoutUnit BlockFormattingContext::MarginCollapse::marginTop(const LayoutContext& layoutContext, const Box& layoutBox)
+LayoutUnit BlockFormattingContext::Geometry::MarginCollapse::marginTop(const LayoutContext& layoutContext, const Box& layoutBox)
 {
     if (layoutBox.isAnonymous())
         return 0;
@@ -231,7 +231,7 @@ LayoutUnit BlockFormattingContext::MarginCollapse::marginTop(const LayoutContext
     return marginValue(marginTop, previousSiblingMarginBottom);
 }
 
-LayoutUnit BlockFormattingContext::MarginCollapse::marginBottom(const LayoutContext& layoutContext, const Box& layoutBox)
+LayoutUnit BlockFormattingContext::Geometry::MarginCollapse::marginBottom(const LayoutContext& layoutContext, const Box& layoutBox)
 {
     if (layoutBox.isAnonymous())
         return 0;
@@ -256,7 +256,7 @@ LayoutUnit BlockFormattingContext::MarginCollapse::marginBottom(const LayoutCont
     return nonCollapsedMarginBottom(layoutContext, layoutBox);
 }
 
-bool BlockFormattingContext::MarginCollapse::isMarginBottomCollapsedWithParent(const LayoutContext& layoutContext, const Box& layoutBox)
+bool BlockFormattingContext::Geometry::MarginCollapse::isMarginBottomCollapsedWithParent(const LayoutContext& layoutContext, const Box& layoutBox)
 {
     // last inflow box to parent.
     // https://www.w3.org/TR/CSS21/box.html#collapsing-margins
@@ -298,12 +298,12 @@ bool BlockFormattingContext::MarginCollapse::isMarginBottomCollapsedWithParent(c
     return true;
 }
 
-bool BlockFormattingContext::MarginCollapse::isMarginTopCollapsedWithParentMarginBottom(const Box&)
+bool BlockFormattingContext::Geometry::MarginCollapse::isMarginTopCollapsedWithParentMarginBottom(const Box&)
 {
     return false;
 }
 
-LayoutUnit BlockFormattingContext::MarginCollapse::collapsedMarginBottomFromLastChild(const LayoutContext& layoutContext, const Box& layoutBox)
+LayoutUnit BlockFormattingContext::Geometry::MarginCollapse::collapsedMarginBottomFromLastChild(const LayoutContext& layoutContext, const Box& layoutBox)
 {
     ASSERT(layoutBox.isBlockLevelBox());
 
@@ -324,7 +324,7 @@ LayoutUnit BlockFormattingContext::MarginCollapse::collapsedMarginBottomFromLast
     return marginValue(computedNonCollapsedMarginBottom(layoutContext, lastInFlowChild), collapsedMarginBottomFromLastChild(layoutContext, lastInFlowChild));
 }
 
-LayoutUnit BlockFormattingContext::MarginCollapse::nonCollapsedMarginBottom(const LayoutContext& layoutContext, const Box& layoutBox)
+LayoutUnit BlockFormattingContext::Geometry::MarginCollapse::nonCollapsedMarginBottom(const LayoutContext& layoutContext, const Box& layoutBox)
 {
     ASSERT(layoutBox.isBlockLevelBox());
 
@@ -332,18 +332,6 @@ LayoutUnit BlockFormattingContext::MarginCollapse::nonCollapsedMarginBottom(cons
     return marginValue(computedNonCollapsedMarginBottom(layoutContext, layoutBox), collapsedMarginBottomFromLastChild(layoutContext, layoutBox));
 }
 
-LayoutUnit BlockFormattingContext::MarginCollapse::estimatedMarginTop(const LayoutContext& layoutContext, const Box& layoutBox)
-{
-    ASSERT(layoutBox.isBlockLevelBox());
-    // Can't estimate vertical margins for out of flow boxes (and we shouldn't need to do it for float boxes).
-    ASSERT(layoutBox.isInFlow());
-    // Can't cross block formatting context boundary.
-    ASSERT(!layoutBox.establishesBlockFormattingContext());
-
-    // Let's just use the normal path for now.
-    return marginTop(layoutContext, layoutBox);
-}
-
 }
 }
 #endif