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 957ecad4da47dc281d667cbd7d469519da0556cd..98adfd19fd3af04df9ba4a853f839ba2d617a393 100644 |
--- a/third_party/WebKit/Source/core/layout/LayoutGrid.cpp |
+++ b/third_party/WebKit/Source/core/layout/LayoutGrid.cpp |
@@ -1366,32 +1366,41 @@ void LayoutGrid::PopulateGridPositionsForDirection( |
// lines positions are 'direction' unaware. This simplification allows us to |
// use the same indexes to identify the columns independently on the |
// inline-axis direction. |
+ auto& grid = track_sizing_algorithm_.GetGrid(); |
svillar
2017/04/20 08:49:37
You don't need to do this. You already have grid_
|
bool is_row_axis = direction == kForColumns; |
auto& tracks = track_sizing_algorithm_.Tracks(direction); |
size_t number_of_tracks = tracks.size(); |
size_t number_of_lines = number_of_tracks + 1; |
size_t last_line = number_of_lines - 1; |
+ size_t number_of_non_empty_tracks = number_of_tracks; |
+ size_t number_of_collapsed_tracks = 0; |
+ bool has_collapsed_tracks = grid.HasAutoRepeatEmptyTracks(direction); |
+ if (has_collapsed_tracks) { |
+ number_of_collapsed_tracks = grid.AutoRepeatEmptyTracks(direction)->size(); |
+ number_of_non_empty_tracks -= number_of_collapsed_tracks; |
+ } |
Manuel Rego
2017/04/19 10:33:51
Nit: I think you can change this by something like
jfernandez
2017/04/19 11:05:51
yes, I thought about that, but with this new code
Manuel Rego
2017/04/19 11:46:08
Yeah, I didn't realize. Good point.
svillar
2017/04/20 08:49:36
Adding one arithmetic operation per layout is not
jfernandez
2017/04/20 17:29:47
Acknowledged.
|
ContentAlignmentData offset = ComputeContentPositionAndDistributionOffset( |
direction, track_sizing_algorithm_.FreeSpace(direction).value(), |
- number_of_tracks); |
+ number_of_non_empty_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 |
? GridGapForDirection(direction, kTrackSizing) |
: LayoutUnit(); |
size_t next_to_last_line = number_of_lines - 2; |
- for (size_t i = 0; i < next_to_last_line; ++i) |
- positions[i + 1] = positions[i] + offset.distribution_offset + |
- tracks[i].BaseSize() + gap; |
+ for (size_t i = 0; i < next_to_last_line; ++i) { |
+ positions[i + 1] = positions[i] + tracks[i].BaseSize() + gap; |
+ if (!has_collapsed_tracks || |
+ !grid.IsEmptyAutoRepeatTrack(direction, i + 1)) |
svillar
2017/04/20 08:49:37
In contrast this might be potentially problematic
jfernandez
2017/04/20 17:29:47
Only in the case that there are collapsed tracks.
svillar
2017/04/21 07:37:51
No because as you said 0px is a valid value for ro
|
+ positions[i + 1] += offset.distribution_offset; |
+ } |
positions[last_line] = |
positions[next_to_last_line] + tracks[next_to_last_line].BaseSize(); |
@@ -1400,8 +1409,7 @@ void LayoutGrid::PopulateGridPositionsForDirection( |
// they become 0. |
if (has_collapsed_tracks) { |
gap = GridGapForDirection(direction, kTrackSizing); |
- size_t remaining_empty_tracks = |
- grid.AutoRepeatEmptyTracks(direction)->size(); |
+ size_t remaining_empty_tracks = number_of_collapsed_tracks; |
Manuel Rego
2017/04/19 10:33:51
We're mixing "collapsed" and "empty" terms...
Not
jfernandez
2017/04/19 11:05:51
Im using the old notation, hence if we want to ren
|
LayoutUnit gap_accumulator; |
for (size_t i = 1; i < last_line; ++i) { |
if (grid.IsEmptyAutoRepeatTrack(direction, i - 1)) { |