Changeset 284397 in webkit


Ignore:
Timestamp:
Oct 18, 2021 1:50:56 PM (9 months ago)
Author:
svillar@igalia.com
Message:

[css-flexbox] Do not clamp flex base size with {min|max}-{height|width}
https://bugs.webkit.org/show_bug.cgi?id=225590
<rdar://problem/78100329>

Reviewed by Manuel Rego Casasnovas.

Source/WebCore:

When computing flex base size we should not clamp it with neither min-{height|width}
nor max-{height|width}. That would be done later and will be called the hypothetical
main size.

For most of the cases we were already doing it, however there are some particular cases
in which we have to call the generic layout code which does clamp the sizes using min
and max sizes. In order to make those code paths work, we reset the min|max values to
their initial ones (so they effectively become inactive) and then we set the original
values back after computing the base size.

This is a reland of r279271 which was pretty similar but caused a visual regression in
GMail. After r284359 this is no longer a problem of this patch.

This fixes 3 WPT flexbox tests.

  • rendering/RenderFlexibleBox.cpp:

(WebCore::ScopedUnboundedBoxWithFlexBasisAsChildMainSize::ScopedUnboundedBoxWithFlexBasisAsChildMainSize):
renamed from ScopedFlexBasisAsChildMainSize. Resets min|max-size to their initial values.
(WebCore::ScopedUnboundedBoxWithFlexBasisAsChildMainSize::~ScopedUnboundedBoxWithFlexBasisAsChildMainSize):
ditto. Restores min|max-size original values.
(WebCore::RenderFlexibleBox::computeFlexBaseSizeForChild):
(WebCore::ScopedFlexBasisAsChildMainSize::ScopedFlexBasisAsChildMainSize): Deleted.
(WebCore::ScopedFlexBasisAsChildMainSize::~ScopedFlexBasisAsChildMainSize): Deleted.

LayoutTests:

