Bug 1425599 part 9 - [css-grid] Merge DistributeToTrackLimits/Bases (idempotent change). r=dholbert a=jcristau
authorMats Palmgren <mats@mozilla.com>
Thu, 15 Mar 2018 22:41:24 +0100
changeset 462723 6dba9c6e951f01da0e34f57da853a739c9dc29df
parent 462722 58331302df7612830f4049907bfc6a738c5fdc17
child 462724 c8c86f719155e279cb7e2d102aaaa07dd12278cd
push id1683
push usersfraser@mozilla.com
push dateThu, 26 Apr 2018 16:43:40 +0000
treeherdermozilla-release@5af6cb21869d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdholbert, jcristau
bugs1425599
milestone60.0
Bug 1425599 part 9 - [css-grid] Merge DistributeToTrackLimits/Bases (idempotent change). r=dholbert a=jcristau
layout/generic/nsGridContainerFrame.cpp
--- a/layout/generic/nsGridContainerFrame.cpp
+++ b/layout/generic/nsGridContainerFrame.cpp
@@ -1476,17 +1476,17 @@ struct nsGridContainerFrame::Tracks
                          "unless we clamped some track's size");
   }
 
   /**
    * Distribute aAvailableSpace to the planned base size for aGrowableTracks
    * up to their limits, then distribute the remaining space beyond the limits.
    */
   template<TrackSizingPhase phase>
-  void DistributeToTrackBases(nscoord              aAvailableSpace,
+  void DistributeToTrackSizes(nscoord              aAvailableSpace,
                               nsTArray<TrackSize>& aPlan,
                               nsTArray<TrackSize>& aItemPlan,
                               nsTArray<uint32_t>&  aGrowableTracks,
                               TrackSize::StateBits aSelector,
                               const FitContentClamper& aFitContentClamper)
   {
     InitializeItemPlan<phase>(aItemPlan, aGrowableTracks);
     nscoord space = GrowTracksToLimit(aAvailableSpace, aItemPlan, aGrowableTracks,
@@ -1500,42 +1500,16 @@ struct nsGridContainerFrame::Tracks
       nscoord itemIncurredSize = aItemPlan[track].mBase;
       if (plannedSize < itemIncurredSize) {
         plannedSize = itemIncurredSize;
       }
     }
   }
 
   /**
-   * 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:
    * http://dev.w3.org/csswg/css-grid/#algo-grow-tracks
    */
   void DistributeFreeSpace(nscoord aAvailableSize)
   {
     const uint32_t numTracks = mSizes.Length();
     if (MOZ_UNLIKELY(numTracks == 0 || aAvailableSize <= 0)) {
       return;
@@ -4262,17 +4236,17 @@ nsGridContainerFrame::Tracks::GrowBaseFo
     nscoord space = item.SizeContributionForPhase(phase);
     if (space <= 0) {
       continue;
     }
     aTracks.ClearAndRetainStorage();
     space = CollectGrowable<phase>(space, item.mLineRange, aSelector,
                                    aTracks);
     if (space > 0) {
-      DistributeToTrackBases<phase>(space, aPlan, aItemPlan, aTracks, aSelector,
+      DistributeToTrackSizes<phase>(space, aPlan, aItemPlan, aTracks, aSelector,
                                     aFitContentClamper);
       updatedBase = true;
     }
   }
   if (updatedBase) {
     CopyPlanToBase(aPlan);
   }
   return updatedBase;
@@ -4300,18 +4274,19 @@ nsGridContainerFrame::Tracks::GrowLimitF
       aPlan[j].mState |= TrackSize::eModified;
     }
     nscoord space = item.SizeContributionForPhase(phase);
     if (space > 0) {
       aTracks.ClearAndRetainStorage();
       space = CollectGrowable<phase>(space, item.mLineRange, aSelector,
                                      aTracks);
       if (space > 0) {
-        DistributeToTrackLimits<phase>(space, aPlan, aItemPlan, aTracks,
-                                       aFitContentClamper);
+        DistributeToTrackSizes<phase>(space, aPlan, aItemPlan, aTracks,
+                                      TrackSize::StateBits(0),
+                                      aFitContentClamper);
       }
     }
   }
   return true;
 }
 
 void
 nsGridContainerFrame::Tracks::ResolveIntrinsicSize(