Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(6)

Side by Side Diff: third_party/WebKit/Source/core/layout/LayoutGrid.cpp

Issue 2522503002: [css-grid] Convert GridRepresentation into an actual class (Closed)
Patch Set: Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2011 Apple Inc. All rights reserved. 2 * Copyright (C) 2011 Apple Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 24 matching lines...) Expand all
35 #include "wtf/PtrUtil.h" 35 #include "wtf/PtrUtil.h"
36 #include <algorithm> 36 #include <algorithm>
37 #include <memory> 37 #include <memory>
38 38
39 namespace blink { 39 namespace blink {
40 40
41 static const int infinity = -1; 41 static const int infinity = -1;
42 42
43 class GridItemWithSpan; 43 class GridItemWithSpan;
44 44
45 void LayoutGrid::Grid::ensureGridSize(size_t maximumRowSize,
46 size_t maximumColumnSize) {
47 const size_t oldRowSize = numRows();
48 if (maximumRowSize > oldRowSize) {
49 m_grid.grow(maximumRowSize);
50 for (size_t row = oldRowSize; row < numRows(); ++row)
51 m_grid[row].grow(numColumns());
52 }
53
54 if (maximumColumnSize > numColumns()) {
55 for (size_t row = 0; row < numRows(); ++row)
56 m_grid[row].grow(maximumColumnSize);
57 }
58 }
59
60 void LayoutGrid::Grid::insert(LayoutBox& child, const GridArea& area) {
61 DCHECK(area.rows.isTranslatedDefinite() &&
62 area.columns.isTranslatedDefinite());
63 ensureGridSize(area.rows.endLine(), area.columns.endLine());
64
65 for (const auto& row : area.rows) {
66 for (const auto& column : area.columns)
67 m_grid[row][column].append(&child);
68 }
69 }
70
71 void LayoutGrid::Grid::clear() {
72 m_grid.resize(0);
73 }
74
45 class GridTrack { 75 class GridTrack {
46 public: 76 public:
47 GridTrack() : m_infinitelyGrowable(false) {} 77 GridTrack() : m_infinitelyGrowable(false) {}
48 78
49 LayoutUnit baseSize() const { 79 LayoutUnit baseSize() const {
50 DCHECK(isGrowthLimitBiggerThanBaseSize()); 80 DCHECK(isGrowthLimitBiggerThanBaseSize());
51 return m_baseSize; 81 return m_baseSize;
52 } 82 }
53 83
54 LayoutUnit growthLimit() const { 84 LayoutUnit growthLimit() const {
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
145 ForbidInfinity, 175 ForbidInfinity,
146 }; 176 };
147 177
148 class LayoutGrid::GridIterator { 178 class LayoutGrid::GridIterator {
149 WTF_MAKE_NONCOPYABLE(GridIterator); 179 WTF_MAKE_NONCOPYABLE(GridIterator);
150 180
151 public: 181 public:
152 // |direction| is the direction that is fixed to |fixedTrackIndex| so e.g 182 // |direction| is the direction that is fixed to |fixedTrackIndex| so e.g
153 // GridIterator(m_grid, ForColumns, 1) will walk over the rows of the 2nd 183 // GridIterator(m_grid, ForColumns, 1) will walk over the rows of the 2nd
154 // column. 184 // column.
155 GridIterator(const GridRepresentation& grid, 185 GridIterator(const Grid& grid,
156 GridTrackSizingDirection direction, 186 GridTrackSizingDirection direction,
157 size_t fixedTrackIndex, 187 size_t fixedTrackIndex,
158 size_t varyingTrackIndex = 0) 188 size_t varyingTrackIndex = 0)
159 : m_grid(grid), 189 : m_grid(grid.m_grid),
160 m_direction(direction), 190 m_direction(direction),
161 m_rowIndex((direction == ForColumns) ? varyingTrackIndex 191 m_rowIndex((direction == ForColumns) ? varyingTrackIndex
162 : fixedTrackIndex), 192 : fixedTrackIndex),
163 m_columnIndex((direction == ForColumns) ? fixedTrackIndex 193 m_columnIndex((direction == ForColumns) ? fixedTrackIndex
164 : varyingTrackIndex), 194 : varyingTrackIndex),
165 m_childIndex(0) { 195 m_childIndex(0) {
166 DCHECK(!m_grid.isEmpty()); 196 DCHECK(!m_grid.isEmpty());
167 DCHECK(!m_grid[0].isEmpty()); 197 DCHECK(!m_grid[0].isEmpty());
168 DCHECK(m_rowIndex < m_grid.size()); 198 DCHECK(m_rowIndex < m_grid.size());
169 DCHECK(m_columnIndex < m_grid[0].size()); 199 DCHECK(m_columnIndex < m_grid[0].size());
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
233 // Advance the iterator to avoid an infinite loop where we would return 263 // Advance the iterator to avoid an infinite loop where we would return
234 // the same grid area over and over. 264 // the same grid area over and over.
235 ++varyingTrackIndex; 265 ++varyingTrackIndex;
236 return result; 266 return result;
237 } 267 }
238 } 268 }
239 return nullptr; 269 return nullptr;
240 } 270 }
241 271
242 private: 272 private:
243 const GridRepresentation& m_grid; 273 const GridAsVector& m_grid;
244 GridTrackSizingDirection m_direction; 274 GridTrackSizingDirection m_direction;
245 size_t m_rowIndex; 275 size_t m_rowIndex;
246 size_t m_columnIndex; 276 size_t m_columnIndex;
247 size_t m_childIndex; 277 size_t m_childIndex;
248 }; 278 };
249 279
250 struct LayoutGrid::GridSizingData { 280 struct LayoutGrid::GridSizingData {
251 WTF_MAKE_NONCOPYABLE(GridSizingData); 281 WTF_MAKE_NONCOPYABLE(GridSizingData);
252 STACK_ALLOCATED(); 282 STACK_ALLOCATED();
253 283
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
393 } 423 }
394 424
395 bool LayoutGrid::namedGridLinesDefinitionDidChange( 425 bool LayoutGrid::namedGridLinesDefinitionDidChange(
396 const ComputedStyle& oldStyle) const { 426 const ComputedStyle& oldStyle) const {
397 return oldStyle.namedGridRowLines() != styleRef().namedGridRowLines() || 427 return oldStyle.namedGridRowLines() != styleRef().namedGridRowLines() ||
398 oldStyle.namedGridColumnLines() != styleRef().namedGridColumnLines(); 428 oldStyle.namedGridColumnLines() != styleRef().namedGridColumnLines();
399 } 429 }
400 430
401 size_t LayoutGrid::gridColumnCount() const { 431 size_t LayoutGrid::gridColumnCount() const {
402 DCHECK(!m_gridIsDirty); 432 DCHECK(!m_gridIsDirty);
403 return m_grid.size() ? m_grid[0].size() : 0; 433 return m_grid.numColumns();
404 } 434 }
405 435
406 size_t LayoutGrid::gridRowCount() const { 436 size_t LayoutGrid::gridRowCount() const {
407 DCHECK(!m_gridIsDirty); 437 DCHECK(!m_gridIsDirty);
408 return m_grid.size(); 438 return m_grid.numRows();
409 } 439 }
410 440
411 LayoutUnit LayoutGrid::computeTrackBasedLogicalHeight( 441 LayoutUnit LayoutGrid::computeTrackBasedLogicalHeight(
412 const GridSizingData& sizingData) const { 442 const GridSizingData& sizingData) const {
413 LayoutUnit logicalHeight; 443 LayoutUnit logicalHeight;
414 444
415 for (const auto& row : sizingData.rowTracks) 445 for (const auto& row : sizingData.rowTracks)
416 logicalHeight += row.baseSize(); 446 logicalHeight += row.baseSize();
417 447
418 logicalHeight += guttersSize(ForRows, 0, sizingData.rowTracks.size(), 448 logicalHeight += guttersSize(ForRows, 0, sizingData.rowTracks.size(),
(...skipping 1367 matching lines...) Expand 10 before | Expand all | Expand 10 after
1786 GridTrackSize trackSize = 1816 GridTrackSize trackSize =
1787 gridTrackSize(direction, i, sizingData.sizingOperation); 1817 gridTrackSize(direction, i, sizingData.sizingOperation);
1788 if (computeUsedBreadthOfMinLength(trackSize, maxSize) > 1818 if (computeUsedBreadthOfMinLength(trackSize, maxSize) >
1789 tracks[i].baseSize()) 1819 tracks[i].baseSize())
1790 return false; 1820 return false;
1791 } 1821 }
1792 return true; 1822 return true;
1793 } 1823 }
1794 #endif 1824 #endif
1795 1825
1796 void LayoutGrid::ensureGridSize(size_t maximumRowSize,
1797 size_t maximumColumnSize) {
1798 const size_t oldRowSize = gridRowCount();
1799 if (maximumRowSize > oldRowSize) {
1800 m_grid.grow(maximumRowSize);
1801 for (size_t row = oldRowSize; row < gridRowCount(); ++row)
1802 m_grid[row].grow(gridColumnCount());
1803 }
1804
1805 if (maximumColumnSize > gridColumnCount()) {
1806 for (size_t row = 0; row < gridRowCount(); ++row)
1807 m_grid[row].grow(maximumColumnSize);
1808 }
1809 }
1810
1811 void LayoutGrid::insertItemIntoGrid(LayoutBox& child, const GridArea& area) {
1812 RELEASE_ASSERT(area.rows.isTranslatedDefinite() &&
1813 area.columns.isTranslatedDefinite());
1814 ensureGridSize(area.rows.endLine(), area.columns.endLine());
1815
1816 for (const auto& row : area.rows) {
1817 for (const auto& column : area.columns)
1818 m_grid[row][column].append(&child);
1819 }
1820 }
1821
1822 void LayoutGrid::updateAutoRepeatTracksAndSetDirtyIfNeeded( 1826 void LayoutGrid::updateAutoRepeatTracksAndSetDirtyIfNeeded(
1823 SizingOperation sizingOperation) { 1827 SizingOperation sizingOperation) {
1824 size_t newAutoRepeatColumns = 1828 size_t newAutoRepeatColumns =
1825 computeAutoRepeatTracksCount(ForColumns, sizingOperation); 1829 computeAutoRepeatTracksCount(ForColumns, sizingOperation);
1826 size_t newAutoRepeatRows = 1830 size_t newAutoRepeatRows =
1827 computeAutoRepeatTracksCount(ForRows, sizingOperation); 1831 computeAutoRepeatTracksCount(ForRows, sizingOperation);
1828 1832
1829 if (m_autoRepeatColumns != newAutoRepeatColumns || 1833 if (m_autoRepeatColumns != newAutoRepeatColumns ||
1830 m_autoRepeatRows != newAutoRepeatRows) 1834 m_autoRepeatRows != newAutoRepeatRows)
1831 dirtyGrid(); 1835 dirtyGrid();
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after
2010 if (area.rows.isIndefinite() || area.columns.isIndefinite()) { 2014 if (area.rows.isIndefinite() || area.columns.isIndefinite()) {
2011 GridSpan majorAxisPositions = 2015 GridSpan majorAxisPositions =
2012 (autoPlacementMajorAxisDirection() == ForColumns) ? area.columns 2016 (autoPlacementMajorAxisDirection() == ForColumns) ? area.columns
2013 : area.rows; 2017 : area.rows;
2014 if (majorAxisPositions.isIndefinite()) 2018 if (majorAxisPositions.isIndefinite())
2015 autoMajorAxisAutoGridItems.append(child); 2019 autoMajorAxisAutoGridItems.append(child);
2016 else 2020 else
2017 specifiedMajorAxisAutoGridItems.append(child); 2021 specifiedMajorAxisAutoGridItems.append(child);
2018 continue; 2022 continue;
2019 } 2023 }
2020 insertItemIntoGrid(*child, area); 2024 m_grid.insert(*child, area);
2021 } 2025 }
2022 2026
2023 #if ENABLE(ASSERT) 2027 #if ENABLE(ASSERT)
2024 if (!m_gridItemArea.isEmpty()) { 2028 if (!m_gridItemArea.isEmpty()) {
2025 DCHECK_GE(gridRowCount(), GridPositionsResolver::explicitGridRowCount( 2029 DCHECK_GE(gridRowCount(), GridPositionsResolver::explicitGridRowCount(
2026 *style(), m_autoRepeatRows)); 2030 *style(), m_autoRepeatRows));
2027 DCHECK_GE(gridColumnCount(), GridPositionsResolver::explicitGridColumnCount( 2031 DCHECK_GE(gridColumnCount(), GridPositionsResolver::explicitGridColumnCount(
2028 *style(), m_autoRepeatColumns)); 2032 *style(), m_autoRepeatColumns));
2029 } 2033 }
2030 #endif 2034 #endif
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
2096 columnPositions.untranslatedEndLine()); 2100 columnPositions.untranslatedEndLine());
2097 } else { 2101 } else {
2098 // Grow the grid for items with a definite column span, getting the 2102 // Grow the grid for items with a definite column span, getting the
2099 // largest such span. 2103 // largest such span.
2100 size_t spanSize = GridPositionsResolver::spanSizeForAutoPlacedItem( 2104 size_t spanSize = GridPositionsResolver::spanSizeForAutoPlacedItem(
2101 *style(), *child, ForColumns); 2105 *style(), *child, ForColumns);
2102 maximumColumnIndex = std::max(maximumColumnIndex, spanSize); 2106 maximumColumnIndex = std::max(maximumColumnIndex, spanSize);
2103 } 2107 }
2104 } 2108 }
2105 2109
2106 m_grid.grow(maximumRowIndex + abs(m_smallestRowStart)); 2110 m_grid.ensureGridSize(maximumRowIndex + abs(m_smallestRowStart),
2107 for (auto& column : m_grid) 2111 maximumColumnIndex + abs(m_smallestColumnStart));
2108 column.grow(maximumColumnIndex + abs(m_smallestColumnStart));
2109 } 2112 }
2110 2113
2111 std::unique_ptr<GridArea> 2114 std::unique_ptr<GridArea>
2112 LayoutGrid::createEmptyGridAreaAtSpecifiedPositionsOutsideGrid( 2115 LayoutGrid::createEmptyGridAreaAtSpecifiedPositionsOutsideGrid(
2113 const LayoutBox& gridItem, 2116 const LayoutBox& gridItem,
2114 GridTrackSizingDirection specifiedDirection, 2117 GridTrackSizingDirection specifiedDirection,
2115 const GridSpan& specifiedPositions) const { 2118 const GridSpan& specifiedPositions) const {
2116 GridTrackSizingDirection crossDirection = 2119 GridTrackSizingDirection crossDirection =
2117 specifiedDirection == ForColumns ? ForRows : ForColumns; 2120 specifiedDirection == ForColumns ? ForRows : ForColumns;
2118 const size_t endOfCrossDirection = 2121 const size_t endOfCrossDirection =
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
2157 isGridAutoFlowDense 2160 isGridAutoFlowDense
2158 ? 0 2161 ? 0
2159 : minorAxisCursors.get(majorAxisInitialPosition)); 2162 : minorAxisCursors.get(majorAxisInitialPosition));
2160 std::unique_ptr<GridArea> emptyGridArea = iterator.nextEmptyGridArea( 2163 std::unique_ptr<GridArea> emptyGridArea = iterator.nextEmptyGridArea(
2161 majorAxisPositions.integerSpan(), minorAxisSpanSize); 2164 majorAxisPositions.integerSpan(), minorAxisSpanSize);
2162 if (!emptyGridArea) 2165 if (!emptyGridArea)
2163 emptyGridArea = createEmptyGridAreaAtSpecifiedPositionsOutsideGrid( 2166 emptyGridArea = createEmptyGridAreaAtSpecifiedPositionsOutsideGrid(
2164 *autoGridItem, autoPlacementMajorAxisDirection(), majorAxisPositions); 2167 *autoGridItem, autoPlacementMajorAxisDirection(), majorAxisPositions);
2165 2168
2166 m_gridItemArea.set(autoGridItem, *emptyGridArea); 2169 m_gridItemArea.set(autoGridItem, *emptyGridArea);
2167 insertItemIntoGrid(*autoGridItem, *emptyGridArea); 2170 m_grid.insert(*autoGridItem, *emptyGridArea);
2168 2171
2169 if (!isGridAutoFlowDense) 2172 if (!isGridAutoFlowDense)
2170 minorAxisCursors.set(majorAxisInitialPosition, 2173 minorAxisCursors.set(majorAxisInitialPosition,
2171 isForColumns ? emptyGridArea->rows.startLine() 2174 isForColumns ? emptyGridArea->rows.startLine()
2172 : emptyGridArea->columns.startLine()); 2175 : emptyGridArea->columns.startLine());
2173 } 2176 }
2174 } 2177 }
2175 2178
2176 void LayoutGrid::placeAutoMajorAxisItemsOnGrid( 2179 void LayoutGrid::placeAutoMajorAxisItemsOnGrid(
2177 const Vector<LayoutBox*>& autoGridItems) { 2180 const Vector<LayoutBox*>& autoGridItems) {
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
2265 minorAxisAutoPlacementCursor = 0; 2268 minorAxisAutoPlacementCursor = 0;
2266 } 2269 }
2267 2270
2268 if (!emptyGridArea) 2271 if (!emptyGridArea)
2269 emptyGridArea = createEmptyGridAreaAtSpecifiedPositionsOutsideGrid( 2272 emptyGridArea = createEmptyGridAreaAtSpecifiedPositionsOutsideGrid(
2270 gridItem, autoPlacementMinorAxisDirection(), 2273 gridItem, autoPlacementMinorAxisDirection(),
2271 GridSpan::translatedDefiniteGridSpan(0, minorAxisSpanSize)); 2274 GridSpan::translatedDefiniteGridSpan(0, minorAxisSpanSize));
2272 } 2275 }
2273 2276
2274 m_gridItemArea.set(&gridItem, *emptyGridArea); 2277 m_gridItemArea.set(&gridItem, *emptyGridArea);
2275 insertItemIntoGrid(gridItem, *emptyGridArea); 2278 m_grid.insert(gridItem, *emptyGridArea);
2276 // Move auto-placement cursor to the new position. 2279 // Move auto-placement cursor to the new position.
2277 autoPlacementCursor.first = emptyGridArea->rows.startLine(); 2280 autoPlacementCursor.first = emptyGridArea->rows.startLine();
2278 autoPlacementCursor.second = emptyGridArea->columns.startLine(); 2281 autoPlacementCursor.second = emptyGridArea->columns.startLine();
2279 } 2282 }
2280 2283
2281 GridTrackSizingDirection LayoutGrid::autoPlacementMajorAxisDirection() const { 2284 GridTrackSizingDirection LayoutGrid::autoPlacementMajorAxisDirection() const {
2282 return style()->isGridAutoFlowDirectionColumn() ? ForColumns : ForRows; 2285 return style()->isGridAutoFlowDirectionColumn() ? ForColumns : ForRows;
2283 } 2286 }
2284 2287
2285 GridTrackSizingDirection LayoutGrid::autoPlacementMinorAxisDirection() const { 2288 GridTrackSizingDirection LayoutGrid::autoPlacementMinorAxisDirection() const {
2286 return style()->isGridAutoFlowDirectionColumn() ? ForRows : ForColumns; 2289 return style()->isGridAutoFlowDirectionColumn() ? ForRows : ForColumns;
2287 } 2290 }
2288 2291
2289 void LayoutGrid::dirtyGrid() { 2292 void LayoutGrid::dirtyGrid() {
2290 if (m_gridIsDirty) 2293 if (m_gridIsDirty)
2291 return; 2294 return;
2292 2295
2293 m_grid.resize(0); 2296 m_grid.clear();
2294 m_gridItemArea.clear(); 2297 m_gridItemArea.clear();
2295 m_gridItemsOverflowingGridArea.resize(0); 2298 m_gridItemsOverflowingGridArea.resize(0);
2296 m_gridItemsIndexesMap.clear(); 2299 m_gridItemsIndexesMap.clear();
2297 m_autoRepeatColumns = 0; 2300 m_autoRepeatColumns = 0;
2298 m_autoRepeatRows = 0; 2301 m_autoRepeatRows = 0;
2299 m_gridIsDirty = true; 2302 m_gridIsDirty = true;
2300 m_autoRepeatEmptyColumns = nullptr; 2303 m_autoRepeatEmptyColumns = nullptr;
2301 m_autoRepeatEmptyRows = nullptr; 2304 m_autoRepeatEmptyRows = nullptr;
2302 } 2305 }
2303 2306
(...skipping 692 matching lines...) Expand 10 before | Expand all | Expand 10 after
2996 2999
2997 return baseline + beforeMarginInLineDirection(direction); 3000 return baseline + beforeMarginInLineDirection(direction);
2998 } 3001 }
2999 3002
3000 bool LayoutGrid::isInlineBaselineAlignedChild(const LayoutBox* child) const { 3003 bool LayoutGrid::isInlineBaselineAlignedChild(const LayoutBox* child) const {
3001 return alignSelfForChild(*child).position() == ItemPositionBaseline && 3004 return alignSelfForChild(*child).position() == ItemPositionBaseline &&
3002 !isOrthogonalChild(*child) && !hasAutoMarginsInColumnAxis(*child); 3005 !isOrthogonalChild(*child) && !hasAutoMarginsInColumnAxis(*child);
3003 } 3006 }
3004 3007
3005 int LayoutGrid::firstLineBoxBaseline() const { 3008 int LayoutGrid::firstLineBoxBaseline() const {
3006 if (isWritingModeRoot() || m_grid.isEmpty()) 3009 if (isWritingModeRoot() || m_gridItemArea.isEmpty())
3007 return -1; 3010 return -1;
3008 const LayoutBox* baselineChild = nullptr; 3011 const LayoutBox* baselineChild = nullptr;
3009 const LayoutBox* firstChild = nullptr; 3012 const LayoutBox* firstChild = nullptr;
3010 bool isBaselineAligned = false; 3013 bool isBaselineAligned = false;
3011 // Finding the first grid item in grid order. 3014 // Finding the first grid item in grid order.
3012 for (size_t column = 0; !isBaselineAligned && column < m_grid[0].size(); 3015 for (size_t column = 0; !isBaselineAligned && column < m_grid.numColumns();
3013 column++) { 3016 column++) {
3014 for (size_t index = 0; index < m_grid[0][column].size(); index++) { 3017 for (size_t index = 0; index < m_grid.cell(0, column).size(); index++) {
3015 const LayoutBox* child = m_grid[0][column][index]; 3018 const LayoutBox* child = m_grid.cell(0, column)[index];
3016 DCHECK(!child->isOutOfFlowPositioned()); 3019 DCHECK(!child->isOutOfFlowPositioned());
3017 // If an item participates in baseline alignmen, we select such item. 3020 // If an item participates in baseline alignmen, we select such item.
3018 if (isInlineBaselineAlignedChild(child)) { 3021 if (isInlineBaselineAlignedChild(child)) {
3019 // TODO (lajava): self-baseline and content-baseline alignment 3022 // TODO (lajava): self-baseline and content-baseline alignment
3020 // still not implemented. 3023 // still not implemented.
3021 baselineChild = child; 3024 baselineChild = child;
3022 isBaselineAligned = true; 3025 isBaselineAligned = true;
3023 break; 3026 break;
3024 } 3027 }
3025 if (!baselineChild) { 3028 if (!baselineChild) {
(...skipping 472 matching lines...) Expand 10 before | Expand all | Expand 10 after
3498 } 3501 }
3499 3502
3500 size_t LayoutGrid::numTracks(GridTrackSizingDirection direction) const { 3503 size_t LayoutGrid::numTracks(GridTrackSizingDirection direction) const {
3501 // Due to limitations in our internal representation, we cannot know the 3504 // Due to limitations in our internal representation, we cannot know the
3502 // number of columns from m_grid *if* there is no row (because m_grid would be 3505 // number of columns from m_grid *if* there is no row (because m_grid would be
3503 // empty). That's why in that case we need to get it from the style. Note that 3506 // empty). That's why in that case we need to get it from the style. Note that
3504 // we know for sure that there are't any implicit tracks, because not having 3507 // we know for sure that there are't any implicit tracks, because not having
3505 // rows implies that there are no "normal" children (out-of-flow children are 3508 // rows implies that there are no "normal" children (out-of-flow children are
3506 // not stored in m_grid). 3509 // not stored in m_grid).
3507 if (direction == ForRows) 3510 if (direction == ForRows)
3508 return m_grid.size(); 3511 return m_grid.numRows();
3509 3512
3510 return m_grid.size() ? m_grid[0].size() 3513 return m_grid.numRows() ? m_grid.numColumns()
3511 : GridPositionsResolver::explicitGridColumnCount( 3514 : GridPositionsResolver::explicitGridColumnCount(
3512 styleRef(), m_autoRepeatColumns); 3515 styleRef(), m_autoRepeatColumns);
3513 } 3516 }
3514 3517
3515 } // namespace blink 3518 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698