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

Unified Diff: third_party/WebKit/Source/core/layout/LayoutGrid.cpp

Issue 2521553002: [css-grid] Isolate internal grid size from the actual grid size (Closed)
Patch Set: Created 4 years, 1 month 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/WebKit/Source/core/layout/LayoutGrid.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/core/layout/LayoutGrid.cpp
diff --git a/third_party/WebKit/Source/core/layout/LayoutGrid.cpp b/third_party/WebKit/Source/core/layout/LayoutGrid.cpp
index cb52b7acaa913ca94f88f90c69cc728421147d4e..9df052fa4d7ca981d5638f6e6a117d17759a9a0f 100644
--- a/third_party/WebKit/Source/core/layout/LayoutGrid.cpp
+++ b/third_party/WebKit/Source/core/layout/LayoutGrid.cpp
@@ -400,15 +400,7 @@ bool LayoutGrid::namedGridLinesDefinitionDidChange(
size_t LayoutGrid::gridColumnCount() const {
DCHECK(!m_gridIsDirty);
- // Due to limitations in our internal representation, we cannot know the
- // number of columns from m_grid *if* there is no row (because m_grid would be
- // empty). That's why in that case we need to get it from the style. Note that
- // we know for sure that there are't any implicit tracks, because not having
- // rows implies that there are no "normal" children (out-of-flow children are
- // not stored in m_grid).
- return m_grid.size() ? m_grid[0].size()
- : GridPositionsResolver::explicitGridColumnCount(
- styleRef(), m_autoRepeatColumns);
+ return m_grid.size() ? m_grid[0].size() : 0;
}
size_t LayoutGrid::gridRowCount() const {
@@ -513,7 +505,7 @@ void LayoutGrid::layoutBlock(bool relayoutChildren) {
updateAutoRepeatTracksAndSetDirtyIfNeeded(TrackSizing);
placeItemsOnGrid();
- GridSizingData sizingData(gridColumnCount(), gridRowCount());
+ GridSizingData sizingData(numTracks(ForColumns), numTracks(ForRows));
// 1- First, the track sizing algorithm is used to resolve the sizes of the
// grid columns.
@@ -691,7 +683,7 @@ void LayoutGrid::computeIntrinsicLogicalWidths(
IntrinsicSizeComputation);
const_cast<LayoutGrid*>(this)->placeItemsOnGrid();
- GridSizingData sizingData(gridColumnCount(), gridRowCount());
+ GridSizingData sizingData(numTracks(ForColumns), numTracks(ForRows));
computeTrackSizesForIndefiniteSize(ForColumns, sizingData, minLogicalWidth,
maxLogicalWidth);
@@ -2028,10 +2020,14 @@ void LayoutGrid::placeItemsOnGrid() {
insertItemIntoGrid(*child, area);
}
- DCHECK_GE(gridRowCount(), GridPositionsResolver::explicitGridRowCount(
- *style(), m_autoRepeatRows));
- DCHECK_GE(gridColumnCount(), GridPositionsResolver::explicitGridColumnCount(
- *style(), m_autoRepeatColumns));
+#if ENABLE(ASSERT)
+ if (!m_gridItemArea.isEmpty()) {
+ DCHECK_GE(gridRowCount(), GridPositionsResolver::explicitGridRowCount(
+ *style(), m_autoRepeatRows));
+ DCHECK_GE(gridColumnCount(), GridPositionsResolver::explicitGridColumnCount(
+ *style(), m_autoRepeatColumns));
+ }
+#endif
placeSpecifiedMajorAxisItemsOnGrid(specifiedMajorAxisAutoGridItems);
placeAutoMajorAxisItemsOnGrid(autoMajorAxisAutoGridItems);
@@ -2545,7 +2541,7 @@ void LayoutGrid::offsetAndBreadthForPositionedChild(
: child.style()->gridRowStart();
GridPosition endPosition = isForColumns ? child.style()->gridColumnEnd()
: child.style()->gridRowEnd();
- int lastLine = isForColumns ? gridColumnCount() : gridRowCount();
+ int lastLine = numTracks(direction);
bool startIsAuto =
startPosition.isAuto() ||
@@ -3501,4 +3497,19 @@ bool LayoutGrid::cachedHasDefiniteLogicalHeight() const {
return m_hasDefiniteLogicalHeight.value();
}
+size_t LayoutGrid::numTracks(GridTrackSizingDirection direction) const {
+ // Due to limitations in our internal representation, we cannot know the
+ // number of columns from m_grid *if* there is no row (because m_grid would be
+ // empty). That's why in that case we need to get it from the style. Note that
+ // we know for sure that there are't any implicit tracks, because not having
+ // rows implies that there are no "normal" children (out-of-flow children are
+ // not stored in m_grid).
+ if (direction == ForRows)
+ return m_grid.size();
+
+ return m_grid.size() ? m_grid[0].size()
+ : GridPositionsResolver::explicitGridColumnCount(
+ styleRef(), m_autoRepeatColumns);
+}
+
} // namespace blink
« no previous file with comments | « third_party/WebKit/Source/core/layout/LayoutGrid.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698