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

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: Patch for landing. Rebased 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 9c3e7d8f9da0f02cf6ac9197786fef40db66bf7b..1c4e415ffd06de055bb1e88b443e62901612aaf0 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 {
@@ -519,7 +511,7 @@ void LayoutGrid::layoutBlock(bool relayoutChildren) {
dirtyGrid();
placeItemsOnGrid(TrackSizing);
- 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.
@@ -695,7 +687,7 @@ void LayoutGrid::computeIntrinsicLogicalWidths(
LayoutUnit& maxLogicalWidth) const {
const_cast<LayoutGrid*>(this)->placeItemsOnGrid(IntrinsicSizeComputation);
- GridSizingData sizingData(gridColumnCount(), gridRowCount());
+ GridSizingData sizingData(numTracks(ForColumns), numTracks(ForRows));
computeTrackSizesForIndefiniteSize(ForColumns, sizingData, minLogicalWidth,
maxLogicalWidth);
@@ -2025,10 +2017,14 @@ void LayoutGrid::placeItemsOnGrid(SizingOperation sizingOperation) {
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);
@@ -2542,7 +2538,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() ||
@@ -3498,4 +3494,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