[LFC] Drop Display:Box from FormattingContext::compute* functions
authorzalan@apple.com <zalan@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 5 Sep 2018 17:54:05 +0000 (17:54 +0000)
committerzalan@apple.com <zalan@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 5 Sep 2018 17:54:05 +0000 (17:54 +0000)
https://bugs.webkit.org/show_bug.cgi?id=189309

Reviewed by Antti Koivisto.

They are redundant and could get out of sync.

* layout/FormattingContext.cpp:
(WebCore::Layout::FormattingContext::computeOutOfFlowHorizontalGeometry const):
(WebCore::Layout::FormattingContext::computeOutOfFlowVerticalGeometry const):
(WebCore::Layout::FormattingContext::computeBorderAndPadding const):
(WebCore::Layout::FormattingContext::placeInFlowPositionedChildren const):
(WebCore::Layout::FormattingContext::layoutOutOfFlowDescendants const):
* layout/FormattingContext.h:
* layout/blockformatting/BlockFormattingContext.cpp:
(WebCore::Layout::BlockFormattingContext::layout const):
(WebCore::Layout::BlockFormattingContext::layoutFormattingContextRoot const):
(WebCore::Layout::BlockFormattingContext::computeStaticPosition const):
(WebCore::Layout::BlockFormattingContext::computeEstimatedMarginTop const):
(WebCore::Layout::BlockFormattingContext::computeEstimatedMarginTopForAncestors const):
(WebCore::Layout::BlockFormattingContext::computeFloatingPosition const):
(WebCore::Layout::BlockFormattingContext::computePositionToAvoidFloats const):
(WebCore::Layout::BlockFormattingContext::computeVerticalPositionForFloatClear const):
(WebCore::Layout::BlockFormattingContext::computeInFlowPositionedPosition const):
(WebCore::Layout::BlockFormattingContext::computeWidthAndMargin const):
(WebCore::Layout::BlockFormattingContext::computeHeightAndMargin const):
* layout/blockformatting/BlockFormattingContext.h:
* layout/inlineformatting/InlineFormattingContext.cpp:
(WebCore::Layout::InlineFormattingContext::computeStaticPosition const):
(WebCore::Layout::InlineFormattingContext::computeInFlowPositionedPosition const):
* layout/inlineformatting/InlineFormattingContext.h:

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

Source/WebCore/ChangeLog
Source/WebCore/layout/FormattingContext.cpp
Source/WebCore/layout/FormattingContext.h
Source/WebCore/layout/blockformatting/BlockFormattingContext.cpp
Source/WebCore/layout/blockformatting/BlockFormattingContext.h
Source/WebCore/layout/inlineformatting/InlineFormattingContext.cpp
Source/WebCore/layout/inlineformatting/InlineFormattingContext.h

index 31efd2a..51cbf46 100644 (file)
@@ -1,3 +1,37 @@
+2018-09-05  Zalan Bujtas  <zalan@apple.com>
+
+        [LFC] Drop Display:Box from FormattingContext::compute* functions
+        https://bugs.webkit.org/show_bug.cgi?id=189309
+
+        Reviewed by Antti Koivisto.
+
+        They are redundant and could get out of sync.
+
+        * layout/FormattingContext.cpp:
+        (WebCore::Layout::FormattingContext::computeOutOfFlowHorizontalGeometry const):
+        (WebCore::Layout::FormattingContext::computeOutOfFlowVerticalGeometry const):
+        (WebCore::Layout::FormattingContext::computeBorderAndPadding const):
+        (WebCore::Layout::FormattingContext::placeInFlowPositionedChildren const):
+        (WebCore::Layout::FormattingContext::layoutOutOfFlowDescendants const):
+        * layout/FormattingContext.h:
+        * layout/blockformatting/BlockFormattingContext.cpp:
+        (WebCore::Layout::BlockFormattingContext::layout const):
+        (WebCore::Layout::BlockFormattingContext::layoutFormattingContextRoot const):
+        (WebCore::Layout::BlockFormattingContext::computeStaticPosition const):
+        (WebCore::Layout::BlockFormattingContext::computeEstimatedMarginTop const):
+        (WebCore::Layout::BlockFormattingContext::computeEstimatedMarginTopForAncestors const):
+        (WebCore::Layout::BlockFormattingContext::computeFloatingPosition const):
+        (WebCore::Layout::BlockFormattingContext::computePositionToAvoidFloats const):
+        (WebCore::Layout::BlockFormattingContext::computeVerticalPositionForFloatClear const):
+        (WebCore::Layout::BlockFormattingContext::computeInFlowPositionedPosition const):
+        (WebCore::Layout::BlockFormattingContext::computeWidthAndMargin const):
+        (WebCore::Layout::BlockFormattingContext::computeHeightAndMargin const):
+        * layout/blockformatting/BlockFormattingContext.h:
+        * layout/inlineformatting/InlineFormattingContext.cpp:
+        (WebCore::Layout::InlineFormattingContext::computeStaticPosition const):
+        (WebCore::Layout::InlineFormattingContext::computeInFlowPositionedPosition const):
+        * layout/inlineformatting/InlineFormattingContext.h:
+
 2018-09-05  Jer Noble  <jer.noble@apple.com>
 
         Add MediaCapabilities as an Experimental Feature