Location:
trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r284387 r284397  
     12021-10-15  Sergio Villar Senin  <svillar@igalia.com>
     2
     3        [css-flexbox] Do not clamp flex base size with {min|max}-{height|width}
     4        https://bugs.webkit.org/show_bug.cgi?id=225590
     5        <rdar://problem/78100329>
     6
     7        Reviewed by Manuel Rego Casasnovas.
     8
     9        * TestExpectations: Unskipped 3 tests that are now passing.
     10
    1112021-10-18  Tyler Wilcock  <tyler_w@apple.com>
    212
  • trunk/LayoutTests/TestExpectations

    r284359 r284397  
    41634163webkit.org/b/209080 imported/w3c/web-platform-tests/css/css-writing-modes/vertical-alignment-srl-040.xht [ ImageOnlyFailure ]
    41644164
    4165 webkit.org/b/219343 imported/w3c/web-platform-tests/css/css-flexbox/flex-aspect-ratio-img-column-012.html [ ImageOnlyFailure ]
    41664165webkit.org/b/219343 imported/w3c/web-platform-tests/css/css-flexbox/flex-aspect-ratio-img-column-015.html [ ImageOnlyFailure ]
    4167 webkit.org/b/219343 imported/w3c/web-platform-tests/css/css-flexbox/flex-aspect-ratio-img-row-007.html [ ImageOnlyFailure ]
    41684166webkit.org/b/219343 imported/w3c/web-platform-tests/css/css-flexbox/flex-aspect-ratio-img-row-010.html [ ImageOnlyFailure ]
    41694167webkit.org/b/219343 imported/w3c/web-platform-tests/css/css-flexbox/aspect-ratio-intrinsic-size-005.html [ ImageOnlyFailure ]
     
    41914189webkit.org/b/221473 imported/w3c/web-platform-tests/css/css-flexbox/table-as-item-inflexible-in-column-2.html [ ImageOnlyFailure ]
    41924190webkit.org/b/221473 imported/w3c/web-platform-tests/css/css-flexbox/table-as-item-inflexible-in-row-2.html [ ImageOnlyFailure ]
    4193 webkit.org/b/221473 imported/w3c/web-platform-tests/css/css-flexbox/table-as-item-min-height-1.html [ ImageOnlyFailure ]
    41944191
    41954192# SVGs as flex items.
  • trunk/Source/WebCore/ChangeLog

    r284387 r284397  
     12021-10-15  Sergio Villar Senin  <svillar@igalia.com>
     2
     3        [css-flexbox] Do not clamp flex base size with {min|max}-{height|width}
     4        https://bugs.webkit.org/show_bug.cgi?id=225590
     5        <rdar://problem/78100329>
     6
     7        Reviewed by Manuel Rego Casasnovas.
     8
     9        When computing flex base size we should not clamp it with neither min-{height|width}
     10        nor max-{height|width}. That would be done later and will be called the hypothetical
     11        main size.
     12
     13        For most of the cases we were already doing it, however there are some particular cases
     14        in which we have to call the generic layout code which does clamp the sizes using min
     15        and max sizes. In order to make those code paths work, we reset the min|max values to
     16        their initial ones (so they effectively become inactive) and then we set the original
     17        values back after computing the base size.
     18
     19        This is a reland of r279271 which was pretty similar but caused a visual regression in
     20        GMail. After r284359 this is no longer a problem of this patch.
     21
     22        This fixes 3 WPT flexbox tests.
     23
     24        * rendering/RenderFlexibleBox.cpp:
     25        (WebCore::ScopedUnboundedBoxWithFlexBasisAsChildMainSize::ScopedUnboundedBoxWithFlexBasisAsChildMainSize):
     26        renamed from ScopedFlexBasisAsChildMainSize. Resets min|max-size to their initial values.
     27        (WebCore::ScopedUnboundedBoxWithFlexBasisAsChildMainSize::~ScopedUnboundedBoxWithFlexBasisAsChildMainSize):
     28        ditto. Restores min|max-size original values.
     29        (WebCore::RenderFlexibleBox::computeFlexBaseSizeForChild):
     30        (WebCore::ScopedFlexBasisAsChildMainSize::ScopedFlexBasisAsChildMainSize): Deleted.
     31        (WebCore::ScopedFlexBasisAsChildMainSize::~ScopedFlexBasisAsChildMainSize): Deleted.
     32
    1332021-10-18  Tyler Wilcock  <tyler_w@apple.com>
    234
  • trunk/Source/WebCore/rendering/RenderFlexibleBox.cpp

    r284359 r284397  
    997997}
    998998
    999 // This is a RAII class that is used to temporarily set the flex basis as the child size in the main axis.
    1000 class ScopedFlexBasisAsChildMainSize {
     999// This is a RAII class that is used to temporarily set the flex basis as the child size in the main axis. Apart from that
     1000// the min|max-size restrictions are ignored for this computation. See https://drafts.csswg.org/css-flexbox/#algo-main-item
     1001// for further details.
     1002class ScopedUnboundedBoxWithFlexBasisAsChildMainSize {
    10011003public:
    1002     ScopedFlexBasisAsChildMainSize(RenderBox& child, Length flexBasis, bool mainAxisIsInlineAxis)
     1004    ScopedUnboundedBoxWithFlexBasisAsChildMainSize(RenderBox& child, Length flexBasis, bool mainAxisIsInlineAxis)
    10031005        : m_child(child)
     1006        , m_isHorizontalWritingModeInParallelFlow(mainAxisIsInlineAxis == child.isHorizontalWritingMode())
    10041007        , m_mainAxisIsInlineAxis(mainAxisIsInlineAxis)
    10051008    {
     1009        if (m_isHorizontalWritingModeInParallelFlow) {
     1010            m_originalMinSize = m_child.style().minWidth();
     1011            m_originalMaxSize = m_child.style().maxWidth();
     1012            m_child.mutableStyle().setMinWidth(RenderStyle::initialMinSize());
     1013            m_child.mutableStyle().setMaxWidth(RenderStyle::initialMaxSize());
     1014        } else {
     1015            m_originalMinSize = m_child.style().minHeight();
     1016            m_originalMaxSize = m_child.style().maxHeight();
     1017            m_child.mutableStyle().setMinHeight(RenderStyle::initialMinSize());
     1018            m_child.mutableStyle().setMaxHeight(RenderStyle::initialMaxSize());
     1019        }
     1020
    10061021        if (m_mainAxisIsInlineAxis) {
    1007             m_originalLength = m_child.style().logicalWidth();
     1022            m_originalSize = m_child.style().logicalWidth();
    10081023            m_child.mutableStyle().setLogicalWidth(Length(flexBasis));
    10091024            return;
    10101025        }
    1011         m_originalLength = m_child.style().logicalHeight();
     1026        m_originalSize = m_child.style().logicalHeight();
    10121027        m_child.mutableStyle().setLogicalHeight(Length(flexBasis));
    10131028    }
    1014     ~ScopedFlexBasisAsChildMainSize()
     1029    ~ScopedUnboundedBoxWithFlexBasisAsChildMainSize()
    10151030    {
     1031        if (m_isHorizontalWritingModeInParallelFlow) {
     1032            m_child.mutableStyle().setMinWidth(Length(m_originalMinSize));
     1033            m_child.mutableStyle().setMaxWidth(Length(m_originalMaxSize));
     1034        } else {
     1035            m_child.mutableStyle().setMinHeight(Length(m_originalMinSize));
     1036            m_child.mutableStyle().setMaxHeight(Length(m_originalMaxSize));
     1037        }
     1038
    10161039        if (m_mainAxisIsInlineAxis)
    1017             m_child.mutableStyle().setLogicalWidth(Length(m_originalLength));
     1040            m_child.mutableStyle().setLogicalWidth(Length(m_originalSize));
    10181041        else
    1019             m_child.mutableStyle().setLogicalHeight(Length(m_originalLength));
     1042            m_child.mutableStyle().setLogicalHeight(Length(m_originalSize));
    10201043    }
    10211044private:
    10221045    RenderBox& m_child;
     1046    bool m_isHorizontalWritingModeInParallelFlow;
    10231047    bool m_mainAxisIsInlineAxis;
    1024     Length m_originalLength;
     1048    Length m_originalSize;
     1049    Length m_originalMinSize;
     1050    Length m_originalMaxSize;
    10251051};
    10261052
     
    10441070    // 9.3.2 E. Otherwise, size the item into the available space using its used flex basis in place of its main size.
    10451071    {
    1046         ScopedFlexBasisAsChildMainSize flexBasisScope(child, flexBasis, mainAxisIsChildInlineAxis(child));
     1072        ScopedUnboundedBoxWithFlexBasisAsChildMainSize flexBasisScope(child, flexBasis, mainAxisIsChildInlineAxis(child));
    10471073        if (mainAxisIsChildInlineAxis(child))
    10481074            return child.maxPreferredLogicalWidth() - mainAxisBorderAndPadding;
Note: See TracChangeset for help on using the changeset viewer.