[LFC] Make the nested Geometry/MarginCollapse/Quirks c'tors private.
authorzalan@apple.com <zalan@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 16 Sep 2019 18:44:36 +0000 (18:44 +0000)
committerzalan@apple.com <zalan@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 16 Sep 2019 18:44:36 +0000 (18:44 +0000)
https://bugs.webkit.org/show_bug.cgi?id=201825
<rdar://problem/55403474>

Reviewed by Antti Koivisto.

The Geometry/MarginCollapse/Quirks objects should be constructed through the corresponding accessor functions.
This is also a preparation for being able to pass the layout box in to these stack objects and call geometry(layoutBox)->outOfFlowVerticalGeometry() vs. geometry()->outOfFlowVerticalGeometry(layoutBox).

* layout/FormattingContext.h:
* layout/blockformatting/BlockFormattingContext.h:
* layout/blockformatting/BlockFormattingContextGeometry.cpp:
(WebCore::Layout::BlockFormattingContext::Geometry::inFlowNonReplacedHeightAndMargin):
* layout/blockformatting/BlockFormattingContextQuirks.cpp:
(WebCore::Layout::BlockFormattingContext::Quirks::stretchedInFlowHeight):
* layout/inlineformatting/InlineFormattingContext.h:
* layout/tableformatting/TableFormattingContext.h:

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

Source/WebCore/ChangeLog
Source/WebCore/layout/FormattingContext.h
Source/WebCore/layout/blockformatting/BlockFormattingContext.h
Source/WebCore/layout/blockformatting/BlockFormattingContextGeometry.cpp
Source/WebCore/layout/blockformatting/BlockFormattingContextQuirks.cpp
Source/WebCore/layout/inlineformatting/InlineFormattingContext.h
Source/WebCore/layout/tableformatting/TableFormattingContext.h

index 886b8b7..0b78079 100644 (file)
@@ -1,3 +1,23 @@
+2019-09-16  Zalan Bujtas  <zalan@apple.com>
+
+        [LFC] Make the nested Geometry/MarginCollapse/Quirks c'tors private.
+        https://bugs.webkit.org/show_bug.cgi?id=201825
+        <rdar://problem/55403474>
+
+        Reviewed by Antti Koivisto.
+
+        The Geometry/MarginCollapse/Quirks objects should be constructed through the corresponding accessor functions.
+        This is also a preparation for being able to pass the layout box in to these stack objects and call geometry(layoutBox)->outOfFlowVerticalGeometry() vs. geometry()->outOfFlowVerticalGeometry(layoutBox). 
+
+        * layout/FormattingContext.h:
+        * layout/blockformatting/BlockFormattingContext.h:
+        * layout/blockformatting/BlockFormattingContextGeometry.cpp:
+        (WebCore::Layout::BlockFormattingContext::Geometry::inFlowNonReplacedHeightAndMargin):
+        * layout/blockformatting/BlockFormattingContextQuirks.cpp:
+        (WebCore::Layout::BlockFormattingContext::Quirks::stretchedInFlowHeight):
+        * layout/inlineformatting/InlineFormattingContext.h:
+        * layout/tableformatting/TableFormattingContext.h:
+
 2019-09-16  Jon Davis  <jond@apple.com>
 
         Update feature status for Battery Status API, WebGL 2, and Dialog Element
