[LFC] Add missing margins for inflow, non replaced block and replaced inline elements
authorzalan@apple.com <zalan@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 6 Jun 2018 03:10:45 +0000 (03:10 +0000)
committerzalan@apple.com <zalan@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 6 Jun 2018 03:10:45 +0000 (03:10 +0000)
https://bugs.webkit.org/show_bug.cgi?id=186332

Reviewed by Darin Adler.

* layout/FormattingContextGeometry.cpp:
(WebCore::Layout::FormattingContext::Geometry::inlineReplacedWidthAndMargin):
* layout/blockformatting/BlockFormattingContextGeometry.cpp:
(WebCore::Layout::BlockFormattingContext::Geometry::inFlowNonReplacedWidthAndMargin):

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

Source/WebCore/ChangeLog
Source/WebCore/layout/FormattingContextGeometry.cpp
Source/WebCore/layout/blockformatting/BlockFormattingContextGeometry.cpp

index 2032b9e..d689cd4 100644 (file)
@@ -1,3 +1,15 @@
+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
+
+        Reviewed by Darin Adler.
+
+        * layout/FormattingContextGeometry.cpp:
+        (WebCore::Layout::FormattingContext::Geometry::inlineReplacedWidthAndMargin):
+        * layout/blockformatting/BlockFormattingContextGeometry.cpp:
+        (WebCore::Layout::BlockFormattingContext::Geometry::inFlowNonReplacedWidthAndMargin):
+
 2018-06-05  Wenson Hsieh  <wenson_hsieh@apple.com>
 
         [macOS] Spelling errors in the middle of an inserted paragraph are not displayed
index 1a26fef..4839cda 100644 (file)
@@ -542,16 +542,16 @@ FormattingContext::Geometry::WidthAndMargin FormattingContext::Geometry::inlineR
     //    If 300px is too wide to fit the device, UAs should use the width of the largest rectangle that has a 2:1 ratio and fits the device instead.
     auto& style = layoutBox.style();
     LayoutUnit computedWidthValue;
-    LayoutUnit computedMarginLeft;
-    LayoutUnit computedMarginRight;
+    LayoutUnit computedMarginLeftValue;
+    LayoutUnit computedMarginRightValue;
 
     {
         auto marginLeft = style.marginLeft();
         auto marginRight = style.marginRight();
         auto containingBlockWidth = layoutContext.displayBoxForLayoutBox(*layoutBox.containingBlock())->width();
 
-        computedMarginLeft = marginLeft.isAuto() ? LayoutUnit(0) : valueForLength(marginLeft, containingBlockWidth);
-        computedMarginRight = marginRight.isAuto() ? LayoutUnit(0) : valueForLength(marginRight, containingBlockWidth);
+        computedMarginLeftValue = marginLeft.isAuto() ? LayoutUnit(0) : valueForLength(marginLeft, containingBlockWidth);
+        computedMarginRightValue = marginRight.isAuto() ? LayoutUnit(0) : valueForLength(marginRight, containingBlockWidth);
     }
 
     auto width = style.logicalWidth();
@@ -578,7 +578,7 @@ FormattingContext::Geometry::WidthAndMargin FormattingContext::Geometry::inlineR
         computedWidthValue = 300;
     }
 
-    return WidthAndMargin { computedWidthValue, { } };
+    return WidthAndMargin { computedWidthValue, { computedMarginLeftValue, computedMarginRightValue } };
 }
 
 Display::Box::Edges FormattingContext::Geometry::computedBorder(LayoutContext&, const Box& layoutBox)
index 552829b..88ee569 100644 (file)
@@ -216,7 +216,7 @@ FormattingContext::Geometry::WidthAndMargin BlockFormattingContext::Geometry::in
     if (!isStretchedToViewport(layoutContext, layoutBox))
         return computedWidthAndMarginValue;
     auto initialContainingBlockWidth = layoutContext.displayBoxForLayoutBox(initialContainingBlock(layoutBox))->contentBox().width();
-    return FormattingContext::Geometry::WidthAndMargin { std::max(computedWidthAndMarginValue.width, initialContainingBlockWidth), { } };
+    return FormattingContext::Geometry::WidthAndMargin { std::max(computedWidthAndMarginValue.width, initialContainingBlockWidth), { computedWidthAndMarginValue.margin } };
 }
 
 LayoutPoint BlockFormattingContext::Geometry::staticPosition(LayoutContext& layoutContext, const Box& layoutBox)