[LFC] Move inflow, replaced width and margin computation to a dedicated function.
authorzalan@apple.com <zalan@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 6 Jun 2018 04:23:26 +0000 (04:23 +0000)
committerzalan@apple.com <zalan@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 6 Jun 2018 04:23:26 +0000 (04:23 +0000)
https://bugs.webkit.org/show_bug.cgi?id=186327

Reviewed by Sam Weinig.

I was searching for the function inFlowReplacedWidthAndMargin() and there was none.

* layout/blockformatting/BlockFormattingContext.h:
* layout/blockformatting/BlockFormattingContextGeometry.cpp:
(WebCore::Layout::BlockFormattingContext::Geometry::inFlowReplacedWidthAndMargin):
(WebCore::Layout::BlockFormattingContext::Geometry::inFlowWidthAndMargin):

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

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

index d689cd4..204e21a 100644 (file)
@@ -1,5 +1,19 @@
 2018-06-05  Zalan Bujtas  <zalan@apple.com>
 
 2018-06-05  Zalan Bujtas  <zalan@apple.com>
 
+        [LFC] Move inflow, replaced width and margin computation to a dedicated function.
+        https://bugs.webkit.org/show_bug.cgi?id=186327
+
+        Reviewed by Sam Weinig.
+
+        I was searching for the function inFlowReplacedWidthAndMargin() and there was none.
+
+        * layout/blockformatting/BlockFormattingContext.h:
+        * layout/blockformatting/BlockFormattingContextGeometry.cpp:
+        (WebCore::Layout::BlockFormattingContext::Geometry::inFlowReplacedWidthAndMargin):
+        (WebCore::Layout::BlockFormattingContext::Geometry::inFlowWidthAndMargin):
+
+2018-06-05  Zalan Bujtas  <zalan@apple.com>
+
         [LFC] Add missing margins for inflow, non replaced block and replaced inline elements
         https://bugs.webkit.org/show_bug.cgi?id=186332
 
         [LFC] Add missing margins for inflow, non replaced block and replaced inline elements
         https://bugs.webkit.org/show_bug.cgi?id=186332
 
index 48a01a5..58ab2ed 100644 (file)
@@ -71,6 +71,7 @@ private:
     private:
         static LayoutUnit inFlowNonReplacedHeight(LayoutContext&, const Box&);
         static FormattingContext::Geometry::WidthAndMargin inFlowNonReplacedWidthAndMargin(LayoutContext&, const Box&, std::optional<LayoutUnit> precomputedWidth = std::nullopt);
     private:
         static LayoutUnit inFlowNonReplacedHeight(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&);
     };
     
     // This class implements margin collapsing for block formatting context.
     };
     
     // This class implements margin collapsing for block formatting context.
index 88ee569..574b851 100644 (file)
@@ -219,6 +219,23 @@ FormattingContext::Geometry::WidthAndMargin BlockFormattingContext::Geometry::in
     return FormattingContext::Geometry::WidthAndMargin { std::max(computedWidthAndMarginValue.width, initialContainingBlockWidth), { computedWidthAndMarginValue.margin } };
 }
 
     return FormattingContext::Geometry::WidthAndMargin { std::max(computedWidthAndMarginValue.width, initialContainingBlockWidth), { computedWidthAndMarginValue.margin } };
 }
 
+FormattingContext::Geometry::WidthAndMargin BlockFormattingContext::Geometry::inFlowReplacedWidthAndMargin(LayoutContext& layoutContext, const Box& layoutBox)
+{
+    ASSERT(layoutBox.isInFlow() && layoutBox.replaced());
+
+    // 10.3.4 Block-level, replaced elements in normal flow
+    //
+    // 1. The used value of 'width' is determined as for inline replaced elements.
+    // 2. Then the rules for non-replaced block-level elements are applied to determine the margins.
+
+    // #1
+    auto inlineReplacedWidthAndMargin = FormattingContext::Geometry::inlineReplacedWidthAndMargin(layoutContext, layoutBox);
+    // #2
+    auto inlineReplacedWidthAndBlockNonReplacedMargin = inFlowNonReplacedWidthAndMargin(layoutContext, layoutBox, inlineReplacedWidthAndMargin.width);
+    ASSERT(inlineReplacedWidthAndMargin.width == inlineReplacedWidthAndBlockNonReplacedMargin.width);
+    return inlineReplacedWidthAndBlockNonReplacedMargin;
+}
+
 LayoutPoint BlockFormattingContext::Geometry::staticPosition(LayoutContext& layoutContext, const Box& layoutBox)
 {
     // https://www.w3.org/TR/CSS22/visuren.html#block-formatting
 LayoutPoint BlockFormattingContext::Geometry::staticPosition(LayoutContext& layoutContext, const Box& layoutBox)
 {
     // https://www.w3.org/TR/CSS22/visuren.html#block-formatting
@@ -319,17 +336,7 @@ FormattingContext::Geometry::WidthAndMargin BlockFormattingContext::Geometry::in
 
     if (!layoutBox.replaced())
         return inFlowNonReplacedWidthAndMargin(layoutContext, layoutBox);
 
     if (!layoutBox.replaced())
         return inFlowNonReplacedWidthAndMargin(layoutContext, layoutBox);
-    // 10.3.4 Block-level, replaced elements in normal flow
-    //
-    // 1. The used value of 'width' is determined as for inline replaced elements.
-    // 2. Then the rules for non-replaced block-level elements are applied to determine the margins.
-
-    // #1
-    auto inlineReplacedWidthAndMargin = FormattingContext::Geometry::inlineReplacedWidthAndMargin(layoutContext, layoutBox);
-    // #2
-    auto inlineReplacedWidthAndBlockNonReplacedMargin = Geometry::inFlowNonReplacedWidthAndMargin(layoutContext, layoutBox, inlineReplacedWidthAndMargin.width);
-    ASSERT(inlineReplacedWidthAndMargin.width == inlineReplacedWidthAndBlockNonReplacedMargin.width);
-    return inlineReplacedWidthAndBlockNonReplacedMargin;
+    return inFlowReplacedWidthAndMargin(layoutContext, layoutBox);
 }
 
 }
 }
 
 }