Title: [239608] trunk/Source/WebCore
Revision
239608
Author
[email protected]
Date
2019-01-04 07:21:45 -0800 (Fri, 04 Jan 2019)

Log Message

[LFC][BFC] Use computedValue and usedValue consistently
https://bugs.webkit.org/show_bug.cgi?id=193059

Reviewed by Antti Koivisto.

https://www.w3.org/TR/CSS22/cascade.html#value-stages

6.1.2 Computed values
Specified values are resolved to computed values during the cascade; for example URIs are made absolute and 'em' and 'ex' units
are computed to pixel or absolute lengths. Computing a value never requires the user agent to render the document...

6.1.3 Used values
Computed values are processed as far as possible without formatting the document. Some values, however, can only be determined when the document
is being laid out. For example, if the width of an element is set to be a certain percentage of its containing block, the width cannot be determined
until the width of the containing block has been determined. The used value is the result of taking the computed value and resolving any remaining
dependencies into an absolute value.

* layout/FormattingContext.cpp:
(WebCore::Layout::FormattingContext::computeOutOfFlowHorizontalGeometry const):
* layout/FormattingContextGeometry.cpp:
(WebCore::Layout::FormattingContext::Geometry::outOfFlowNonReplacedHorizontalGeometry):
(WebCore::Layout::FormattingContext::Geometry::outOfFlowReplacedVerticalGeometry):
(WebCore::Layout::FormattingContext::Geometry::outOfFlowReplacedHorizontalGeometry):
(WebCore::Layout::FormattingContext::Geometry::complicatedCases):
(WebCore::Layout::FormattingContext::Geometry::inlineReplacedWidthAndMargin):
* layout/LayoutState.cpp:
(WebCore::Layout::LayoutState::LayoutState):
* layout/LayoutUnits.h:
* layout/Verification.cpp:
(WebCore::Layout::outputMismatchingBlockBoxInformationIfNeeded):
* layout/blockformatting/BlockFormattingContext.cpp:
(WebCore::Layout::BlockFormattingContext::computeWidthAndMargin const):
* layout/blockformatting/BlockFormattingContextGeometry.cpp:
(WebCore::Layout::BlockFormattingContext::Geometry::inFlowNonReplacedWidthAndMargin):
(WebCore::Layout::BlockFormattingContext::Geometry::inFlowReplacedWidthAndMargin):
* layout/displaytree/DisplayBox.cpp:
(WebCore::Display::Box::Box):
* layout/displaytree/DisplayBox.h:
(WebCore::Display::Box::setHasValidHorizontalComputedMargin):
(WebCore::Display::Box::setHorizontalComputedMargin):
(WebCore::Display::Box::computedMarginStart const):
(WebCore::Display::Box::computedMarginEnd const):
(WebCore::Display::Box::setHasValidHorizontalNonComputedMargin): Deleted.
(WebCore::Display::Box::setHorizontalNonComputedMargin): Deleted.
(WebCore::Display::Box::nonComputedMarginStart const): Deleted.
(WebCore::Display::Box::nonComputedMarginEnd const): Deleted.
* layout/floats/FloatAvoider.h:
(WebCore::Layout::FloatAvoider::marginStart const):
(WebCore::Layout::FloatAvoider::marginEnd const):
* layout/inlineformatting/InlineFormattingContext.cpp:
(WebCore::Layout::InlineFormattingContext::computeWidthAndMargin const):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (239607 => 239608)


--- trunk/Source/WebCore/ChangeLog	2019-01-04 14:34:39 UTC (rev 239607)
+++ trunk/Source/WebCore/ChangeLog	2019-01-04 15:21:45 UTC (rev 239608)
@@ -1,3 +1,57 @@
+2019-01-04  Zalan Bujtas  <[email protected]>
+
+        [LFC][BFC] Use computedValue and usedValue consistently
+        https://bugs.webkit.org/show_bug.cgi?id=193059
+
+        Reviewed by Antti Koivisto.
+
+        https://www.w3.org/TR/CSS22/cascade.html#value-stages
+
+        6.1.2 Computed values
+        Specified values are resolved to computed values during the cascade; for example URIs are made absolute and 'em' and 'ex' units
+        are computed to pixel or absolute lengths. Computing a value never requires the user agent to render the document...
+
+        6.1.3 Used values
+        Computed values are processed as far as possible without formatting the document. Some values, however, can only be determined when the document
+        is being laid out. For example, if the width of an element is set to be a certain percentage of its containing block, the width cannot be determined
+        until the width of the containing block has been determined. The used value is the result of taking the computed value and resolving any remaining
+        dependencies into an absolute value.
+
+        * layout/FormattingContext.cpp:
+        (WebCore::Layout::FormattingContext::computeOutOfFlowHorizontalGeometry const):
+        * layout/FormattingContextGeometry.cpp:
+        (WebCore::Layout::FormattingContext::Geometry::outOfFlowNonReplacedHorizontalGeometry):
+        (WebCore::Layout::FormattingContext::Geometry::outOfFlowReplacedVerticalGeometry):
+        (WebCore::Layout::FormattingContext::Geometry::outOfFlowReplacedHorizontalGeometry):
+        (WebCore::Layout::FormattingContext::Geometry::complicatedCases):
+        (WebCore::Layout::FormattingContext::Geometry::inlineReplacedWidthAndMargin):
+        * layout/LayoutState.cpp:
+        (WebCore::Layout::LayoutState::LayoutState):
+        * layout/LayoutUnits.h:
+        * layout/Verification.cpp:
+        (WebCore::Layout::outputMismatchingBlockBoxInformationIfNeeded):
+        * layout/blockformatting/BlockFormattingContext.cpp:
+        (WebCore::Layout::BlockFormattingContext::computeWidthAndMargin const):
+        * layout/blockformatting/BlockFormattingContextGeometry.cpp:
+        (WebCore::Layout::BlockFormattingContext::Geometry::inFlowNonReplacedWidthAndMargin):
+        (WebCore::Layout::BlockFormattingContext::Geometry::inFlowReplacedWidthAndMargin):
+        * layout/displaytree/DisplayBox.cpp:
+        (WebCore::Display::Box::Box):
+        * layout/displaytree/DisplayBox.h:
+        (WebCore::Display::Box::setHasValidHorizontalComputedMargin):
+        (WebCore::Display::Box::setHorizontalComputedMargin):
+        (WebCore::Display::Box::computedMarginStart const):
+        (WebCore::Display::Box::computedMarginEnd const):
+        (WebCore::Display::Box::setHasValidHorizontalNonComputedMargin): Deleted.
+        (WebCore::Display::Box::setHorizontalNonComputedMargin): Deleted.
+        (WebCore::Display::Box::nonComputedMarginStart const): Deleted.
+        (WebCore::Display::Box::nonComputedMarginEnd const): Deleted.
+        * layout/floats/FloatAvoider.h:
+        (WebCore::Layout::FloatAvoider::marginStart const):
+        (WebCore::Layout::FloatAvoider::marginEnd const):
+        * layout/inlineformatting/InlineFormattingContext.cpp:
+        (WebCore::Layout::InlineFormattingContext::computeWidthAndMargin const):
+
 2019-01-03  Zalan Bujtas  <[email protected]>
 
         REGRESSION: -webkit-appearance test case crashes

Modified: trunk/Source/WebCore/layout/FormattingContext.cpp (239607 => 239608)


--- trunk/Source/WebCore/layout/FormattingContext.cpp	2019-01-04 14:34:39 UTC (rev 239607)
+++ trunk/Source/WebCore/layout/FormattingContext.cpp	2019-01-04 15:21:45 UTC (rev 239608)
@@ -87,10 +87,10 @@
     }
 
     auto& displayBox = layoutState.displayBoxForLayoutBox(layoutBox);
-    displayBox.setLeft(horizontalGeometry.left + horizontalGeometry.widthAndMargin.margin.start);
+    displayBox.setLeft(horizontalGeometry.left + horizontalGeometry.widthAndMargin.usedMargin.start);
     displayBox.setContentBoxWidth(horizontalGeometry.widthAndMargin.width);
