[LFC] Merge height and vertical margin computation
authorzalan@apple.com <zalan@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 7 Jun 2018 15:39:06 +0000 (15:39 +0000)
committerzalan@apple.com <zalan@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 7 Jun 2018 15:39:06 +0000 (15:39 +0000)
https://bugs.webkit.org/show_bug.cgi?id=186394

Reviewed by Antti Koivisto.

To match the spec (and the width/horizontal margin computation). -currently with default values.

* layout/FormattingContext.cpp:
(WebCore::Layout::FormattingContext::computeFloatingHeightAndMargin const):
(WebCore::Layout::FormattingContext::computeOutOfFlowHeight const):
(WebCore::Layout::FormattingContext::computeFloatingHeight const): Deleted.
* layout/FormattingContext.h:
* layout/FormattingContextGeometry.cpp:
(WebCore::Layout::FormattingContext::Geometry::outOfFlowNonReplacedHeightAndMargin):
(WebCore::Layout::FormattingContext::Geometry::outOfFlowReplacedHeightAndMargin):
(WebCore::Layout::FormattingContext::Geometry::floatingNonReplacedHeightAndMargin):
(WebCore::Layout::FormattingContext::Geometry::floatingReplacedHeightAndMargin):
(WebCore::Layout::FormattingContext::Geometry::outOfFlowHeightAndMargin):
(WebCore::Layout::FormattingContext::Geometry::floatingHeightAndMargin):
(WebCore::Layout::FormattingContext::Geometry::inlineReplacedHeightAndMargin):
(WebCore::Layout::outOfFlowNonReplacedHeight): Deleted.
(WebCore::Layout::FormattingContext::Geometry::outOfFlowReplacedHeight): Deleted.
(WebCore::Layout::floatingNonReplacedHeight): Deleted.
(WebCore::Layout::FormattingContext::Geometry::floatingReplacedHeight): Deleted.
(WebCore::Layout::FormattingContext::Geometry::outOfFlowHeight): Deleted.
(WebCore::Layout::FormattingContext::Geometry::floatingHeight): Deleted.
(WebCore::Layout::FormattingContext::Geometry::inlineReplacedHeight): Deleted.
* layout/blockformatting/BlockFormattingContext.cpp:
(WebCore::Layout::BlockFormattingContext::layout const):
(WebCore::Layout::BlockFormattingContext::computeHeightAndMargin const):
(WebCore::Layout::BlockFormattingContext::computeInFlowHeightAndMargin const):
(WebCore::Layout::BlockFormattingContext::computeHeight const): Deleted.
(WebCore::Layout::BlockFormattingContext::computeInFlowHeight const): Deleted.
* layout/blockformatting/BlockFormattingContext.h:
* layout/blockformatting/BlockFormattingContextGeometry.cpp:
(WebCore::Layout::BlockFormattingContext::Geometry::inFlowNonReplacedHeightAndMargin):
(WebCore::Layout::BlockFormattingContext::Geometry::inFlowHeightAndMargin):
(WebCore::Layout::BlockFormattingContext::Geometry::inFlowNonReplacedHeight): Deleted.
(WebCore::Layout::BlockFormattingContext::Geometry::inFlowHeight): Deleted.

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

Source/WebCore/ChangeLog
Source/WebCore/layout/FormattingContext.cpp
Source/WebCore/layout/FormattingContext.h
Source/WebCore/layout/FormattingContextGeometry.cpp
Source/WebCore/layout/blockformatting/BlockFormattingContext.cpp
Source/WebCore/layout/blockformatting/BlockFormattingContext.h
Source/WebCore/layout/blockformatting/BlockFormattingContextGeometry.cpp

