Changeset 289993 in webkit


Ignore:
Timestamp:
Feb 16, 2022 7:40:20 PM (5 months ago)
Author:
commit-queue@webkit.org
Message:

Implement getComputedStyle for subgrids
https://bugs.webkit.org/show_bug.cgi?id=236148

Patch by Matt Woodrow <Matt Woodrow> on 2022-02-16
Reviewed by Manuel Rego Casasnovas.

Source/WebCore:

Adds OrderedNamedLinesCollectorInSubgridLayout to iterate the subgrid names list, stopping
at the number of actual tracks in the grid.

  • css/CSSComputedStyleDeclaration.cpp:

(WebCore::OrderedNamedLinesCollectorInSubgridLayout::OrderedNamedLinesCollectorInSubgridLayout):
(WebCore::OrderedNamedLinesCollectorInGridLayout::collectLineNamesForIndex const):
(WebCore::OrderedNamedLinesCollectorInSubgridLayout::collectLineNamesForIndex const):
(WebCore::addValuesForNamedGridLinesAtIndex):
(WebCore::populateSubgridTrackList):
(WebCore::valueForGridTrackList):

  • rendering/RenderGrid.cpp:

(WebCore::RenderGrid::computeAutoRepeatTracksCount const):

  • rendering/RenderGrid.h:
  • rendering/style/GridPositionsResolver.cpp:

(WebCore::NamedLineCollection::contains const):

  • style/StyleBuilderConverter.h:

(WebCore::Style::BuilderConverter::createGridTrackList):

LayoutTests:

Mark tests as no longer crashing.