index ba820ce..614124c 100644 (file)
@@ -51,18 +51,22 @@ FormattingContext::~FormattingContext()
 {
 }
 
-void FormattingContext::computeOutOfFlowHorizontalGeometry(LayoutContext& layoutContext, const Box& layoutBox, Display::Box& displayBox) const
+void FormattingContext::computeOutOfFlowHorizontalGeometry(LayoutContext& layoutContext, const Box& layoutBox) const
 {
     auto horizontalGeometry = Geometry::outOfFlowHorizontalGeometry(layoutContext, *this, layoutBox);
+
+    auto& displayBox = *layoutContext.displayBoxForLayoutBox(layoutBox);
     displayBox.setLeft(horizontalGeometry.left + horizontalGeometry.widthAndMargin.margin.left);
     displayBox.setContentBoxWidth(horizontalGeometry.widthAndMargin.width);
     displayBox.setHorizontalMargin(horizontalGeometry.widthAndMargin.margin);
     displayBox.setHorizontalNonComputedMargin(horizontalGeometry.widthAndMargin.nonComputedMargin);
 }
 
-void FormattingContext::computeOutOfFlowVerticalGeometry(LayoutContext& layoutContext, const Box& layoutBox, Display::Box& displayBox) const
+void FormattingContext::computeOutOfFlowVerticalGeometry(LayoutContext& layoutContext, const Box& layoutBox) const
 {
     auto verticalGeometry = Geometry::outOfFlowVerticalGeometry(layoutContext, layoutBox);
+
+    auto& displayBox = *layoutContext.displayBoxForLayoutBox(layoutBox);
     displayBox.setTop(verticalGeometry.top + verticalGeometry.heightAndMargin.margin.top);
     displayBox.setContentBoxHeight(verticalGeometry.heightAndMargin.height);
     ASSERT(!verticalGeometry.heightAndMargin.collapsedMargin);
@@ -70,8 +74,9 @@ void FormattingContext::computeOutOfFlowVerticalGeometry(LayoutContext& layoutCo
     displayBox.setVerticalNonCollapsedMargin(verticalGeometry.heightAndMargin.margin);
 }
 
-void FormattingContext::computeBorderAndPadding(LayoutContext& layoutContext, const Box& layoutBox, Display::Box& displayBox) const
+void FormattingContext::computeBorderAndPadding(LayoutContext& layoutContext, const Box& layoutBox) const
 {
+    auto& displayBox = *layoutContext.displayBoxForLayoutBox(layoutBox);
     displayBox.setBorder(Geometry::computedBorder(layoutContext, layoutBox));
     displayBox.setPadding(Geometry::computedPadding(layoutContext, layoutBox));
 }
@@ -86,7 +91,7 @@ void FormattingContext::placeInFlowPositionedChildren(LayoutContext& layoutConte
     for (auto& layoutBox : childrenOfType<Box>(container)) {
         if (!layoutBox.isInFlowPositioned())
             continue;
-        computeInFlowPositionedPosition(layoutContext, layoutBox, *layoutContext.displayBoxForLayoutBox(layoutBox));
+        computeInFlowPositionedPosition(layoutContext, layoutBox);
     }
     LOG_WITH_STREAM(FormattingContextLayout, stream << "End: move in-flow positioned children -> context: " << &layoutContext << " parent: " << &container);
 }
@@ -108,17 +113,17 @@ void FormattingContext::layoutOutOfFlowDescendants(LayoutContext& layoutContext,
 
     for (auto& outOfFlowBox : container.outOfFlowDescendants()) {
         auto& layoutBox = *outOfFlowBox;
-        auto& displayBox = layoutContext.createDisplayBox(layoutBox);
+        layoutContext.createDisplayBox(layoutBox);
 
         ASSERT(layoutBox.establishesFormattingContext());
         auto formattingContext = layoutContext.formattingContext(layoutBox);
 
-        computeBorderAndPadding(layoutContext, layoutBox, displayBox);
-        computeOutOfFlowHorizontalGeometry(layoutContext, layoutBox, displayBox);
+        computeBorderAndPadding(layoutContext, layoutBox);
+        computeOutOfFlowHorizontalGeometry(layoutContext, layoutBox);
 
         formattingContext->layout(layoutContext, layoutContext.establishedFormattingState(layoutBox));
 
-        computeOutOfFlowVerticalGeometry(layoutContext, layoutBox, displayBox);
+        computeOutOfFlowVerticalGeometry(layoutContext, layoutBox);
         layoutOutOfFlowDescendants(layoutContext, layoutBox);
     }
     LOG_WITH_STREAM(FormattingContextLayout, stream << "End: layout out-of-flow descendants -> context: " << &layoutContext << " root: " << &root());
index 11c7717..114a431 100644 (file)
@@ -64,18 +64,14 @@ public:
     static Position mapCoordinateToAncestor(const LayoutContext&, Position, const Container& containingBlock, const Container& ancestor);
 
 protected:
-    struct BoxPair {
-        const Box& layout;
-        Display::Box& display;
-    };
-    using LayoutQueue = Vector<std::unique_ptr<BoxPair>>;
+    using LayoutQueue = Vector<const Box*>;
 
     const Box& root() const { return *m_root; }
 
-    virtual void computeStaticPosition(LayoutContext&, const Box&, Display::Box&) const = 0;
-    virtual void computeInFlowPositionedPosition(LayoutContext&, const Box&, Display::Box&) const = 0;
+    virtual void computeStaticPosition(LayoutContext&, const Box&) const = 0;
+    virtual void computeInFlowPositionedPosition(LayoutContext&, const Box&) const = 0;
 
-    void computeBorderAndPadding(LayoutContext&, const Box&, Display::Box&) const;
+    void computeBorderAndPadding(LayoutContext&, const Box&) const;
 
     void placeInFlowPositionedChildren(LayoutContext&, const Container&) const;
 
@@ -123,8 +119,8 @@ protected:
     };
 
 private:
-    void computeOutOfFlowVerticalGeometry(LayoutContext&, const Box&, Display::Box&) const;
-    void computeOutOfFlowHorizontalGeometry(LayoutContext&, const Box&, Display::Box&) const;
+    void computeOutOfFlowVerticalGeometry(LayoutContext&, const Box&) const;
+    void computeOutOfFlowHorizontalGeometry(LayoutContext&, const Box&) const;
 
     WeakPtr<Box> m_root;
 };
