Changeset 291952 in webkit
- Timestamp:
- Mar 27, 2022 1:24:03 PM (4 months ago)
- Location:
- trunk
- Files:
-
- 1 added
- 6 edited
-
LayoutTests/ChangeLog (modified) (1 diff)
-
LayoutTests/TestExpectations (modified) (1 diff)
-
LayoutTests/imported/w3c/ChangeLog (modified) (1 diff)
-
LayoutTests/imported/w3c/web-platform-tests/css/css-grid/grid-definition/grid-limits-001-expected.txt (added)
-
Source/WebCore/ChangeLog (modified) (1 diff)
-
Source/WebCore/rendering/Grid.cpp (modified) (8 diffs)
-
Source/WebCore/rendering/Grid.h (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r291951 r291952 1 2022-03-27 Matt Woodrow <mattwoodrow@apple.com> 2 3 Lazily allocate backing store for grid columns. 4 https://bugs.webkit.org/show_bug.cgi?id=212201 5 6 Reviewed by Dean Jackson. 7 8 * TestExpectations: 9 10 Remove skip annotation for test grid-limits-001 that now passes. 11 1 12 2022-03-27 Alan Bujtas <zalan@apple.com> 2 13 -
trunk/LayoutTests/TestExpectations
r291949 r291952 4251 4251 webkit.org/b/209460 imported/w3c/web-platform-tests/css/css-grid/abspos/descendant-static-position-002.html [ ImageOnlyFailure ] 4252 4252 webkit.org/b/209460 imported/w3c/web-platform-tests/css/css-grid/abspos/descendant-static-position-003.html [ ImageOnlyFailure ] 4253 webkit.org/b/212201 imported/w3c/web-platform-tests/css/css-grid/grid-definition/grid-limits-001.html [ Skip ]4254 4253 webkit.org/b/212246 imported/w3c/web-platform-tests/css/css-grid/alignment/grid-baseline-align-cycles-001.html [ ImageOnlyFailure ] 4255 4254 webkit.org/b/231021 imported/w3c/web-platform-tests/css/css-grid/alignment/grid-inline-baseline.html [ ImageOnlyFailure ] -
trunk/LayoutTests/imported/w3c/ChangeLog
r291949 r291952 1 2022-03-27 Matt Woodrow <mattwoodrow@apple.com> 2 3 Lazily allocate backing store for grid columns. 4 https://bugs.webkit.org/show_bug.cgi?id=212201 5 6 Reviewed by Dean Jackson. 7 8 * web-platform-tests/css/css-grid/grid-definition/grid-limits-001-expected.txt: Added. 9 10 Add passing expectations file for previously skipped test. 11 1 12 2022-03-26 Noam Rosenthal <noam@webkit.org> 2 13 -
trunk/Source/WebCore/ChangeLog
r291951 r291952 1 2022-03-27 Matt Woodrow <mattwoodrow@apple.com> 2 3 Lazily allocate backing store for grid columns. 4 https://bugs.webkit.org/show_bug.cgi?id=212201 5 6 Reviewed by Dean Jackson. 7 8 Existing WPT test grid-limits-001.html marked as passing. 9 10 * rendering/Grid.cpp: 11 (WebCore::Grid::ensureGridSize): 12 (WebCore::Grid::ensureStorageForRow): 13 (WebCore::Grid::insert): 14 (WebCore::Grid::cell const): 15 16 Only grow the first row's column storage (since we use this 17 to remember the column count) and lazily grow the others when 18 we try write to them. 19 20 (WebCore::GridIterator::GridIterator): 21 (WebCore::GridIterator::nextGridItem): 22 (WebCore::GridIterator::isEmptyAreaEnough const): 23 (WebCore::GridIterator::nextEmptyGridArea): 24 * rendering/Grid.h: 25 26 Changes GridIterator to use the Grid API rather than directly 27 accessing the inner Vector using 'friend'. This makes it easier to 28 ensure that we never access areas outside of our lazy allocations. 29 1 30 2022-03-27 Alan Bujtas <zalan@apple.com> 2 31 -
trunk/Source/WebCore/rendering/Grid.cpp
r290572 r291952 52 52 if (maximumRowSize > oldRowSize) { 53 53 m_grid.grow(maximumRowSize); 54 for (size_t row = oldRowSize; row < maximumRowSize; ++row) 55 m_grid[row].grow(oldColumnSize); 56 } 57 58 if (maximumColumnSize > oldColumnSize) { 59 for (size_t row = 0; row < numTracks(ForRows); ++row) 60 m_grid[row].grow(maximumColumnSize); 61 } 54 } 55 56 // Just grow the first row for now so that we know the requested size, 57 // and we'll lazily allocate the others when they get used. 58 if (maximumColumnSize > oldColumnSize && maximumRowSize) { 59 m_grid[0].grow(maximumColumnSize); 60 } 61 } 62 63 void Grid::ensureStorageForRow(unsigned row) 64 { 65 m_grid[row].grow(m_grid[0].size()); 62 66 } 63 67 … … 74 78 75 79 for (auto row : clampedArea.rows) { 80 ensureStorageForRow(row); 76 81 for (auto column : clampedArea.columns) 77 82 m_grid[row][column].append(child); … … 80 85 setGridItemArea(child, clampedArea); 81 86 return clampedArea; 87 } 88 89 const GridCell& Grid::cell(unsigned row, unsigned column) const 90 { 91 // Storage for rows other than the first is lazily allocated. We can 92 // just return a fake entry if the request is outside the allocated area, 93 // since it must be empty. 94 static const NeverDestroyed<GridCell> emptyCell; 95 if (row && m_grid[row].size() <= column) 96 return emptyCell; 97 98 return m_grid[row][column]; 82 99 } 83 100 … … 192 209 193 210 GridIterator::GridIterator(const Grid& grid, GridTrackSizingDirection direction, unsigned fixedTrackIndex, unsigned varyingTrackIndex) 194 : m_grid(grid .m_grid)211 : m_grid(grid) 195 212 , m_direction(direction) 196 213 , m_rowIndex((direction == ForColumns) ? varyingTrackIndex : fixedTrackIndex) … … 198 215 , m_childIndex(0) 199 216 { 200 ASSERT( !m_grid.isEmpty());201 ASSERT( !m_grid[0].isEmpty());202 ASSERT(m_rowIndex < m_grid. size());203 ASSERT(m_columnIndex < m_grid [0].size());217 ASSERT(m_grid.numTracks(ForRows)); 218 ASSERT(m_grid.numTracks(ForColumns)); 219 ASSERT(m_rowIndex < m_grid.numTracks(ForRows)); 220 ASSERT(m_columnIndex < m_grid.numTracks(ForColumns)); 204 221 } 205 222 206 223 RenderBox* GridIterator::nextGridItem() 207 224 { 208 ASSERT( !m_grid.isEmpty());209 ASSERT( !m_grid[0].isEmpty());225 ASSERT(m_grid.numTracks(ForRows)); 226 ASSERT(m_grid.numTracks(ForColumns)); 210 227 211 228 unsigned& varyingTrackIndex = (m_direction == ForColumns) ? m_rowIndex : m_columnIndex; 212 const unsigned endOfVaryingTrackIndex = (m_direction == ForColumns) ? m_grid. size() : m_grid[0].size();229 const unsigned endOfVaryingTrackIndex = (m_direction == ForColumns) ? m_grid.numTracks(ForRows) : m_grid.numTracks(ForColumns); 213 230 for (; varyingTrackIndex < endOfVaryingTrackIndex; ++varyingTrackIndex) { 214 const auto& children = m_grid [m_rowIndex][m_columnIndex];231 const auto& children = m_grid.cell(m_rowIndex, m_columnIndex); 215 232 if (m_childIndex < children.size()) 216 233 return children[m_childIndex++].get(); … … 223 240 bool GridIterator::isEmptyAreaEnough(unsigned rowSpan, unsigned columnSpan) const 224 241 { 225 ASSERT( !m_grid.isEmpty());226 ASSERT( !m_grid[0].isEmpty());242 ASSERT(m_grid.numTracks(ForRows)); 243 ASSERT(m_grid.numTracks(ForColumns)); 227 244 228 245 // Ignore cells outside current grid as we will grow it later if needed. 229 unsigned maxRows = std::min<unsigned>(m_rowIndex + rowSpan, m_grid. size());230 unsigned maxColumns = std::min<unsigned>(m_columnIndex + columnSpan, m_grid [0].size());246 unsigned maxRows = std::min<unsigned>(m_rowIndex + rowSpan, m_grid.numTracks(ForRows)); 247 unsigned maxColumns = std::min<unsigned>(m_columnIndex + columnSpan, m_grid.numTracks(ForColumns)); 231 248 232 249 // This adds a O(N^2) behavior that shouldn't be a big deal as we expect spanning areas to be small. 233 250 for (unsigned row = m_rowIndex; row < maxRows; ++row) { 234 251 for (unsigned column = m_columnIndex; column < maxColumns; ++column) { 235 auto& children = m_grid [row][column];252 auto& children = m_grid.cell(row, column); 236 253 if (!children.isEmpty()) 237 254 return false; … … 244 261 std::unique_ptr<GridArea> GridIterator::nextEmptyGridArea(unsigned fixedTrackSpan, unsigned varyingTrackSpan) 245 262 { 246 ASSERT( !m_grid.isEmpty());247 ASSERT( !m_grid[0].isEmpty());263 ASSERT(m_grid.numTracks(ForRows)); 264 ASSERT(m_grid.numTracks(ForColumns)); 248 265 ASSERT(fixedTrackSpan >= 1); 249 266 ASSERT(varyingTrackSpan >= 1); 250 267 251 if ( m_grid.isEmpty())268 if (!m_grid.hasGridItems()) 252 269 return nullptr; 253 270 … … 256 273 257 274 unsigned& varyingTrackIndex = (m_direction == ForColumns) ? m_rowIndex : m_columnIndex; 258 const unsigned endOfVaryingTrackIndex = (m_direction == ForColumns) ? m_grid. size() : m_grid[0].size();275 const unsigned endOfVaryingTrackIndex = (m_direction == ForColumns) ? m_grid.numTracks(ForRows) : m_grid.numTracks(ForColumns); 259 276 for (; varyingTrackIndex < endOfVaryingTrackIndex; ++varyingTrackIndex) { 260 277 if (isEmptyAreaEnough(rowSpan, columnSpan)) { -
trunk/Source/WebCore/rendering/Grid.h
r290077 r291952 60 60 GridSpan gridItemSpan(const RenderBox&, GridTrackSizingDirection) const; 61 61 62 const GridCell& cell(unsigned row, unsigned column) const { return m_grid[row][column]; }62 const GridCell& cell(unsigned row, unsigned column) const; 63 63 64 64 unsigned explicitGridStart(GridTrackSizingDirection) const; … … 87 87 88 88 private: 89 friend class GridIterator;89 void ensureStorageForRow(unsigned row); 90 90 91 91 OrderIterator m_orderIterator; … … 129 129 130 130 private: 131 const Grid AsMatrix& m_grid;131 const Grid& m_grid; 132 132 GridTrackSizingDirection m_direction; 133 133 unsigned m_rowIndex;
Note: See TracChangeset
for help on using the changeset viewer.