-    displayBox.setHorizontalMargin(horizontalGeometry.widthAndMargin.margin);
-    displayBox.setHorizontalNonComputedMargin(horizontalGeometry.widthAndMargin.nonComputedMargin);
+    displayBox.setHorizontalMargin(horizontalGeometry.widthAndMargin.usedMargin);
+    displayBox.setHorizontalComputedMargin(horizontalGeometry.widthAndMargin.computedMargin);
 }
 
 void FormattingContext::computeOutOfFlowVerticalGeometry(const Box& layoutBox) const

Modified: trunk/Source/WebCore/layout/FormattingContextGeometry.cpp (239607 => 239608)


--- trunk/Source/WebCore/layout/FormattingContextGeometry.cpp	2019-01-04 14:34:39 UTC (rev 239607)
+++ trunk/Source/WebCore/layout/FormattingContextGeometry.cpp	2019-01-04 15:21:45 UTC (rev 239608)
@@ -280,8 +280,10 @@
     auto top = computedValueIfNotAuto(style.logicalTop(), containingBlockWidth);
     auto bottom = computedValueIfNotAuto(style.logicalBottom(), containingBlockWidth);
     auto height = usedHeight ? usedHeight.value() : computedHeightValue(layoutState, layoutBox, HeightType::Normal);
-    auto marginBefore = computedValueIfNotAuto(style.marginBefore(), containingBlockWidth);
-    auto marginAfter = computedValueIfNotAuto(style.marginAfter(), containingBlockWidth);
+    auto computedMarginBefore = computedValueIfNotAuto(style.marginBefore(), containingBlockWidth);
+    auto computedMarginAfter = computedValueIfNotAuto(style.marginAfter(), containingBlockWidth);
+    auto usedMarginBefore = computedMarginBefore;
+    auto usedMarginAfter = computedMarginAfter;
     auto paddingTop = displayBox.paddingTop().valueOr(0);
     auto paddingBottom = displayBox.paddingBottom().valueOr(0);
     auto borderTop = displayBox.borderTop();
@@ -291,72 +293,72 @@
         top = staticVerticalPositionForOutOfFlowPositioned(layoutState, layoutBox);
 
     if (top && height && bottom) {
-        if (!marginBefore && !marginAfter) {
+        if (!usedMarginBefore && !usedMarginAfter) {
             auto marginBeforeAndAfter = containingBlockHeight - (*top + borderTop + paddingTop + *height + paddingBottom + borderBottom + *bottom);
-            marginBefore = marginAfter = marginBeforeAndAfter / 2;
-        } else if (!marginBefore)
-            marginBefore = containingBlockHeight - (*top + borderTop + paddingTop + *height + paddingBottom + borderBottom + *marginAfter + *bottom);
+            usedMarginBefore = usedMarginAfter = marginBeforeAndAfter / 2;
+        } else if (!usedMarginBefore)
+            usedMarginBefore = containingBlockHeight - (*top + borderTop + paddingTop + *height + paddingBottom + borderBottom + *usedMarginAfter + *bottom);
         else
-            marginAfter = containingBlockHeight - (*top + *marginBefore + borderTop + paddingTop + *height + paddingBottom + borderBottom + *bottom);
+            usedMarginAfter = containingBlockHeight - (*top + *usedMarginBefore + borderTop + paddingTop + *height + paddingBottom + borderBottom + *bottom);
         // Over-constrained?
-        auto boxHeight = *top + *marginBefore + borderTop + paddingTop + *height + paddingBottom + borderBottom + *marginAfter + *bottom;
+        auto boxHeight = *top + *usedMarginBefore + borderTop + paddingTop + *height + paddingBottom + borderBottom + *usedMarginAfter + *bottom;
         if (boxHeight > containingBlockHeight)
-            bottom = containingBlockHeight - (*top + *marginBefore + borderTop + paddingTop + *height + paddingBottom + borderBottom + *marginAfter); 
+            bottom = containingBlockHeight - (*top + *usedMarginBefore + borderTop + paddingTop + *height + paddingBottom + borderBottom + *usedMarginAfter); 
     }
 
     if (!top && !height && bottom) {
         // #1
         height = contentHeightForFormattingContextRoot(layoutState, layoutBox);
-        marginBefore = marginBefore.valueOr(0);
-        marginAfter = marginAfter.valueOr(0);
-        top = containingBlockHeight - (*marginBefore + borderTop + paddingTop + *height + paddingBottom + borderBottom + *marginAfter + *bottom); 
+        usedMarginBefore = usedMarginBefore.valueOr(0);
+        usedMarginAfter = usedMarginAfter.valueOr(0);
+        top = containingBlockHeight - (*usedMarginBefore + borderTop + paddingTop + *height + paddingBottom + borderBottom + *usedMarginAfter + *bottom); 
     }
 
     if (!top && !bottom && height) {
         // #2
         top = staticVerticalPositionForOutOfFlowPositioned(layoutState, layoutBox);
-        marginBefore = marginBefore.valueOr(0);
-        marginAfter = marginAfter.valueOr(0);
-        bottom = containingBlockHeight - (*top + *marginBefore + borderTop + paddingTop + *height + paddingBottom + borderBottom + *marginAfter); 
+        usedMarginBefore = usedMarginBefore.valueOr(0);
+        usedMarginAfter = usedMarginAfter.valueOr(0);
+        bottom = containingBlockHeight - (*top + *usedMarginBefore + borderTop + paddingTop + *height + paddingBottom + borderBottom + *usedMarginAfter); 
     }
 
     if (!height && !bottom && top) {
         // #3
         height = contentHeightForFormattingContextRoot(layoutState, layoutBox);
-        marginBefore = marginBefore.valueOr(0);
-        marginAfter = marginAfter.valueOr(0);
-        bottom = containingBlockHeight - (*top + *marginBefore + borderTop + paddingTop + *height + paddingBottom + borderBottom + *marginAfter); 
+        usedMarginBefore = usedMarginBefore.valueOr(0);
+        usedMarginAfter = usedMarginAfter.valueOr(0);
+        bottom = containingBlockHeight - (*top + *usedMarginBefore + borderTop + paddingTop + *height + paddingBottom + borderBottom + *usedMarginAfter); 
     }
 
     if (!top && height && bottom) {
         // #4
-        marginBefore = marginBefore.valueOr(0);
-        marginAfter = marginAfter.valueOr(0);
-        top = containingBlockHeight - (*marginBefore + borderTop + paddingTop + *height + paddingBottom + borderBottom + *marginAfter + *bottom); 
+        usedMarginBefore = usedMarginBefore.valueOr(0);
+        usedMarginAfter = usedMarginAfter.valueOr(0);
+        top = containingBlockHeight - (*usedMarginBefore + borderTop + paddingTop + *height + paddingBottom + borderBottom + *usedMarginAfter + *bottom); 
     }
 
     if (!height && top && bottom) {
         // #5
-        marginBefore = marginBefore.valueOr(0);
-        marginAfter = marginAfter.valueOr(0);
-        height = containingBlockHeight - (*top + *marginBefore + borderTop + paddingTop + paddingBottom + borderBottom + *marginAfter + *bottom); 
+        usedMarginBefore = usedMarginBefore.valueOr(0);
+        usedMarginAfter = usedMarginAfter.valueOr(0);
+        height = containingBlockHeight - (*top + *usedMarginBefore + borderTop + paddingTop + paddingBottom + borderBottom + *usedMarginAfter + *bottom); 
     }
 
     if (!bottom && top && height) {
         // #6
-        marginBefore = marginBefore.valueOr(0);
-        marginAfter = marginAfter.valueOr(0);
-        bottom = containingBlockHeight - (*top + *marginBefore + borderTop + paddingTop + *height + paddingBottom + borderBottom + *marginAfter); 
+        usedMarginBefore = usedMarginBefore.valueOr(0);
+        usedMarginAfter = usedMarginAfter.valueOr(0);
+        bottom = containingBlockHeight - (*top + *usedMarginBefore + borderTop + paddingTop + *height + paddingBottom + borderBottom + *usedMarginAfter); 
     }
 
     ASSERT(top);
     ASSERT(bottom);
     ASSERT(height);
-    ASSERT(marginBefore);
-    ASSERT(marginAfter);
+    ASSERT(usedMarginBefore);
+    ASSERT(usedMarginAfter);
 
