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

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: 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
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..f4e0f5b16cc5692a5dd07600daa664392e721c44 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,42 @@ LayoutGrid::computeEmptyTracksForAutoRepeat(
return emptyTrackIndexes;
}
+size_t LayoutGrid::clampAutoRepeatTracks(GridTrackSizingDirection direction,
+ size_t autoRepeatTracks) const {
+ if (!autoRepeatTracks)
+ return 0;
+
+ bool isRowAxis = direction == ForColumns;
+ size_t otherTracks = isRowAxis ? styleRef().gridTemplateColumns().size()
+ : styleRef().gridTemplateRows().size();
+ size_t totalTracks = autoRepeatTracks + otherTracks;
+
+ if (totalTracks <= kGridMaxTracks)
+ return autoRepeatTracks;
+
+ if (otherTracks >= kGridMaxTracks)
Manuel Rego 2017/02/06 09:51:12 We can move this if above.
svillar 2017/02/06 10:06:03 Acknowledged.
+ return 0;
+
+ size_t autoRepeatTrackListLength =
+ isRowAxis ? styleRef().gridAutoRepeatColumns().size()
+ : styleRef().gridAutoRepeatRows().size();
+ DCHECK_GT(autoRepeatTrackListLength, 0u);
+
+ size_t repetitions =
+ (kGridMaxTracks - otherTracks) / autoRepeatTrackListLength;
+ return repetitions * autoRepeatTrackListLength;
Manuel Rego 2017/02/06 09:51:12 Might be worth to explain here that we've decided
svillar 2017/02/06 10:06:03 Yeah, you're right. As this is not in the specs we
Manuel Rego 2017/02/06 10:09:52 Oops, sorry but I believe this is against the spec
+}
+
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);

Powered by Google App Engine
This is Rietveld 408576698