index b9640e8..89464ac 100644 (file)
@@ -65,8 +65,10 @@ void BlockFormattingContext::layout(LayoutContext& layoutContext, FormattingStat
     FloatingContext floatingContext(formattingState.floatingState());
     // This is a post-order tree traversal layout.
     // The root container layout is done in the formatting context it lives in, not that one it creates, so let's start with the first child.
-    if (auto* firstChild = formattingRoot.firstInFlowOrFloatingChild())
-        layoutQueue.append(std::make_unique<BoxPair>(BoxPair {*firstChild, layoutContext.createDisplayBox(*firstChild)}));
+    if (auto* firstChild = formattingRoot.firstInFlowOrFloatingChild()) {
+        layoutQueue.append(firstChild);
+        layoutContext.createDisplayBox(*firstChild);
+    }
     // 1. Go all the way down to the leaf node
     // 2. Compute static position and width as we traverse down
     // 3. As we climb back on the tree, compute height and finialize position
@@ -74,53 +76,52 @@ void BlockFormattingContext::layout(LayoutContext& layoutContext, FormattingStat
     while (!layoutQueue.isEmpty()) {
         // Traverse down on the descendants and compute width/static position until we find a leaf node.
         while (true) {
-            auto& boxPair = *layoutQueue.last();
-            auto& layoutBox = boxPair.layout;
-            auto& displayBox = boxPair.display;
+            auto& layoutBox = *layoutQueue.last();
 
             if (layoutBox.establishesFormattingContext()) {
-                layoutFormattingContextRoot(layoutContext, floatingContext, formattingState, layoutBox, displayBox);
+                layoutFormattingContextRoot(layoutContext, floatingContext, formattingState, layoutBox);
                 layoutQueue.removeLast();
                 // Since this box is a formatting context root, it takes care of its entire subtree.
                 // Continue with next sibling if exists.
                 if (!layoutBox.nextInFlowOrFloatingSibling())
                     break;
                 auto* nextSibling = layoutBox.nextInFlowOrFloatingSibling();
-                layoutQueue.append(std::make_unique<BoxPair>(BoxPair {*nextSibling, layoutContext.createDisplayBox(*nextSibling)}));
+                layoutQueue.append(nextSibling);
+                layoutContext.createDisplayBox(*nextSibling);
                 continue;
             }
 
             LOG_WITH_STREAM(FormattingContextLayout, stream << "[Compute] -> [Position][Border][Padding][Width][Margin] -> for layoutBox(" << &layoutBox << ")");
-            computeStaticPosition(layoutContext, layoutBox, displayBox);
-            computeBorderAndPadding(layoutContext, layoutBox, displayBox);
-            computeWidthAndMargin(layoutContext, layoutBox, displayBox);
+            computeStaticPosition(layoutContext, layoutBox);
+            computeBorderAndPadding(layoutContext, layoutBox);
+            computeWidthAndMargin(layoutContext, layoutBox);
             if (!is<Container>(layoutBox) || !downcast<Container>(layoutBox).hasInFlowOrFloatingChild())
                 break;
-            auto& firstChild = *downcast<Container>(layoutBox).firstInFlowOrFloatingChild();
-            layoutQueue.append(std::make_unique<BoxPair>(BoxPair {firstChild, layoutContext.createDisplayBox(firstChild)}));
+            auto* firstChild = downcast<Container>(layoutBox).firstInFlowOrFloatingChild();
+            layoutQueue.append(firstChild);
+            layoutContext.createDisplayBox(*firstChild);
         }
 
         // Climb back on the ancestors and compute height/final position.
         while (!layoutQueue.isEmpty()) {
             // All inflow descendants (if there are any) are laid out by now. Let's compute the box's height.
-            auto boxPair = layoutQueue.takeLast();
-            auto& layoutBox = boxPair->layout;
-            auto& displayBox = boxPair->display;
+            auto& layoutBox = *layoutQueue.takeLast();
 
             LOG_WITH_STREAM(FormattingContextLayout, stream << "[Compute] -> [Height][Margin] -> for layoutBox(" << &layoutBox << ")");
             // Formatting root boxes are special-cased and they don't come here.
             ASSERT(!layoutBox.establishesFormattingContext());
-            computeHeightAndMargin(layoutContext, layoutBox, displayBox);
+            computeHeightAndMargin(layoutContext, layoutBox);
             // Finalize position with clearance.
             if (layoutBox.hasFloatClear())
-                computeVerticalPositionForFloatClear(layoutContext, floatingContext, layoutBox, displayBox);
+                computeVerticalPositionForFloatClear(layoutContext, floatingContext, layoutBox);
             if (!is<Container>(layoutBox))
                 continue;
             auto& container = downcast<Container>(layoutBox);
             // Move in-flow positioned children to their final position.
             placeInFlowPositionedChildren(layoutContext, container);
             if (auto* nextSibling = container.nextInFlowOrFloatingSibling()) {
-                layoutQueue.append(std::make_unique<BoxPair>(BoxPair {*nextSibling, layoutContext.createDisplayBox(*nextSibling)}));
+                layoutQueue.append(nextSibling);
+                layoutContext.createDisplayBox(*nextSibling);
                 break;
             }
         }
@@ -130,13 +131,13 @@ void BlockFormattingContext::layout(LayoutContext& layoutContext, FormattingStat
     LOG_WITH_STREAM(FormattingContextLayout, stream << "[End] -> block formatting context -> layout context(" << &layoutContext << ") formatting root(" << &root() << ")");
 }
 
-void BlockFormattingContext::layoutFormattingContextRoot(LayoutContext& layoutContext, FloatingContext& floatingContext, FormattingState&, const Box& layoutBox, Display::Box& displayBox) const
+void BlockFormattingContext::layoutFormattingContextRoot(LayoutContext& layoutContext, FloatingContext& floatingContext, FormattingState&, const Box& layoutBox) const
 {
     // Start laying out this formatting root in the formatting contenxt it lives in.
     LOG_WITH_STREAM(FormattingContextLayout, stream << "[Compute] -> [Position][Border][Padding][Width][Margin] -> for layoutBox(" << &layoutBox << ")");
-    computeStaticPosition(layoutContext, layoutBox, displayBox);
-    computeBorderAndPadding(layoutContext, layoutBox, displayBox);
-    computeWidthAndMargin(layoutContext, layoutBox, displayBox);
+    computeStaticPosition(layoutContext, layoutBox);
+    computeBorderAndPadding(layoutContext, layoutBox);
+    computeWidthAndMargin(layoutContext, layoutBox);
 
     // Swich over to the new formatting context (the one that the root creates).
     auto formattingContext = layoutContext.formattingContext(layoutBox);
@@ -144,28 +145,30 @@ void BlockFormattingContext::layoutFormattingContextRoot(LayoutContext& layoutCo
 
     // Come back and finalize the root's geometry.
     LOG_WITH_STREAM(FormattingContextLayout, stream << "[Compute] -> [Height][Margin] -> for layoutBox(" << &layoutBox << ")");
-    computeHeightAndMargin(layoutContext, layoutBox, displayBox);
+    computeHeightAndMargin(layoutContext, layoutBox);
 
     // Float related final positioning.
     if (layoutBox.isFloatingPositioned())
-        computeFloatingPosition(layoutContext, floatingContext, layoutBox, displayBox);
+        computeFloatingPosition(layoutContext, floatingContext, layoutBox);
     else if (layoutBox.hasFloatClear())
-        computeVerticalPositionForFloatClear(layoutContext, floatingContext, layoutBox, displayBox);
+        computeVerticalPositionForFloatClear(layoutContext, floatingContext, layoutBox);
     else
-        computePositionToAvoidFloats(layoutContext, floatingContext, layoutBox, displayBox);
+        computePositionToAvoidFloats(layoutContext, floatingContext, layoutBox);
 
     // Now that we computed the root's height, we can go back and layout the out-of-flow descedants (if any).
     formattingContext->layoutOutOfFlowDescendants(layoutContext, layoutBox);
 }
 
-void BlockFormattingContext::computeStaticPosition(LayoutContext& layoutContext, const Box& layoutBox, Display::Box& displayBox) const
+void BlockFormattingContext::computeStaticPosition(LayoutContext& layoutContext, const Box& layoutBox) const
 {
-    displayBox.setTopLeft(Geometry::staticPosition(layoutContext, layoutBox));
+    layoutContext.displayBoxForLayoutBox(layoutBox)->setTopLeft(Geometry::staticPosition(layoutContext, layoutBox));
 }
 
-void BlockFormattingContext::computeEstimatedMarginTop(LayoutContext& layoutContext, const Box& layoutBox, Display::Box& displayBox) const
+void BlockFormattingContext::computeEstimatedMarginTop(LayoutContext& layoutContext, const Box& layoutBox) const
 {
     auto estimatedMarginTop = Geometry::estimatedMarginTop(layoutContext, layoutBox);
+
+    auto& displayBox = *layoutContext.displayBoxForLayoutBox(layoutBox);
     displayBox.setEstimatedMarginTop(estimatedMarginTop);
     displayBox.moveVertically(estimatedMarginTop);
 }
@@ -192,13 +195,14 @@ void BlockFormattingContext::computeEstimatedMarginTopForAncestors(LayoutContext
         if (displayBox->estimatedMarginTop())
             return;
 
-        computeEstimatedMarginTop(layoutContext, *ancestor, *displayBox);
+        computeEstimatedMarginTop(layoutContext, *ancestor);
     }
 }
 
-void BlockFormattingContext::computeFloatingPosition(LayoutContext& layoutContext, FloatingContext& floatingContext, const Box& layoutBox, Display::Box& displayBox) const
+void BlockFormattingContext::computeFloatingPosition(LayoutContext& layoutContext, FloatingContext& floatingContext, const Box& layoutBox) const
 {
     ASSERT(layoutBox.isFloatingPositioned());
+    auto& displayBox = *layoutContext.displayBoxForLayoutBox(layoutBox);
     // 8.3.1 Collapsing margins
     // In block formatting context margins between a floated box and any other box do not collapse.
     // Adjust the static position by using the previous inflow box's non-collapsed margin.
@@ -211,7 +215,7 @@ void BlockFormattingContext::computeFloatingPosition(LayoutContext& layoutContex
     floatingContext.floatingState().append(layoutBox);
 }
 
-void BlockFormattingContext::computePositionToAvoidFloats(LayoutContext& layoutContext, FloatingContext& floatingContext, const Box& layoutBox, Display::Box& displayBox) const
+void BlockFormattingContext::computePositionToAvoidFloats(LayoutContext& layoutContext, FloatingContext& floatingContext, const Box& layoutBox) const
 {
     // Formatting context roots avoid floats.
     ASSERT(layoutBox.establishesBlockFormattingContext());
@@ -223,10 +227,10 @@ void BlockFormattingContext::computePositionToAvoidFloats(LayoutContext& layoutC
 
     computeEstimatedMarginTopForAncestors(layoutContext, layoutBox);
     if (auto adjustedPosition = floatingContext.positionForFloatAvoiding(layoutBox))
-        displayBox.setTopLeft(*adjustedPosition);
+        layoutContext.displayBoxForLayoutBox(layoutBox)->setTopLeft(*adjustedPosition);
 }
 
-void BlockFormattingContext::computeVerticalPositionForFloatClear(LayoutContext& layoutContext, const FloatingContext& floatingContext, const Box& layoutBox, Display::Box& displayBox) const
+void BlockFormattingContext::computeVerticalPositionForFloatClear(LayoutContext& layoutContext, const FloatingContext& floatingContext, const Box& layoutBox) const
 {
     ASSERT(layoutBox.hasFloatClear());
     if (floatingContext.floatingState().isEmpty())
@@ -234,15 +238,15 @@ void BlockFormattingContext::computeVerticalPositionForFloatClear(LayoutContext&
 
     computeEstimatedMarginTopForAncestors(layoutContext, layoutBox);
     if (auto verticalPositionWithClearance = floatingContext.verticalPositionWithClearance(layoutBox))
-        displayBox.setTop(*verticalPositionWithClearance);
+        layoutContext.displayBoxForLayoutBox(layoutBox)->setTop(*verticalPositionWithClearance);
 }
 
-void BlockFormattingContext::computeInFlowPositionedPosition(LayoutContext& layoutContext, const Box& layoutBox, Display::Box& displayBox) const
+void BlockFormattingContext::computeInFlowPositionedPosition(LayoutContext& layoutContext, const Box& layoutBox) const
 {
-    displayBox.setTopLeft(Geometry::inFlowPositionedPosition(layoutContext, layoutBox));
+    layoutContext.displayBoxForLayoutBox(layoutBox)->setTopLeft(Geometry::inFlowPositionedPosition(layoutContext, layoutBox));
 }
 
-void BlockFormattingContext::computeWidthAndMargin(LayoutContext& layoutContext, const Box& layoutBox, Display::Box& displayBox) const
+void BlockFormattingContext::computeWidthAndMargin(LayoutContext& layoutContext, const Box& layoutBox) const
 {
     WidthAndMargin widthAndMargin;
 
@@ -253,16 +257,18 @@ void BlockFormattingContext::computeWidthAndMargin(LayoutContext& layoutContext,
     else
         ASSERT_NOT_REACHED();
 
+    auto& displayBox = *layoutContext.displayBoxForLayoutBox(layoutBox);
     displayBox.setContentBoxWidth(widthAndMargin.width);
     displayBox.moveHorizontally(widthAndMargin.margin.left);
     displayBox.setHorizontalMargin(widthAndMargin.margin);
     displayBox.setHorizontalNonComputedMargin(widthAndMargin.nonComputedMargin);
 }
 
-void BlockFormattingContext::computeHeightAndMargin(LayoutContext& layoutContext, const Box& layoutBox, Display::Box& displayBox) const
+void BlockFormattingContext::computeHeightAndMargin(LayoutContext& layoutContext, const Box& layoutBox) const
 {
     HeightAndMargin heightAndMargin;
     std::optional<LayoutUnit> marginTopOffset;
+    auto& displayBox = *layoutContext.displayBoxForLayoutBox(layoutBox);
 
     if (layoutBox.isInFlow()) {
         heightAndMargin = Geometry::inFlowHeightAndMargin(layoutContext, layoutBox);
index a1ae7e2..9892561 100644 (file)
@@ -50,18 +50,18 @@ public:
     void layout(LayoutContext&, FormattingState&) const override;
 
 private:
-    void layoutFormattingContextRoot(LayoutContext&, FloatingContext&, FormattingState&, const Box&, Display::Box&) const;
+    void layoutFormattingContextRoot(LayoutContext&, FloatingContext&, FormattingState&, const Box&) const;
 
-    void computeWidthAndMargin(LayoutContext&, const Box&, Display::Box&) const;
-    void computeHeightAndMargin(LayoutContext&, const Box&, Display::Box&) const;
+    void computeWidthAndMargin(LayoutContext&, const Box&) const;
+    void computeHeightAndMargin(LayoutContext&, const Box&) const;
 
-    void computeStaticPosition(LayoutContext&, const Box&, Display::Box&) const override;
-    void computeFloatingPosition(LayoutContext&, FloatingContext&, const Box&, Display::Box&) const;
-    void computePositionToAvoidFloats(LayoutContext&, FloatingContext&, const Box&, Display::Box&) const;
-    void computeVerticalPositionForFloatClear(LayoutContext&, const FloatingContext&, const Box&, Display::Box&) const;
+    void computeStaticPosition(LayoutContext&, const Box&) const override;
+    void computeFloatingPosition(LayoutContext&, FloatingContext&, const Box&) const;
+    void computePositionToAvoidFloats(LayoutContext&, FloatingContext&, const Box&) const;
+    void computeVerticalPositionForFloatClear(LayoutContext&, const FloatingContext&, const Box&) const;
 
-    void computeInFlowPositionedPosition(LayoutContext&, const Box&, Display::Box&) const override;
-    void computeEstimatedMarginTop(LayoutContext&, const Box&, Display::Box&) const;
+    void computeInFlowPositionedPosition(LayoutContext&, const Box&) const override;
+    void computeEstimatedMarginTop(LayoutContext&, const Box&) const;
     void computeEstimatedMarginTopForAncestors(LayoutContext&, const Box&) const;
 
     InstrinsicWidthConstraints instrinsicWidthConstraints(LayoutContext&, const Box&) const override;
index e3f6aa2..e16c228 100644 (file)
@@ -102,11 +102,11 @@ void InlineFormattingContext::layout(LayoutContext& layoutContext, FormattingSta
     LOG_WITH_STREAM(FormattingContextLayout, stream << "[End] -> inline formatting context -> layout context(" << &layoutContext << ") formatting root(" << &root() << ")");
 }
 
-void InlineFormattingContext::computeStaticPosition(LayoutContext&, const Box&, Display::Box&) const
+void InlineFormattingContext::computeStaticPosition(LayoutContext&, const Box&) const
 {
 }
 
-void InlineFormattingContext::computeInFlowPositionedPosition(LayoutContext&, const Box&, Display::Box&) const
+void InlineFormattingContext::computeInFlowPositionedPosition(LayoutContext&, const Box&) const
 {
 }
 
index d704335..0266df3 100644 (file)
@@ -46,8 +46,8 @@ public:
     void layout(LayoutContext&, FormattingState&) const override;
 
 private:
-    void computeStaticPosition(LayoutContext&, const Box&, Display::Box&) const override;
-    void computeInFlowPositionedPosition(LayoutContext&, const Box&, Display::Box&) const override;
+    void computeStaticPosition(LayoutContext&, const Box&) const override;
+    void computeInFlowPositionedPosition(LayoutContext&, const Box&) const override;
 
     InstrinsicWidthConstraints instrinsicWidthConstraints(LayoutContext&, const Box&) const override;
 };