Bug 1425599 part 9 - [css-grid] Merge DistributeToTrackLimits/Bases (idempotent change). r=dholbert

This commit is contained in:
Mats Palmgren 2018-03-15 22:41:24 +01:00
Родитель 0d5ad6e072
Коммит c635cef6a8
1 изменённых файлов: 5 добавлений и 30 удалений

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

@ -1481,7 +1481,7 @@ struct nsGridContainerFrame::Tracks
* up to their limits, then distribute the remaining space beyond the limits. * up to their limits, then distribute the remaining space beyond the limits.
*/ */
template<TrackSizingPhase phase> template<TrackSizingPhase phase>
void DistributeToTrackBases(nscoord aAvailableSpace, void DistributeToTrackSizes(nscoord aAvailableSpace,
nsTArray<TrackSize>& aPlan, nsTArray<TrackSize>& aPlan,
nsTArray<TrackSize>& aItemPlan, nsTArray<TrackSize>& aItemPlan,
nsTArray<uint32_t>& aGrowableTracks, nsTArray<uint32_t>& aGrowableTracks,
@ -1504,32 +1504,6 @@ struct nsGridContainerFrame::Tracks
} }
} }
/**
* Distribute aAvailableSpace to the planned limits for aGrowableTracks.
*/
template<TrackSizingPhase phase>
void DistributeToTrackLimits(nscoord aAvailableSpace,
nsTArray<TrackSize>& aPlan,
nsTArray<TrackSize>& aItemPlan,
nsTArray<uint32_t>& aGrowableTracks,
const FitContentClamper& aFitContentClamper)
{
InitializeItemPlan<phase>(aItemPlan, aGrowableTracks);
nscoord space = GrowTracksToLimit(aAvailableSpace, aItemPlan, aGrowableTracks,
aFitContentClamper);
if (space > 0) {
GrowSelectedTracksUnlimited(space, aItemPlan, aGrowableTracks,
TrackSize::StateBits(0), aFitContentClamper);
}
for (uint32_t track : aGrowableTracks) {
nscoord& plannedSize = aPlan[track].mBase;
nscoord itemIncurredSize = aItemPlan[track].mBase;
if (plannedSize < itemIncurredSize) {
plannedSize = itemIncurredSize;
}
}
}
/** /**
* Distribute aAvailableSize to the tracks. This implements 12.6 at: * Distribute aAvailableSize to the tracks. This implements 12.6 at:
* http://dev.w3.org/csswg/css-grid/#algo-grow-tracks * http://dev.w3.org/csswg/css-grid/#algo-grow-tracks
@ -4267,7 +4241,7 @@ nsGridContainerFrame::Tracks::GrowBaseForSpanningItems(
space = CollectGrowable<phase>(space, item.mLineRange, aSelector, space = CollectGrowable<phase>(space, item.mLineRange, aSelector,
aTracks); aTracks);
if (space > 0) { if (space > 0) {
DistributeToTrackBases<phase>(space, aPlan, aItemPlan, aTracks, aSelector, DistributeToTrackSizes<phase>(space, aPlan, aItemPlan, aTracks, aSelector,
aFitContentClamper); aFitContentClamper);
updatedBase = true; updatedBase = true;
} }
@ -4305,7 +4279,8 @@ nsGridContainerFrame::Tracks::GrowLimitForSpanningItems(
space = CollectGrowable<phase>(space, item.mLineRange, aSelector, space = CollectGrowable<phase>(space, item.mLineRange, aSelector,
aTracks); aTracks);
if (space > 0) { if (space > 0) {
DistributeToTrackLimits<phase>(space, aPlan, aItemPlan, aTracks, DistributeToTrackSizes<phase>(space, aPlan, aItemPlan, aTracks,
TrackSize::StateBits(0),
aFitContentClamper); aFitContentClamper);
} }
} }