index 2eb7e10..824dd7c 100644 (file)
@@ -1,3 +1,45 @@
+2018-06-07  Zalan Bujtas  <zalan@apple.com>
+
+        [LFC] Merge height and vertical margin computation
+        https://bugs.webkit.org/show_bug.cgi?id=186394
+
+        Reviewed by Antti Koivisto.
+
+        To match the spec (and the width/horizontal margin computation). -currently with default values.
+
+        * layout/FormattingContext.cpp:
+        (WebCore::Layout::FormattingContext::computeFloatingHeightAndMargin const):
+        (WebCore::Layout::FormattingContext::computeOutOfFlowHeight const):
+        (WebCore::Layout::FormattingContext::computeFloatingHeight const): Deleted.
+        * layout/FormattingContext.h:
+        * layout/FormattingContextGeometry.cpp:
+        (WebCore::Layout::FormattingContext::Geometry::outOfFlowNonReplacedHeightAndMargin):
+        (WebCore::Layout::FormattingContext::Geometry::outOfFlowReplacedHeightAndMargin):
+        (WebCore::Layout::FormattingContext::Geometry::floatingNonReplacedHeightAndMargin):
+        (WebCore::Layout::FormattingContext::Geometry::floatingReplacedHeightAndMargin):
+        (WebCore::Layout::FormattingContext::Geometry::outOfFlowHeightAndMargin):
+        (WebCore::Layout::FormattingContext::Geometry::floatingHeightAndMargin):
+        (WebCore::Layout::FormattingContext::Geometry::inlineReplacedHeightAndMargin):
+        (WebCore::Layout::outOfFlowNonReplacedHeight): Deleted.
+        (WebCore::Layout::FormattingContext::Geometry::outOfFlowReplacedHeight): Deleted.
+        (WebCore::Layout::floatingNonReplacedHeight): Deleted.
+        (WebCore::Layout::FormattingContext::Geometry::floatingReplacedHeight): Deleted.
+        (WebCore::Layout::FormattingContext::Geometry::outOfFlowHeight): Deleted.
+        (WebCore::Layout::FormattingContext::Geometry::floatingHeight): Deleted.
+        (WebCore::Layout::FormattingContext::Geometry::inlineReplacedHeight): Deleted.
+        * layout/blockformatting/BlockFormattingContext.cpp:
+        (WebCore::Layout::BlockFormattingContext::layout const):
+        (WebCore::Layout::BlockFormattingContext::computeHeightAndMargin const):
+        (WebCore::Layout::BlockFormattingContext::computeInFlowHeightAndMargin const):
+        (WebCore::Layout::BlockFormattingContext::computeHeight const): Deleted.
+        (WebCore::Layout::BlockFormattingContext::computeInFlowHeight const): Deleted.
+        * layout/blockformatting/BlockFormattingContext.h:
+        * layout/blockformatting/BlockFormattingContextGeometry.cpp:
+        (WebCore::Layout::BlockFormattingContext::Geometry::inFlowNonReplacedHeightAndMargin):
+        (WebCore::Layout::BlockFormattingContext::Geometry::inFlowHeightAndMargin):
+        (WebCore::Layout::BlockFormattingContext::Geometry::inFlowNonReplacedHeight): Deleted.
+        (WebCore::Layout::BlockFormattingContext::Geometry::inFlowHeight): Deleted.
+
 2018-06-07  Antti Koivisto  <antti@apple.com>
 
         Don't start service worker fetch when there is substitute data
index a48fce3..51c2623 100644 (file)
@@ -54,9 +54,11 @@ void FormattingContext::computeOutOfFlowPosition(LayoutContext& layoutContext, c
     displayBox.setTopLeft(Geometry::outOfFlowPosition(layoutContext, layoutBox));
 }
 
-void FormattingContext::computeFloatingHeight(LayoutContext& layoutContext, const Box& layoutBox, Display::Box& displayBox) const
+void FormattingContext::computeFloatingHeightAndMargin(LayoutContext& layoutContext, const Box& layoutBox, Display::Box& displayBox) const
 {
-    displayBox.setHeight(Geometry::floatingHeight(layoutContext, layoutBox));
+    auto heightAndMargin = Geometry::floatingHeightAndMargin(layoutContext, layoutBox);
+    displayBox.setHeight(heightAndMargin.height);
+    displayBox.setVerticalMargin(heightAndMargin.margin);
 }
 
 void FormattingContext::computeFloatingWidthAndMargin(LayoutContext& layoutContext, const Box& layoutBox, Display::Box& displayBox) const
