Changeset 210211 in webkit


Ignore:
Timestamp:
Dec 30, 2016 2:53:58 AM (7 years ago)
Author:
svillar@igalia.com
Message:

[css-grid] Isolate instrinsic size computation from layout
https://bugs.webkit.org/show_bug.cgi?id=166530

Reviewed by Darin Adler.

Source/WebCore:

This is the last patch of the items placement data refactoring. By using a different Grid
instance in computeIntrinsicLogicalWidths we effectively isolate the intrinsic size
computation from the layout. They are now using different data structures so they don't
interfere each other.

This also means that we no longer reuse the placement of items done in the intrinsic size
computation. That shouldn't be a big issue once we make m_grid persistent on RenderGrid.

Last but not least, this patch finally removes the ugly const_cast's we had in
computeIntrinsicLogicalWidths() as we no longer modify the internal state of RenderGrid.

Tests: fast/css-grid-layout/grid-auto-repeat-intrinsic.html

fast/css-grid-layout/grid-change-intrinsic-size-with-auto-repeat-tracks.html

  • rendering/RenderGrid.cpp:

(WebCore::RenderGrid::computeIntrinsicLogicalWidths): Use a new instance of Grid.
(WebCore::RenderGrid::computeEmptyTracksForAutoRepeat): Fixed a missing m_grid -> grid
rename.
(WebCore::RenderGrid::placeItemsOnGrid): Constify it. It nows repositions the items if the
number of auto repeat tracks has changed.

  • rendering/RenderGrid.h:

LayoutTests:

  • fast/css-grid-layout/grid-auto-repeat-intrinsic-expected.txt: Added.
  • fast/css-grid-layout/grid-auto-repeat-intrinsic.html: Added.
  • fast/css-grid-layout/grid-change-intrinsic-size-with-auto-repeat-tracks-expected.txt: Added.
  • fast/css-grid-layout/grid-change-intrinsic-size-with-auto-repeat-tracks.html: Added.
