Title: [240711] trunk
Revision
240711
Author
[email protected]
Date
2019-01-30 08:13:07 -0800 (Wed, 30 Jan 2019)

Log Message

[LFC] Use the used margin values in outOfFlowReplacedVerticalGeometry consistently
https://bugs.webkit.org/show_bug.cgi?id=194020

Reviewed by Antti Koivisto.

Source/WebCore:

Check the used margin variables whether we already computed before/after values.

Test: fast/block/block-only/absolute-position-with-margin-auto-simple.html

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

Tools:

* LayoutReloaded/misc/LFC-passing-tests.txt:

LayoutTests:

* fast/block/block-only/absolute-position-with-margin-auto-simple-expected.html: Added.
* fast/block/block-only/absolute-position-with-margin-auto-simple.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (240710 => 240711)


--- trunk/LayoutTests/ChangeLog	2019-01-30 15:10:36 UTC (rev 240710)
+++ trunk/LayoutTests/ChangeLog	2019-01-30 16:13:07 UTC (rev 240711)
@@ -1,3 +1,13 @@
+2019-01-30  Zalan Bujtas  <[email protected]>
+
+        [LFC] Use the used margin values in outOfFlowReplacedVerticalGeometry consistently
+        https://bugs.webkit.org/show_bug.cgi?id=194020
+
+        Reviewed by Antti Koivisto.
+
+        * fast/block/block-only/absolute-position-with-margin-auto-simple-expected.html: Added.
+        * fast/block/block-only/absolute-position-with-margin-auto-simple.html: Added.
+
 2019-01-30  Chris Fleizach  <[email protected]>
 
         AX: Support color well on iOS

Added: trunk/LayoutTests/fast/block/block-only/absolute-position-with-margin-auto-simple-expected.html (0 => 240711)


--- trunk/LayoutTests/fast/block/block-only/absolute-position-with-margin-auto-simple-expected.html	                        (rev 0)
+++ trunk/LayoutTests/fast/block/block-only/absolute-position-with-margin-auto-simple-expected.html	2019-01-30 16:13:07 UTC (rev 240711)
@@ -0,0 +1,9 @@
+<style>
+div {
+    background-color: green;
+    width: 100px;
+    height: 100px;
+}
+</style>
+<div style="position: relative; top: 10px;"></div>
+<div style="position: relative; top: 290px;"></div>

Added: trunk/LayoutTests/fast/block/block-only/absolute-position-with-margin-auto-simple.html (0 => 240711)


--- trunk/LayoutTests/fast/block/block-only/absolute-position-with-margin-auto-simple.html	                        (rev 0)
+++ trunk/LayoutTests/fast/block/block-only/absolute-position-with-margin-auto-simple.html	2019-01-30 16:13:07 UTC (rev 240711)
@@ -0,0 +1,15 @@
+<style>
+div {
+    margin-bottom: auto;
+    margin-top: auto;
+    position: absolute;
+    background-color: green;
+    width: 100px;
+}
+</style>
+<div style="height: 500px; width: 500px; background-color: transparent">
+ <div style="top: 10px;"></div>
+ <div style="bottom: 10px;"></div>
+ <div style="top: 10px; height: 100px"></div>
+ <div style="bottom: 10px; height: 100px"></div>
+</div>
\ No newline at end of file

Modified: trunk/Source/WebCore/ChangeLog (240710 => 240711)


--- trunk/Source/WebCore/ChangeLog	2019-01-30 15:10:36 UTC (rev 240710)
+++ trunk/Source/WebCore/ChangeLog	2019-01-30 16:13:07 UTC (rev 240711)
@@ -1,3 +1,17 @@
+2019-01-30  Zalan Bujtas  <[email protected]>
+
+        [LFC] Use the used margin values in outOfFlowReplacedVerticalGeometry consistently
+        https://bugs.webkit.org/show_bug.cgi?id=194020
+
+        Reviewed by Antti Koivisto.
+
+        Check the used margin variables whether we already computed before/after values.
+
+        Test: fast/block/block-only/absolute-position-with-margin-auto-simple.html
+
+        * layout/FormattingContextGeometry.cpp:
+        (WebCore::Layout::FormattingContext::Geometry::outOfFlowReplacedVerticalGeometry):
+
 2019-01-30  Chris Fleizach  <[email protected]>
 
         AX: Support color well on iOS

Modified: trunk/Source/WebCore/layout/FormattingContextGeometry.cpp (240710 => 240711)


--- trunk/Source/WebCore/layout/FormattingContextGeometry.cpp	2019-01-30 15:10:36 UTC (rev 240710)
+++ trunk/Source/WebCore/layout/FormattingContextGeometry.cpp	2019-01-30 16:13:07 UTC (rev 240711)
@@ -554,7 +554,8 @@
     auto isStaticallyPositioned = !top && !bottom;
     auto height = inlineReplacedHeightAndMargin(layoutState, layoutBox, usedHeight).height;
     auto computedVerticalMargin = Geometry::computedVerticalMargin(layoutState, layoutBox);
-    UsedVerticalMargin::NonCollapsedValues usedVerticalMargin; 
+    Optional<LayoutUnit> usedMarginBefore;
+    Optional<LayoutUnit> usedMarginAfter;
     auto paddingTop = displayBox.paddingTop().valueOr(0);
     auto paddingBottom = displayBox.paddingBottom().valueOr(0);
     auto borderTop = displayBox.borderTop();
@@ -567,32 +568,34 @@
 
     if (!bottom) {
         // #2
-        usedVerticalMargin = { computedVerticalMargin.before.valueOr(0), computedVerticalMargin.after.valueOr(0) };
+        usedMarginBefore = computedVerticalMargin.before.valueOr(0);
+        usedMarginAfter = usedMarginBefore;
     }
 