@@ -75,7 +77,9 @@ void FormattingContext::computeOutOfFlowWidthAndMargin(LayoutContext& layoutCont
 
 void FormattingContext::computeOutOfFlowHeight(LayoutContext& layoutContext, const Box& layoutBox, Display::Box& displayBox) const
 {
-    displayBox.setHeight(Geometry::outOfFlowHeight(layoutContext, layoutBox));
+    auto heightAndMargin = Geometry::outOfFlowHeightAndMargin(layoutContext, layoutBox);
+    displayBox.setHeight(heightAndMargin.height);
+    displayBox.setVerticalMargin(heightAndMargin.margin);
 }
 
 void FormattingContext::computeBorderAndPadding(LayoutContext& layoutContext, const Box& layoutBox, Display::Box& displayBox) const
index 56c0b03..736376c 100644 (file)
@@ -66,7 +66,7 @@ protected:
     virtual void computeStaticPosition(LayoutContext&, const Box&, Display::Box&) const = 0;
     virtual void computeInFlowPositionedPosition(LayoutContext&, const Box&, Display::Box&) const = 0;
 
-    void computeFloatingHeight(LayoutContext&, const Box&, Display::Box&) const;
+    void computeFloatingHeightAndMargin(LayoutContext&, const Box&, Display::Box&) const;
     void computeFloatingWidthAndMargin(LayoutContext&, const Box&, Display::Box&) const;
 
     void computeBorderAndPadding(LayoutContext&, const Box&, Display::Box&) const;
@@ -86,15 +86,20 @@ protected:
             Display::Box::HorizontalEdges margin;
         };
 
-        static LayoutUnit outOfFlowHeight(LayoutContext&, const Box&);
+        struct HeightAndMargin {
+            LayoutUnit height;
+            Display::Box::VerticalEdges margin;
+        };
+
+        static HeightAndMargin outOfFlowHeightAndMargin(LayoutContext&, const Box&);
         static WidthAndMargin outOfFlowWidthAndMargin(LayoutContext&, const Box&);
 
-        static LayoutUnit floatingHeight(LayoutContext&, const Box&);
+        static HeightAndMargin floatingHeightAndMargin(LayoutContext&, const Box&);
         static WidthAndMargin floatingWidthAndMargin(LayoutContext&, const Box&);
 
         static LayoutPoint outOfFlowPosition(LayoutContext&, const Box&);
 
-        static LayoutUnit inlineReplacedHeight(LayoutContext&, const Box&);
+        static HeightAndMargin inlineReplacedHeightAndMargin(LayoutContext&, const Box&);
         static WidthAndMargin inlineReplacedWidthAndMargin(LayoutContext&, const Box&, std::optional<LayoutUnit> precomputedMarginLeft = { },
             std::optional<LayoutUnit> precomputedMarginRight = { });
 
@@ -102,14 +107,16 @@ protected:
         static std::optional<Display::Box::Edges> computedPadding(LayoutContext&, const Box&);
 
     private:
-        static LayoutUnit outOfFlowReplacedHeight(LayoutContext&, const Box&);
+        static HeightAndMargin outOfFlowReplacedHeightAndMargin(LayoutContext&, const Box&);
         static WidthAndMargin outOfFlowReplacedWidthAndMargin(LayoutContext&, const Box&);
 
+        static HeightAndMargin outOfFlowNonReplacedHeightAndMargin(LayoutContext&, const Box&);
         static WidthAndMargin outOfFlowNonReplacedWidthAndMargin(LayoutContext&, const Box&);
 
-        static LayoutUnit floatingReplacedHeight(LayoutContext&, const Box&);
+        static HeightAndMargin floatingReplacedHeightAndMargin(LayoutContext&, const Box&);
         static WidthAndMargin floatingReplacedWidthAndMargin(LayoutContext&, const Box&);
 