Location:
trunk
Files:
4 added
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r210200 r210211  
     12016-12-28  Sergio Villar Senin  <svillar@igalia.com>
     2
     3        [css-grid] Isolate instrinsic size computation from layout
     4        https://bugs.webkit.org/show_bug.cgi?id=166530
     5
     6        Reviewed by Darin Adler.
     7
     8        * fast/css-grid-layout/grid-auto-repeat-intrinsic-expected.txt: Added.
     9        * fast/css-grid-layout/grid-auto-repeat-intrinsic.html: Added.
     10        * fast/css-grid-layout/grid-change-intrinsic-size-with-auto-repeat-tracks-expected.txt: Added.
     11        * fast/css-grid-layout/grid-change-intrinsic-size-with-auto-repeat-tracks.html: Added.
     12
    1132016-12-28  Carlos Alberto Lopez Perez  <clopez@igalia.com>
    214
  • trunk/Source/WebCore/ChangeLog

    r210207 r210211  
     12016-12-28  Sergio Villar Senin  <svillar@igalia.com>
     2
     3        [css-grid] Isolate instrinsic size computation from layout
     4        https://bugs.webkit.org/show_bug.cgi?id=166530
     5
     6        Reviewed by Darin Adler.
     7
     8        This is the last patch of the items placement data refactoring. By using a different Grid
     9        instance in computeIntrinsicLogicalWidths we effectively isolate the intrinsic size
     10        computation from the layout. They are now using different data structures so they don't
     11        interfere each other.
     12
     13        This also means that we no longer reuse the placement of items done in the intrinsic size
     14        computation. That shouldn't be a big issue once we make m_grid persistent on RenderGrid.
     15
     16        Last but not least, this patch finally removes the ugly const_cast's we had in
     17        computeIntrinsicLogicalWidths() as we no longer modify the internal state of RenderGrid.
     18
     19        Tests: fast/css-grid-layout/grid-auto-repeat-intrinsic.html
     20               fast/css-grid-layout/grid-change-intrinsic-size-with-auto-repeat-tracks.html
     21
     22        * rendering/RenderGrid.cpp:
     23        (WebCore::RenderGrid::computeIntrinsicLogicalWidths): Use a new instance of Grid.
     24        (WebCore::RenderGrid::computeEmptyTracksForAutoRepeat): Fixed a missing m_grid -> grid
     25        rename.
     26        (WebCore::RenderGrid::placeItemsOnGrid): Constify it. It nows repositions the items if the
     27        number of auto repeat tracks has changed.
     28        * rendering/RenderGrid.h:
     29
    1302016-12-30  Michael Catanzaro  <mcatanzaro@igalia.com>
    231
  • trunk/Source/WebCore/rendering/RenderGrid.cpp

    r210197 r210211  
    736736void RenderGrid::computeIntrinsicLogicalWidths(LayoutUnit& minLogicalWidth, LayoutUnit& maxLogicalWidth) const
    737737{
    738     bool wasPopulated = !m_grid.needsItemsPlacement();
    739     if (!wasPopulated)
    740         const_cast<RenderGrid*>(this)->placeItemsOnGrid(const_cast<Grid&>(m_grid), IntrinsicSizeComputation);
    741 
    742     GridSizingData sizingData(numTracks(ForColumns, m_grid), numTracks(ForRows, m_grid), const_cast<Grid&>(m_grid));
     738    Grid grid(const_cast<RenderGrid&>(*this));
     739    placeItemsOnGrid(grid, IntrinsicSizeComputation);
     740
     741    GridSizingData sizingData(numTracks(ForColumns, grid), numTracks(ForRows, grid), grid);
    743742    sizingData.setAvailableSpace(std::nullopt);
    744743    sizingData.setFreeSpace(ForColumns, std::nullopt);
     
    753752    minLogicalWidth += scrollbarWidth;
    754753    maxLogicalWidth += scrollbarWidth;
    755 
    756     if (!wasPopulated)
    757         const_cast<RenderGrid*>(this)->clearGrid();
    758754}
    759755
     
    17091705    unsigned lastAutoRepeatTrack = firstAutoRepeatTrack + grid.autoRepeatTracks(direction);
    17101706
    1711     if (!m_grid.hasGridItems()) {
     1707    if (!grid.hasGridItems()) {
    17121708        emptyTrackIndexes = std::make_unique<OrderedTrackIndexSet>();
    17131709        for (unsigned trackIndex = firstAutoRepeatTrack; trackIndex < lastAutoRepeatTrack; ++trackIndex)
     
    17261722}
    17271723
    1728 void RenderGrid::placeItemsOnGrid(Grid& grid, SizingOperation sizingOperation)
    1729 {
    1730     ASSERT(grid.needsItemsPlacement());
    1731     ASSERT(!grid.hasGridItems());
    1732 
     1724void RenderGrid::placeItemsOnGrid(Grid& grid, SizingOperation sizingOperation) const
     1725{
    17331726    unsigned autoRepeatColumns = computeAutoRepeatTracksCount(ForColumns, sizingOperation);
    17341727    unsigned autoRepeatRows = computeAutoRepeatTracksCount(ForRows, sizingOperation);
    1735     grid.setAutoRepeatTracks(autoRepeatRows, autoRepeatColumns);
    1736 
     1728    if (autoRepeatColumns != grid.autoRepeatTracks(ForColumns) || autoRepeatRows != grid.autoRepeatTracks(ForRows)) {
     1729        grid.setNeedsItemsPlacement(true);
     1730        grid.setAutoRepeatTracks(autoRepeatRows, autoRepeatColumns);
     1731    }
     1732
     1733    if (!grid.needsItemsPlacement())
     1734        return;
     1735
     1736    ASSERT(!grid.hasGridItems());
    17371737    populateExplicitGridAndOrderIterator(grid);
    17381738
     
    27942794    // because not having rows implies that there are no "normal" children (out-of-flow children are
    27952795    // not stored in m_grid).
    2796     ASSERT(!m_grid.needsItemsPlacement());
     2796    ASSERT(!grid.needsItemsPlacement());
    27972797    if (direction == ForRows)
    27982798        return grid.numTracks(ForRows);
  • trunk/Source/WebCore/rendering/RenderGrid.h

    r210197 r210211  
    9595    std::unique_ptr<OrderedTrackIndexSet> computeEmptyTracksForAutoRepeat(Grid&, GridTrackSizingDirection) const;
    9696
    97     void placeItemsOnGrid(Grid&, SizingOperation);
     97    void placeItemsOnGrid(Grid&, SizingOperation) const;
    9898    void populateExplicitGridAndOrderIterator(Grid&) const;
    9999    std::unique_ptr<GridArea> createEmptyGridAreaAtSpecifiedPositionsOutsideGrid(Grid&, const RenderBox&, GridTrackSizingDirection, const GridSpan&) const;
Note: See TracChangeset for help on using the changeset viewer.