Changeset 286207 in webkit


Ignore:
Timestamp:
Nov 29, 2021 2:29:38 AM (8 months ago)
Author:
svillar@igalia.com
Message:

[css-flexbox] Do not shrink tables bellow their intrinsic sizes
https://bugs.webkit.org/show_bug.cgi?id=232383

Reviewed by Manuel Rego Casasnovas.

Source/WebCore:

Flex layout algorithm uses the flex items min|max sizes to compute the hypothetical main size which
will be used to clamp the size of the items when flexed. In the case of tables as flex items, we were
using the min-size straight away whenever that was definite. However we cannot do that because tables
must not shrink bellow their intrinsic sizes. That's why we should select the maximum of the intrinsic
size and the min-size.

This fixes a WPT test covering this case.

  • rendering/RenderFlexibleBox.cpp:

(WebCore::RenderFlexibleBox::computeFlexItemMinMaxSizes): Do not select a min-size smaller than the
table intrinsic size in the main axis.

LayoutTests:

  • TestExpectations: Unskip table-as-item-fixed-min-width-3.html which works fine now.
Location:
trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r286206 r286207  
     12021-10-27  Sergio Villar Senin  <svillar@igalia.com>
     2
     3        [css-flexbox] Do not shrink tables bellow their intrinsic sizes
     4        https://bugs.webkit.org/show_bug.cgi?id=232383
     5
     6        Reviewed by Manuel Rego Casasnovas.
     7
     8        * TestExpectations: Unskip table-as-item-fixed-min-width-3.html which works fine now.
     9
    1102021-10-27  Sergio Villar Senin  <svillar@igalia.com>
    211
  • trunk/LayoutTests/TestExpectations

    r286206 r286207  
    42354235
    42364236# Tables as flex items.
    4237 webkit.org/b/221473 imported/w3c/web-platform-tests/css/css-flexbox/table-as-item-fixed-min-width-3.html [ ImageOnlyFailure ]
    42384237webkit.org/b/221473 imported/w3c/web-platform-tests/css/css-flexbox/table-as-item-inflexible-in-column-1.html [ ImageOnlyFailure ]
    42394238webkit.org/b/221473 imported/w3c/web-platform-tests/css/css-flexbox/table-as-item-inflexible-in-column-2.html [ ImageOnlyFailure ]
  • trunk/Source/WebCore/ChangeLog

    r286206 r286207  
     12021-10-27  Sergio Villar Senin  <svillar@igalia.com>
     2
     3        [css-flexbox] Do not shrink tables bellow their intrinsic sizes
     4        https://bugs.webkit.org/show_bug.cgi?id=232383
     5
     6        Reviewed by Manuel Rego Casasnovas.
     7
     8        Flex layout algorithm uses the flex items min|max sizes to compute the hypothetical main size which
     9        will be used to clamp the size of the items when flexed. In the case of tables as flex items, we were
     10        using the min-size straight away whenever that was definite. However we cannot do that because tables
     11        must not shrink bellow their intrinsic sizes. That's why we should select the maximum of the intrinsic
     12        size and the min-size.
     13
     14        This fixes a WPT test covering this case.
     15
     16        * rendering/RenderFlexibleBox.cpp:
     17        (WebCore::RenderFlexibleBox::computeFlexItemMinMaxSizes): Do not select a min-size smaller than the
     18        table intrinsic size in the main axis.
     19
    1202021-10-27  Sergio Villar Senin  <svillar@igalia.com>
    221
  • trunk/Source/WebCore/rendering/RenderFlexibleBox.cpp

    r286206 r286207  
    13241324    Length min = mainSizeLengthForChild(MinSize, child);
    13251325    // Intrinsic sizes in child's block axis are handled by the min-size:auto code path.
    1326     if (min.isSpecified() || (min.isIntrinsic() && mainAxisIsChildInlineAxis(child)))
    1327         return { computeMainAxisExtentForChild(child, MinSize, min).value_or(0_lu), maxExtent.value_or(LayoutUnit::max()) };
     1326    if (min.isSpecified() || (min.isIntrinsic() && mainAxisIsChildInlineAxis(child))) {
     1327        auto minExtent = computeMainAxisExtentForChild(child, MinSize, min).value_or(0_lu);
     1328        // We must never return a min size smaller than the min preferred size for tables.
     1329        if (child.isTable() && mainAxisIsChildInlineAxis(child))
     1330            minExtent = std::max(minExtent, child.minPreferredLogicalWidth());
     1331        return { minExtent, maxExtent.value_or(LayoutUnit::max()) };
     1332    }
    13281333   
    13291334    if (shouldApplyMinSizeAutoForChild(child)) {
Note: See TracChangeset for help on using the changeset viewer.