+        static HeightAndMargin floatingNonReplacedHeightAndMargin(LayoutContext&, const Box&);
         static WidthAndMargin floatingNonReplacedWidthAndMargin(LayoutContext&, const Box&);
     };
 
index 355d9b3..6a4fff0 100644 (file)
@@ -64,7 +64,7 @@ static LayoutUnit shrinkToFitWidth(LayoutContext&, const Box&)
     return { };
 }
 
-static LayoutUnit outOfFlowNonReplacedHeight(LayoutContext& layoutContext, const Box& layoutBox)
+FormattingContext::Geometry::HeightAndMargin FormattingContext::Geometry::outOfFlowNonReplacedHeightAndMargin(LayoutContext& layoutContext, const Box& layoutBox)
 {
     ASSERT(layoutBox.isOutOfFlowPositioned() && !layoutBox.replaced());
 
@@ -125,7 +125,7 @@ static LayoutUnit outOfFlowNonReplacedHeight(LayoutContext& layoutContext, const
         ASSERT_NOT_REACHED();
     }
 
-    return computedHeightValue;
+    return { computedHeightValue, { } };
 }
 
 FormattingContext::Geometry::WidthAndMargin FormattingContext::Geometry::outOfFlowNonReplacedWidthAndMargin(LayoutContext& layoutContext, const Box& layoutBox)
@@ -186,13 +186,13 @@ FormattingContext::Geometry::WidthAndMargin FormattingContext::Geometry::outOfFl
     return WidthAndMargin { computedWidthValue, { } };
 }
 
-LayoutUnit FormattingContext::Geometry::outOfFlowReplacedHeight(LayoutContext& layoutContext, const Box& layoutBox)
+FormattingContext::Geometry::HeightAndMargin FormattingContext::Geometry::outOfFlowReplacedHeightAndMargin(LayoutContext& layoutContext, const Box& layoutBox)
 {
     ASSERT(layoutBox.isOutOfFlowPositioned() && layoutBox.replaced());
     // 10.6.5 Absolutely positioned, replaced elements
     //
     // The used value of 'height' is determined as for inline replaced elements.
-    return inlineReplacedHeight(layoutContext, layoutBox);
+    return inlineReplacedHeightAndMargin(layoutContext, layoutBox);
 }
 
 FormattingContext::Geometry::WidthAndMargin FormattingContext::Geometry::outOfFlowReplacedWidthAndMargin(LayoutContext& layoutContext, const Box& layoutBox)
@@ -204,7 +204,7 @@ FormattingContext::Geometry::WidthAndMargin FormattingContext::Geometry::outOfFl
     return inlineReplacedWidthAndMargin(layoutContext, layoutBox);
 }
 
-static LayoutUnit floatingNonReplacedHeight(LayoutContext& layoutContext, const Box& layoutBox)
+FormattingContext::Geometry::HeightAndMargin FormattingContext::Geometry::floatingNonReplacedHeightAndMargin(LayoutContext& layoutContext, const Box& layoutBox)
 {
     ASSERT(layoutBox.isFloatingPositioned() && !layoutBox.replaced());
     // 10.6.6 Complicated cases
@@ -213,7 +213,8 @@ static LayoutUnit floatingNonReplacedHeight(LayoutContext& layoutContext, const
     //
     // If 'height' is 'auto', the height depends on the element's descendants per 10.6.7.
     auto height = layoutBox.style().logicalHeight();
-    return height.isAuto() ? contentHeightForFormattingContextRoot(layoutContext, layoutBox) : LayoutUnit(height.value());
+    auto computedHeightValue = height.isAuto() ? contentHeightForFormattingContextRoot(layoutContext, layoutBox) : LayoutUnit { height.value() };
+    return FormattingContext::Geometry::HeightAndMargin { computedHeightValue, { } };
 }
 
 FormattingContext::Geometry::WidthAndMargin FormattingContext::Geometry::floatingNonReplacedWidthAndMargin(LayoutContext& layoutContext, const Box& layoutBox)
@@ -242,12 +243,12 @@ FormattingContext::Geometry::WidthAndMargin FormattingContext::Geometry::floatin
     return FormattingContext::Geometry::WidthAndMargin { computedWidthValue, { computedMarginLeftValue, computedMarginRightValue } };
 }
 
