Changeset 290577 in webkit


Ignore:
Timestamp:
Feb 27, 2022 7:03:39 PM (5 months ago)
Author:
Matt Woodrow
Message:

Compute correct containing block override size for items that are subgridden in one dimension only.
https://bugs.webkit.org/show_bug.cgi?id=236951

Reviewed by Dean Jackson.

LayoutTests/imported/w3c:

Added new WPT similar to auto-track-sizing-001 which adds new variations
with nested subgrids and varying whether the other axis is subgridded.

  • web-platform-tests/css/css-grid/subgrid/auto-track-sizing-002-expected.html: Added.
  • web-platform-tests/css/css-grid/subgrid/auto-track-sizing-002.html: Added.

Source/WebCore:

Items that are subgridded in one dimension will be included in the track sizing algorithm of the
outer grid for that dimension. When measuring their size in the subgridded dimension, we need to
set their containing block size in the other (non-subgridded) dimension, which is only available
from the subgrid's track sizing, not the outer track sizes.

This recurses up to set the override size on the subgrid element instead, and forces a layout
there, which should copy down subgrid track sizes and compute the other dimension, making it
available on the inner item we need.

Test: imported/w3c/web-platform-tests/css/css-grid/subgrid/auto-track-sizing-002.html

  • rendering/GridLayoutFunctions.cpp:

(WebCore::GridLayoutFunctions::extraMarginForSubgridAncestors):

  • rendering/GridLayoutFunctions.h:
  • rendering/GridTrackSizingAlgorithm.cpp:

(WebCore::GridTrackSizingAlgorithmStrategy::updateOverridingContainingBlockContentSizeForChild const):

  • rendering/RenderGrid.cpp:

(WebCore::RenderGrid::isSubgridOf):

  • rendering/RenderGrid.h:

LayoutTests:

Marked existing WPT as passing.

