Bug 1260614 - Cleanup grid item iterator Reset() calls. r=dholbert
authorMats Palmgren <mats@mozilla.com>
Fri, 01 Apr 2016 02:08:15 +0200
changeset 291069 cbeaca0a84e90dc8df4e5a30a262744c512f7030
parent 291068 f76979736a41aa110d1f87ba17f14efb06e46707
child 291070 cb55f73763cd7838760ab747510d12e7f039f108
push id74441
push usermpalmgren@mozilla.com
push dateFri, 01 Apr 2016 00:08:25 +0000
treeherdermozilla-inbound@cb55f73763cd [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdholbert
bugs1260614
milestone48.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1260614 - Cleanup grid item iterator Reset() calls. r=dholbert
layout/generic/nsGridContainerFrame.cpp
--- a/layout/generic/nsGridContainerFrame.cpp
+++ b/layout/generic/nsGridContainerFrame.cpp
@@ -2034,22 +2034,20 @@ nsGridContainerFrame::GridReflowState::C
   const LogicalSize& aContentBox,
   IntrinsicISizeType aConstraint)
 {
   mCols.Initialize(mColFunctions, mGridStyle->mGridColumnGap,
                    aGrid.mGridColEnd, aContentBox.ISize(mWM));
   mRows.Initialize(mRowFunctions, mGridStyle->mGridRowGap,
                    aGrid.mGridRowEnd, aContentBox.BSize(mWM));
 
-  mIter.Reset(); // XXX cleanup this Reset mess!
   mCols.CalculateSizes(*this, mGridItems, mColFunctions,
                        aContentBox.ISize(mWM), &GridArea::mCols,
                        aConstraint);
 
-  mIter.Reset(); // XXX cleanup this Reset mess!
   mRows.CalculateSizes(*this, mGridItems, mRowFunctions,
                        aContentBox.BSize(mWM), &GridArea::mRows,
                        aConstraint);
 }
 
 /**
  * (XXX share this utility function with nsFlexContainerFrame at some point)
  *
@@ -2933,16 +2931,17 @@ nsGridContainerFrame::Grid::PlaceGridIte
     aState.mRowFunctions.ComputeExplicitGridEnd(areas ? areas->NRows() + 1 : 1);
   LineNameMap rowLineNameMap(gridStyle->mGridTemplateRows, numRepeatRows);
 
   // http://dev.w3.org/csswg/css-grid/#line-placement
   // Resolve definite positions per spec chap 9.2.
   int32_t minCol = 1;
   int32_t minRow = 1;
   aState.mGridItems.ClearAndRetainStorage();
+  aState.mIter.Reset();
   for (; !aState.mIter.AtEnd(); aState.mIter.Next()) {
     nsIFrame* child = *aState.mIter;
     GridItemInfo* info =
         aState.mGridItems.AppendElement(GridItemInfo(child,
                                           PlaceDefinite(child,
                                                         colLineNameMap,
                                                         rowLineNameMap,
                                                         gridStyle)));
@@ -3481,16 +3480,17 @@ nsGridContainerFrame::Tracks::ResolveInt
   nsTArray<Step2ItemData> step2Items;
   GridItemCSSOrderIterator& iter = aState.mIter;
   nsRenderingContext* rc = &aState.mRenderingContext;
   WritingMode wm = aState.mWM;
   uint32_t maxSpan = 0; // max span of the step2Items items
   const TrackSize::StateBits flexMin =
     aConstraint == nsLayoutUtils::MIN_ISIZE ? TrackSize::eFlexMinSizing
                                             : TrackSize::StateBits(0);
+  iter.Reset();
   for (; !iter.AtEnd(); iter.Next()) {
     nsIFrame* child = *iter;
     const GridArea& area = aGridItems[iter.GridItemIndex()].mArea;
     const LineRange& lineRange = area.*aRange;
     uint32_t span = lineRange.Extent();
     if (span == 1) {
       // Step 1. Size tracks to fit non-spanning items.
       aGridItems[iter.GridItemIndex()].mIsFlexing[mAxis] =
@@ -5001,17 +5001,16 @@ nsGridContainerFrame::Reflow(nsPresConte
         (stylePos->MinBSize(wm).HasPercent() && cbState &&
          cbState->ComputedSize(wm).BSize(wm) == NS_UNCONSTRAINEDSIZE)) {
       computedMinSize.BSize(wm) = NS_UNCONSTRAINEDSIZE;
     }
     Grid grid;
     grid.PlaceGridItems(gridReflowState, computedMinSize, computedSize,
                         aReflowState.ComputedMaxSize());
 
-    gridReflowState.mIter.Reset();
     gridReflowState.CalculateTrackSizes(grid, computedSize,
                                         nsLayoutUtils::PREF_ISIZE);
 
     // FIXME bug 1229180: Instead of doing this on every reflow, we should only
     // set these properties if they are needed.
     nsTArray<nscoord> colTrackSizes(gridReflowState.mCols.mSizes.Length());
     for (const TrackSize& sz : gridReflowState.mCols.mSizes) {
       colTrackSizes.AppendElement(sz.mBase);
@@ -5145,17 +5144,16 @@ nsGridContainerFrame::IntrinsicISize(nsR
   LogicalSize indefinite(state.mWM, NS_UNCONSTRAINEDSIZE, NS_UNCONSTRAINEDSIZE);
   Grid grid;
   grid.PlaceGridItems(state, indefinite, indefinite, indefinite);  // XXX optimize
   if (grid.mGridColEnd == 0) {
     return 0;
   }
   state.mCols.Initialize(state.mColFunctions, state.mGridStyle->mGridColumnGap,
                          grid.mGridColEnd, NS_UNCONSTRAINEDSIZE);
-  state.mIter.Reset();
   state.mCols.CalculateSizes(state, state.mGridItems, state.mColFunctions,
                              NS_UNCONSTRAINEDSIZE, &GridArea::mCols,
                              aConstraint);
   nscoord length = 0;
   for (const TrackSize& sz : state.mCols.mSizes) {
     length += sz.mBase;
   }
   return length + state.mCols.SumOfGridGaps();