-LayoutUnit FormattingContext::Geometry::floatingReplacedHeight(LayoutContext& layoutContext, const Box& layoutBox)
+FormattingContext::Geometry::HeightAndMargin FormattingContext::Geometry::floatingReplacedHeightAndMargin(LayoutContext& layoutContext, const Box& layoutBox)
 {
     ASSERT(layoutBox.isFloatingPositioned() && layoutBox.replaced());
     // 10.6.2 Inline replaced elements, block-level replaced elements in normal flow, 'inline-block'
     // replaced elements in normal flow and floating replaced elements
-    return inlineReplacedHeight(layoutContext, layoutBox);
+    return inlineReplacedHeightAndMargin(layoutContext, layoutBox);
 }
 
 FormattingContext::Geometry::WidthAndMargin FormattingContext::Geometry::floatingReplacedWidthAndMargin(LayoutContext& layoutContext, const Box& layoutBox)
@@ -457,13 +458,13 @@ static LayoutPoint outOfFlowReplacedPosition(LayoutContext& layoutContext, const
     return { computedLeftValue, computedTopValue };
 }
 
-LayoutUnit FormattingContext::Geometry::outOfFlowHeight(LayoutContext& layoutContext, const Box& layoutBox)
+FormattingContext::Geometry::HeightAndMargin FormattingContext::Geometry::outOfFlowHeightAndMargin(LayoutContext& layoutContext, const Box& layoutBox)
 {
     ASSERT(layoutBox.isOutOfFlowPositioned());
 
     if (!layoutBox.replaced())
-        return outOfFlowNonReplacedHeight(layoutContext, layoutBox);
-    return outOfFlowReplacedHeight(layoutContext, layoutBox);
+        return outOfFlowNonReplacedHeightAndMargin(layoutContext, layoutBox);
+    return outOfFlowReplacedHeightAndMargin(layoutContext, layoutBox);
 }
 
 FormattingContext::Geometry::WidthAndMargin FormattingContext::Geometry::outOfFlowWidthAndMargin(LayoutContext& layoutContext, const Box& layoutBox)
@@ -475,13 +476,13 @@ FormattingContext::Geometry::WidthAndMargin FormattingContext::Geometry::outOfFl
     return outOfFlowReplacedWidthAndMargin(layoutContext, layoutBox);
 }
 
-LayoutUnit FormattingContext::Geometry::floatingHeight(LayoutContext& layoutContext, const Box& layoutBox)
+FormattingContext::Geometry::HeightAndMargin FormattingContext::Geometry::floatingHeightAndMargin(LayoutContext& layoutContext, const Box& layoutBox)
 {
     ASSERT(layoutBox.isFloatingPositioned());
 
     if (!layoutBox.replaced())
-        return floatingNonReplacedHeight(layoutContext, layoutBox);
-    return floatingReplacedHeight(layoutContext, layoutBox);
+        return floatingNonReplacedHeightAndMargin(layoutContext, layoutBox);
+    return floatingReplacedHeightAndMargin(layoutContext, layoutBox);
 }
 
 FormattingContext::Geometry::WidthAndMargin FormattingContext::Geometry::floatingWidthAndMargin(LayoutContext& layoutContext, const Box& layoutBox)
@@ -502,7 +503,7 @@ LayoutPoint FormattingContext::Geometry::outOfFlowPosition(LayoutContext& layout
     return outOfFlowReplacedPosition(layoutContext, layoutBox);
 }
 