-    LOG_WITH_STREAM(FormattingContextLayout, stream << "[Position][Height][Margin] -> out-of-flow non-replaced -> top(" << *top << "px) bottom("  << *bottom << "px) height(" << *height << "px) margin(" << *marginBefore << "px, "  << *marginAfter << "px) layoutBox(" << &layoutBox << ")");
-    return { *top, *bottom, { *height, { { *marginBefore, *marginAfter }, { } } } };
+    LOG_WITH_STREAM(FormattingContextLayout, stream << "[Position][Height][Margin] -> out-of-flow non-replaced -> top(" << *top << "px) bottom("  << *bottom << "px) height(" << *height << "px) margin(" << *usedMarginBefore << "px, "  << *usedMarginAfter << "px) layoutBox(" << &layoutBox << ")");
+    return { *top, *bottom, { *height, { { *usedMarginBefore, *usedMarginAfter }, { } } } };
 }
 
 HorizontalGeometry FormattingContext::Geometry::outOfFlowNonReplacedHorizontalGeometry(LayoutState& layoutState, const Box& layoutBox, Optional<LayoutUnit> usedWidth)
@@ -398,10 +400,10 @@
     auto left = computedValueIfNotAuto(style.logicalLeft(), containingBlockWidth);
     auto right = computedValueIfNotAuto(style.logicalRight(), containingBlockWidth);
     auto width = computedValueIfNotAuto(usedWidth ? Length { usedWidth.value(), Fixed } : style.logicalWidth(), containingBlockWidth);
-    auto marginStart = computedValueIfNotAuto(style.marginStart(), containingBlockWidth);
-    auto marginEnd = computedValueIfNotAuto(style.marginEnd(), containingBlockWidth);
-    auto nonComputedMarginStart = marginStart.valueOr(0);
-    auto nonComputedMarginEnd = marginEnd.valueOr(0);
+    auto computedMarginStart = computedValueIfNotAuto(style.marginStart(), containingBlockWidth);
+    auto computedMarginEnd = computedValueIfNotAuto(style.marginEnd(), containingBlockWidth);
+    auto usedMarginStart = computedMarginStart;
+    auto usedMarginEnd = computedMarginEnd;
     auto paddingLeft = displayBox.paddingLeft().valueOr(0);
     auto paddingRight = displayBox.paddingRight().valueOr(0);
     auto borderLeft = displayBox.borderLeft();
@@ -411,8 +413,8 @@
         // If all three of 'left', 'width', and 'right' are 'auto': First set any 'auto' values for 'margin-left' and 'margin-right' to 0.
         // Then, if the 'direction' property of the element establishing the static-position containing block is 'ltr' set 'left' to the static
         // position and apply rule number three below; otherwise, set 'right' to the static position and apply rule number one below.
-        marginStart = marginStart.valueOr(0);
-        marginEnd = marginEnd.valueOr(0);
+        usedMarginStart = usedMarginStart.valueOr(0);
+        usedMarginEnd = usedMarginEnd.valueOr(0);
 
         auto staticHorizontalPosition = staticHorizontalPositionForOutOfFlowPositioned(layoutState, layoutBox);
         if (isLeftToRightDirection)
@@ -425,84 +427,84 @@
         // solve for 'margin-right' ('margin-left'). If one of 'margin-left' or 'margin-right' is 'auto', solve the equation for that value.
         // If the values are over-constrained, ignore the value for 'left' (in case the 'direction' property of the containing block is 'rtl') or 'right'
         // (in case 'direction' is 'ltr') and solve for that value.
