diff --git a/layout/generic/nsGridContainerFrame.cpp b/layout/generic/nsGridContainerFrame.cpp index ec95b226e09b..78e4e85e1571 100644 --- a/layout/generic/nsGridContainerFrame.cpp +++ b/layout/generic/nsGridContainerFrame.cpp @@ -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 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),