Title: [232533] trunk/Source/WebCore
Revision
232533
Author
[email protected]
Date
2018-06-05 21:23:26 -0700 (Tue, 05 Jun 2018)

Log Message

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

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (232532 => 232533)


--- trunk/Source/WebCore/ChangeLog	2018-06-06 03:10:45 UTC (rev 232532)
+++ trunk/Source/WebCore/ChangeLog	2018-06-06 04:23:26 UTC (rev 232533)
@@ -1,5 +1,19 @@
 2018-06-05  Zalan Bujtas  <[email protected]>
 
+        [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  <[email protected]>
+
         [LFC] Add missing margins for inflow, non replaced block and replaced inline elements
         https://bugs.webkit.org/show_bug.cgi?id=186332
 

Modified: trunk/Source/WebCore/layout/blockformatting/BlockFormattingContext.h (232532 => 232533)


--- trunk/Source/WebCore/layout/blockformatting/BlockFormattingContext.h	2018-06-06 03:10:45 UTC (rev 232532)
+++ trunk/Source/WebCore/layout/blockformatting/BlockFormattingContext.h	2018-06-06 04:23:26 UTC (rev 232533)
@@ -71,6 +71,7 @@
     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.

Modified: trunk/Source/WebCore/layout/blockformatting/BlockFormattingContextGeometry.cpp (232532 => 232533)


--- trunk/Source/WebCore/layout/blockformatting/BlockFormattingContextGeometry.cpp	2018-06-06 03:10:45 UTC (rev 232532)
+++ trunk/Source/WebCore/layout/blockformatting/BlockFormattingContextGeometry.cpp	2018-06-06 04:23:26 UTC (rev 232533)
@@ -219,6 +219,23 @@
     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
@@ -319,17 +336,7 @@
 
     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);
 }
 
 }
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to