-        if (!marginStart && !marginEnd) {
+        if (!usedMarginStart && !usedMarginEnd) {
             auto marginStartAndEnd = containingBlockWidth - (*left + borderLeft + paddingLeft + *width + paddingRight + borderRight + *right);
             if (marginStartAndEnd >= 0)
-                marginStart = marginEnd = marginStartAndEnd / 2;  
+                usedMarginStart = usedMarginEnd = marginStartAndEnd / 2;  
             else {
                 if (isLeftToRightDirection) {
-                    marginStart = 0_lu;
-                    marginEnd = containingBlockWidth - (*left + *marginStart + borderLeft + paddingLeft + *width + paddingRight + borderRight + *right);
+                    usedMarginStart = 0_lu;
+                    usedMarginEnd = containingBlockWidth - (*left + *usedMarginStart + borderLeft + paddingLeft + *width + paddingRight + borderRight + *right);
                 } else {
-                    marginEnd = 0_lu;
-                    marginStart = containingBlockWidth - (*left + borderLeft + paddingLeft + *width + paddingRight + borderRight + *marginEnd + *right);
+                    usedMarginEnd = 0_lu;
+                    usedMarginStart = containingBlockWidth - (*left + borderLeft + paddingLeft + *width + paddingRight + borderRight + *usedMarginEnd + *right);
                 }
             }
-        } else if (!marginStart) {
-            marginStart = containingBlockWidth - (*left + borderLeft + paddingLeft + *width + paddingRight + borderRight + *marginEnd + *right);
+        } else if (!usedMarginStart) {
+            usedMarginStart = containingBlockWidth - (*left + borderLeft + paddingLeft + *width + paddingRight + borderRight + *usedMarginEnd + *right);
             // Overconstrained? Ignore right (left).
-            if (*marginStart < 0) {
+            if (*usedMarginStart < 0) {
                 if (isLeftToRightDirection)
-                    marginStart = containingBlockWidth - (*left + borderLeft + paddingLeft + *width + paddingRight + borderRight + *marginEnd);
+                    usedMarginStart = containingBlockWidth - (*left + borderLeft + paddingLeft + *width + paddingRight + borderRight + *usedMarginEnd);
                 else
-                    marginStart = containingBlockWidth - (borderLeft + paddingLeft + *width + paddingRight + borderRight + *marginEnd + *right);
+                    usedMarginStart = containingBlockWidth - (borderLeft + paddingLeft + *width + paddingRight + borderRight + *usedMarginEnd + *right);
             }
-        } else if (!marginEnd) {
-            marginEnd = containingBlockWidth - (*left + *marginStart + borderLeft + paddingLeft + *width + paddingRight + borderRight + *right);
+        } else if (!usedMarginEnd) {
+            usedMarginEnd = containingBlockWidth - (*left + *usedMarginStart + borderLeft + paddingLeft + *width + paddingRight + borderRight + *right);
             // Overconstrained? Ignore right (left).
-            if (*marginEnd < 0) {
+            if (*usedMarginEnd < 0) {
                 if (isLeftToRightDirection)
-                    marginEnd = containingBlockWidth - (*left + *marginStart + borderLeft + paddingLeft + *width + paddingRight + borderRight);
+                    usedMarginEnd = containingBlockWidth - (*left + *usedMarginStart + borderLeft + paddingLeft + *width + paddingRight + borderRight);
                 else
-                    marginEnd = containingBlockWidth - (*marginStart + borderLeft + paddingLeft + *width + paddingRight + borderRight + *right);
+                    usedMarginEnd = containingBlockWidth - (*usedMarginStart + borderLeft + paddingLeft + *width + paddingRight + borderRight + *right);
             }
         }
     } else {
         // Otherwise, set 'auto' values for 'margin-left' and 'margin-right' to 0, and pick the one of the following six rules that applies.
-        marginStart = marginStart.valueOr(0);
-        marginEnd = marginEnd.valueOr(0);
+        usedMarginStart = usedMarginStart.valueOr(0);
+        usedMarginEnd = usedMarginEnd.valueOr(0);
     }
 
-    ASSERT(marginStart);
-    ASSERT(marginEnd);
+    ASSERT(usedMarginStart);
+    ASSERT(usedMarginEnd);
 
     if (!left && !width && right) {
         // #1
         width = shrinkToFitWidth(layoutState, layoutBox);
-        left = containingBlockWidth - (*marginStart + borderLeft + paddingLeft + *width + paddingRight  + borderRight + *marginEnd + *right);
+        left = containingBlockWidth - (*usedMarginStart + borderLeft + paddingLeft + *width + paddingRight  + borderRight + *usedMarginEnd + *right);
     } else if (!left && !right && width) {
         // #2
         auto staticHorizontalPosition = staticHorizontalPositionForOutOfFlowPositioned(layoutState, layoutBox);
         if (isLeftToRightDirection) {
             left = staticHorizontalPosition;
-            right = containingBlockWidth - (*left + *marginStart + borderLeft + paddingLeft + *width + paddingRight + borderRight + *marginEnd);
+            right = containingBlockWidth - (*left + *usedMarginStart + borderLeft + paddingLeft + *width + paddingRight + borderRight + *usedMarginEnd);
         } else {
             right = staticHorizontalPosition;
-            left = containingBlockWidth - (*marginStart + borderLeft + paddingLeft + *width + paddingRight + borderRight + *marginEnd + *right);
+            left = containingBlockWidth - (*usedMarginStart + borderLeft + paddingLeft + *width + paddingRight + borderRight + *usedMarginEnd + *right);
         }
     } else if (!width && !right && left) {
         // #3
         width = shrinkToFitWidth(layoutState, layoutBox);
-        right = containingBlockWidth - (*left + *marginStart + borderLeft + paddingLeft + *width + paddingRight + borderRight + *marginEnd);
+        right = containingBlockWidth - (*left + *usedMarginStart + borderLeft + paddingLeft + *width + paddingRight + borderRight + *usedMarginEnd);
     } else if (!left && width && right) {
         // #4
-        left = containingBlockWidth - (*marginStart + borderLeft + paddingLeft + *width + paddingRight + borderRight + *marginEnd + *right);
+        left = containingBlockWidth - (*usedMarginStart + borderLeft + paddingLeft + *width + paddingRight + borderRight + *usedMarginEnd + *right);
     } else if (!width && left && right) {
         // #5
-        width = containingBlockWidth - (*left + *marginStart + borderLeft + paddingLeft + paddingRight  + borderRight + *marginEnd + *right);
+        width = containingBlockWidth - (*left + *usedMarginStart + borderLeft + paddingLeft + paddingRight  + borderRight + *usedMarginEnd + *right);
     } else if (!right && left && width) {
         // #6
-        right = containingBlockWidth - (*left + *marginStart + borderLeft + paddingLeft + *width + paddingRight + borderRight + *marginEnd);
+        right = containingBlockWidth - (*left + *usedMarginStart + borderLeft + paddingLeft + *width + paddingRight + borderRight + *usedMarginEnd);
     }
 
     ASSERT(left);
     ASSERT(right);
     ASSERT(width);
-    ASSERT(marginStart);
-    ASSERT(marginEnd);
+    ASSERT(usedMarginStart);
+    ASSERT(usedMarginEnd);
 
-    LOG_WITH_STREAM(FormattingContextLayout, stream << "[Position][Width][Margin] -> out-of-flow non-replaced -> left(" << *left << "px) right("  << *right << "px) width(" << *width << "px) margin(" << *marginStart << "px, "  << *marginEnd << "px) layoutBox(" << &layoutBox << ")");
-    return { *left, *right, { *width, { *marginStart, *marginEnd }, { nonComputedMarginStart, nonComputedMarginEnd } } };
+    LOG_WITH_STREAM(FormattingContextLayout, stream << "[Position][Width][Margin] -> out-of-flow non-replaced -> left(" << *left << "px) right("  << *right << "px) width(" << *width << "px) margin(" << *usedMarginStart << "px, "  << *usedMarginEnd << "px) layoutBox(" << &layoutBox << ")");
+    return { *left, *right, { *width, { *usedMarginStart, *usedMarginEnd }, { computedMarginStart.valueOr(0), computedMarginEnd.valueOr(0) } } };
 }
 
 VerticalGeometry FormattingContext::Geometry::outOfFlowReplacedVerticalGeometry(const LayoutState& layoutState, const Box& layoutBox, Optional<LayoutUnit> usedHeight)
@@ -528,8 +530,10 @@
     auto top = computedValueIfNotAuto(style.logicalTop(), containingBlockWidth);
     auto bottom = computedValueIfNotAuto(style.logicalBottom(), containingBlockWidth);
     auto height = inlineReplacedHeightAndMargin(layoutState, layoutBox, usedHeight).height;
-    auto marginBefore = computedValueIfNotAuto(style.marginBefore(), containingBlockWidth);
-    auto marginAfter = computedValueIfNotAuto(style.marginAfter(), containingBlockWidth);
+    auto computedMarginBefore = computedValueIfNotAuto(style.marginBefore(), containingBlockWidth);
+    auto computedMarginAfter = computedValueIfNotAuto(style.marginAfter(), containingBlockWidth);
+    auto usedMarginBefore = computedMarginBefore;
+    auto usedMarginAfter = computedMarginAfter;
     auto paddingTop = displayBox.paddingTop().valueOr(0);
     auto paddingBottom = displayBox.paddingBottom().valueOr(0);
     auto borderTop = displayBox.borderTop();
@@ -542,36 +546,36 @@
 
     if (!bottom) {
         // #2
-        marginBefore = marginBefore.valueOr(0);
-        marginAfter = marginAfter.valueOr(0);
+        usedMarginBefore = usedMarginBefore.valueOr(0);
+        usedMarginAfter = usedMarginAfter.valueOr(0);
     }
 
-    if (!marginBefore && !marginAfter) {
+    if (!usedMarginBefore && !usedMarginAfter) {
         // #3
         auto marginBeforeAndAfter = containingBlockHeight - (*top + borderTop + paddingTop + height + paddingBottom + borderBottom + *bottom);
-        marginBefore = marginAfter = marginBeforeAndAfter / 2;
+        usedMarginBefore = usedMarginAfter = marginBeforeAndAfter / 2;
     }
 
     // #4
     if (!top)
-        top = containingBlockHeight - (*marginBefore + borderTop + paddingTop + height + paddingBottom + borderBottom + *marginAfter + *bottom);
+        top = containingBlockHeight - (*usedMarginBefore + borderTop + paddingTop + height + paddingBottom + borderBottom + *usedMarginAfter + *bottom);
 
     if (!bottom)
-        bottom = containingBlockHeight - (*top + *marginBefore + borderTop + paddingTop + height + paddingBottom + borderBottom + *marginAfter);
+        bottom = containingBlockHeight - (*top + *usedMarginBefore + borderTop + paddingTop + height + paddingBottom + borderBottom + *usedMarginAfter);
 
-    if (!marginBefore)
-        marginBefore = containingBlockHeight - (*top + borderTop + paddingTop + height + paddingBottom + borderBottom + *marginAfter + *bottom);
+    if (!usedMarginBefore)
+        usedMarginBefore = containingBlockHeight - (*top + borderTop + paddingTop + height + paddingBottom + borderBottom + *usedMarginAfter + *bottom);
 
-    if (!marginAfter)
-        marginAfter = containingBlockHeight - (*top + *marginBefore + borderTop + paddingTop + height + paddingBottom + borderBottom + *bottom);
+    if (!usedMarginAfter)
+        usedMarginAfter = containingBlockHeight - (*top + *usedMarginBefore + borderTop + paddingTop + height + paddingBottom + borderBottom + *bottom);
 
     // #5
-    auto boxHeight = *top + *marginBefore + borderTop + paddingTop + height + paddingBottom + borderBottom + *marginAfter + *bottom;
+    auto boxHeight = *top + *usedMarginBefore + borderTop + paddingTop + height + paddingBottom + borderBottom + *usedMarginAfter + *bottom;
     if (boxHeight > containingBlockHeight)
-        bottom = containingBlockHeight - (*top + *marginBefore + borderTop + paddingTop + height + paddingBottom + borderBottom + *marginAfter); 
+        bottom = containingBlockHeight - (*top + *usedMarginBefore + borderTop + paddingTop + height + paddingBottom + borderBottom + *usedMarginAfter); 
 
-    LOG_WITH_STREAM(FormattingContextLayout, stream << "[Position][Height][Margin] -> out-of-flow replaced -> top(" << *top << "px) bottom("  << *bottom << "px) height(" << height << "px) margin(" << *marginBefore << "px, "  << *marginAfter << "px) layoutBox(" << &layoutBox << ")");
-    return { *top, *bottom, { height, { { *marginBefore, *marginAfter }, { } } } };
+    LOG_WITH_STREAM(FormattingContextLayout, stream << "[Position][Height][Margin] -> out-of-flow replaced -> top(" << *top << "px) bottom("  << *bottom << "px) height(" << height << "px) margin(" << *usedMarginBefore << "px, "  << *usedMarginAfter << "px) layoutBox(" << &layoutBox << ")");
+    return { *top, *bottom, { height, { { *usedMarginBefore, *usedMarginAfter }, { } } } };
 }
 
 HorizontalGeometry FormattingContext::Geometry::outOfFlowReplacedHorizontalGeometry(const LayoutState& layoutState, const Box& layoutBox, Optional<LayoutUnit> usedWidth)
@@ -600,10 +604,10 @@
 
     auto left = computedValueIfNotAuto(style.logicalLeft(), containingBlockWidth);
     auto right = computedValueIfNotAuto(style.logicalRight(), containingBlockWidth);
-    auto marginStart = computedValueIfNotAuto(style.marginStart(), containingBlockWidth);
-    auto marginEnd = computedValueIfNotAuto(style.marginEnd(), containingBlockWidth);
-    auto nonComputedMarginStart = marginStart.valueOr(0);
-    auto nonComputedMarginEnd = marginEnd.valueOr(0);
+    auto computedMarginStart = computedValueIfNotAuto(style.marginStart(), containingBlockWidth);
+    auto computedMarginEnd = computedValueIfNotAuto(style.marginEnd(), containingBlockWidth);
+    auto usedMarginStart = computedMarginStart;
+    auto usedMarginEnd = computedMarginEnd;
     auto width = inlineReplacedWidthAndMargin(layoutState, layoutBox, usedWidth).width;
     auto paddingLeft = displayBox.paddingLeft().valueOr(0);
     auto paddingRight = displayBox.paddingRight().valueOr(0);
@@ -621,22 +625,22 @@
 
     if (!left || !right) {
         // #2
-        marginStart = marginStart.valueOr(0); 
-        marginEnd = marginEnd.valueOr(0); 
+        usedMarginStart = usedMarginStart.valueOr(0); 
+        usedMarginEnd = usedMarginEnd.valueOr(0); 
     }
 
-    if (!marginStart && !marginEnd) {
+    if (!usedMarginStart && !usedMarginEnd) {
         // #3
         auto marginStartAndEnd = containingBlockWidth - (*left + borderLeft + paddingLeft + width + paddingRight + borderRight + *right);
         if (marginStartAndEnd >= 0)
-            marginStart = marginEnd = marginStartAndEnd / 2;
+            usedMarginStart = usedMarginEnd = marginStartAndEnd / 2;
         else {
             if (isLeftToRightDirection) {
-                marginStart = 0_lu;
-                marginEnd = containingBlockWidth - (*left + *marginStart + borderLeft + paddingLeft + width + paddingRight + borderRight + *right);
+                usedMarginStart = 0_lu;
+                usedMarginEnd = containingBlockWidth - (*left + *usedMarginStart + borderLeft + paddingLeft + width + paddingRight + borderRight + *right);
             } else {
-                marginEnd = 0_lu;
-                marginStart = containingBlockWidth - (*left + borderLeft + paddingLeft + width + paddingRight + borderRight + *marginEnd + *right);
+                usedMarginEnd = 0_lu;
+                usedMarginStart = containingBlockWidth - (*left + borderLeft + paddingLeft + width + paddingRight + borderRight + *usedMarginEnd + *right);
             }
         }
     }
@@ -643,33 +647,33 @@
 
     // #4
     if (!left)
-        left = containingBlockWidth - (*marginStart + borderLeft + paddingLeft + width + paddingRight + borderRight + *marginEnd + *right);
+        left = containingBlockWidth - (*usedMarginStart + borderLeft + paddingLeft + width + paddingRight + borderRight + *usedMarginEnd + *right);
 
     if (!right)
-        right = containingBlockWidth - (*left + *marginStart + borderLeft + paddingLeft + width + paddingRight + borderRight + *marginEnd);
+        right = containingBlockWidth - (*left + *usedMarginStart + borderLeft + paddingLeft + width + paddingRight + borderRight + *usedMarginEnd);
 
-    if (!marginStart)
-        marginStart = containingBlockWidth - (*left + borderLeft + paddingLeft + width + paddingRight + borderRight + *marginEnd + *right);
+    if (!usedMarginStart)
+        usedMarginStart = containingBlockWidth - (*left + borderLeft + paddingLeft + width + paddingRight + borderRight + *usedMarginEnd + *right);
 
-    if (!marginEnd)
-        marginEnd = containingBlockWidth - (*left + *marginStart + borderLeft + paddingLeft + width + paddingRight + borderRight + *right);
+    if (!usedMarginEnd)
+        usedMarginEnd = containingBlockWidth - (*left + *usedMarginStart + borderLeft + paddingLeft + width + paddingRight + borderRight + *right);
 
-    auto boxWidth = (*left + *marginStart + borderLeft + paddingLeft + width + paddingRight + borderRight + *marginEnd + *right);
+    auto boxWidth = (*left + *usedMarginStart + borderLeft + paddingLeft + width + paddingRight + borderRight + *usedMarginEnd + *right);
     if (boxWidth > containingBlockWidth) {
         // #5 Over-constrained?
         if (isLeftToRightDirection)
-            right = containingBlockWidth - (*left + *marginStart + borderLeft + paddingLeft + width + paddingRight + borderRight + *marginEnd);
+            right = containingBlockWidth - (*left + *usedMarginStart + borderLeft + paddingLeft + width + paddingRight + borderRight + *usedMarginEnd);
         else
-            left = containingBlockWidth - (*marginStart + borderLeft + paddingLeft + width + paddingRight + borderRight + *marginEnd + *right);
+            left = containingBlockWidth - (*usedMarginStart + borderLeft + paddingLeft + width + paddingRight + borderRight + *usedMarginEnd + *right);
     }
 
     ASSERT(left);
     ASSERT(right);
-    ASSERT(marginStart);
-    ASSERT(marginEnd);
+    ASSERT(usedMarginStart);
+    ASSERT(usedMarginEnd);
 
-    LOG_WITH_STREAM(FormattingContextLayout, stream << "[Position][Width][Margin] -> out-of-flow replaced -> left(" << *left << "px) right("  << *right << "px) width(" << width << "px) margin(" << *marginStart << "px, "  << *marginEnd << "px) layoutBox(" << &layoutBox << ")");
-    return { *left, *right, { width, { *marginStart, *marginEnd }, { nonComputedMarginStart, nonComputedMarginEnd } } };
+    LOG_WITH_STREAM(FormattingContextLayout, stream << "[Position][Width][Margin] -> out-of-flow replaced -> left(" << *left << "px) right("  << *right << "px) width(" << width << "px) margin(" << *usedMarginStart << "px, "  << *usedMarginEnd << "px) layoutBox(" << &layoutBox << ")");
+    return { *left, *right, { width, { *usedMarginStart, *usedMarginEnd }, { computedMarginStart.valueOr(0), computedMarginEnd.valueOr(0) } } };
 }
 
 HeightAndMargin FormattingContext::Geometry::complicatedCases(const LayoutState& layoutState, const Box& layoutBox, Optional<LayoutUnit> usedHeight)
@@ -693,12 +697,13 @@
     auto containingBlockWidth = containingBlockDisplayBox.contentBoxWidth();
 
     auto height = usedHeight ? usedHeight.value() : computedHeightValue(layoutState, layoutBox, HeightType::Normal);
-    auto marginBefore = computedValueIfNotAuto(style.marginBefore(), containingBlockWidth);
-    auto marginAfter = computedValueIfNotAuto(style.marginAfter(), containingBlockWidth);
+    auto computedMarginBefore = computedValueIfNotAuto(style.marginBefore(), containingBlockWidth);
+    auto computedMarginAfter = computedValueIfNotAuto(style.marginAfter(), containingBlockWidth);
 
     // #1
-    marginBefore = marginBefore.valueOr(0);
-    marginAfter = marginAfter.valueOr(0);
+    auto usedMarginBefore = computedMarginBefore.valueOr(0);
+    auto usedMarginAfter = computedMarginAfter.valueOr(0);
+
     // #2
     if (!height) {
         ASSERT(isHeightAuto(layoutBox));
@@ -706,11 +711,9 @@
     }
 
     ASSERT(height);
-    ASSERT(marginBefore);
-    ASSERT(marginAfter);
 
-    LOG_WITH_STREAM(FormattingContextLayout, stream << "[Height][Margin] -> floating non-replaced -> height(" << *height << "px) margin(" << *marginBefore << "px, " << *marginAfter << "px) -> layoutBox(" << &layoutBox << ")");
-    return HeightAndMargin { *height, { { *marginBefore, *marginAfter }, { } } };
+    LOG_WITH_STREAM(FormattingContextLayout, stream << "[Height][Margin] -> floating non-replaced -> height(" << *height << "px) margin(" << usedMarginBefore << "px, " << usedMarginAfter << "px) -> layoutBox(" << &layoutBox << ")");
+    return HeightAndMargin { *height, { { usedMarginBefore, usedMarginAfter }, { } } };
 }
 
 WidthAndMargin FormattingContext::Geometry::floatingNonReplacedWidthAndMargin(LayoutState& layoutState, const Box& layoutBox, Optional<LayoutUnit> usedWidth)
