Title: [249908] trunk/Source/WebCore
Revision
249908
Author
za...@apple.com
Date
2019-09-16 11:44:36 -0700 (Mon, 16 Sep 2019)

Log Message

[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:

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (249907 => 249908)


--- trunk/Source/WebCore/ChangeLog	2019-09-16 18:29:49 UTC (rev 249907)
+++ trunk/Source/WebCore/ChangeLog	2019-09-16 18:44:36 UTC (rev 249908)
@@ -1,3 +1,23 @@
+2019-09-16  Zalan Bujtas  <za...@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  <j...@apple.com>
 
         Update feature status for Battery Status API, WebGL 2, and Dialog Element

Modified: trunk/Source/WebCore/layout/FormattingContext.h (249907 => 249908)


--- trunk/Source/WebCore/layout/FormattingContext.h	2019-09-16 18:29:49 UTC (rev 249907)
+++ trunk/Source/WebCore/layout/FormattingContext.h	2019-09-16 18:44:36 UTC (rev 249908)
@@ -93,8 +93,6 @@
     // 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 @@
         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 @@
 
     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; }

Modified: trunk/Source/WebCore/layout/blockformatting/BlockFormattingContext.h (249907 => 249908)


--- trunk/Source/WebCore/layout/blockformatting/BlockFormattingContext.h	2019-09-16 18:29:49 UTC (rev 249907)
+++ trunk/Source/WebCore/layout/blockformatting/BlockFormattingContext.h	2019-09-16 18:44:36 UTC (rev 249908)
@@ -75,8 +75,6 @@
     // 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 @@
         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 @@
     // 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 @@
         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 @@
 
     class Quirks : public FormattingContext::Quirks {
     public:
-        Quirks(const BlockFormattingContext&);
-
         bool needsStretching(const Box&) const;
         HeightAndMargin stretchedInFlowHeight(const Box&, HeightAndMargin);
 
@@ -148,6 +148,9 @@
         bool shouldIgnoreMarginAfter(const Box&) const;
 
     private:
+        friend class BlockFormattingContext;
+        Quirks(const BlockFormattingContext&);
+
         const BlockFormattingContext& formattingContext() const { return downcast<BlockFormattingContext>(FormattingContext::Quirks::formattingContext()); }
 
     };

Modified: trunk/Source/WebCore/layout/blockformatting/BlockFormattingContextGeometry.cpp (249907 => 249908)


--- trunk/Source/WebCore/layout/blockformatting/BlockFormattingContextGeometry.cpp	2019-09-16 18:29:49 UTC (rev 249907)
+++ trunk/Source/WebCore/layout/blockformatting/BlockFormattingContextGeometry.cpp	2019-09-16 18:44:36 UTC (rev 249908)
@@ -84,8 +84,7 @@
         // 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 @@
 
         // 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);

Modified: trunk/Source/WebCore/layout/blockformatting/BlockFormattingContextQuirks.cpp (249907 => 249908)


--- trunk/Source/WebCore/layout/blockformatting/BlockFormattingContextQuirks.cpp	2019-09-16 18:29:49 UTC (rev 249907)
+++ trunk/Source/WebCore/layout/blockformatting/BlockFormattingContextQuirks.cpp	2019-09-16 18:44:36 UTC (rev 249908)
@@ -89,7 +89,7 @@
         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);
     }

Modified: trunk/Source/WebCore/layout/inlineformatting/InlineFormattingContext.h (249907 => 249908)


--- trunk/Source/WebCore/layout/inlineformatting/InlineFormattingContext.h	2019-09-16 18:29:49 UTC (rev 249907)
+++ trunk/Source/WebCore/layout/inlineformatting/InlineFormattingContext.h	2019-09-16 18:44:36 UTC (rev 249908)
@@ -71,12 +71,13 @@
 
     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 @@
 
     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()); }
 
     };

Modified: trunk/Source/WebCore/layout/tableformatting/TableFormattingContext.h (249907 => 249908)


--- trunk/Source/WebCore/layout/tableformatting/TableFormattingContext.h	2019-09-16 18:29:49 UTC (rev 249907)
+++ trunk/Source/WebCore/layout/tableformatting/TableFormattingContext.h	2019-09-16 18:44:36 UTC (rev 249908)
@@ -45,11 +45,12 @@
 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); }
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to