Changeset 287064 in webkit


Ignore:
Timestamp:
Dec 15, 2021 1:03:52 AM (7 months ago)
Author:
svillar@igalia.com
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.

Location:
trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/imported/w3c/ChangeLog

    r287063 r287064  
     12021-12-13  Sergio Villar Senin  <svillar@igalia.com>
     2
     3        [css-flexbox] Absolutely positioned children should be aligned using the margin box
     4        https://bugs.webkit.org/show_bug.cgi?id=234244
     5
     6        Reviewed by Darin Adler.
     7
     8        * web-platform-tests/css/css-flexbox/abspos/position-absolute-014-expected.txt: Replaced FAIL
     9        by PASS expectations.
     10
    1112021-12-14  Joonghun Park  <jh718.park@samsung.com>
    212
  • trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-flexbox/abspos/position-absolute-014-expected.txt

    r272644 r287064  
    11aaa bbb aaa bbb aaa bbb
    22
    3 FAIL The bottom of each pair of boxes should be the same assert_equals: expected 166 but got 106
     3PASS The bottom of each pair of boxes should be the same
    44
  • trunk/Source/WebCore/ChangeLog

    r287063 r287064  
     12021-12-13  Sergio Villar Senin  <svillar@igalia.com>
     2
     3        [css-flexbox] Absolutely positioned children should be aligned using the margin box
     4        https://bugs.webkit.org/show_bug.cgi?id=234244
     5
     6        Reviewed by Darin Adler.
     7
     8        When aligning absolutely positioned children we must use the child's margin box. We were
     9        using the border box instead, and thus ignoring margins when aligning absolutely positioned
     10        flexbox children.
     11
     12        This fixes position-absolute-014.html from the WPT suite.
     13
     14        * rendering/RenderFlexibleBox.cpp:
     15        (WebCore::RenderFlexibleBox::availableAlignmentSpaceForChild): Removed the !isOutOfFlowPositioned()
     16        ASSERT. It's true that in the past it was called only from code dealing with flex items but the code
     17        implementing the function does not really have that restriction at all.
     18        (WebCore::RenderFlexibleBox::staticCrossAxisPositionForPositionedChild): Directly call
     19        availableAlignmentSpaceForChild() as it already uses the margin box.
     20
    1212021-12-14  Joonghun Park  <jh718.park@samsung.com>
    222
  • trunk/Source/WebCore/rendering/RenderFlexibleBox.cpp

    r286654 r287064  
    12251225LayoutUnit RenderFlexibleBox::availableAlignmentSpaceForChild(LayoutUnit lineCrossAxisExtent, const RenderBox& child)
    12261226{
    1227     ASSERT(!child.isOutOfFlowPositioned());
    12281227    LayoutUnit childCrossExtent = crossAxisMarginExtentForChild(child) + crossAxisExtentForChild(child);
    12291228    return lineCrossAxisExtent - childCrossExtent;
     
    16851684LayoutUnit RenderFlexibleBox::staticCrossAxisPositionForPositionedChild(const RenderBox& child)
    16861685{
    1687     LayoutUnit availableSpace = crossAxisContentExtent() - crossAxisExtentForChild(child);
     1686    auto availableSpace = availableAlignmentSpaceForChild(crossAxisContentExtent(), child);
    16881687    return alignmentOffset(availableSpace, alignmentForChild(child), 0_lu, 0_lu, style().flexWrap() == FlexWrap::Reverse);
    16891688}
Note: See TracChangeset for help on using the changeset viewer.