@@ -869,7 +872,14 @@
     auto& containingBlockDisplayBox = layoutState.displayBoxForLayoutBox(*layoutBox.containingBlock());
     auto containingBlockWidth = containingBlockDisplayBox.width();
 
-    auto computeMarginEnd = [&]() {
+    auto usedMarginStart = [&] {
+        if (precomputedMarginStart)
+            return precomputedMarginStart.value();
+        auto marginStart = computedValueIfNotAuto(style.marginStart(), containingBlockWidth);
+        return marginStart.valueOr(0_lu);
+    };
+
+    auto usedMarginEnd = [&] {
         if (precomputedMarginEnd)
             return precomputedMarginEnd.value();
         auto marginEnd = computedValueIfNotAuto(style.marginEnd(), containingBlockWidth);
@@ -876,22 +886,10 @@
         return marginEnd.valueOr(0_lu);
     };
 
-    auto computeMarginStart = [&]() {
-        if (precomputedMarginStart)
-            return precomputedMarginStart.value();
-        auto marginStart = computedValueIfNotAuto(style.marginStart(), containingBlockWidth);
-        return marginStart.valueOr(0_lu);
-    };
-
     auto replaced = layoutBox.replaced();
     ASSERT(replaced);
 
-    auto marginStart = computeMarginStart();
-    auto marginEnd = computeMarginEnd();
-    auto nonComputedMarginStart = computedValueIfNotAuto(style.marginStart(), containingBlockWidth).valueOr(0);
-    auto nonComputedMarginEnd = computedValueIfNotAuto(style.marginEnd(), containingBlockWidth).valueOr(0);
     auto width = computedValueIfNotAuto(usedWidth ? Length { usedWidth.value(), Fixed } : style.logicalWidth(), containingBlockWidth);
-
     auto heightIsAuto = isHeightAuto(layoutBox);
     auto height = computedHeightValue(layoutState, layoutBox, HeightType::Normal);
 
@@ -916,8 +914,10 @@
 
     ASSERT(width);
 
-    LOG_WITH_STREAM(FormattingContextLayout, stream << "[Width][Margin] -> inflow replaced -> width(" << *width << "px) margin(" << marginStart << "px, " << marginEnd << "px) -> layoutBox(" << &layoutBox << ")");
-    return { *width, { marginStart, marginEnd }, { nonComputedMarginStart, nonComputedMarginEnd } };
+    LOG_WITH_STREAM(FormattingContextLayout, stream << "[Width][Margin] -> inflow replaced -> width(" << *width << "px) margin(" << usedMarginStart() << "px, " << usedMarginEnd() << "px) -> layoutBox(" << &layoutBox << ")");
+    auto computedMarginStart = computedValueIfNotAuto(style.marginStart(), containingBlockWidth);
+    auto computedMarginEnd = computedValueIfNotAuto(style.marginEnd(), containingBlockWidth);
+    return { *width, { usedMarginStart(), usedMarginEnd() }, { computedMarginStart.valueOr(0), computedMarginEnd.valueOr(0) } };
 }
 
 LayoutSize FormattingContext::Geometry::inFlowPositionedPositionOffset(const LayoutState& layoutState, const Box& layoutBox)
