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

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

Issue 2825133003: [css-grid] Ignore collapsed tracks on content-distribution alignment (Closed)
Patch Set: Applied suggested changes. Created 3 years, 8 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 | « no previous file | 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 00436b95c574ea8221b85725c835a36ec99822cc..0747afe4cfe606eac2eed4819e1a9be794b98269 100644
--- a/third_party/WebKit/Source/core/layout/LayoutGrid.cpp
+++ b/third_party/WebKit/Source/core/layout/LayoutGrid.cpp
@@ -1405,20 +1405,22 @@ void LayoutGrid::PopulateGridPositionsForDirection(
size_t number_of_tracks = tracks.size();
size_t number_of_lines = number_of_tracks + 1;
size_t last_line = number_of_lines - 1;
+ auto& grid = track_sizing_algorithm_.GetGrid();
svillar 2017/04/25 08:03:29 Same comment, I know this was already here, but yo
+ bool has_collapsed_tracks = grid.HasAutoRepeatEmptyTracks(direction);
+ size_t number_of_collapsed_tracks =
+ has_collapsed_tracks ? grid.AutoRepeatEmptyTracks(direction)->size() : 0;
ContentAlignmentData offset = ComputeContentPositionAndDistributionOffset(
direction, track_sizing_algorithm_.FreeSpace(direction).value(),
- number_of_tracks);
+ number_of_tracks - number_of_collapsed_tracks);
auto& positions = is_row_axis ? column_positions_ : row_positions_;
positions.Resize(number_of_lines);
auto border_and_padding =
is_row_axis ? BorderAndPaddingLogicalLeft() : BorderAndPaddingBefore();
positions[0] = border_and_padding + offset.position_offset;
- const Grid& grid = track_sizing_algorithm_.GetGrid();
if (number_of_lines > 1) {
// If we have collapsed tracks we just ignore gaps here and add them later
// as we might not compute the gap between two consecutive tracks without
// examining the surrounding ones.
- bool has_collapsed_tracks = grid.HasAutoRepeatEmptyTracks(direction);
LayoutUnit gap = !has_collapsed_tracks ? GridGap(direction) : LayoutUnit();
size_t next_to_last_line = number_of_lines - 2;
for (size_t i = 0; i < next_to_last_line; ++i)
@@ -1432,12 +1434,13 @@ void LayoutGrid::PopulateGridPositionsForDirection(
// they become 0.
if (has_collapsed_tracks) {
gap = GridGap(direction);
- size_t remaining_empty_tracks =
- grid.AutoRepeatEmptyTracks(direction)->size();
+ size_t remaining_empty_tracks = number_of_collapsed_tracks;
+ size_t last_empty_track = 0;
LayoutUnit gap_accumulator;
for (size_t i = 1; i < last_line; ++i) {
if (grid.IsEmptyAutoRepeatTrack(direction, i - 1)) {
--remaining_empty_tracks;
+ last_empty_track = i - 1;
} else {
// Add gap between consecutive non empty tracks. Add it also just once
// for an arbitrary number of empty tracks between two non empty ones.
@@ -1447,7 +1450,8 @@ void LayoutGrid::PopulateGridPositionsForDirection(
!grid.IsEmptyAutoRepeatTrack(direction, i))
gap_accumulator += gap;
}
- positions[i] += gap_accumulator;
+ positions[i] +=
+ gap_accumulator - last_empty_track * offset.distribution_offset;
svillar 2017/04/25 08:03:29 I think this is wrong. Instead of the last empty t
}
positions[last_line] += gap_accumulator;
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698