⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 286148 in webkit


Ignore:
Timestamp:
Nov 24, 2021, 7:04:31 AM (5 years ago)
Author:
Ziran Sun
Message:

[css-grid] Track sizing algorithm not repeated even if used flex fraction would change
https://bugs.webkit.org/show_bug.cgi?id=232617

Reviewed by Javier Fernandez.

Source/WebCore:

According to https://drafts.csswg.org/css-grid/#algo-flex-tracks, when row height is
indefinite, for each grid item that crosses a flexible track, we run the track sizing
algorithm under a max-content constraint to find the flex fraction. Then we work out
the grid container height as definite, which may cause the flex fraction change. At this
point, we need to repeat the track sizing algorithm for row and layout the grid for real.
The current implementation doesn't repeat the track sizing algorithm for row.

The complication with calling RenderGrid::repeatTracksSizingIfNeeded() for flex max-sizing
is that it might change a grid item's status of participating in Baseline Alignment for
a cyclic sizing dependncy case, which should be definitively excluded. See
https://github.com/w3c/csswg-drafts/issues/3046 for more details. This issue should be handled
in a seperate bug. This CL only handle test cases that don't have baseline alignment specified.

  • rendering/GridTrackSizingAlgorithm.cpp:

(WebCore::GridTrackSizingAlgorithm::initializeTrackSizes):
(WebCore::GridTrackSizingAlgorithm::setup):
(WebCore::GridTrackSizingAlgorithm::reset):

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

(WebCore::RenderGrid::repeatTracksSizingIfNeeded):
(WebCore::RenderGrid::layoutBlock):

  • rendering/RenderGrid.h:

LayoutTests:

Unskip two tests that are passing.