@@ -1037,11 +1037,11 @@
     auto& style = layoutBox.style();
     auto containingBlockWidth = layoutState.displayBoxForLayoutBox(*layoutBox.containingBlock()).contentBoxWidth();
 
-    auto marginBefore = computedValueIfNotAuto(style.marginBefore(), containingBlockWidth).valueOr(0_lu);
-    auto marginAfter = computedValueIfNotAuto(style.marginAfter(), containingBlockWidth).valueOr(0_lu);
+    auto usedMarginBefore = computedValueIfNotAuto(style.marginBefore(), containingBlockWidth).valueOr(0_lu);
+    auto usedMarginAfter = computedValueIfNotAuto(style.marginAfter(), containingBlockWidth).valueOr(0_lu);
 
-    LOG_WITH_STREAM(FormattingContextLayout, stream << "[Margin] -> non collapsed vertical -> margin(" << marginBefore << "px, " << marginAfter << "px) -> layoutBox: " << &layoutBox);
-    return { marginBefore, marginAfter };
+    LOG_WITH_STREAM(FormattingContextLayout, stream << "[Margin] -> non collapsed vertical -> margin(" << usedMarginBefore << "px, " << usedMarginAfter << "px) -> layoutBox: " << &layoutBox);
+    return { usedMarginBefore, usedMarginAfter };
 }
 
 }

Modified: trunk/Source/WebCore/layout/LayoutState.cpp (239607 => 239608)


--- trunk/Source/WebCore/layout/LayoutState.cpp	2019-01-04 14:34:39 UTC (rev 239607)
+++ trunk/Source/WebCore/layout/LayoutState.cpp	2019-01-04 15:21:45 UTC (rev 239608)
@@ -54,7 +54,7 @@
 
     auto& displayBox = displayBoxForLayoutBox(initialContainingBlock);
     displayBox.setHorizontalMargin({ });
-    displayBox.setHorizontalNonComputedMargin({ });
+    displayBox.setHorizontalComputedMargin({ });
     displayBox.setVerticalMargin({ });
     displayBox.setBorder({ });
     displayBox.setPadding({ });

Modified: trunk/Source/WebCore/layout/LayoutUnits.h (239607 => 239608)


--- trunk/Source/WebCore/layout/LayoutUnits.h	2019-01-04 14:34:39 UTC (rev 239607)
+++ trunk/Source/WebCore/layout/LayoutUnits.h	2019-01-04 15:21:45 UTC (rev 239608)
@@ -103,9 +103,8 @@
 
 struct WidthAndMargin {
     LayoutUnit width;
-    HorizontalMargin margin;
-    // FIXME: Figure out if we really really need this.
-    HorizontalMargin nonComputedMargin;
+    HorizontalMargin usedMargin;
+    HorizontalMargin computedMargin;
 };
 
 struct HeightAndMargin {

Modified: trunk/Source/WebCore/layout/Verification.cpp (239607 => 239608)


--- trunk/Source/WebCore/layout/Verification.cpp	2019-01-04 14:34:39 UTC (rev 239607)
+++ trunk/Source/WebCore/layout/Verification.cpp	2019-01-04 15:21:45 UTC (rev 239608)
@@ -247,8 +247,8 @@
 
         return Display::Box::Rect {
             borderBox.top() - displayBox.nonCollapsedMarginBefore(),
-            borderBox.left() - displayBox.nonComputedMarginStart(),
-            displayBox.nonComputedMarginStart() + borderBox.width() + displayBox.nonComputedMarginEnd(),
+            borderBox.left() - displayBox.computedMarginStart(),
+            displayBox.computedMarginStart() + borderBox.width() + displayBox.computedMarginEnd(),
             displayBox.nonCollapsedMarginBefore() + borderBox.height() + displayBox.nonCollapsedMarginAfter()
         };
     };

Modified: trunk/Source/WebCore/layout/blockformatting/BlockFormattingContext.cpp (239607 => 239608)


--- trunk/Source/WebCore/layout/blockformatting/BlockFormattingContext.cpp	2019-01-04 14:34:39 UTC (rev 239607)
+++ trunk/Source/WebCore/layout/blockformatting/BlockFormattingContext.cpp	2019-01-04 15:21:45 UTC (rev 239608)
@@ -331,9 +331,9 @@
 
     auto& displayBox = layoutState.displayBoxForLayoutBox(layoutBox);
     displayBox.setContentBoxWidth(widthAndMargin.width);