-    if (!computedVerticalMargin.before && !computedVerticalMargin.after) {
+    if (!usedMarginBefore && !usedMarginAfter) {
         // #3
         auto marginBeforeAndAfter = containingBlockHeight - (*top + borderTop + paddingTop + height + paddingBottom + borderBottom + *bottom);
-        usedVerticalMargin = { marginBeforeAndAfter / 2, marginBeforeAndAfter / 2 };
+        usedMarginBefore = marginBeforeAndAfter / 2;
+        usedMarginAfter = usedMarginBefore;
     }
 
     // #4
     if (!top)
-        top = containingBlockHeight - (usedVerticalMargin.before + borderTop + paddingTop + height + paddingBottom + borderBottom + usedVerticalMargin.after + *bottom);
+        top = containingBlockHeight - (*usedMarginBefore + borderTop + paddingTop + height + paddingBottom + borderBottom + *usedMarginAfter + *bottom);
 
     if (!bottom)
-        bottom = containingBlockHeight - (*top + usedVerticalMargin.before + borderTop + paddingTop + height + paddingBottom + borderBottom + usedVerticalMargin.after);
+        bottom = containingBlockHeight - (*top + *usedMarginBefore + borderTop + paddingTop + height + paddingBottom + borderBottom + *usedMarginAfter);
 
-    if (!computedVerticalMargin.before)
-        usedVerticalMargin.before = containingBlockHeight - (*top + borderTop + paddingTop + height + paddingBottom + borderBottom + usedVerticalMargin.after + *bottom);
+    if (!usedMarginBefore)
+        usedMarginBefore = containingBlockHeight - (*top + borderTop + paddingTop + height + paddingBottom + borderBottom + *usedMarginAfter + *bottom);
 
-    if (!computedVerticalMargin.after)
-        usedVerticalMargin.after = containingBlockHeight - (*top + usedVerticalMargin.before + borderTop + paddingTop + height + paddingBottom + borderBottom + *bottom);
+    if (!usedMarginAfter)
+        usedMarginAfter = containingBlockHeight - (*top + *usedMarginBefore + borderTop + paddingTop + height + paddingBottom + borderBottom + *bottom);
 
     // #5
-    auto boxHeight = *top + usedVerticalMargin.before + borderTop + paddingTop + height + paddingBottom + borderBottom + usedVerticalMargin.after + *bottom;
+    auto boxHeight = *top + *usedMarginBefore + borderTop + paddingTop + height + paddingBottom + borderBottom + *usedMarginAfter + *bottom;
     if (boxHeight > containingBlockHeight)
-        bottom = containingBlockHeight - (*top + usedVerticalMargin.before + borderTop + paddingTop + height + paddingBottom + borderBottom + usedVerticalMargin.after); 
+        bottom = containingBlockHeight - (*top + *usedMarginBefore + borderTop + paddingTop + height + paddingBottom + borderBottom + *usedMarginAfter); 
 
     // For out-of-flow elements the containing block is formed by the padding edge of the ancestor.
     // At this point the non-statically positioned value is in the coordinate system of the padding box. Let's convert it to border box coordinate system.
@@ -602,8 +605,12 @@
         *bottom += containingBlockPaddingVerticalEdge;
     }
 
-    LOG_WITH_STREAM(FormattingContextLayout, stream << "[Position][Height][Margin] -> out-of-flow replaced -> top(" << *top << "px) bottom("  << *bottom << "px) height(" << height << "px) margin(" << usedVerticalMargin.before << "px, "  << usedVerticalMargin.after << "px) layoutBox(" << &layoutBox << ")");
-    return { *top, *bottom, { height, usedVerticalMargin } };
+    ASSERT(top);
+    ASSERT(bottom);
+    ASSERT(usedMarginBefore);
+    ASSERT(usedMarginAfter);
+    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)

Modified: trunk/Tools/ChangeLog (240710 => 240711)


--- trunk/Tools/ChangeLog	2019-01-30 15:10:36 UTC (rev 240710)
+++ trunk/Tools/ChangeLog	2019-01-30 16:13:07 UTC (rev 240711)
@@ -1,3 +1,12 @@
+2019-01-30  Zalan Bujtas  <[email protected]>
+
+        [LFC] Use the used margin values in outOfFlowReplacedVerticalGeometry consistently
+        https://bugs.webkit.org/show_bug.cgi?id=194020
+
+        Reviewed by Antti Koivisto.
+
+        * LayoutReloaded/misc/LFC-passing-tests.txt:
+
 2019-01-30  Chris Fleizach  <[email protected]>
 
         AX: Support color well on iOS

Modified: trunk/Tools/LayoutReloaded/misc/LFC-passing-tests.txt (240710 => 240711)


--- trunk/Tools/LayoutReloaded/misc/LFC-passing-tests.txt	2019-01-30 15:10:36 UTC (rev 240710)
+++ trunk/Tools/LayoutReloaded/misc/LFC-passing-tests.txt	2019-01-30 16:13:07 UTC (rev 240711)
@@ -82,6 +82,7 @@
 fast/block/block-only/non-auto-top-bottom-height-with-margins.html
 fast/block/block-only/non-auto-top-bottom-height-with-auto-margins.html
 fast/block/block-only/abs-pos-with-border-padding-and-float-child-expected.html
+fast/block/block-only/absolute-position-with-margin-auto-simple.html
 fast/block/basic/002.html
 fast/block/basic/003.html
 fast/block/basic/004.html
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to