Commit 1683a227 authored by Ethan Jimenez's avatar Ethan Jimenez Committed by Chromium LUCI CQ

[GridNG] Refactor track direction to be contained in track collection

1. Refactoring `NGGridLayoutAlgorithmTrackCollection::SetIterator` to
   allow callers access to the iterator from a const reference/pointer
   to the collection; this change improves the `NGGridLayoutAlgorithm`
   implementation since previously we were not able to pass const
   references to an algorithm track collection as an input parameter
   (because of the non-const restriction imposed by `SetIterator`).

2. Refactoring use of `GridTrackSizingDirection` into track collections;
   several methods in `NGGridLayoutAlgorithm` received both, track
   collection and its respective direction, as parameters. Since the
   direction is already tied to the specified collection, this change
   moves the `GridTrackSizingDirection` into the collection class.

Bug: 1045599
Change-Id: Ibbc7d2d93c5947106b0fe627d67dce2fb24916f2
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2573889Reviewed-by: default avatarChristian Biesinger <cbiesinger@chromium.org>
Reviewed-by: default avatarIan Kilpatrick <ikilpatrick@chromium.org>
Reviewed-by: default avatarJacques Newman <janewman@microsoft.com>
Reviewed-by: default avatarKurt Catti-Schmidt <kschmi@microsoft.com>
Commit-Queue: Ethan Jimenez <ethavar@microsoft.com>
Cr-Commit-Position: refs/heads/master@{#833870}
parent 30079c58
...@@ -122,7 +122,6 @@ class CORE_EXPORT NGGridLayoutAlgorithm ...@@ -122,7 +122,6 @@ class CORE_EXPORT NGGridLayoutAlgorithm
// in the relevant track collection. // in the relevant track collection.
static NGGridLayoutAlgorithmTrackCollection::SetIterator static NGGridLayoutAlgorithmTrackCollection::SetIterator
GetSetIteratorForItem(const GridItemData& item, GetSetIteratorForItem(const GridItemData& item,
GridTrackSizingDirection track_direction,
NGGridLayoutAlgorithmTrackCollection& track_collection); NGGridLayoutAlgorithmTrackCollection& track_collection);
// Returns the size that a grid item will distribute across the tracks with an // Returns the size that a grid item will distribute across the tracks with an
...@@ -149,8 +148,7 @@ class CORE_EXPORT NGGridLayoutAlgorithm ...@@ -149,8 +148,7 @@ class CORE_EXPORT NGGridLayoutAlgorithm
NGGridLayoutAlgorithmTrackCollection* row_track_collection) const; NGGridLayoutAlgorithmTrackCollection* row_track_collection) const;
// Sets specified track lists on |track_collection|. // Sets specified track lists on |track_collection|.
void SetSpecifiedTracks(GridTrackSizingDirection track_direction, void SetSpecifiedTracks(wtf_size_t automatic_repetitions,
wtf_size_t automatic_repetitions,
NGGridBlockTrackCollection* track_collection) const; NGGridBlockTrackCollection* track_collection) const;
// Determines the explicit column and row track starts. // Determines the explicit column and row track starts.
void DetermineExplicitTrackStarts(wtf_size_t automatic_column_repetitions, void DetermineExplicitTrackStarts(wtf_size_t automatic_column_repetitions,
...@@ -164,32 +162,27 @@ class CORE_EXPORT NGGridLayoutAlgorithm ...@@ -164,32 +162,27 @@ class CORE_EXPORT NGGridLayoutAlgorithm
// "begin" and "end" such that the item spans every set from the respective // "begin" and "end" such that the item spans every set from the respective
// collection's |sets_| with an index in the range [begin, end). // collection's |sets_| with an index in the range [begin, end).
void CacheItemSetIndices( void CacheItemSetIndices(
GridTrackSizingDirection track_direction, const NGGridLayoutAlgorithmTrackCollection& track_collection,
const NGGridLayoutAlgorithmTrackCollection* track_collection,
Vector<GridItemData>* grid_items) const; Vector<GridItemData>* grid_items) const;
// For every grid item, determines if it spans a track with an intrinsic or // For every grid item, determines if it spans a track with an intrinsic or
// flexible sizing function and caches the answer in its |GridItemData|. // flexible sizing function and caches the answer in its |GridItemData|.
void DetermineGridItemsSpanningIntrinsicOrFlexTracks( void DetermineGridItemsSpanningIntrinsicOrFlexTracks(
GridTrackSizingDirection track_direction, const NGGridLayoutAlgorithmTrackCollection& track_collection,
Vector<GridItemData>* grid_items, Vector<GridItemData>* grid_items,
Vector<wtf_size_t>* reordered_item_indices, Vector<wtf_size_t>* reordered_item_indices) const;
NGGridLayoutAlgorithmTrackCollection* track_collection) const;
// Calculates from the min and max track sizing functions the used track size. // Calculates from the min and max track sizing functions the used track size.
void ComputeUsedTrackSizes( void ComputeUsedTrackSizes(
GridTrackSizingDirection track_direction, NGGridLayoutAlgorithmTrackCollection* track_collection,
Vector<GridItemData>* grid_items, Vector<GridItemData>* grid_items) const;
NGGridLayoutAlgorithmTrackCollection* track_collection) const;
// These methods implement the steps of the algorithm for intrinsic track size // These methods implement the steps of the algorithm for intrinsic track size
// resolution defined in https://drafts.csswg.org/css-grid-1/#algo-content. // resolution defined in https://drafts.csswg.org/css-grid-1/#algo-content.
void ResolveIntrinsicTrackSizes( void ResolveIntrinsicTrackSizes(
GridTrackSizingDirection track_direction, NGGridLayoutAlgorithmTrackCollection* track_collection,
Vector<GridItemData>* grid_items, Vector<GridItemData>* grid_items,
Vector<wtf_size_t>* reordered_item_indices, Vector<wtf_size_t>* reordered_item_indices) const;
NGGridLayoutAlgorithmTrackCollection* track_collection) const;
void IncreaseTrackSizesToAccommodateGridItems( void IncreaseTrackSizesToAccommodateGridItems(
GridTrackSizingDirection track_direction,
ReorderedGridItems::Iterator group_begin, ReorderedGridItems::Iterator group_begin,
ReorderedGridItems::Iterator group_end, ReorderedGridItems::Iterator group_end,
GridItemContributionType contribution_type, GridItemContributionType contribution_type,
...@@ -220,9 +213,8 @@ class CORE_EXPORT NGGridLayoutAlgorithm ...@@ -220,9 +213,8 @@ class CORE_EXPORT NGGridLayoutAlgorithm
// Calculates inline and block offsets for all tracks. // Calculates inline and block offsets for all tracks.
Vector<LayoutUnit> ComputeSetOffsets( Vector<LayoutUnit> ComputeSetOffsets(
GridTrackSizingDirection track_direction, const NGGridLayoutAlgorithmTrackCollection& track_collection,
LayoutUnit grid_gap, LayoutUnit grid_gap) const;
NGGridLayoutAlgorithmTrackCollection& track_collection) const;
// Tests whether the row gap is unresolvable based on its type and the // Tests whether the row gap is unresolvable based on its type and the
// available size. // available size.
......
...@@ -50,22 +50,18 @@ class NGGridLayoutAlgorithmTest ...@@ -50,22 +50,18 @@ class NGGridLayoutAlgorithmTest
&algorithm_row_track_collection_); &algorithm_row_track_collection_);
// Cache set indices. // Cache set indices.
algorithm.CacheItemSetIndices(GridTrackSizingDirection::kForColumns, algorithm.CacheItemSetIndices(algorithm_column_track_collection_,
&algorithm_column_track_collection_,
&grid_items_); &grid_items_);
algorithm.CacheItemSetIndices(GridTrackSizingDirection::kForRows, algorithm.CacheItemSetIndices(algorithm_row_track_collection_,
&algorithm_row_track_collection_,
&grid_items_); &grid_items_);
// Resolve inline size. // Resolve inline size.
algorithm.ComputeUsedTrackSizes(GridTrackSizingDirection::kForColumns, algorithm.ComputeUsedTrackSizes(&algorithm_column_track_collection_,
&grid_items_, &grid_items_);
&algorithm_column_track_collection_);
// Resolve block size. // Resolve block size.
algorithm.ComputeUsedTrackSizes(GridTrackSizingDirection::kForRows, algorithm.ComputeUsedTrackSizes(&algorithm_row_track_collection_,
&grid_items_, &grid_items_);
&algorithm_row_track_collection_);
} }
NGGridLayoutAlgorithmTrackCollection& TrackCollection( NGGridLayoutAlgorithmTrackCollection& TrackCollection(
...@@ -116,15 +112,14 @@ class NGGridLayoutAlgorithmTest ...@@ -116,15 +112,14 @@ class NGGridLayoutAlgorithmTest
} }
void DetermineGridItemsSpanningIntrinsicOrFlexTracks( void DetermineGridItemsSpanningIntrinsicOrFlexTracks(
NGGridLayoutAlgorithm& algorithm, const NGGridLayoutAlgorithm& algorithm,
GridTrackSizingDirection track_direction) { const NGGridLayoutAlgorithmTrackCollection& track_collection) {
Vector<wtf_size_t> reordered_item_indices; Vector<wtf_size_t> reordered_item_indices;
reordered_item_indices.ReserveInitialCapacity(grid_items_.size()); reordered_item_indices.ReserveInitialCapacity(grid_items_.size());
for (wtf_size_t i = 0; i < grid_items_.size(); ++i) for (wtf_size_t i = 0; i < grid_items_.size(); ++i)
reordered_item_indices.push_back(i); reordered_item_indices.push_back(i);
algorithm.DetermineGridItemsSpanningIntrinsicOrFlexTracks( algorithm.DetermineGridItemsSpanningIntrinsicOrFlexTracks(
track_direction, &grid_items_, &reordered_item_indices, track_collection, &grid_items_, &reordered_item_indices);
&TrackCollection(track_direction));
} }
Vector<wtf_size_t> GridItemsSpanningIntrinsicTrack( Vector<wtf_size_t> GridItemsSpanningIntrinsicTrack(
...@@ -1196,7 +1191,8 @@ TEST_F(NGGridLayoutAlgorithmTest, ...@@ -1196,7 +1191,8 @@ TEST_F(NGGridLayoutAlgorithmTest,
NGGridLayoutAlgorithm algorithm({node, fragment_geometry, space}); NGGridLayoutAlgorithm algorithm({node, fragment_geometry, space});
BuildGridItemsAndTrackCollections(algorithm); BuildGridItemsAndTrackCollections(algorithm);
DetermineGridItemsSpanningIntrinsicOrFlexTracks(algorithm, kForColumns); DetermineGridItemsSpanningIntrinsicOrFlexTracks(algorithm,
TrackCollection(kForColumns));
Vector<wtf_size_t> expected_grid_items_spanning_intrinsic_track = {0, 1, 3}; Vector<wtf_size_t> expected_grid_items_spanning_intrinsic_track = {0, 1, 3};
Vector<wtf_size_t> expected_grid_items_spanning_flex_track = {1}; Vector<wtf_size_t> expected_grid_items_spanning_flex_track = {1};
...@@ -1212,7 +1208,8 @@ TEST_F(NGGridLayoutAlgorithmTest, ...@@ -1212,7 +1208,8 @@ TEST_F(NGGridLayoutAlgorithmTest,
for (wtf_size_t i = 0; i < actual_items.size(); ++i) for (wtf_size_t i = 0; i < actual_items.size(); ++i)
EXPECT_EQ(expected_grid_items_spanning_flex_track[i], actual_items[i]); EXPECT_EQ(expected_grid_items_spanning_flex_track[i], actual_items[i]);
DetermineGridItemsSpanningIntrinsicOrFlexTracks(algorithm, kForRows); DetermineGridItemsSpanningIntrinsicOrFlexTracks(algorithm,
TrackCollection(kForRows));
expected_grid_items_spanning_intrinsic_track = {1, 2, 3}; expected_grid_items_spanning_intrinsic_track = {1, 2, 3};
expected_grid_items_spanning_flex_track = {2}; expected_grid_items_spanning_flex_track = {2};
......
...@@ -136,6 +136,10 @@ bool NGGridTrackCollectionBase::RangeRepeatIterator::SetRangeIndex( ...@@ -136,6 +136,10 @@ bool NGGridTrackCollectionBase::RangeRepeatIterator::SetRangeIndex(
return true; return true;
} }
NGGridBlockTrackCollection::NGGridBlockTrackCollection(
GridTrackSizingDirection direction)
: direction_(direction) {}
void NGGridBlockTrackCollection::SetSpecifiedTracks( void NGGridBlockTrackCollection::SetSpecifiedTracks(
const NGGridTrackList* explicit_tracks, const NGGridTrackList* explicit_tracks,
const NGGridTrackList* implicit_tracks, const NGGridTrackList* implicit_tracks,
...@@ -481,36 +485,10 @@ NGGridLayoutAlgorithmTrackCollection::Range::Range( ...@@ -481,36 +485,10 @@ NGGridLayoutAlgorithmTrackCollection::Range::Range(
starting_set_index(starting_set_index), starting_set_index(starting_set_index),
is_collapsed(block_track_range.is_collapsed) {} is_collapsed(block_track_range.is_collapsed) {}
NGGridLayoutAlgorithmTrackCollection::SetIterator::SetIterator(
NGGridLayoutAlgorithmTrackCollection* collection,
wtf_size_t begin_set_index,
wtf_size_t end_set_index)
: collection_(collection),
current_set_index_(begin_set_index),
end_set_index_(end_set_index) {
DCHECK(collection_);
DCHECK_LE(current_set_index_, end_set_index_);
}
bool NGGridLayoutAlgorithmTrackCollection::SetIterator::IsAtEnd() const {
DCHECK_LE(current_set_index_, end_set_index_);
return current_set_index_ == end_set_index_;
}
bool NGGridLayoutAlgorithmTrackCollection::SetIterator::MoveToNextSet() {
current_set_index_ = std::min(current_set_index_ + 1, end_set_index_);
return current_set_index_ < end_set_index_;
}
NGGridSet& NGGridLayoutAlgorithmTrackCollection::SetIterator::CurrentSet()
const {
DCHECK_LT(current_set_index_, end_set_index_);
return collection_->SetAt(current_set_index_);
}
NGGridLayoutAlgorithmTrackCollection::NGGridLayoutAlgorithmTrackCollection( NGGridLayoutAlgorithmTrackCollection::NGGridLayoutAlgorithmTrackCollection(
const NGGridBlockTrackCollection& block_track_collection, const NGGridBlockTrackCollection& block_track_collection,
bool is_content_box_size_indefinite) { bool is_content_box_size_indefinite)
: direction_(block_track_collection.Direction()) {
for (auto range_iterator = block_track_collection.RangeIterator(); for (auto range_iterator = block_track_collection.RangeIterator();
!range_iterator.IsAtEnd(); range_iterator.MoveToNextRange()) { !range_iterator.IsAtEnd(); range_iterator.MoveToNextRange()) {
const NGGridBlockTrackCollection::Range& block_track_range = const NGGridBlockTrackCollection::Range& block_track_range =
...@@ -602,19 +580,35 @@ NGGridSet& NGGridLayoutAlgorithmTrackCollection::SetAt(wtf_size_t set_index) { ...@@ -602,19 +580,35 @@ NGGridSet& NGGridLayoutAlgorithmTrackCollection::SetAt(wtf_size_t set_index) {
return sets_[set_index]; return sets_[set_index];
} }
const NGGridSet& NGGridLayoutAlgorithmTrackCollection::SetAt(
wtf_size_t set_index) const {
DCHECK_LT(set_index, SetCount());
return sets_[set_index];
}
NGGridLayoutAlgorithmTrackCollection::SetIterator NGGridLayoutAlgorithmTrackCollection::SetIterator
NGGridLayoutAlgorithmTrackCollection::GetSetIterator() { NGGridLayoutAlgorithmTrackCollection::GetSetIterator() {
return SetIterator(this, 0u, SetCount()); return SetIterator(this, 0u, SetCount());
} }
NGGridLayoutAlgorithmTrackCollection::ConstSetIterator
NGGridLayoutAlgorithmTrackCollection::GetSetIterator() const {
return ConstSetIterator(this, 0u, SetCount());
}
NGGridLayoutAlgorithmTrackCollection::SetIterator NGGridLayoutAlgorithmTrackCollection::SetIterator
NGGridLayoutAlgorithmTrackCollection::GetSetIterator(wtf_size_t begin_set_index, NGGridLayoutAlgorithmTrackCollection::GetSetIterator(wtf_size_t begin_set_index,
wtf_size_t end_set_index) { wtf_size_t end_set_index) {
DCHECK_LE(end_set_index, SetCount());
DCHECK_LE(begin_set_index, end_set_index);
return SetIterator(this, begin_set_index, end_set_index); return SetIterator(this, begin_set_index, end_set_index);
} }
NGGridLayoutAlgorithmTrackCollection::ConstSetIterator
NGGridLayoutAlgorithmTrackCollection::GetSetIterator(
wtf_size_t begin_set_index,
wtf_size_t end_set_index) const {
return ConstSetIterator(this, begin_set_index, end_set_index);
}
wtf_size_t NGGridLayoutAlgorithmTrackCollection::RangeSetCount( wtf_size_t NGGridLayoutAlgorithmTrackCollection::RangeSetCount(
wtf_size_t range_index) const { wtf_size_t range_index) const {
DCHECK_LT(range_index, RangeCount()); DCHECK_LT(range_index, RangeCount());
......
...@@ -58,13 +58,10 @@ class CORE_EXPORT NGGridTrackCollectionBase { ...@@ -58,13 +58,10 @@ class CORE_EXPORT NGGridTrackCollectionBase {
protected: protected:
// Returns the first track number of a range. // Returns the first track number of a range.
virtual wtf_size_t RangeTrackNumber(wtf_size_t range_index) const = 0; virtual wtf_size_t RangeTrackNumber(wtf_size_t range_index) const = 0;
// Returns the number of tracks in a range. // Returns the number of tracks in a range.
virtual wtf_size_t RangeTrackCount(wtf_size_t range_index) const = 0; virtual wtf_size_t RangeTrackCount(wtf_size_t range_index) const = 0;
// Returns true if the range at the given index is collapsed. // Returns true if the range at the given index is collapsed.
virtual bool IsRangeCollapsed(wtf_size_t range_index) const = 0; virtual bool IsRangeCollapsed(wtf_size_t range_index) const = 0;
// Returns the number of track ranges in the collection. // Returns the number of track ranges in the collection.
virtual wtf_size_t RangeCount() const = 0; virtual wtf_size_t RangeCount() const = 0;
}; };
...@@ -82,6 +79,9 @@ class CORE_EXPORT NGGridBlockTrackCollection ...@@ -82,6 +79,9 @@ class CORE_EXPORT NGGridBlockTrackCollection
bool is_collapsed : 1; bool is_collapsed : 1;
}; };
explicit NGGridBlockTrackCollection(
GridTrackSizingDirection track_direction = kForColumns);
// Sets the specified, implicit tracks, along with a given auto repeat value. // Sets the specified, implicit tracks, along with a given auto repeat value.
void SetSpecifiedTracks(const NGGridTrackList* explicit_tracks, void SetSpecifiedTracks(const NGGridTrackList* explicit_tracks,
const NGGridTrackList* implicit_tracks, const NGGridTrackList* implicit_tracks,
...@@ -98,9 +98,11 @@ class CORE_EXPORT NGGridBlockTrackCollection ...@@ -98,9 +98,11 @@ class CORE_EXPORT NGGridBlockTrackCollection
// Returns the range at the given track. // Returns the range at the given track.
const Range& RangeAtTrackNumber(wtf_size_t track_number) const; const Range& RangeAtTrackNumber(wtf_size_t track_number) const;
GridTrackSizingDirection Direction() const { return direction_; }
bool IsForColumns() const { return direction_ == kForColumns; }
const NGGridTrackList& ExplicitTracks() const; const NGGridTrackList& ExplicitTracks() const;
const NGGridTrackList& ImplicitTracks() const; const NGGridTrackList& ImplicitTracks() const;
String ToString() const; String ToString() const;
protected: protected:
...@@ -117,6 +119,7 @@ class CORE_EXPORT NGGridBlockTrackCollection ...@@ -117,6 +119,7 @@ class CORE_EXPORT NGGridBlockTrackCollection
wtf_size_t ImplicitRepeatSize() const; wtf_size_t ImplicitRepeatSize() const;
bool track_indices_need_sort_ = false; bool track_indices_need_sort_ = false;
GridTrackSizingDirection direction_;
wtf_size_t auto_repeat_count_ = 0; wtf_size_t auto_repeat_count_ = 0;
// Stores the specified and implicit tracks specified by SetSpecifiedTracks. // Stores the specified and implicit tracks specified by SetSpecifiedTracks.
...@@ -233,23 +236,51 @@ class CORE_EXPORT NGGridLayoutAlgorithmTrackCollection ...@@ -233,23 +236,51 @@ class CORE_EXPORT NGGridLayoutAlgorithmTrackCollection
bool is_collapsed : 1; bool is_collapsed : 1;
}; };
// Note that this iterator can alter any set's data. template <bool is_const>
class CORE_EXPORT SetIterator { class CORE_EXPORT SetIteratorBase {
public: public:
SetIterator(NGGridLayoutAlgorithmTrackCollection* collection, using TrackCollectionPtr =
typename std::conditional<is_const,
const NGGridLayoutAlgorithmTrackCollection*,
NGGridLayoutAlgorithmTrackCollection*>::type;
using NGGridSetRef =
typename std::conditional<is_const, const NGGridSet&, NGGridSet&>::type;
SetIteratorBase(TrackCollectionPtr track_collection,
wtf_size_t begin_set_index, wtf_size_t begin_set_index,
wtf_size_t end_set_index); wtf_size_t end_set_index)
: track_collection_(track_collection),
current_set_index_(begin_set_index),
end_set_index_(end_set_index) {
DCHECK(track_collection_);
DCHECK_LE(current_set_index_, end_set_index_);
DCHECK_LE(end_set_index_, track_collection_->SetCount());
}
bool IsAtEnd() const; bool IsAtEnd() const {
bool MoveToNextSet(); DCHECK_LE(current_set_index_, end_set_index_);
NGGridSet& CurrentSet() const; return current_set_index_ == end_set_index_;
}
bool MoveToNextSet() {
current_set_index_ = std::min(current_set_index_ + 1, end_set_index_);
return current_set_index_ < end_set_index_;
}
NGGridSetRef CurrentSet() const {
DCHECK_LT(current_set_index_, end_set_index_);
return track_collection_->SetAt(current_set_index_);
}
private: private:
NGGridLayoutAlgorithmTrackCollection* collection_; TrackCollectionPtr track_collection_;
wtf_size_t current_set_index_; wtf_size_t current_set_index_;
wtf_size_t end_set_index_; wtf_size_t end_set_index_;
}; };
using SetIterator = SetIteratorBase<false>;
using ConstSetIterator = SetIteratorBase<true>;
NGGridLayoutAlgorithmTrackCollection() = default; NGGridLayoutAlgorithmTrackCollection() = default;
// |is_content_box_size_indefinite| is used to normalize percentage track // |is_content_box_size_indefinite| is used to normalize percentage track
// sizing functions (see the constructor for |NGGridSet|). // sizing functions (see the constructor for |NGGridSet|).
...@@ -261,12 +292,16 @@ class CORE_EXPORT NGGridLayoutAlgorithmTrackCollection ...@@ -261,12 +292,16 @@ class CORE_EXPORT NGGridLayoutAlgorithmTrackCollection
wtf_size_t SetCount() const; wtf_size_t SetCount() const;
// Returns a reference to the set located at position |set_index|. // Returns a reference to the set located at position |set_index|.
NGGridSet& SetAt(wtf_size_t set_index); NGGridSet& SetAt(wtf_size_t set_index);
const NGGridSet& SetAt(wtf_size_t set_index) const;
// Returns an iterator for all the sets contained in this collection. // Returns an iterator for all the sets contained in this collection.
SetIterator GetSetIterator(); SetIterator GetSetIterator();
ConstSetIterator GetSetIterator() const;
// Returns an iterator for every set in this collection's |sets_| located at // Returns an iterator for every set in this collection's |sets_| located at
// an index in the interval [begin_set_index, end_set_index). // an index in the interval [begin_set_index, end_set_index).
SetIterator GetSetIterator(wtf_size_t begin_set_index, SetIterator GetSetIterator(wtf_size_t begin_set_index,
wtf_size_t end_set_index); wtf_size_t end_set_index);
ConstSetIterator GetSetIterator(wtf_size_t begin_set_index,
wtf_size_t end_set_index) const;
wtf_size_t RangeSetCount(wtf_size_t range_index) const; wtf_size_t RangeSetCount(wtf_size_t range_index) const;
wtf_size_t RangeStartingSetIndex(wtf_size_t range_index) const; wtf_size_t RangeStartingSetIndex(wtf_size_t range_index) const;
...@@ -276,6 +311,9 @@ class CORE_EXPORT NGGridLayoutAlgorithmTrackCollection ...@@ -276,6 +311,9 @@ class CORE_EXPORT NGGridLayoutAlgorithmTrackCollection
// Returns true if the range contains a set with a flexible sizing function. // Returns true if the range contains a set with a flexible sizing function.
bool IsRangeSpanningFlexTrack(wtf_size_t range_index) const; bool IsRangeSpanningFlexTrack(wtf_size_t range_index) const;
GridTrackSizingDirection Direction() const { return direction_; }
bool IsForColumns() const { return direction_ == kForColumns; }
protected: protected:
// NGGridTrackCollectionBase overrides. // NGGridTrackCollectionBase overrides.
wtf_size_t RangeTrackNumber(wtf_size_t range_index) const override; wtf_size_t RangeTrackNumber(wtf_size_t range_index) const override;
...@@ -289,6 +327,8 @@ class CORE_EXPORT NGGridLayoutAlgorithmTrackCollection ...@@ -289,6 +327,8 @@ class CORE_EXPORT NGGridLayoutAlgorithmTrackCollection
const NGGridTrackList& specified_track_list, const NGGridTrackList& specified_track_list,
bool is_content_box_size_indefinite); bool is_content_box_size_indefinite);
GridTrackSizingDirection direction_;
Vector<Range> ranges_; Vector<Range> ranges_;
// A vector of every set element that compose the entire collection's ranges; // A vector of every set element that compose the entire collection's ranges;
// track definitions from the same set are stored in consecutive positions, // track definitions from the same set are stored in consecutive positions,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment