Changeset 285987 in webkit


Ignore:
Timestamp:
Nov 18, 2021 1:12:50 AM (8 months ago)
Author:
Ziran Sun
Message:

[css-grid] Transfer size for grid item with an aspect-ratio and stretch alignment against the definite row
https://bugs.webkit.org/show_bug.cgi?id=232987

Reviewed by Javier Fernandez.

Source/WebCore:

For a grid item with an aspect-ratio, if it has stretch alignment against the definite row, it should
try and resolve it if possible and transfer this size into the inline direction for the min/max content
size. For the case that the grid width is content sized, we need to update the width before laying out
the grid items. Since the min-content contribution of the grid item has changed based on the row sizes
calculated in step 2 of sizing algorithm, we also need to repeat the sizing algorithm steps to update
the width of the track sizes.

  • rendering/GridLayoutFunctions.cpp:

(WebCore::GridLayoutFunctions::isAspectRatioBlockSizeDependentChild):

  • rendering/RenderGrid.cpp:

(WebCore::RenderGrid::updateGridAreaForAspectRatioItems):

  • rendering/RenderReplaced.cpp:

(WebCore::RenderReplaced::needsPreferredWidthsRecalculation const):

LayoutTests:

Location:
trunk
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r285984 r285987  
     12021-11-18  Ziran Sun  <zsun@igalia.com>
     2
     3        [css-grid] Transfer size for grid item with an aspect-ratio and stretch alignment against the definite row
     4        https://bugs.webkit.org/show_bug.cgi?id=232987
     5
     6        Reviewed by Javier Fernandez.
     7
     8        * TestExpectations: unskip the test that is now passing.
     9
    1102021-11-17  Youenn Fablet  <youenn@apple.com>
    211
  • trunk/LayoutTests/TestExpectations

    r285923 r285987  
    13961396imported/w3c/web-platform-tests/css/css-grid/grid-definition/grid-repeat-max-width-001.html [ ImageOnlyFailure ]
    13971397
    1398 imported/w3c/web-platform-tests/css/css-grid/grid-items/aspect-ratio-004.html [ ImageOnlyFailure ]
    13991398imported/w3c/web-platform-tests/css/css-grid/grid-items/grid-item-inline-contribution-003.html [ ImageOnlyFailure ]
    14001399webkit.org/b/231021 imported/w3c/web-platform-tests/css/css-grid/grid-items/grid-size-with-orthogonal-child-dynamic.html [ ImageOnlyFailure ]
  • trunk/Source/WebCore/ChangeLog

    r285986 r285987  
     12021-11-18  Ziran Sun  <zsun@igalia.com>
     2
     3        [css-grid] Transfer size for grid item with an aspect-ratio and stretch alignment against the definite row
     4        https://bugs.webkit.org/show_bug.cgi?id=232987
     5
     6        Reviewed by Javier Fernandez.
     7
     8        For a grid item with an aspect-ratio, if it has stretch alignment against the definite row, it should
     9        try and resolve it if possible and transfer this size into the inline direction for the min/max content
     10        size. For the case that the grid width is content sized, we need to update the width before laying out
     11        the grid items. Since the min-content contribution of the grid item has changed based on the row sizes
     12        calculated in step 2 of sizing algorithm, we also need to repeat the sizing algorithm steps to update
     13        the width of the track sizes.
     14
     15        * rendering/GridLayoutFunctions.cpp:
     16        (WebCore::GridLayoutFunctions::isAspectRatioBlockSizeDependentChild):
     17        * rendering/RenderGrid.cpp:
     18        (WebCore::RenderGrid::updateGridAreaForAspectRatioItems):
     19        * rendering/RenderReplaced.cpp:
     20        (WebCore::RenderReplaced::needsPreferredWidthsRecalculation const):
     21
    1222021-11-18 Antoine Quint  <graouts@webkit.org>
    223
  • trunk/Source/WebCore/rendering/GridLayoutFunctions.cpp

    r285497 r285987  
    8585bool isAspectRatioBlockSizeDependentChild(const RenderBox& child)
    8686{
    87     return (child.style().hasAspectRatio() || child.hasIntrinsicAspectRatio()) && child.hasRelativeLogicalHeight();
     87    return (child.style().hasAspectRatio() || child.hasIntrinsicAspectRatio()) && (child.hasRelativeLogicalHeight() || child.hasStretchedLogicalHeight());
    8888}
    8989
  • trunk/Source/WebCore/rendering/RenderGrid.cpp

    r285857 r285987  
    961961    populateGridPositionsForDirection(ForRows);
    962962
    963     for (auto& autoGridItem : autoGridItems)
     963    for (auto& autoGridItem : autoGridItems) {
    964964        updateGridAreaLogicalSize(*autoGridItem, gridAreaBreadthForChildIncludingAlignmentOffsets(*autoGridItem, ForColumns), gridAreaBreadthForChildIncludingAlignmentOffsets(*autoGridItem, ForRows));
     965        // For an item wtih aspect-ratio, if it has stretch alignment that stretches to the definite row, we also need to transfer the size before laying out the grid item.
     966        if (autoGridItem->hasStretchedLogicalHeight())
     967            applyStretchAlignmentToChildIfNeeded(*autoGridItem);
     968    }
    965969}
    966970
  • trunk/Source/WebCore/rendering/RenderReplaced.cpp

    r285857 r285987  
    803803{
    804804    // If the height is a percentage and the width is auto, then the containingBlocks's height changing can cause this node to change it's preferred width because it maintains aspect ratio.
    805     return hasRelativeLogicalHeight() && style().logicalWidth().isAuto();
    806 }
    807 
    808 }
     805    return (hasRelativeLogicalHeight() || (isGridItem() && hasStretchedLogicalHeight())) && style().logicalWidth().isAuto();
     806}
     807
     808}
Note: See TracChangeset for help on using the changeset viewer.