Title: [235639] trunk/Source/WebCore
Revision
235639
Author
[email protected]
Date
2018-09-04 14:25:50 -0700 (Tue, 04 Sep 2018)

Log Message

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

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (235638 => 235639)


--- trunk/Source/WebCore/ChangeLog	2018-09-04 21:23:26 UTC (rev 235638)
+++ trunk/Source/WebCore/ChangeLog	2018-09-04 21:25:50 UTC (rev 235639)
@@ -1,3 +1,23 @@
+2018-09-04  Zalan Bujtas  <[email protected]>
+
+        [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  <[email protected]>
 
         Adjust XMLHttpRequest username/password precedence rules

Modified: trunk/Source/WebCore/layout/FormattingContext.cpp (235638 => 235639)


--- trunk/Source/WebCore/layout/FormattingContext.cpp	2018-09-04 21:23:26 UTC (rev 235638)
+++ trunk/Source/WebCore/layout/FormattingContext.cpp	2018-09-04 21:25:50 UTC (rev 235639)
@@ -51,25 +51,6 @@
 {
 }
 
-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);

Modified: trunk/Source/WebCore/layout/FormattingContext.h (235638 => 235639)


--- trunk/Source/WebCore/layout/FormattingContext.h	2018-09-04 21:23:26 UTC (rev 235638)
+++ trunk/Source/WebCore/layout/FormattingContext.h	2018-09-04 21:25:50 UTC (rev 235639)
@@ -75,9 +75,6 @@
     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;

Modified: trunk/Source/WebCore/layout/blockformatting/BlockFormattingContext.cpp (235638 => 235639)


--- trunk/Source/WebCore/layout/blockformatting/BlockFormattingContext.cpp	2018-09-04 21:23:26 UTC (rev 235638)
+++ trunk/Source/WebCore/layout/blockformatting/BlockFormattingContext.cpp	2018-09-04 21:25:50 UTC (rev 235639)
@@ -244,48 +244,47 @@
 
 void BlockFormattingContext::computeWidthAndMargin(LayoutContext& layoutContext, const Box& layoutBox, Display::Box& displayBox) const
 {
+    WidthAndMargin widthAndMargin;
+
     if (layoutBox.isInFlow())
-        return computeInFlowWidthAndMargin(layoutContext, layoutBox, displayBox);
+        widthAndMargin = Geometry::inFlowWidthAndMargin(layoutContext, layoutBox);
+    else if (layoutBox.isFloatingPositioned())
+        widthAndMargin = FormattingContext::Geometry::floatingWidthAndMargin(layoutContext, *this, layoutBox);
+    else
+        ASSERT_NOT_REACHED();
 
-    if (layoutBox.isFloatingPositioned())
-        return computeFloatingWidthAndMargin(layoutContext, layoutBox, displayBox);
-
-    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);
 
-void BlockFormattingContext::computeInFlowHeightAndMargin(LayoutContext& layoutContext, const Box& layoutBox, Display::Box& displayBox) const
-{
-    auto heightAndMargin = Geometry::inFlowHeightAndMargin(layoutContext, layoutBox);
+        marginTopOffset = heightAndMargin.margin.top;
+    } else
+        ASSERT_NOT_REACHED();
+
     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);
+    displayBox.setVerticalMargin(heightAndMargin.collapsedMargin.value_or(heightAndMargin.margin));
+    if (marginTopOffset)
+        displayBox.moveVertically(*marginTopOffset);
 }
 
-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);
-}
-
 FormattingContext::InstrinsicWidthConstraints BlockFormattingContext::instrinsicWidthConstraints(LayoutContext& layoutContext, const Box& layoutBox) const
 {
     auto& formattingState = layoutContext.formattingStateForBox(layoutBox);

Modified: trunk/Source/WebCore/layout/blockformatting/BlockFormattingContext.h (235638 => 235639)


--- trunk/Source/WebCore/layout/blockformatting/BlockFormattingContext.h	2018-09-04 21:23:26 UTC (rev 235638)
+++ trunk/Source/WebCore/layout/blockformatting/BlockFormattingContext.h	2018-09-04 21:25:50 UTC (rev 235639)
@@ -59,9 +59,8 @@
     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;
 
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to