Bug 1341507 - Refactor TrackSizingFunctions::mRepeatEndDelta to be a getter function rather than a variable. r=emilio

The information in it is always derivable from the values of mRepeatAutoStart
and mRepeatAutoEnd. Additionally, its value is used in some cases where it has
not yet been set properly (such as CalculateRepeatFillCount).

This works out currently because the default value is zero we only accept
repeat(auto-fill, ...) and repeat(auto-fit, ...) CSS values that have a single
element in the repeat. In that case, zero is the correct value for
RepeatEndDelta.

Differential Revision: https://phabricator.services.mozilla.com/D58871

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Emily McDonough 2020-01-07 00:50:58 +00:00
Родитель 5fbcf93b87
Коммит 9108c52192
1 изменённых файлов: 10 добавлений и 8 удалений

Просмотреть файл

@ -966,7 +966,6 @@ struct nsGridContainerFrame::TrackSizingFunctions {
mExplicitGridOffset(0),
mRepeatAutoStart(aRepeatAutoIndex.valueOr(0)),
mRepeatAutoEnd(mRepeatAutoStart),
mRepeatEndDelta(0),
mHasRepeatAuto(aRepeatAutoIndex.isSome()) {
MOZ_ASSERT(!mHasRepeatAuto || !aIsSubgrid,
"a track-list for a subgrid can't have an <auto-repeat> track");
@ -1183,7 +1182,7 @@ struct nsGridContainerFrame::TrackSizingFunctions {
if (index < mRepeatAutoEnd) {
index = mRepeatAutoStart;
} else {
index -= mRepeatEndDelta;
index -= RepeatEndDelta();
}
}
if (index >= mExpandedTracks.Length()) {
@ -1204,13 +1203,16 @@ struct nsGridContainerFrame::TrackSizingFunctions {
return SizingFor(aTrackIndex).GetMin();
}
uint32_t NumExplicitTracks() const {
return mExpandedTracks.Length() + mRepeatEndDelta;
return mExpandedTracks.Length() + RepeatEndDelta();
}
uint32_t NumRepeatTracks() const { return mRepeatAutoEnd - mRepeatAutoStart; }
// The difference between mExplicitGridEnd and mSizingFunctions.Length().
int32_t RepeatEndDelta() const {
return mHasRepeatAuto ? int32_t(NumRepeatTracks()) - 1 : 0;
}
void SetNumRepeatTracks(uint32_t aNumRepeatTracks) {
MOZ_ASSERT(mHasRepeatAuto || aNumRepeatTracks == 0);
mRepeatAutoEnd = mRepeatAutoStart + aNumRepeatTracks;
mRepeatEndDelta = mHasRepeatAuto ? int32_t(aNumRepeatTracks) - 1 : 0;
}
// Store mTrackListValues into mExpandedTracks with `repeat(INTEGER, ...)`
@ -1226,7 +1228,9 @@ struct nsGridContainerFrame::TrackSizingFunctions {
if (!repeat.count.IsNumber()) {
MOZ_ASSERT(i == mRepeatAutoStart);
mRepeatAutoStart = mExpandedTracks.Length();
mRepeatAutoEnd = mRepeatAutoStart;
// The + 1 indicates the number of values in the repeat.
// TODO: This will need to be updated in bug 1341507
mRepeatAutoEnd = mRepeatAutoStart + 1;
mExpandedTracks.AppendElement(MakePair(i, size_t(0)));
continue;
}
@ -1265,8 +1269,6 @@ struct nsGridContainerFrame::TrackSizingFunctions {
uint32_t mRepeatAutoStart;
// The (hypothetical) index of the last such repeat() track.
uint32_t mRepeatAutoEnd;
// The difference between mExplicitGridEnd and mSizingFunctions.Length().
int32_t mRepeatEndDelta;
// True if there is a specified repeat(auto-fill/fit) track.
bool mHasRepeatAuto;
// True if this track (relative to mRepeatAutoStart) is a removed auto-fit.
@ -1301,7 +1303,7 @@ class MOZ_STACK_CLASS nsGridContainerFrame::LineNameMap {
mAreas(aImplicitNamedAreas),
mRepeatAutoStart(aTracks.mRepeatAutoStart),
mRepeatAutoEnd(aTracks.mRepeatAutoEnd),
mRepeatEndDelta(aTracks.mRepeatEndDelta),
mRepeatEndDelta(aTracks.RepeatEndDelta()),
mParentLineNameMap(aParentLineNameMap),
mRange(aRange),
mIsSameDirection(aIsSameDirection),