-    displayBox.moveHorizontally(widthAndMargin.margin.start);
-    displayBox.setHorizontalMargin(widthAndMargin.margin);
-    displayBox.setHorizontalNonComputedMargin(widthAndMargin.nonComputedMargin);
+    displayBox.moveHorizontally(widthAndMargin.usedMargin.start);
+    displayBox.setHorizontalMargin(widthAndMargin.usedMargin);
+    displayBox.setHorizontalComputedMargin(widthAndMargin.computedMargin);
 }
 
 void BlockFormattingContext::computeHeightAndMargin(const Box& layoutBox) const

Modified: trunk/Source/WebCore/layout/blockformatting/BlockFormattingContextGeometry.cpp (239607 => 239608)


--- trunk/Source/WebCore/layout/blockformatting/BlockFormattingContextGeometry.cpp	2019-01-04 14:34:39 UTC (rev 239607)
+++ trunk/Source/WebCore/layout/blockformatting/BlockFormattingContextGeometry.cpp	2019-01-04 15:21:45 UTC (rev 239608)
@@ -141,10 +141,10 @@
         auto& displayBox = layoutState.displayBoxForLayoutBox(layoutBox);
 
         auto width = computedValueIfNotAuto(usedWidth ? Length { usedWidth.value(), Fixed } : style.logicalWidth(), containingBlockWidth);
-        auto marginStart = computedValueIfNotAuto(style.marginStart(), containingBlockWidth);
-        auto marginEnd = computedValueIfNotAuto(style.marginEnd(), containingBlockWidth);
-        auto nonComputedMarginStart = marginStart.valueOr(0);
-        auto nonComputedMarginEnd = marginEnd.valueOr(0);
+        auto computedMarginStart = computedValueIfNotAuto(style.marginStart(), containingBlockWidth);
+        auto computedMarginEnd = computedValueIfNotAuto(style.marginEnd(), containingBlockWidth);
+        auto usedMarginStart = computedMarginStart;
+        auto usedMarginEnd = computedMarginEnd;
         auto borderLeft = displayBox.borderLeft();
         auto borderRight = displayBox.borderRight();
         auto paddingLeft = displayBox.paddingLeft().valueOr(0);
@@ -152,51 +152,51 @@
 
         // #1
         if (width) {
-            auto horizontalSpaceForMargin = containingBlockWidth - (marginStart.valueOr(0) + borderLeft + paddingLeft + *width + paddingRight + borderRight + marginEnd.valueOr(0));
+            auto horizontalSpaceForMargin = containingBlockWidth - (usedMarginStart.valueOr(0) + borderLeft + paddingLeft + *width + paddingRight + borderRight + usedMarginEnd.valueOr(0));
             if (horizontalSpaceForMargin < 0) {
-                marginStart = marginStart.valueOr(0);
-                marginEnd = marginEnd.valueOr(0);
+                usedMarginStart = usedMarginStart.valueOr(0);
+                usedMarginEnd = usedMarginEnd.valueOr(0);
             }
         }
 
         // #2
-        if (width && marginStart && marginEnd) {
+        if (width && usedMarginStart && usedMarginEnd) {
             if (containingBlock->style().isLeftToRightDirection())
-                marginEnd = containingBlockWidth - (*marginStart + borderLeft + paddingLeft  + *width + paddingRight + borderRight);
+                usedMarginEnd = containingBlockWidth - (*usedMarginStart + borderLeft + paddingLeft  + *width + paddingRight + borderRight);
             else
-                marginStart = containingBlockWidth - (borderLeft + paddingLeft + *width + paddingRight + borderRight + *marginEnd);
+                usedMarginStart = containingBlockWidth - (borderLeft + paddingLeft + *width + paddingRight + borderRight + *usedMarginEnd);
         }
 
         // #3
-        if (!marginStart && width && marginEnd)
-            marginStart = containingBlockWidth - (borderLeft + paddingLeft  + *width + paddingRight + borderRight + *marginEnd);
-        else if (marginStart && !width && marginEnd)
-            width = containingBlockWidth - (*marginStart + borderLeft + paddingLeft + paddingRight + borderRight + *marginEnd);
-        else if (marginStart && width && !marginEnd)
-            marginEnd = containingBlockWidth - (*marginStart + borderLeft + paddingLeft + *width + paddingRight + borderRight);
+        if (!usedMarginStart && width && usedMarginEnd)
+            usedMarginStart = containingBlockWidth - (borderLeft + paddingLeft  + *width + paddingRight + borderRight + *usedMarginEnd);
+        else if (usedMarginStart && !width && usedMarginEnd)
+            width = containingBlockWidth - (*usedMarginStart + borderLeft + paddingLeft + paddingRight + borderRight + *usedMarginEnd);
+        else if (usedMarginStart && width && !usedMarginEnd)
+            usedMarginEnd = containingBlockWidth - (*usedMarginStart + borderLeft + paddingLeft + *width + paddingRight + borderRight);
 
         // #4
         if (!width) {
-            marginStart = marginStart.valueOr(0);
-            marginEnd = marginEnd.valueOr(0);
-            width = containingBlockWidth - (*marginStart + borderLeft + paddingLeft + paddingRight + borderRight + *marginEnd);
+            usedMarginStart = usedMarginStart.valueOr(0);
+            usedMarginEnd = usedMarginEnd.valueOr(0);
+            width = containingBlockWidth - (*usedMarginStart + borderLeft + paddingLeft + paddingRight + borderRight + *usedMarginEnd);
         }
 
         // #5
-        if (!marginStart && !marginEnd) {
+        if (!usedMarginStart && !usedMarginEnd) {
             auto horizontalSpaceForMargin = containingBlockWidth - (borderLeft + paddingLeft  + *width + paddingRight + borderRight);
-            marginStart = marginEnd = horizontalSpaceForMargin / 2;
+            usedMarginStart = usedMarginEnd = horizontalSpaceForMargin / 2;
         }
 
         ASSERT(width);
-        ASSERT(marginStart);
-        ASSERT(marginEnd);
+        ASSERT(usedMarginStart);
+        ASSERT(usedMarginEnd);
 
-        return WidthAndMargin { *width, { *marginStart, *marginEnd }, { nonComputedMarginStart, nonComputedMarginEnd } };
+        return WidthAndMargin { *width, { *usedMarginStart, *usedMarginEnd }, { computedMarginStart.valueOr(0), computedMarginEnd.valueOr(0) } };
     };
 
     auto widthAndMargin = compute();
-    LOG_WITH_STREAM(FormattingContextLayout, stream << "[Width][Margin] -> inflow non-replaced -> width(" << widthAndMargin.width << "px) margin(" << widthAndMargin.margin.start << "px, " << widthAndMargin.margin.end << "px) -> layoutBox(" << &layoutBox << ")");
+    LOG_WITH_STREAM(FormattingContextLayout, stream << "[Width][Margin] -> inflow non-replaced -> width(" << widthAndMargin.width << "px) margin(" << widthAndMargin.usedMargin.start << "px, " << widthAndMargin.usedMargin.end << "px) -> layoutBox(" << &layoutBox << ")");
     return widthAndMargin;
 }
 
@@ -214,8 +214,8 @@
     // #2
     auto nonReplacedWidthAndMargin = inFlowNonReplacedWidthAndMargin(layoutState, layoutBox, width);
 
-    LOG_WITH_STREAM(FormattingContextLayout, stream << "[Width][Margin] -> inflow replaced -> width(" << width << "px) margin(" << nonReplacedWidthAndMargin.margin.start << "px, " << nonReplacedWidthAndMargin.margin.end << "px) -> layoutBox(" << &layoutBox << ")");
-    return { width, nonReplacedWidthAndMargin.margin, nonReplacedWidthAndMargin.nonComputedMargin };
+    LOG_WITH_STREAM(FormattingContextLayout, stream << "[Width][Margin] -> inflow replaced -> width(" << width << "px) margin(" << nonReplacedWidthAndMargin.usedMargin.start << "px, " << nonReplacedWidthAndMargin.usedMargin.end << "px) -> layoutBox(" << &layoutBox << ")");
+    return { width, nonReplacedWidthAndMargin.usedMargin, nonReplacedWidthAndMargin.computedMargin };
 }
 
 Point BlockFormattingContext::Geometry::staticPosition(const LayoutState& layoutState, const Box& layoutBox)

