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

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

Issue 2670363003: [css-grid] Clamp the number of auto repeat tracks in all cases (Closed)
Patch Set: New version matching the specs Created 3 years, 10 months 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 34b55a70a2063202930120719a8669c2e797dda3..c31ba362d245d262c64025621e509251576dee0f 100644
--- a/third_party/WebKit/Source/core/layout/LayoutGrid.cpp
+++ b/third_party/WebKit/Source/core/layout/LayoutGrid.cpp
@@ -547,13 +547,6 @@ size_t LayoutGrid::computeAutoRepeatTracksCount(
if (needsToFulfillMinimumSize)
++repetitions;
- // Clamp the number of repetitions so we don't end up with too many tracks.
- if (repetitions > kGridMaxTracks) {
- DCHECK_GT(autoRepeatTrackListLength, 0u);
- repetitions =
- (kGridMaxTracks - trackSizes.size()) / autoRepeatTrackListLength;
- }
-
return repetitions * autoRepeatTrackListLength;
}
@@ -594,12 +587,35 @@ LayoutGrid::computeEmptyTracksForAutoRepeat(
return emptyTrackIndexes;
}
+size_t LayoutGrid::clampAutoRepeatTracks(GridTrackSizingDirection direction,
+ size_t autoRepeatTracks) const {
+ if (!autoRepeatTracks)
+ return 0;
+
+ size_t insertionPoint = direction == ForColumns
+ ? styleRef().gridAutoRepeatColumnsInsertionPoint()
+ : styleRef().gridAutoRepeatRowsInsertionPoint();
+
+ if (insertionPoint == 0)
+ return std::min<size_t>(autoRepeatTracks, kGridMaxTracks);
+
+ if (insertionPoint >= kGridMaxTracks)
+ return 0;
+
+ return std::min(autoRepeatTracks,
+ static_cast<size_t>(kGridMaxTracks) - insertionPoint);
+}
+
void LayoutGrid::placeItemsOnGrid(Grid& grid,
SizingOperation sizingOperation) const {
size_t autoRepeatRows =
computeAutoRepeatTracksCount(ForRows, sizingOperation);
size_t autoRepeatColumns =
computeAutoRepeatTracksCount(ForColumns, sizingOperation);
+
+ autoRepeatRows = clampAutoRepeatTracks(ForRows, autoRepeatRows);
+ autoRepeatColumns = clampAutoRepeatTracks(ForColumns, autoRepeatColumns);
+
if (autoRepeatRows != grid.autoRepeatTracks(ForRows) ||
autoRepeatColumns != grid.autoRepeatTracks(ForColumns)) {
grid.setNeedsItemsPlacement(true);
« 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