Skip to content

Commit

Permalink
[GridNG] Implementation of NGGridLayoutAlgorithmTrackCollection
Browse files Browse the repository at this point in the history
1. Refactoring `NGGridTrackRepeater` to store the `GridTrackSize` of its
   specified track definition; updating `NGGridTrackList::AddRepeater`
   to take the track sizes as a parameter and implicitly handle repeater
   indexes, which were unnecessarily specified by the caller.

   Adding grid track sizes in `NGGridTrackList` unit tests.

2. Fixing a bug in `NGGridBlockTrackCollection::FinalizeRanges` where
   ranges spanning implicit tracks after the explicit grid didn't
   resolve their respective repeater offsets correctly.

3. Introducing the concept of a "set" with the `NGGridSet` class; any
   range from the new algorithm collection is composed of distinct track
   definitions which compose a "set", see the class's definition for a
   detailed explanation of how these sets work.

4. Introducing `NGGridLayoutAlgorithmTrackCollection` - builds ranges
   and their respective sets from the `NGGridBlockTrackCollection` to be
   used in the track sizing algorithm in `NGGridLayoutAlgorithm`.

5. Adding unit tests for the new `NGGridLayoutAlgorithmTrackCollection`
   constructor and `NGGridLayoutAlgorithmTrackCollection::SetIterator`.

Bug: 1045599
Change-Id: I31036f0cf91a958ed74ada31f5dce5d9087faf49
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2272126
Commit-Queue: Ethan Jimenez <ethavar@microsoft.com>
Reviewed-by: Christian Biesinger <cbiesinger@chromium.org>
Reviewed-by: Ian Kilpatrick <ikilpatrick@chromium.org>
Reviewed-by: Jacques Newman <janewman@microsoft.com>
Reviewed-by: Kurt Catti-Schmidt <kschmi@microsoft.com>
Cr-Commit-Position: refs/heads/master@{#785679}
  • Loading branch information
ethanjv authored and Commit Bot committed Jul 7, 2020
1 parent 3dc3830 commit 714881a
Show file tree
Hide file tree
Showing 4 changed files with 683 additions and 151 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -99,22 +99,20 @@ void NGGridLayoutAlgorithm::BuildTrackLists() {

// TODO(kschmi): Auto track repeat count should be based on the number of
// children, rather than specified auto-column/track.
NGGridTrackList implicit_columns;
NGGridTrackList implicit_rows;
implicit_columns.AddRepeater(
/*track_index*/ 0, /*track_count*/ 1,
/*repeat_count*/ grid_style.GridAutoColumns().size());
implicit_rows.AddRepeater(/*track_index*/ 0, 1 /*track_count*/,
/*repeat_count*/ grid_style.GridAutoRows().size());
NGGridTrackList implicit_columns;
implicit_rows.AddRepeater(grid_style.GridAutoRows(), /* repeat_count */ 1);
implicit_columns.AddRepeater(grid_style.GridAutoColumns(),
/* repeat_count */ 1);

// TODO(janewman): We need to implement calculation for track auto repeat
// count so this can be used outside of testing.
column_track_collection_.SetSpecifiedTracks(
column_track_list_, automatic_column_repetitions_for_testing,
implicit_columns);
column_track_list_, implicit_columns,
automatic_column_repetitions_for_testing);

row_track_collection_.SetSpecifiedTracks(
row_track_list_, automatic_row_repetitions_for_testing, implicit_rows);
row_track_list_, implicit_rows, automatic_row_repetitions_for_testing);
}

void NGGridLayoutAlgorithm::EnsureTrackCoverageForGridItem(
Expand Down Expand Up @@ -149,17 +147,14 @@ void NGGridLayoutAlgorithm::AddRepeaters(
AutoRepeatType repeat_type,
NGGridTrackList& track_list) {
wtf_size_t repeat_start = NGGridBlockTrackCollection::kInvalidRangeIndex;
wtf_size_t unique_track_count = 0;
// TODO(janewman): Track lists should live on the computed style, mirroring
// the legacy layout's template_tracks and auto tracks vectors. For now, build
// up the NG version from what already exists on the computed style.
for (wtf_size_t i = 0; i < template_tracks.size(); ++i) {
const GridTrackSize& current_track = template_tracks[i];
// If this is the insertion point for an auto repeater, add it here.
if (!auto_tracks.IsEmpty() && i == auto_insertion_point) {
track_list.AddAutoRepeater(unique_track_count, auto_tracks.size(),
repeat_type);
unique_track_count += auto_tracks.size();
track_list.AddAutoRepeater(auto_tracks, repeat_type);
repeat_start = NGGridBlockTrackCollection::kInvalidRangeIndex;
}
// As the legacy implementation expands repeaters out, compress repeated
Expand All @@ -183,8 +178,7 @@ void NGGridLayoutAlgorithm::AddRepeaters(
repeat_count = i + 1 - repeat_start;
DCHECK_NE(0u, repeat_count);
DCHECK_NE(NGGridBlockTrackCollection::kInvalidRangeIndex, repeat_count);
track_list.AddRepeater(unique_track_count++, /*track_count*/ 1,
repeat_count);
track_list.AddRepeater({template_tracks[i]}, repeat_count);
repeat_start = NGGridBlockTrackCollection::kInvalidRangeIndex;
}
}
Expand Down

0 comments on commit 714881a

Please sign in to comment.