Location:
trunk
Files:
2 added
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r289990 r289993  
     12022-02-16  Matt Woodrow  <mattwoodrow@apple.com>
     2
     3        Implement getComputedStyle for subgrids
     4        https://bugs.webkit.org/show_bug.cgi?id=236148
     5
     6        Reviewed by Manuel Rego Casasnovas.
     7
     8        Mark tests as no longer crashing.
     9
     10        * TestExpectations:
     11
    1122022-02-16  Jon Lee  <jonlee@apple.com>
    213
  • trunk/LayoutTests/TestExpectations

    r289965 r289993  
    14351435imported/w3c/web-platform-tests/css/css-grid/subgrid/subgrid-mbp-overflow-003.html [ ImageOnlyFailure ]
    14361436imported/w3c/web-platform-tests/css/css-grid/subgrid/subgrid-mbp-overflow-004.html [ ImageOnlyFailure ]
    1437 imported/w3c/web-platform-tests/css/css-grid/subgrid/grid-subgridded-axis-auto-repeater-crash-001.html [ Crash ]
    1438 imported/w3c/web-platform-tests/css/css-grid/subgrid/grid-subgridded-axis-auto-repeater-crash-002.html [ Crash ]
    14391437
    14401438webkit.org/b/149890 fast/css-grid-layout/grid-shorthands-style-format.html [ Failure ]
  • trunk/Source/WebCore/ChangeLog

    r289992 r289993  
     12022-02-16  Matt Woodrow  <mattwoodrow@apple.com>
     2
     3        Implement getComputedStyle for subgrids
     4        https://bugs.webkit.org/show_bug.cgi?id=236148
     5
     6        Reviewed by Manuel Rego Casasnovas.
     7
     8        Adds OrderedNamedLinesCollectorInSubgridLayout to iterate the subgrid names list, stopping
     9        at the number of actual tracks in the grid.
     10
     11
     12        * css/CSSComputedStyleDeclaration.cpp:
     13        (WebCore::OrderedNamedLinesCollectorInSubgridLayout::OrderedNamedLinesCollectorInSubgridLayout):
     14        (WebCore::OrderedNamedLinesCollectorInGridLayout::collectLineNamesForIndex const):
     15        (WebCore::OrderedNamedLinesCollectorInSubgridLayout::collectLineNamesForIndex const):
     16        (WebCore::addValuesForNamedGridLinesAtIndex):
     17        (WebCore::populateSubgridTrackList):
     18        (WebCore::valueForGridTrackList):
     19        * rendering/RenderGrid.cpp:
     20        (WebCore::RenderGrid::computeAutoRepeatTracksCount const):
     21        * rendering/RenderGrid.h:
     22        * rendering/style/GridPositionsResolver.cpp:
     23        (WebCore::NamedLineCollection::contains const):
     24        * style/StyleBuilderConverter.h:
     25        (WebCore::Style::BuilderConverter::createGridTrackList):
     26
    1272022-02-16  Fujii Hironori  <Hironori.Fujii@sony.com>
    228
  • trunk/Source/WebCore/css/CSSComputedStyleDeclaration.cpp

    r289876 r289993  
    899899};
    900900
     901class OrderedNamedLinesCollectorInSubgridLayout : public OrderedNamedLinesCollector {
     902public:
     903    OrderedNamedLinesCollectorInSubgridLayout(const RenderStyle& style, bool isRowAxis, unsigned totalTracksCount)
     904        : OrderedNamedLinesCollector(style, isRowAxis)
     905        , m_insertionPoint(isRowAxis ? style.gridAutoRepeatColumnsInsertionPoint() : style.gridAutoRepeatRowsInsertionPoint())
     906        , m_autoRepeatLineSetListLength((isRowAxis ? style.autoRepeatOrderedNamedGridColumnLines() : style.autoRepeatOrderedNamedGridRowLines()).size())
     907        , m_totalLines(totalTracksCount + 1)
     908    {
     909        if (!m_autoRepeatLineSetListLength) {
     910            m_autoRepeatTotalLineSets = 0;
     911            return;
     912        }
     913        unsigned named = (isRowAxis ? style.orderedNamedGridColumnLines() : style.orderedNamedGridRowLines()).size();
     914        if (named >= m_totalLines) {
     915            m_autoRepeatTotalLineSets = 0;
     916            return;
     917        }
     918        m_autoRepeatTotalLineSets = (m_totalLines - named) / m_autoRepeatLineSetListLength;
     919        m_autoRepeatTotalLineSets *= m_autoRepeatLineSetListLength;
     920    }
     921
     922    void collectLineNamesForIndex(CSSGridLineNamesValue&, unsigned index) const override;
     923
     924    int namedGridLineCount() const override { return m_totalLines; }
     925private:
     926    unsigned m_insertionPoint;
     927    unsigned m_autoRepeatTotalLineSets;
     928    unsigned m_autoRepeatLineSetListLength;
     929    unsigned m_totalLines;
     930};
     931
    901932void OrderedNamedLinesCollector::appendLines(CSSGridLineNamesValue& lineNamesValue, unsigned index, NamedLinesType type) const
    902933{
     
    956987}
    957988
     989void OrderedNamedLinesCollectorInSubgridLayout::collectLineNamesForIndex(CSSGridLineNamesValue& lineNamesValue, unsigned i) const
     990{
     991    if (!m_autoRepeatLineSetListLength || i < m_insertionPoint) {
     992        appendLines(lineNamesValue, i, NamedLines);
     993        return;
     994    }
     995
     996    if (i >= m_insertionPoint + m_autoRepeatTotalLineSets) {
     997        appendLines(lineNamesValue, i - m_autoRepeatTotalLineSets, NamedLines);
     998        return;
     999    }
     1000
     1001    unsigned autoRepeatIndexInFirstRepetition = (i - m_insertionPoint) % m_autoRepeatLineSetListLength;
     1002    appendLines(lineNamesValue, autoRepeatIndexInFirstRepetition, AutoRepeatNamedLines);
     1003}
     1004
    9581005static void addValuesForNamedGridLinesAtIndex(OrderedNamedLinesCollector& collector, unsigned i, CSSValueList& list, bool renderEmpty = false)
    9591006{
    960     if (collector.isEmpty())
     1007    if (collector.isEmpty() && !renderEmpty)
    9611008        return;
    9621009
     
    10361083    // If the element is a grid container, the resolved value is the used value,
    10371084    // specifying track sizes in pixels and expanding the repeat() notation.
    1038     if (isRenderGrid) {
    1039         // FIXME: We need to handle computed subgrid here.
     1085    // If subgrid was specified, but the element isn't a subgrid (due to not having
     1086    // an appropriate grid parent), then we fall back to using the specified value.
     1087    if (isRenderGrid && (!isSubgrid || downcast<RenderGrid>(renderer)->isSubgrid(direction))) {
    10401088        auto* grid = downcast<RenderGrid>(renderer);
     1089        if (isSubgrid) {
     1090            OrderedNamedLinesCollectorInSubgridLayout collector(style, isRowAxis, grid->numTracks(direction));
     1091            populateSubgridLineNameList(list.get(), collector);
     1092            return list;
     1093        }
    10411094        OrderedNamedLinesCollectorInGridLayout collector(style, isRowAxis, grid->autoRepeatCountForDirection(direction), autoRepeatTrackSizes.size());
    10421095        // Named grid line indices are relative to the explicit grid, but we are including all tracks.
  • trunk/Source/WebCore/rendering/RenderGrid.cpp

    r289986 r289993  
    496496    ASSERT(!availableSize || availableSize.value() != -1);
    497497    bool isRowAxis = direction == ForColumns;
     498    if (isSubgrid(direction))
     499        return 0;
     500
    498501    const auto& autoRepeatTracks = isRowAxis ? style().gridAutoRepeatColumns() : style().gridAutoRepeatRows();
    499502    unsigned autoRepeatTrackListLength = autoRepeatTracks.size();
  • trunk/Source/WebCore/rendering/RenderGrid.h

    r289986 r289993  
    102102    }
    103103
     104    unsigned numTracks(GridTrackSizingDirection direction) const
     105    {
     106        return numTracks(direction, m_grid);
     107    }
     108
    104109private:
    105110    ItemPosition selfAlignmentNormalBehavior(const RenderBox* child = nullptr) const override
  • trunk/Source/WebCore/rendering/style/GridPositionsResolver.cpp

    r289986 r289993  
    8080
    8181    m_autoRepeatTrackListLength = isRowAxis ? gridContainerStyle.gridAutoRepeatColumns().size() : gridContainerStyle.gridAutoRepeatRows().size();
     82    // FIXME: Handle subgrid auto repeat tracks
     83    if (isRowAxis ? gridContainerStyle.gridSubgridColumns() : gridContainerStyle.gridSubgridRows()) {
     84        m_autoRepeatTrackListLength = 0;
     85        m_autoRepeatNamedLinesIndexes = nullptr;
     86    }
    8287}
    8388
Note: See TracChangeset for help on using the changeset viewer.