Location:
trunk
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r286146 r286148  
     12021-11-24  Ziran Sun  <zsun@igalia.com>
     2
     3        [css-grid] Track sizing algorithm not repeated even if used flex fraction would change
     4        https://bugs.webkit.org/show_bug.cgi?id=232617
     5
     6        Reviewed by Javier Fernandez.
     7
     8        Unskip two tests that are passing.
     9 
     10        * TestExpectations:
     11
    1122021-11-24  Manuel Rego Casasnovas  <rego@igalia.com>
    213
  • trunk/LayoutTests/TestExpectations

    r286136 r286148  
    13971397
    13981398imported/w3c/web-platform-tests/css/css-grid/grid-model/grid-areas-overflowing-grid-container-009.html [ ImageOnlyFailure ]
    1399 imported/w3c/web-platform-tests/css/css-grid/layout-algorithm/flex-sizing-rows-indefinite-height.html [ ImageOnlyFailure ]
    1400 webkit.org/b/231021 imported/w3c/web-platform-tests/css/css-grid/layout-algorithm/grid-template-flexible-rerun-track-sizing.html [ ImageOnlyFailure ]
    14011399imported/w3c/web-platform-tests/css/css-grid/masonry/tentative/masonry-align-content-001.html [ ImageOnlyFailure ]
    14021400imported/w3c/web-platform-tests/css/css-grid/masonry/tentative/masonry-align-content-002.html [ ImageOnlyFailure ]
  • trunk/Source/WebCore/ChangeLog

    r286147 r286148  
     12021-11-24  Ziran Sun  <zsun@igalia.com>
     2
     3        [css-grid] Track sizing algorithm not repeated even if used flex fraction would change
     4        https://bugs.webkit.org/show_bug.cgi?id=232617
     5
     6        Reviewed by Javier Fernandez.
     7
     8        According to https://drafts.csswg.org/css-grid/#algo-flex-tracks, when row height is
     9        indefinite, for each grid item that crosses a flexible track, we run the track sizing
     10        algorithm under a max-content constraint to find the flex fraction. Then we work out
     11        the grid container height as definite, which may cause the flex fraction change. At this
     12        point, we need to repeat the track sizing algorithm for row and layout the grid for real.
     13        The current implementation doesn't repeat the track sizing algorithm for row.
     14
     15        The complication with calling RenderGrid::repeatTracksSizingIfNeeded() for flex max-sizing
     16        is that it might change a grid item's status of participating in Baseline Alignment for
     17        a cyclic sizing dependncy case, which should be definitively excluded. See
     18        https://github.com/w3c/csswg-drafts/issues/3046 for more details. This issue should be handled
     19        in a seperate bug. This CL only handle test cases that don't have baseline alignment specified.
     20       
     21        * rendering/GridTrackSizingAlgorithm.cpp:
     22        (WebCore::GridTrackSizingAlgorithm::initializeTrackSizes):
     23        (WebCore::GridTrackSizingAlgorithm::setup):
     24        (WebCore::GridTrackSizingAlgorithm::reset):
     25        * rendering/GridTrackSizingAlgorithm.h:
     26        * rendering/RenderGrid.cpp:
     27        (WebCore::RenderGrid::repeatTracksSizingIfNeeded):
     28        (WebCore::RenderGrid::layoutBlock):
     29        * rendering/RenderGrid.h:
     30
    1312021-11-24  Alan Bujtas  <zalan@apple.com>
    232
  • trunk/Source/WebCore/rendering/GridTrackSizingAlgorithm.cpp

    r285885 r286148  
    11661166    ASSERT(m_autoSizedTracksForStretchIndex.isEmpty());
    11671167    ASSERT(!m_hasPercentSizedRowsIndefiniteHeight);
     1168    ASSERT(!m_hasFlexibleMaxTrackBreadth);
    11681169
    11691170    Vector<GridTrack>& allTracks = tracks(m_direction);
     
    11881189            m_autoSizedTracksForStretchIndex.append(i);
    11891190
    1190         if (!m_hasPercentSizedRowsIndefiniteHeight && indefiniteHeight) {
     1191        if (indefiniteHeight) {
    11911192            auto& rawTrackSize = rawGridTrackSize(m_direction, i);
    1192             if (rawTrackSize.minTrackBreadth().isPercentage() || rawTrackSize.maxTrackBreadth().isPercentage())
     1193            // Set the flag for repeating the track sizing algorithm. For flexible tracks, as per spec https://drafts.csswg.org/css-grid/#algo-flex-tracks,
     1194            // in clause "if the free space is an indefinite length:", it states that "If using this flex fraction would cause the grid to be smaller than
     1195            // the grid container’s min-width/height (or larger than the grid container’s max-width/height), then redo this step".
     1196            if (!m_hasFlexibleMaxTrackBreadth && rawTrackSize.maxTrackBreadth().isFlex())
     1197                m_hasFlexibleMaxTrackBreadth = true;
     1198            if (!m_hasPercentSizedRowsIndefiniteHeight && (rawTrackSize.minTrackBreadth().isPercentage() || rawTrackSize.maxTrackBreadth().isPercentage()))
    11931199                m_hasPercentSizedRowsIndefiniteHeight = true;
    11941200        }
     
    13621368    m_needsSetup = false;
    13631369    m_hasPercentSizedRowsIndefiniteHeight = false;
     1370    m_hasFlexibleMaxTrackBreadth = false;
    13641371
    13651372    computeBaselineAlignmentContext();
     
    14331440    setAvailableSpace(ForColumns, std::nullopt);
    14341441    m_hasPercentSizedRowsIndefiniteHeight = false;
     1442    m_hasFlexibleMaxTrackBreadth = false;
    14351443}
    14361444
  • trunk/Source/WebCore/rendering/GridTrackSizingAlgorithm.h

    r283439 r286148  
    144144
    145145    bool hasAnyPercentSizedRowsIndefiniteHeight() const { return m_hasPercentSizedRowsIndefiniteHeight; }
     146    bool hasAnyFlexibleMaxTrackBreadth() const { return m_hasFlexibleMaxTrackBreadth; }
     147    bool hasAnyBaselineAlignmentItem() const { return !m_columnBaselineItemsMap.isEmpty() || !m_rowBaselineItemsMap.isEmpty(); }
    146148
    147149#if ASSERT_ENABLED
     
    200202    bool m_needsSetup { true };
    201203    bool m_hasPercentSizedRowsIndefiniteHeight { false };
     204    bool m_hasFlexibleMaxTrackBreadth { false };
    202205    std::optional<LayoutUnit> m_availableSpaceRows;
    203206    std::optional<LayoutUnit> m_availableSpaceColumns;
  • trunk/Source/WebCore/rendering/RenderGrid.cpp

    r285998 r286148  
    162162    // cases with orthogonal flows require this extra cycle; we need a more specific
    163163    // condition to detect whether child's min-content contribution has changed or not.
    164     if (m_hasAnyOrthogonalItem || m_trackSizingAlgorithm.hasAnyPercentSizedRowsIndefiniteHeight() || m_hasAspectRatioBlockSizeDependentItem) {
     164    // The complication with repeating the track sizing algorithm for flex max-sizing is that
     165    // it might change a grid item's status of participating in Baseline Alignment for
     166    // a cyclic sizing dependncy case, which should be definitively excluded. See
     167    // https://github.com/w3c/csswg-drafts/issues/3046 for details.
     168    // FIXME: we are avoiding repeating the track sizing algorithm for grid item with baseline alignment
     169    // here in the case of using flex max-sizing functions. We probably also need to investigate whether
     170    // it is applicable for the case of percent-sized rows with indefinite height as well.
     171    if (m_hasAnyOrthogonalItem || m_trackSizingAlgorithm.hasAnyPercentSizedRowsIndefiniteHeight() || (m_trackSizingAlgorithm.hasAnyFlexibleMaxTrackBreadth() && !m_trackSizingAlgorithm.hasAnyBaselineAlignmentItem()) || m_hasAspectRatioBlockSizeDependentItem) {
    165172        computeTrackSizesForDefiniteSize(ForColumns, availableSpaceForColumns);
    166173        computeContentPositionAndDistributionOffset(ForColumns, m_trackSizingAlgorithm.freeSpace(ForColumns).value(), nonCollapsedTracks(ForColumns));
  • trunk/Source/WebCore/rendering/RenderGrid.h

    r285497 r286148  
    208208    bool m_hasAspectRatioBlockSizeDependentItem { false };
    209209    bool m_baselineItemsCached {false};
     210    bool m_hasAnyBaselineAlignmentItem { false };
    210211};
    211212
Note: See TracChangeset for help on using the changeset viewer.