Modified: trunk/Source/WebCore/layout/displaytree/DisplayBox.cpp (239607 => 239608)


--- trunk/Source/WebCore/layout/displaytree/DisplayBox.cpp	2019-01-04 14:34:39 UTC (rev 239607)
+++ trunk/Source/WebCore/layout/displaytree/DisplayBox.cpp	2019-01-04 15:21:45 UTC (rev 239608)
@@ -59,7 +59,7 @@
     , m_contentHeight(other.m_contentHeight)
     , m_horizontalMargin(other.m_horizontalMargin)
     , m_verticalMargin(other.m_verticalMargin)
-    , m_horizontalNonComputedMargin(other.m_horizontalNonComputedMargin)
+    , m_horizontalComputedMargin(other.m_horizontalComputedMargin)
     , m_estimatedMarginBefore(other.m_estimatedMarginBefore)
     , m_border(other.m_border)
     , m_padding(other.m_padding)
@@ -69,7 +69,7 @@
     , m_hasValidHorizontalMargin(other.m_hasValidHorizontalMargin)
     , m_hasValidVerticalMargin(other.m_hasValidVerticalMargin)
     , m_hasValidVerticalNonCollapsedMargin(other.m_hasValidVerticalNonCollapsedMargin)
-    , m_hasValidHorizontalNonComputedMargin(other.m_hasValidHorizontalNonComputedMargin)
+    , m_hasValidHorizontalComputedMargin(other.m_hasValidHorizontalComputedMargin)
     , m_hasValidBorder(other.m_hasValidBorder)
     , m_hasValidPadding(other.m_hasValidPadding)
     , m_hasValidContentHeight(other.m_hasValidContentHeight)

Modified: trunk/Source/WebCore/layout/displaytree/DisplayBox.h (239607 => 239608)


--- trunk/Source/WebCore/layout/displaytree/DisplayBox.h	2019-01-04 14:34:39 UTC (rev 239607)
+++ trunk/Source/WebCore/layout/displaytree/DisplayBox.h	2019-01-04 15:21:45 UTC (rev 239608)
@@ -146,8 +146,8 @@
 
     LayoutUnit nonCollapsedMarginBefore() const;
     LayoutUnit nonCollapsedMarginAfter() const;
-    LayoutUnit nonComputedMarginStart() const;
-    LayoutUnit nonComputedMarginEnd() const;
+    LayoutUnit computedMarginStart() const;
+    LayoutUnit computedMarginEnd() const;
 
     Optional<LayoutUnit> estimatedMarginBefore() const { return m_estimatedMarginBefore; }
 
@@ -193,7 +193,7 @@
 
     void setHorizontalMargin(Layout::HorizontalMargin);
     void setVerticalMargin(Layout::VerticalMargin);
-    void setHorizontalNonComputedMargin(Layout::HorizontalMargin);
+    void setHorizontalComputedMargin(Layout::HorizontalMargin);
     void setEstimatedMarginBefore(LayoutUnit marginBefore) { m_estimatedMarginBefore = marginBefore; }
 
     void setBorder(Layout::Edges);
@@ -208,7 +208,7 @@
     void setHasValidLeft() { m_hasValidLeft = true; }
     void setHasValidVerticalMargin() { m_hasValidVerticalMargin = true; }
     void setHasValidVerticalNonCollapsedMargin() { m_hasValidVerticalNonCollapsedMargin = true; }
-    void setHasValidHorizontalNonComputedMargin() { m_hasValidHorizontalNonComputedMargin = true; }
+    void setHasValidHorizontalComputedMargin() { m_hasValidHorizontalComputedMargin = true; }
     void setHasValidHorizontalMargin() { m_hasValidHorizontalMargin = true; }
 
     void setHasValidBorder() { m_hasValidBorder = true; }
@@ -226,7 +226,7 @@
 
     Layout::HorizontalMargin m_horizontalMargin;
     Layout::VerticalMargin m_verticalMargin;
-    Layout::HorizontalMargin m_horizontalNonComputedMargin;
+    Layout::HorizontalMargin m_horizontalComputedMargin;
     Optional<LayoutUnit> m_estimatedMarginBefore;
 
     Layout::Edges m_border;
@@ -238,7 +238,7 @@
     bool m_hasValidHorizontalMargin { false };
     bool m_hasValidVerticalMargin { false };
     bool m_hasValidVerticalNonCollapsedMargin { false };
-    bool m_hasValidHorizontalNonComputedMargin { false };
+    bool m_hasValidHorizontalComputedMargin { false };
     bool m_hasValidBorder { false };
     bool m_hasValidPadding { false };
     bool m_hasValidContentHeight { false };
@@ -525,12 +525,12 @@
     m_verticalMargin = margin;
 }
 
-inline void Box::setHorizontalNonComputedMargin(Layout::HorizontalMargin margin)
+inline void Box::setHorizontalComputedMargin(Layout::HorizontalMargin margin)
 {
 #if !ASSERT_DISABLED
-    setHasValidHorizontalNonComputedMargin();
+    setHasValidHorizontalComputedMargin();
 #endif
-    m_horizontalNonComputedMargin = margin;
+    m_horizontalComputedMargin = margin;
 }
 
 inline void Box::setBorder(Layout::Edges border)
@@ -591,16 +591,16 @@
     return m_verticalMargin.nonCollapsedValues().after;
 }
 
-inline LayoutUnit Box::nonComputedMarginStart() const
+inline LayoutUnit Box::computedMarginStart() const
 {
-    ASSERT(m_hasValidHorizontalNonComputedMargin);
-    return m_horizontalNonComputedMargin.start;
+    ASSERT(m_hasValidHorizontalComputedMargin);
+    return m_horizontalComputedMargin.start;
 }
 
-inline LayoutUnit Box::nonComputedMarginEnd() const
+inline LayoutUnit Box::computedMarginEnd() const
 {
-    ASSERT(m_hasValidHorizontalNonComputedMargin);
-    return m_horizontalNonComputedMargin.end;
+    ASSERT(m_hasValidHorizontalComputedMargin);
+    return m_horizontalComputedMargin.end;
 }
 
 inline Optional<LayoutUnit> Box::paddingTop() const

Modified: trunk/Source/WebCore/layout/floats/FloatAvoider.h (239607 => 239608)


--- trunk/Source/WebCore/layout/floats/FloatAvoider.h	2019-01-04 14:34:39 UTC (rev 239607)
+++ trunk/Source/WebCore/layout/floats/FloatAvoider.h	2019-01-04 15:21:45 UTC (rev 239608)
@@ -72,8 +72,9 @@
 
     LayoutUnit marginBefore() const { return displayBox().marginBefore(); }
     LayoutUnit marginAfter() const { return displayBox().marginAfter(); }
-    LayoutUnit marginStart() const { return displayBox().nonComputedMarginStart(); }
-    LayoutUnit marginEnd() const { return displayBox().nonComputedMarginEnd(); }
+    // Do not use the used values here because they computed as if this box was not a float avoider.
+    LayoutUnit marginStart() const { return displayBox().computedMarginStart(); }
+    LayoutUnit marginEnd() const { return displayBox().computedMarginEnd(); }
 
     LayoutUnit marginBoxWidth() const { return marginStart() + displayBox().width() + marginEnd(); }
 

Modified: trunk/Source/WebCore/layout/inlineformatting/InlineFormattingContext.cpp (239607 => 239608)


--- trunk/Source/WebCore/layout/inlineformatting/InlineFormattingContext.cpp	2019-01-04 14:34:39 UTC (rev 239607)
+++ trunk/Source/WebCore/layout/inlineformatting/InlineFormattingContext.cpp	2019-01-04 15:21:45 UTC (rev 239608)
@@ -342,8 +342,8 @@
 
     auto& displayBox = layoutState.displayBoxForLayoutBox(layoutBox);
     displayBox.setContentBoxWidth(widthAndMargin.width);
-    displayBox.setHorizontalMargin(widthAndMargin.margin);
-    displayBox.setHorizontalNonComputedMargin(widthAndMargin.nonComputedMargin);
+    displayBox.setHorizontalMargin(widthAndMargin.usedMargin);
+    displayBox.setHorizontalComputedMargin(widthAndMargin.computedMargin);
 }
 
 void InlineFormattingContext::computeHeightAndMargin(const Box& layoutBox) const
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to