[LFC][BFC] Merge computeInFlowWidth(Height)AndMargin and computeFloatingWidth(Height...
authorzalan@apple.com <zalan@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 4 Sep 2018 21:25:50 +0000 (21:25 +0000)
committerzalan@apple.com <zalan@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 4 Sep 2018 21:25:50 +0000 (21:25 +0000)
https://bugs.webkit.org/show_bug.cgi?id=189271

Reviewed by Antti Koivisto.

This is in preparation for adding min/max-widht(height).

* layout/FormattingContext.cpp:
(WebCore::Layout::FormattingContext::computeFloatingHeightAndMargin const): Deleted.
(WebCore::Layout::FormattingContext::computeFloatingWidthAndMargin const): Deleted.
* layout/FormattingContext.h:
* layout/blockformatting/BlockFormattingContext.cpp:
(WebCore::Layout::BlockFormattingContext::computeWidthAndMargin const):
(WebCore::Layout::BlockFormattingContext::computeHeightAndMargin const):
(WebCore::Layout::BlockFormattingContext::computeInFlowHeightAndMargin const): Deleted.
(WebCore::Layout::BlockFormattingContext::computeInFlowWidthAndMargin const): Deleted.
* layout/blockformatting/BlockFormattingContext.h:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@235639 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

index 742c09b..131a91d 100644 (file)
@@ -1,3 +1,23 @@
+2018-09-04  Zalan Bujtas  <zalan@apple.com>
+
+        [LFC][BFC] Merge computeInFlowWidth(Height)AndMargin and computeFloatingWidth(Height)AndMargin.
+        https://bugs.webkit.org/show_bug.cgi?id=189271
+
+        Reviewed by Antti Koivisto.
+
+        This is in preparation for adding min/max-widht(height).
+
+        * layout/FormattingContext.cpp:
+        (WebCore::Layout::FormattingContext::computeFloatingHeightAndMargin const): Deleted.
+        (WebCore::Layout::FormattingContext::computeFloatingWidthAndMargin const): Deleted.
+        * layout/FormattingContext.h:
+        * layout/blockformatting/BlockFormattingContext.cpp:
+        (WebCore::Layout::BlockFormattingContext::computeWidthAndMargin const):
+        (WebCore::Layout::BlockFormattingContext::computeHeightAndMargin const):
+        (WebCore::Layout::BlockFormattingContext::computeInFlowHeightAndMargin const): Deleted.
+        (WebCore::Layout::BlockFormattingContext::computeInFlowWidthAndMargin const): Deleted.
+        * layout/blockformatting/BlockFormattingContext.h:
+
 2018-09-04  Rob Buis  <rbuis@igalia.com>
 
         Adjust XMLHttpRequest username/password precedence rules
index 6f2c5c7..ba820ce 100644 (file)
@@ -51,25 +51,6 @@ FormattingContext::~FormattingContext()
 {
 }
 
-void FormattingContext::computeFloatingHeightAndMargin(LayoutContext& layoutContext, const Box& layoutBox, Display::Box& displayBox) const
-{
-    auto heightAndMargin = Geometry::floatingHeightAndMargin(layoutContext, layoutBox);
-    displayBox.setContentBoxHeight(heightAndMargin.height);
-    displayBox.moveVertically(heightAndMargin.margin.top);
-    ASSERT(!heightAndMargin.collapsedMargin);
-    displayBox.setVerticalMargin(heightAndMargin.margin);
-    displayBox.setVerticalNonCollapsedMargin(heightAndMargin.margin);
-}
-
-void FormattingContext::computeFloatingWidthAndMargin(LayoutContext& layoutContext, const Box& layoutBox, Display::Box& displayBox) const
-{
-    auto widthAndMargin = Geometry::floatingWidthAndMargin(layoutContext, *this, layoutBox);
-    displayBox.setContentBoxWidth(widthAndMargin.width);
-    displayBox.moveHorizontally(widthAndMargin.margin.left);
-    displayBox.setHorizontalMargin(widthAndMargin.margin);
-    displayBox.setHorizontalNonComputedMargin(widthAndMargin.nonComputedMargin);
-}
-
 void FormattingContext::computeOutOfFlowHorizontalGeometry(LayoutContext& layoutContext, const Box& layoutBox, Display::Box& displayBox) const
 {
     auto horizontalGeometry = Geometry::outOfFlowHorizontalGeometry(layoutContext, *this, layoutBox);
index aeb0e2f..2d65206 100644 (file)
@@ -75,9 +75,6 @@ protected:
     virtual void computeStaticPosition(LayoutContext&, const Box&, Display::Box&) const = 0;
     virtual void computeInFlowPositionedPosition(LayoutContext&, const Box&, Display::Box&) const = 0;
 
-    void computeFloatingHeightAndMargin(LayoutContext&, const Box&, Display::Box&) const;
-    void computeFloatingWidthAndMargin(LayoutContext&, const Box&, Display::Box&) const;
-
     void computeBorderAndPadding(LayoutContext&, const Box&, Display::Box&) const;
 
     void placeInFlowPositionedChildren(LayoutContext&, const Container&) const;
index 1118421..a9cfca9 100644 (file)
@@ -244,46 +244,45 @@ void BlockFormattingContext::computeInFlowPositionedPosition(LayoutContext& layo
 
 void BlockFormattingContext::computeWidthAndMargin(LayoutContext& layoutContext, const Box& layoutBox, Display::Box& displayBox) const
 {
-    if (layoutBox.isInFlow())
-        return computeInFlowWidthAndMargin(layoutContext, layoutBox, displayBox);
+    WidthAndMargin widthAndMargin;
 
-    if (layoutBox.isFloatingPositioned())
-        return computeFloatingWidthAndMargin(layoutContext, layoutBox, displayBox);
+    if (layoutBox.isInFlow())
+        widthAndMargin = Geometry::inFlowWidthAndMargin(layoutContext, layoutBox);
+    else if (layoutBox.isFloatingPositioned())
+        widthAndMargin = FormattingContext::Geometry::floatingWidthAndMargin(layoutContext, *this, layoutBox);
+    else
+        ASSERT_NOT_REACHED();
 
-    ASSERT_NOT_REACHED();
+    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
 {
-    if (layoutBox.isInFlow())
-        return computeInFlowHeightAndMargin(layoutContext, layoutBox, displayBox);
+    HeightAndMargin heightAndMargin;
+    std::optional<LayoutUnit> marginTopOffset;
 
-    if (layoutBox.isFloatingPositioned())
-        return computeFloatingHeightAndMargin(layoutContext, layoutBox, displayBox);
+    if (layoutBox.isInFlow()) {
+        heightAndMargin = Geometry::inFlowHeightAndMargin(layoutContext, layoutBox);
 
-    ASSERT_NOT_REACHED();
-}
+        // If this box has already been moved by the estimated vertical margin, no need to move it again.
+        if (!displayBox.estimatedMarginTop())
+            marginTopOffset = heightAndMargin.collapsedMargin.value_or(heightAndMargin.margin).top;
+    } else if (layoutBox.isFloatingPositioned()) {
+        heightAndMargin = FormattingContext::Geometry::floatingHeightAndMargin(layoutContext, layoutBox);
+        ASSERT(!heightAndMargin.collapsedMargin);
+
+        marginTopOffset = heightAndMargin.margin.top;
+    } else
+        ASSERT_NOT_REACHED();
 
-void BlockFormattingContext::computeInFlowHeightAndMargin(LayoutContext& layoutContext, const Box& layoutBox, Display::Box& displayBox) const
-{
-    auto heightAndMargin = Geometry::inFlowHeightAndMargin(layoutContext, layoutBox);
     displayBox.setContentBoxHeight(heightAndMargin.height);
-    auto marginValue = heightAndMargin.collapsedMargin.value_or(heightAndMargin.margin);
-    displayBox.setVerticalMargin(marginValue);
     displayBox.setVerticalNonCollapsedMargin(heightAndMargin.margin);
-
-    // This box has already been moved by the estimated vertical margin. No need to move it again.
-    if (!displayBox.estimatedMarginTop())
-        displayBox.moveVertically(marginValue.top);
-}
-
-void BlockFormattingContext::computeInFlowWidthAndMargin(LayoutContext& layoutContext, const Box& layoutBox, Display::Box& displayBox) const
-{
-    auto widthAndMargin = Geometry::inFlowWidthAndMargin(layoutContext, layoutBox);
-    displayBox.setContentBoxWidth(widthAndMargin.width);
-    displayBox.moveHorizontally(widthAndMargin.margin.left);
-    displayBox.setHorizontalMargin(widthAndMargin.margin);
-    displayBox.setHorizontalNonComputedMargin(widthAndMargin.nonComputedMargin);
+    displayBox.setVerticalMargin(heightAndMargin.collapsedMargin.value_or(heightAndMargin.margin));
+    if (marginTopOffset)
+        displayBox.moveVertically(*marginTopOffset);
 }
 
 FormattingContext::InstrinsicWidthConstraints BlockFormattingContext::instrinsicWidthConstraints(LayoutContext& layoutContext, const Box& layoutBox) const
index 7d601a1..8fcbb91 100644 (file)
@@ -59,9 +59,8 @@ private:
     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 computeInFlowPositionedPosition(LayoutContext&, const Box&, Display::Box&) const override;
-    void computeInFlowWidthAndMargin(LayoutContext&, const Box&, Display::Box&) const;
-    void computeInFlowHeightAndMargin(LayoutContext&, const Box&, Display::Box&) const;
     void computeEstimatedMarginTop(LayoutContext&, const Box&, Display::Box&) const;
     void computeEstimatedMarginTopForAncestors(LayoutContext&, const Box&) const;