Title: [287064] trunk
Revision
287064
Author
svil...@igalia.com
Date
2021-12-15 01:03:52 -0800 (Wed, 15 Dec 2021)

Log Message

[css-flexbox] Absolutely positioned children should be aligned using the margin box
https://bugs.webkit.org/show_bug.cgi?id=234244

Reviewed by Darin Adler.

LayoutTests/imported/w3c:

* web-platform-tests/css/css-flexbox/abspos/position-absolute-014-expected.txt: Replaced FAIL
by PASS expectations.

Source/WebCore:

When aligning absolutely positioned children we must use the child's margin box. We were
using the border box instead, and thus ignoring margins when aligning absolutely positioned
flexbox children.

This fixes position-absolute-014.html from the WPT suite.

* rendering/RenderFlexibleBox.cpp:
(WebCore::RenderFlexibleBox::availableAlignmentSpaceForChild): Removed the !isOutOfFlowPositioned()
ASSERT. It's true that in the past it was called only from code dealing with flex items but the code
implementing the function does not really have that restriction at all.
(WebCore::RenderFlexibleBox::staticCrossAxisPositionForPositionedChild): Directly call
availableAlignmentSpaceForChild() as it already uses the margin box.

Modified Paths

Diff

Modified: trunk/LayoutTests/imported/w3c/ChangeLog (287063 => 287064)


--- trunk/LayoutTests/imported/w3c/ChangeLog	2021-12-15 06:53:53 UTC (rev 287063)
+++ trunk/LayoutTests/imported/w3c/ChangeLog	2021-12-15 09:03:52 UTC (rev 287064)
@@ -1,3 +1,13 @@
+2021-12-13  Sergio Villar Senin  <svil...@igalia.com>
+
+        [css-flexbox] Absolutely positioned children should be aligned using the margin box
+        https://bugs.webkit.org/show_bug.cgi?id=234244
+
+        Reviewed by Darin Adler.
+
+        * web-platform-tests/css/css-flexbox/abspos/position-absolute-014-expected.txt: Replaced FAIL
+        by PASS expectations.
+
 2021-12-14  Joonghun Park  <jh718.p...@samsung.com>
 
         Fix that height is calculated incorrectly when using display:table, box-sizing:border-box and padding.

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-flexbox/abspos/position-absolute-014-expected.txt (287063 => 287064)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-flexbox/abspos/position-absolute-014-expected.txt	2021-12-15 06:53:53 UTC (rev 287063)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-flexbox/abspos/position-absolute-014-expected.txt	2021-12-15 09:03:52 UTC (rev 287064)
@@ -1,4 +1,4 @@
 aaa bbb aaa bbb aaa bbb
 
-FAIL The bottom of each pair of boxes should be the same assert_equals: expected 166 but got 106
+PASS The bottom of each pair of boxes should be the same
 

Modified: trunk/Source/WebCore/ChangeLog (287063 => 287064)


--- trunk/Source/WebCore/ChangeLog	2021-12-15 06:53:53 UTC (rev 287063)
+++ trunk/Source/WebCore/ChangeLog	2021-12-15 09:03:52 UTC (rev 287064)
@@ -1,3 +1,23 @@
+2021-12-13  Sergio Villar Senin  <svil...@igalia.com>
+
+        [css-flexbox] Absolutely positioned children should be aligned using the margin box
+        https://bugs.webkit.org/show_bug.cgi?id=234244
+
+        Reviewed by Darin Adler.
+
+        When aligning absolutely positioned children we must use the child's margin box. We were
+        using the border box instead, and thus ignoring margins when aligning absolutely positioned
+        flexbox children.
+
+        This fixes position-absolute-014.html from the WPT suite.
+
+        * rendering/RenderFlexibleBox.cpp:
+        (WebCore::RenderFlexibleBox::availableAlignmentSpaceForChild): Removed the !isOutOfFlowPositioned()
+        ASSERT. It's true that in the past it was called only from code dealing with flex items but the code
+        implementing the function does not really have that restriction at all.
+        (WebCore::RenderFlexibleBox::staticCrossAxisPositionForPositionedChild): Directly call
+        availableAlignmentSpaceForChild() as it already uses the margin box.
+
 2021-12-14  Joonghun Park  <jh718.p...@samsung.com>
 
         Fix that height is calculated incorrectly when using display:table, box-sizing:border-box and padding.

Modified: trunk/Source/WebCore/rendering/RenderFlexibleBox.cpp (287063 => 287064)


--- trunk/Source/WebCore/rendering/RenderFlexibleBox.cpp	2021-12-15 06:53:53 UTC (rev 287063)
+++ trunk/Source/WebCore/rendering/RenderFlexibleBox.cpp	2021-12-15 09:03:52 UTC (rev 287064)
@@ -1224,7 +1224,6 @@
 
 LayoutUnit RenderFlexibleBox::availableAlignmentSpaceForChild(LayoutUnit lineCrossAxisExtent, const RenderBox& child)
 {
-    ASSERT(!child.isOutOfFlowPositioned());
     LayoutUnit childCrossExtent = crossAxisMarginExtentForChild(child) + crossAxisExtentForChild(child);
     return lineCrossAxisExtent - childCrossExtent;
 }
@@ -1684,7 +1683,7 @@
 
 LayoutUnit RenderFlexibleBox::staticCrossAxisPositionForPositionedChild(const RenderBox& child)
 {
-    LayoutUnit availableSpace = crossAxisContentExtent() - crossAxisExtentForChild(child);
+    auto availableSpace = availableAlignmentSpaceForChild(crossAxisContentExtent(), child);
     return alignmentOffset(availableSpace, alignmentForChild(child), 0_lu, 0_lu, style().flexWrap() == FlexWrap::Reverse);
 }
 
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to