index d3bcb1c..fe4b280 100644 (file)
@@ -93,8 +93,6 @@ protected:
     // This class implements generic positioning and sizing.
     class Geometry {
     public:
-        Geometry(const FormattingContext&);
-
         VerticalGeometry outOfFlowVerticalGeometry(const Box&, UsedHorizontalValues, UsedVerticalValues) const;
         HorizontalGeometry outOfFlowHorizontalGeometry(const Box&, UsedHorizontalValues);
 
@@ -126,6 +124,9 @@ protected:
         LayoutUnit contentHeightForFormattingContextRoot(const Box&) const;
 
     protected:
+        friend class FormattingContext;
+        Geometry(const FormattingContext&);
+
         enum class HeightType { Min, Max, Normal };
         Optional<LayoutUnit> computedHeightValue(const Box&, HeightType, Optional<UsedVerticalValues> = WTF::nullopt) const;
 
@@ -154,11 +155,12 @@ protected:
 
     class Quirks {
     public:
-        Quirks(const FormattingContext&);
-
         LayoutUnit heightValueOfNearestContainingBlockWithFixedHeight(const Box&);
 
     protected:
+        friend class FormattingContext;
+        Quirks(const FormattingContext&);
+
         const LayoutState& layoutState() const { return m_formattingContext.layoutState(); }
         LayoutState& layoutState() { return m_formattingContext.layoutState(); }
         const FormattingContext& formattingContext() const { return m_formattingContext; }
index fb657b6..8fa9c47 100644 (file)
@@ -75,8 +75,6 @@ private:
     // This class implements positioning and sizing for boxes participating in a block formatting context.
     class Geometry : public FormattingContext::Geometry {
     public:
-        Geometry(const BlockFormattingContext&);
-
         HeightAndMargin inFlowHeightAndMargin(const Box&, UsedHorizontalValues, UsedVerticalValues);
         WidthAndMargin inFlowWidthAndMargin(const Box&, UsedHorizontalValues);
 
@@ -87,6 +85,9 @@ private:
         IntrinsicWidthConstraints intrinsicWidthConstraints(const Box&);
 
     private:
+        friend class BlockFormattingContext;
+        Geometry(const BlockFormattingContext&);
+
         HeightAndMargin inFlowNonReplacedHeightAndMargin(const Box&, UsedHorizontalValues, UsedVerticalValues);
         WidthAndMargin inFlowNonReplacedWidthAndMargin(const Box&, UsedHorizontalValues) const;
         WidthAndMargin inFlowReplacedWidthAndMargin(const Box&, UsedHorizontalValues) const;
@@ -99,8 +100,6 @@ private:
     // This class implements margin collapsing for block formatting context.
     class MarginCollapse {
     public:
-        MarginCollapse(const BlockFormattingContext&);
-
         UsedVerticalMargin::CollapsedValues collapsedVerticalValues(const Box&, const UsedVerticalMargin::NonCollapsedValues&);
 
         EstimatedMarginBefore estimatedMarginBefore(const Box&);
@@ -122,6 +121,9 @@ private:
         bool marginsCollapseThrough(const Box&) const;
 
     private:
+        friend class BlockFormattingContext;
+        MarginCollapse(const BlockFormattingContext&);
+
         enum class MarginType { Before, After };
         PositiveAndNegativeVerticalMargin::Values positiveNegativeValues(const Box&, MarginType);
         PositiveAndNegativeVerticalMargin::Values positiveNegativeMarginBefore(const Box&, const UsedVerticalMargin::NonCollapsedValues&);
@@ -138,8 +140,6 @@ private:
 
     class Quirks : public FormattingContext::Quirks {
     public:
-        Quirks(const BlockFormattingContext&);
-
         bool needsStretching(const Box&) const;
         HeightAndMargin stretchedInFlowHeight(const Box&, HeightAndMargin);
 
@@ -148,6 +148,9 @@ private:
         bool shouldIgnoreMarginAfter(const Box&) const;
 
     private:
+        friend class BlockFormattingContext;
+        Quirks(const BlockFormattingContext&);
+
         const BlockFormattingContext& formattingContext() const { return downcast<BlockFormattingContext>(FormattingContext::Quirks::formattingContext()); }
 
     };
index 04efe0d..753191c 100644 (file)
@@ -84,8 +84,7 @@ HeightAndMargin BlockFormattingContext::Geometry::inFlowNonReplacedHeightAndMarg
         // 2. the bottom edge of the bottom (possibly collapsed) margin of its last in-flow child, if the child's bottom margin...
         auto* lastInFlowChild = layoutContainer.lastInFlowChild();
         ASSERT(lastInFlowChild);
-        auto marginCollapse = MarginCollapse(formattingContext());
-        if (!marginCollapse.marginAfterCollapsesWithParentMarginAfter(*lastInFlowChild)) {
+        if (!formattingContext().marginCollapse().marginAfterCollapsesWithParentMarginAfter(*lastInFlowChild)) {
             auto& lastInFlowBoxGeometry = formattingContext().geometryForBox(*lastInFlowChild);
             auto bottomEdgeOfBottomMargin = lastInFlowBoxGeometry.bottom() + (lastInFlowBoxGeometry.hasCollapsedThroughMargin() ? LayoutUnit() : lastInFlowBoxGeometry.marginAfter()); 
             return { bottomEdgeOfBottomMargin - borderAndPaddingTop, nonCollapsedMargin };
@@ -93,7 +92,7 @@ HeightAndMargin BlockFormattingContext::Geometry::inFlowNonReplacedHeightAndMarg
 
         // 3. the bottom border edge of the last in-flow child whose top margin doesn't collapse with the element's bottom margin
         auto* inFlowChild = lastInFlowChild;
-        while (inFlowChild && marginCollapse.marginBeforeCollapsesWithParentMarginAfter(*inFlowChild))
+        while (inFlowChild && formattingContext().marginCollapse().marginBeforeCollapsesWithParentMarginAfter(*inFlowChild))
             inFlowChild = inFlowChild->previousInFlowSibling();
         if (inFlowChild) {
             auto& inFlowDisplayBoxGeometry = formattingContext().geometryForBox(*inFlowChild);
index 1cf5980..4c1e15b 100644 (file)
@@ -89,7 +89,7 @@ HeightAndMargin BlockFormattingContext::Quirks::stretchedInFlowHeight(const Box&
         strechedHeight -= bodyBoxGeometry.verticalBorder() + bodyBoxGeometry.verticalPadding().valueOr(0);
 
         auto nonCollapsedMargin = heightAndMargin.nonCollapsedMargin;
-        auto collapsedMargin = MarginCollapse(formattingContext).collapsedVerticalValues(layoutBox, nonCollapsedMargin);
+        auto collapsedMargin = formattingContext.marginCollapse().collapsedVerticalValues(layoutBox, nonCollapsedMargin);
         totalVerticalMargin = collapsedMargin.before.valueOr(nonCollapsedMargin.before);
         totalVerticalMargin += collapsedMargin.isCollapsedThrough ? nonCollapsedMargin.after : collapsedMargin.after.valueOr(nonCollapsedMargin.after);
     }
index 465748b..07f8bf7 100644 (file)
@@ -71,12 +71,13 @@ private:
 
     class Quirks : public FormattingContext::Quirks {
     public:
-        Quirks(const InlineFormattingContext&);
-
         bool lineDescentNeedsCollapsing(const Line::Content&) const;
         Line::InitialConstraints::HeightAndBaseline lineHeightConstraints(const Box& formattingRoot) const;
 
     private:
+        friend class InlineFormattingContext;
+        Quirks(const InlineFormattingContext&);
+
         const InlineFormattingContext& formattingContext() const { return downcast<InlineFormattingContext>(FormattingContext::Quirks::formattingContext()); }
 
     };
@@ -84,12 +85,13 @@ private:
 
     class Geometry : public FormattingContext::Geometry {
     public:
-        Geometry(const InlineFormattingContext&);
-
         HeightAndMargin inlineBlockHeightAndMargin(const Box&, UsedHorizontalValues) const;
         WidthAndMargin inlineBlockWidthAndMargin(const Box&, UsedHorizontalValues);
 
     private:
+        friend class InlineFormattingContext;
+        Geometry(const InlineFormattingContext&);
+
         const InlineFormattingContext& formattingContext() const { return downcast<InlineFormattingContext>(FormattingContext::Geometry::formattingContext()); }
 
     };
index 97a1446..ea8d3e5 100644 (file)
@@ -45,11 +45,12 @@ public:
 private:
     class Geometry : public FormattingContext::Geometry {
     public:
-        Geometry(const TableFormattingContext&);
-
         HeightAndMargin tableCellHeightAndMargin(const Box&) const;
 
     private:
+        friend class TableFormattingContext;
+        Geometry(const TableFormattingContext&);
+
         const TableFormattingContext& formattingContext() const { return downcast<TableFormattingContext>(FormattingContext::Geometry::formattingContext()); }
     };
     TableFormattingContext::Geometry geometry() const { return Geometry(*this); }