Title: [232540] trunk/Source/WebCore
Revision
232540
Author
[email protected]
Date
2018-06-06 08:25:38 -0700 (Wed, 06 Jun 2018)

Log Message

[LFC] Add margin computation for floating, no-replaced elements.
https://bugs.webkit.org/show_bug.cgi?id=186334

Reviewed by Antti Koivisto.

If 'margin-left', or 'margin-right' are computed as 'auto', their used value is '0'.

* layout/FormattingContextGeometry.cpp:
(WebCore::Layout::FormattingContext::Geometry::floatingNonReplacedWidthAndMargin):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (232539 => 232540)


--- trunk/Source/WebCore/ChangeLog	2018-06-06 14:50:02 UTC (rev 232539)
+++ trunk/Source/WebCore/ChangeLog	2018-06-06 15:25:38 UTC (rev 232540)
@@ -1,3 +1,15 @@
+2018-06-06  Zalan Bujtas  <[email protected]>
+
+        [LFC] Add margin computation for floating, no-replaced elements.
+        https://bugs.webkit.org/show_bug.cgi?id=186334
+
+        Reviewed by Antti Koivisto.
+
+        If 'margin-left', or 'margin-right' are computed as 'auto', their used value is '0'.
+
+        * layout/FormattingContextGeometry.cpp:
+        (WebCore::Layout::FormattingContext::Geometry::floatingNonReplacedWidthAndMargin):
+
 2018-06-06  Antti Koivisto  <[email protected]>
 
         Use minimal coverage rect for tiled layers when under memory pressure

Modified: trunk/Source/WebCore/layout/FormattingContextGeometry.cpp (232539 => 232540)


--- trunk/Source/WebCore/layout/FormattingContextGeometry.cpp	2018-06-06 14:50:02 UTC (rev 232539)
+++ trunk/Source/WebCore/layout/FormattingContextGeometry.cpp	2018-06-06 15:25:38 UTC (rev 232540)
@@ -220,11 +220,26 @@
 {
     ASSERT(layoutBox.isFloatingPositioned() && !layoutBox.replaced());
     // 10.3.5 Floating, non-replaced elements
+    //
+    // 1. If 'margin-left', or 'margin-right' are computed as 'auto', their used value is '0'.
+    // 2. If 'width' is computed as 'auto', the used value is the "shrink-to-fit" width.
+    auto& style = layoutBox.style();
+    auto width = style.logicalWidth();
+    LayoutUnit computedMarginLeftValue;
+    LayoutUnit computedMarginRightValue;
 
-    // If 'width' is computed as 'auto', the used value is the "shrink-to-fit" width.
-    auto width = layoutBox.style().logicalWidth();
+    {
+        auto marginLeft = style.marginLeft();
+        auto marginRight = style.marginRight();
+        auto containingBlockWidth = layoutContext.displayBoxForLayoutBox(*layoutBox.containingBlock())->width();
+        // #1
+        computedMarginLeftValue = marginLeft.isAuto() ? LayoutUnit(0) : valueForLength(marginLeft, containingBlockWidth);
+        computedMarginRightValue = marginRight.isAuto() ? LayoutUnit(0) : valueForLength(marginRight, containingBlockWidth);
+    }
+
+    // #2
     auto computedWidthValue = width.isAuto() ? shrinkToFitWidth(layoutContext, layoutBox) : LayoutUnit(width.value());
-    return FormattingContext::Geometry::WidthAndMargin { computedWidthValue, { } };
+    return FormattingContext::Geometry::WidthAndMargin { computedWidthValue, { computedMarginLeftValue, computedMarginRightValue } };
 }
 
 LayoutUnit FormattingContext::Geometry::floatingReplacedHeight(LayoutContext& layoutContext, const Box& layoutBox)
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to