-LayoutUnit FormattingContext::Geometry::inlineReplacedHeight(LayoutContext&, const Box& layoutBox)
+FormattingContext::Geometry::HeightAndMargin FormattingContext::Geometry::inlineReplacedHeightAndMargin(LayoutContext&, const Box& layoutBox)
 {
     ASSERT((layoutBox.isOutOfFlowPositioned() || layoutBox.isFloatingPositioned() || layoutBox.isInFlow()) && layoutBox.replaced());
     // 10.6.2 Inline replaced elements, block-level replaced elements in normal flow, 'inline-block' replaced elements in normal flow and floating replaced elements
@@ -541,7 +542,7 @@ LayoutUnit FormattingContext::Geometry::inlineReplacedHeight(LayoutContext&, con
     } else
         computedHeightValue = height.value();
 
-    return computedHeightValue;
+    return { computedHeightValue, { } };
 }
 
 FormattingContext::Geometry::WidthAndMargin FormattingContext::Geometry::inlineReplacedWidthAndMargin(LayoutContext& layoutContext, const Box& layoutBox,
index 8f58a22..3c42f4c 100644 (file)
@@ -94,7 +94,7 @@ void BlockFormattingContext::layout(LayoutContext& layoutContext, FormattingStat
             auto& layoutBox = layoutPair->layoutBox;
             auto& displayBox = layoutPair->displayBox;
 
-            computeHeight(layoutContext, layoutBox, displayBox);
+            computeHeightAndMargin(layoutContext, layoutBox, displayBox);
             // Adjust position now that we have all the previous floats placed in this context -if needed.
             floatingContext.computePosition(layoutBox, displayBox);
             if (!is<Container>(layoutBox))
@@ -149,20 +149,22 @@ void BlockFormattingContext::computeWidthAndMargin(LayoutContext& layoutContext,
     ASSERT_NOT_REACHED();
 }
 
-void BlockFormattingContext::computeHeight(LayoutContext& layoutContext, const Box& layoutBox, Display::Box& displayBox) const
+void BlockFormattingContext::computeHeightAndMargin(LayoutContext& layoutContext, const Box& layoutBox, Display::Box& displayBox) const
 {
     if (layoutBox.isInFlow())
-        return computeInFlowHeight(layoutContext, layoutBox, displayBox);
+        return computeInFlowHeightAndMargin(layoutContext, layoutBox, displayBox);
 
     if (layoutBox.isFloatingPositioned())
-        return computeFloatingHeight(layoutContext, layoutBox, displayBox);
+        return computeFloatingHeightAndMargin(layoutContext, layoutBox, displayBox);
 
     ASSERT_NOT_REACHED();
 }
 
-void BlockFormattingContext::computeInFlowHeight(LayoutContext& layoutContext, const Box& layoutBox, Display::Box& displayBox) const
+void BlockFormattingContext::computeInFlowHeightAndMargin(LayoutContext& layoutContext, const Box& layoutBox, Display::Box& displayBox) const
 {
-    displayBox.setHeight(Geometry::inFlowHeight(layoutContext, layoutBox));
+    auto heightAndMargin = Geometry::inFlowHeightAndMargin(layoutContext, layoutBox);
+    displayBox.setHeight(heightAndMargin.height);
+    displayBox.setVerticalMargin(heightAndMargin.margin);
 }
 
 void BlockFormattingContext::computeInFlowWidthAndMargin(LayoutContext& layoutContext, const Box& layoutBox, Display::Box& displayBox) const
index 58ab2ed..857fe15 100644 (file)
@@ -52,24 +52,24 @@ public:
 
 private:
     void computeWidthAndMargin(LayoutContext&, const Box&, Display::Box&) const;
-    void computeHeight(LayoutContext&, const Box&, Display::Box&) const;
+    void computeHeightAndMargin(LayoutContext&, const Box&, Display::Box&) const;
 
     void computeStaticPosition(LayoutContext&, const Box&, Display::Box&) const override;
     void computeInFlowPositionedPosition(LayoutContext&, const Box&, Display::Box&) const override;
     void computeInFlowWidthAndMargin(LayoutContext&, const Box&, Display::Box&) const;
-    void computeInFlowHeight(LayoutContext&, const Box&, Display::Box&) const;
+    void computeInFlowHeightAndMargin(LayoutContext&, const Box&, Display::Box&) const;
 
     // This class implements positioning and sizing for boxes participating in a block formatting context.
     class Geometry {
     public:
-        static LayoutUnit inFlowHeight(LayoutContext&, const Box&);
+        static FormattingContext::Geometry::HeightAndMargin inFlowHeightAndMargin(LayoutContext&, const Box&);
         static FormattingContext::Geometry::WidthAndMargin inFlowWidthAndMargin(LayoutContext&, const Box&);
 
         static LayoutPoint staticPosition(LayoutContext&, const Box&);
         static LayoutPoint inFlowPositionedPosition(LayoutContext&, const Box&);
 
     private:
-        static LayoutUnit inFlowNonReplacedHeight(LayoutContext&, const Box&);
+        static FormattingContext::Geometry::HeightAndMargin inFlowNonReplacedHeightAndMargin(LayoutContext&, const Box&);
         static FormattingContext::Geometry::WidthAndMargin inFlowNonReplacedWidthAndMargin(LayoutContext&, const Box&, std::optional<LayoutUnit> precomputedWidth = std::nullopt);
         static FormattingContext::Geometry::WidthAndMargin inFlowReplacedWidthAndMargin(LayoutContext&, const Box&);
     };
index 574b851..a83fe8c 100644 (file)
@@ -54,7 +54,7 @@ static const Container& initialContainingBlock(const Box& layoutBox)
     return *containingBlock;
 }
 
-LayoutUnit BlockFormattingContext::Geometry::inFlowNonReplacedHeight(LayoutContext& layoutContext, const Box& layoutBox)
+FormattingContext::Geometry::HeightAndMargin BlockFormattingContext::Geometry::inFlowNonReplacedHeightAndMargin(LayoutContext& layoutContext, const Box& layoutBox)
 {
     ASSERT(layoutBox.isInFlow() && !layoutBox.replaced());
 
@@ -108,9 +108,9 @@ LayoutUnit BlockFormattingContext::Geometry::inFlowNonReplacedHeight(LayoutConte
 
     auto computedHeight = compute();
     if (!isStretchedToViewport(layoutContext, layoutBox))
-        return computedHeight;
+        return { computedHeight, { } };
     auto initialContainingBlockHeight = layoutContext.displayBoxForLayoutBox(initialContainingBlock(layoutBox))->contentBox().height();
-    return std::max(computedHeight, initialContainingBlockHeight);
+    return { std::max(computedHeight, initialContainingBlockHeight), { } };
 }
 
 FormattingContext::Geometry::WidthAndMargin BlockFormattingContext::Geometry::inFlowNonReplacedWidthAndMargin(LayoutContext& layoutContext, const Box& layoutBox,
@@ -319,15 +319,15 @@ LayoutPoint BlockFormattingContext::Geometry::inFlowPositionedPosition(LayoutCon
     return { displayBox.left() + leftDelta, displayBox.top() + topDelta };
 }
 
-LayoutUnit BlockFormattingContext::Geometry::inFlowHeight(LayoutContext& layoutContext, const Box& layoutBox)
+FormattingContext::Geometry::HeightAndMargin BlockFormattingContext::Geometry::inFlowHeightAndMargin(LayoutContext& layoutContext, const Box& layoutBox)
 {
     ASSERT(layoutBox.isInFlow());
 
     if (!layoutBox.replaced())
-        return inFlowNonReplacedHeight(layoutContext, layoutBox);
+        return inFlowNonReplacedHeightAndMargin(layoutContext, layoutBox);
     // 10.6.2 Inline replaced elements, block-level replaced elements in normal flow, 'inline-block'
     // replaced elements in normal flow and floating replaced elements
-    return FormattingContext::Geometry::inlineReplacedHeight(layoutContext, layoutBox);
+    return FormattingContext::Geometry::inlineReplacedHeightAndMargin(layoutContext, layoutBox);
 }
 
 FormattingContext::Geometry::WidthAndMargin BlockFormattingContext::Geometry::inFlowWidthAndMargin(LayoutContext& layoutContext, const Box& layoutBox)