Location:
trunk
Files:
2 added
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r290576 r290577  
     12022-02-27  Matt Woodrow  <mattwoodrow@apple.com>
     2
     3        Compute correct containing block override size for items that are subgridden in one dimension only.
     4        https://bugs.webkit.org/show_bug.cgi?id=236951
     5
     6        Reviewed by Dean Jackson.
     7
     8        * TestExpectations:
     9
     10        Marked existing WPT as passing.
     11
    1122022-02-27  Matt Woodrow  <mattwoodrow@apple.com>
    213
  • trunk/LayoutTests/TestExpectations

    r290576 r290577  
    13951395imported/w3c/web-platform-tests/css/css-grid/masonry/tentative/masonry-subgrid-002.html [ ImageOnlyFailure ]
    13961396
    1397 webkit.org/b/236951 imported/w3c/web-platform-tests/css/css-grid/subgrid/auto-track-sizing-001.html [ ImageOnlyFailure ]
    13981397webkit.org/b/236959 imported/w3c/web-platform-tests/css/css-grid/subgrid/baseline-001.html [ ImageOnlyFailure ]
    13991398webkit.org/b/236956 imported/w3c/web-platform-tests/css/css-grid/subgrid/grid-gap-003.html [ ImageOnlyFailure ]
  • trunk/LayoutTests/imported/w3c/ChangeLog

    r290573 r290577  
     12022-02-27  Matt Woodrow  <mattwoodrow@apple.com>
     2
     3        Compute correct containing block override size for items that are subgridden in one dimension only.
     4        https://bugs.webkit.org/show_bug.cgi?id=236951
     5
     6        Reviewed by Dean Jackson.
     7
     8        Added new WPT similar to auto-track-sizing-001 which adds new variations
     9        with nested subgrids and varying whether the other axis is subgridded.
     10
     11        * web-platform-tests/css/css-grid/subgrid/auto-track-sizing-002-expected.html: Added.
     12        * web-platform-tests/css/css-grid/subgrid/auto-track-sizing-002.html: Added.
     13
    1142022-02-27  Antoine Quint  <graouts@webkit.org>
    215
  • trunk/Source/WebCore/ChangeLog

    r290576 r290577  
     12022-02-27  Matt Woodrow  <mattwoodrow@apple.com>
     2
     3        Compute correct containing block override size for items that are subgridden in one dimension only.
     4        https://bugs.webkit.org/show_bug.cgi?id=236951
     5
     6        Reviewed by Dean Jackson.
     7
     8        Items that are subgridded in one dimension will be included in the track sizing algorithm of the
     9        outer grid for that dimension. When measuring their size in the subgridded dimension, we need to
     10        set their containing block size in the other (non-subgridded) dimension, which is only available
     11        from the subgrid's track sizing, not the outer track sizes.
     12
     13        This recurses up to set the override size on the subgrid element instead, and forces a layout
     14        there, which should copy down subgrid track sizes and compute the other dimension, making it
     15        available on the inner item we need.
     16
     17        Test: imported/w3c/web-platform-tests/css/css-grid/subgrid/auto-track-sizing-002.html
     18
     19        * rendering/GridLayoutFunctions.cpp:
     20        (WebCore::GridLayoutFunctions::extraMarginForSubgridAncestors):
     21        * rendering/GridLayoutFunctions.h:
     22        * rendering/GridTrackSizingAlgorithm.cpp:
     23        (WebCore::GridTrackSizingAlgorithmStrategy::updateOverridingContainingBlockContentSizeForChild const):
     24        * rendering/RenderGrid.cpp:
     25        (WebCore::RenderGrid::isSubgridOf):
     26        * rendering/RenderGrid.h:
     27
    1282022-02-27  Matt Woodrow  <mattwoodrow@apple.com>
    229
  • trunk/Source/WebCore/rendering/GridLayoutFunctions.cpp

    r290576 r290577  
    104104}
    105105
    106 static LayoutUnit extraMarginForSubgridAncestors(GridTrackSizingDirection direction, const RenderBox& child)
     106LayoutUnit extraMarginForSubgridAncestors(GridTrackSizingDirection direction, const RenderBox& child)
    107107{
    108108    const RenderGrid* grid = downcast<RenderGrid>(child.parent());
  • trunk/Source/WebCore/rendering/GridLayoutFunctions.h

    r290007 r290577  
    5151bool isFlippedDirection(const RenderGrid&, GridTrackSizingDirection);
    5252bool isSubgridReversedDirection(const RenderGrid&, GridTrackSizingDirection outerDirection, const RenderGrid& subgrid);
     53LayoutUnit extraMarginForSubgridAncestors(GridTrackSizingDirection, const RenderBox& child);
    5354
    5455}
  • trunk/Source/WebCore/rendering/GridTrackSizingAlgorithm.cpp

    r290096 r290577  
    966966        overrideSize = m_algorithm.gridAreaBreadthForChild(child, direction);
    967967
     968    if (renderGrid() != child.parent()) {
     969        RenderGrid* grid = downcast<RenderGrid>(child.parent());
     970
     971        GridTrackSizingDirection subgridDirection = GridLayoutFunctions::flowAwareDirectionForChild(*renderGrid(), *grid, direction);
     972
     973        if (grid->isSubgridOf(subgridDirection, *renderGrid())) {
     974            // If the item is subgridded in this direction (and thus the tracks it covers are tracks
     975            // owned by this sizing algorithm), then we want to take the breadth of the tracks we occupy,
     976            // and subtract any space occupied by the subgrid itself (and any ancestor subgrids).
     977            *overrideSize -= GridLayoutFunctions::extraMarginForSubgridAncestors(subgridDirection, child);
     978        } else {
     979            // Otherwise the tracks that this item covers (in this non-subgridded axis) are owned
     980            // by one of the intermediate RenderGrids (which are subgrids in the other axis). Recurse
     981            // until we find an element this is directly part of this grid and set the override size
     982            // for that, and then layout that item so that it computes the track sizes and sets the
     983            // override size we need.
     984            bool overrideSizeHasChanged =
     985                updateOverridingContainingBlockContentSizeForChild(*grid, direction);
     986            layoutGridItemForMinSizeComputation(*grid, overrideSizeHasChanged);
     987            return overrideSizeHasChanged;
     988        }
     989    }
     990
    968991    if (GridLayoutFunctions::hasOverridingContainingBlockContentSizeForChild(child, direction) && GridLayoutFunctions::overridingContainingBlockContentSizeForChild(child, direction) == overrideSize)
    969992        return false;
  • trunk/Source/WebCore/rendering/RenderGrid.cpp

    r290491 r290577  
    16271627    GridTrackSizingDirection direction = GridLayoutFunctions::flowAwareDirectionForChild(*downcast<RenderGrid>(parent()), *this, parentDirection);
    16281628    return isSubgrid(direction);
     1629}
     1630
     1631bool RenderGrid::isSubgridOf(GridTrackSizingDirection direction, const RenderGrid& ancestor)
     1632{
     1633    if (!isSubgrid(direction))
     1634        return false;
     1635    if (parent() == &ancestor)
     1636        return true;
     1637
     1638    auto& parentGrid = *downcast<RenderGrid>(parent());
     1639    GridTrackSizingDirection parentDirection = GridLayoutFunctions::flowAwareDirectionForParent(parentGrid, *this, direction);
     1640    return parentGrid.isSubgridOf(parentDirection, ancestor);
    16291641}
    16301642
  • trunk/Source/WebCore/rendering/RenderGrid.h

    r290491 r290577  
    9797    }
    9898    bool isSubgridInParentDirection(GridTrackSizingDirection parentDirection) const;
     99
     100    // Returns true if this grid is inheriting subgridded tracks for
     101    // the given direction from the specified ancestor. This handles
     102    // nested subgrids, where ancestor may not be our direct parent.
     103    bool isSubgridOf(GridTrackSizingDirection, const RenderGrid& ancestor);
     104
    99105    bool mayBeSubgridExcludingAbsPos(GridTrackSizingDirection) const;
    100106
Note: See TracChangeset for help on using the changeset viewer.