Bug 812687 part 1: Rename GridItemCSSOrderIteratorT to CSSOrderAwareFrameIteratorT, and drop "Grid" from its method names. r=mats
authorDaniel Holbert <dholbert@cs.stanford.edu>
Wed, 05 Apr 2017 19:31:47 -0700
changeset 351426 5a6f0d546c631ada21d8109eccbb48b64b3be048
parent 351425 f5dbc3ffb11f850eeb23ab84037b1b6678130587
child 351427 1732e9dd1f9e28ec85eecb1ae45730a3d36e2dd5
push id88868
push userdholbert@mozilla.com
push dateThu, 06 Apr 2017 02:32:04 +0000
treeherdermozilla-inbound@001fd3755ac1 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmats
bugs812687
milestone55.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 812687 part 1: Rename GridItemCSSOrderIteratorT to CSSOrderAwareFrameIteratorT, and drop "Grid" from its method names. r=mats This patch is purely type-renames & method-renames, so it should not affect our behavior at all. MozReview-Commit-ID: 5N7zru0uPfD
layout/generic/nsGridContainerFrame.cpp
layout/generic/nsGridContainerFrame.h
--- a/layout/generic/nsGridContainerFrame.cpp
+++ b/layout/generic/nsGridContainerFrame.cpp
@@ -381,31 +381,31 @@ MergeSortedFrameLists(nsFrameList& aDest
 static void
 MergeSortedFrameListsFor(nsFrameList& aDest, nsFrameList& aSrc,
                          nsContainerFrame* aParent)
 {
   MergeSortedFrameLists(aDest, aSrc, aParent->GetContent());
 }
 
 template<typename Iterator>
-class nsGridContainerFrame::GridItemCSSOrderIteratorT
+class nsGridContainerFrame::CSSOrderAwareFrameIteratorT
 {
 public:
   enum OrderState { eUnknownOrder, eKnownOrdered, eKnownUnordered };
   enum ChildFilter { eSkipPlaceholders, eIncludeAll };
-  GridItemCSSOrderIteratorT(nsIFrame* aGridContainer,
-                            nsIFrame::ChildListID aListID,
-                            ChildFilter aFilter = eSkipPlaceholders,
-                            OrderState aState = eUnknownOrder)
-    : mChildren(aGridContainer->GetChildList(aListID))
+  CSSOrderAwareFrameIteratorT(nsIFrame* aContainer,
+                              nsIFrame::ChildListID aListID,
+                              ChildFilter aFilter = eSkipPlaceholders,
+                              OrderState aState = eUnknownOrder)
+    : mChildren(aContainer->GetChildList(aListID))
     , mArrayIndex(0)
-    , mGridItemIndex(0)
+    , mItemIndex(0)
     , mSkipPlaceholders(aFilter == eSkipPlaceholders)
 #ifdef DEBUG
-    , mGridContainer(aGridContainer)
+    , mContainer(aContainer)
     , mListID(aListID)
 #endif
   {
     size_t count = 0;
     bool isOrdered = aState != eKnownUnordered;
     if (aState == eUnknownOrder) {
       auto maxOrder = std::numeric_limits<int32_t>::min();
       for (auto child : mChildren) {
@@ -430,19 +430,19 @@ public:
       // XXX replace this with nsTArray::StableSort when bug 1147091 is fixed.
       std::stable_sort(mArray->begin(), mArray->end(), CSSOrderComparator);
     }
 
     if (mSkipPlaceholders) {
       SkipPlaceholders();
     }
   }
-  ~GridItemCSSOrderIteratorT()
+  ~CSSOrderAwareFrameIteratorT()
   {
-    MOZ_ASSERT(IsForward() == mGridItemCount.isNothing());
+    MOZ_ASSERT(IsForward() == mItemCount.isNothing());
   }
 
   bool IsForward() const;
   Iterator begin(const nsFrameList& aList);
   Iterator end(const nsFrameList& aList);
 
   nsIFrame* operator*() const
   {
@@ -452,36 +452,36 @@ public:
     }
     return (*mArray)[mArrayIndex];
   }
 
   /**
    * Return the child index of the current item, placeholders not counted.
    * It's forbidden to call this method when the current frame is placeholder.
    */
-  size_t GridItemIndex() const
+  size_t ItemIndex() const
   {
     MOZ_ASSERT(!AtEnd());
     MOZ_ASSERT((**this)->GetType() != nsGkAtoms::placeholderFrame,
                "MUST not call this when at a placeholder");
-    MOZ_ASSERT(IsForward() || mGridItemIndex < *mGridItemCount,
-               "Returning an out-of-range mGridItemIndex...");
-    return mGridItemIndex;
-  }
-
-  void SetGridItemCount(size_t aGridItemCount)
+    MOZ_ASSERT(IsForward() || mItemIndex < *mItemCount,
+               "Returning an out-of-range mItemIndex...");
+    return mItemIndex;
+  }
+
+  void SetItemCount(size_t aItemCount)
   {
 #ifndef CLANG_CRASH_BUG
-    MOZ_ASSERT(mIter.isSome() || aGridItemCount <= mArray->Length(),
-               "grid item count mismatch");
+    MOZ_ASSERT(mIter.isSome() || aItemCount <= mArray->Length(),
+               "item count mismatch");
 #endif
-    mGridItemCount.emplace(aGridItemCount);
-    // Note: it's OK if mGridItemIndex underflows -- GridItemIndex()
+    mItemCount.emplace(aItemCount);
+    // Note: it's OK if mItemIndex underflows -- ItemIndex()
     // will not be called unless there is at least one item.
-    mGridItemIndex = IsForward() ? 0 : *mGridItemCount - 1;
+    mItemIndex = IsForward() ? 0 : *mItemCount - 1;
   }
 
   /**
    * Skip over placeholder children.
    */
   void SkipPlaceholders()
   {
     if (mIter.isSome()) {
@@ -509,24 +509,24 @@ public:
 #endif
     return mIter ? (*mIter == *mIterEnd) : mArrayIndex >= mArray->Length();
   }
 
   void Next()
   {
 #ifdef DEBUG
     MOZ_ASSERT(!AtEnd());
-    nsFrameList list = mGridContainer->GetChildList(mListID);
+    nsFrameList list = mContainer->GetChildList(mListID);
     MOZ_ASSERT(list.FirstChild() == mChildren.FirstChild() &&
                list.LastChild() == mChildren.LastChild(),
                "the list of child frames must not change while iterating!");
 #endif
     if (mSkipPlaceholders ||
         (**this)->GetType() != nsGkAtoms::placeholderFrame) {
-      IsForward() ? ++mGridItemIndex : --mGridItemIndex;
+      IsForward() ? ++mItemIndex : --mItemIndex;
     }
     if (mIter.isSome()) {
       ++*mIter;
     } else {
       ++mArrayIndex;
     }
     if (mSkipPlaceholders) {
       SkipPlaceholders();
@@ -538,17 +538,17 @@ public:
     if (mIter.isSome()) {
       mIter.reset();
       mIter.emplace(begin(mChildren));
       mIterEnd.reset();
       mIterEnd.emplace(end(mChildren));
     } else {
       mArrayIndex = 0;
     }
-    mGridItemIndex = IsForward() ? 0 : *mGridItemCount - 1;
+    mItemIndex = IsForward() ? 0 : *mItemCount - 1;
     mSkipPlaceholders = aFilter == eSkipPlaceholders;
     if (mSkipPlaceholders) {
       SkipPlaceholders();
     }
   }
 
   bool IsValid() const { return mIter.isSome() || mArray.isSome(); }
 
@@ -566,25 +566,25 @@ private:
   nsFrameList mChildren;
   // Used if child list is already in ascending 'order'.
   Maybe<Iterator> mIter;
   Maybe<Iterator> mIterEnd;
   // Used if child list is *not* in ascending 'order'.
   // This array is pre-sorted in reverse order for a reverse iterator.
   Maybe<nsTArray<nsIFrame*>> mArray;
   size_t mArrayIndex;
-  // The index of the current grid item (placeholders excluded).
-  size_t mGridItemIndex;
-  // The number of grid items (placeholders excluded).
+  // The index of the current item (placeholders excluded).
+  size_t mItemIndex;
+  // The number of items (placeholders excluded).
   // It's only initialized and used in a reverse iterator.
-  Maybe<size_t> mGridItemCount;
+  Maybe<size_t> mItemCount;
   // Skip placeholder children in the iteration?
   bool mSkipPlaceholders;
 #ifdef DEBUG
-  nsIFrame* mGridContainer;
+  nsIFrame* mContainer;
   nsIFrame::ChildListID mListID;
 #endif
 };
 
 using GridItemCSSOrderIterator = nsGridContainerFrame::GridItemCSSOrderIterator;
 using ReverseGridItemCSSOrderIterator = nsGridContainerFrame::ReverseGridItemCSSOrderIterator;
 
 template<>
@@ -3351,18 +3351,18 @@ nsGridContainerFrame::Grid::PlaceGridIte
   for (; !aState.mIter.AtEnd(); aState.mIter.Next()) {
     nsIFrame* child = *aState.mIter;
     GridItemInfo* info =
         aState.mGridItems.AppendElement(GridItemInfo(child,
                                           PlaceDefinite(child,
                                                         colLineNameMap,
                                                         rowLineNameMap,
                                                         gridStyle)));
-    MOZ_ASSERT(aState.mIter.GridItemIndex() == aState.mGridItems.Length() - 1,
-               "GridItemIndex() is broken");
+    MOZ_ASSERT(aState.mIter.ItemIndex() == aState.mGridItems.Length() - 1,
+               "ItemIndex() is broken");
     GridArea& area = info->mArea;
     if (area.mCols.IsDefinite()) {
       minCol = std::min(minCol, area.mCols.mUntranslatedStart);
     }
     if (area.mRows.IsDefinite()) {
       minRow = std::min(minRow, area.mRows.mUntranslatedStart);
     }
   }
@@ -3373,17 +3373,17 @@ nsGridContainerFrame::Grid::PlaceGridIte
   aState.mColFunctions.mExplicitGridOffset = mExplicitGridOffsetCol;
   aState.mRowFunctions.mExplicitGridOffset = mExplicitGridOffsetRow;
   const int32_t offsetToColZero = int32_t(mExplicitGridOffsetCol) - 1;
   const int32_t offsetToRowZero = int32_t(mExplicitGridOffsetRow) - 1;
   mGridColEnd += offsetToColZero;
   mGridRowEnd += offsetToRowZero;
   aState.mIter.Reset();
   for (; !aState.mIter.AtEnd(); aState.mIter.Next()) {
-    GridArea& area = aState.mGridItems[aState.mIter.GridItemIndex()].mArea;
+    GridArea& area = aState.mGridItems[aState.mIter.ItemIndex()].mArea;
     if (area.mCols.IsDefinite()) {
       area.mCols.mStart = area.mCols.mUntranslatedStart + offsetToColZero;
       area.mCols.mEnd = area.mCols.mUntranslatedEnd + offsetToColZero;
     }
     if (area.mRows.IsDefinite()) {
       area.mRows.mStart = area.mRows.mUntranslatedStart + offsetToRowZero;
       area.mRows.mEnd = area.mRows.mUntranslatedEnd + offsetToRowZero;
     }
@@ -3404,17 +3404,17 @@ nsGridContainerFrame::Grid::PlaceGridIte
     Maybe<nsDataHashtable<nsUint32HashKey, uint32_t>> cursors;
     if (isSparse) {
       cursors.emplace();
     }
     auto placeAutoMinorFunc = isRowOrder ? &Grid::PlaceAutoCol
                                          : &Grid::PlaceAutoRow;
     aState.mIter.Reset();
     for (; !aState.mIter.AtEnd(); aState.mIter.Next()) {
-      GridArea& area = aState.mGridItems[aState.mIter.GridItemIndex()].mArea;
+      GridArea& area = aState.mGridItems[aState.mIter.ItemIndex()].mArea;
       LineRange& major = isRowOrder ? area.mRows : area.mCols;
       LineRange& minor = isRowOrder ? area.mCols : area.mRows;
       if (major.IsDefinite() && minor.IsAuto()) {
         // Items with 'auto' in the minor dimension only.
         uint32_t cursor = 0;
         if (isSparse) {
           cursors->Get(major.mStart, &cursor);
         }
@@ -3438,18 +3438,18 @@ nsGridContainerFrame::Grid::PlaceGridIte
 
   // Step 3, place the remaining grid items
   uint32_t cursorMajor = 0; // for 'dense' these two cursors will stay at 0,0
   uint32_t cursorMinor = 0;
   auto placeAutoMajorFunc = isRowOrder ? &Grid::PlaceAutoRow
                                        : &Grid::PlaceAutoCol;
   aState.mIter.Reset();
   for (; !aState.mIter.AtEnd(); aState.mIter.Next()) {
-    GridArea& area = aState.mGridItems[aState.mIter.GridItemIndex()].mArea;
-    MOZ_ASSERT(*aState.mIter == aState.mGridItems[aState.mIter.GridItemIndex()].mFrame,
+    GridArea& area = aState.mGridItems[aState.mIter.ItemIndex()].mArea;
+    MOZ_ASSERT(*aState.mIter == aState.mGridItems[aState.mIter.ItemIndex()].mFrame,
                "iterator out of sync with aState.mGridItems");
     LineRange& major = isRowOrder ? area.mRows : area.mCols;
     LineRange& minor = isRowOrder ? area.mCols : area.mRows;
     if (major.IsAuto()) {
       if (minor.IsDefinite()) {
         // Items with 'auto' in the major dimension only.
         if (isSparse) {
           if (minor.mStart < cursorMinor) {
@@ -4117,17 +4117,17 @@ nsGridContainerFrame::Tracks::Initialize
   nsTArray<ItemBaselineData> firstBaselineItems;
   nsTArray<ItemBaselineData> lastBaselineItems;
   WritingMode wm = aState.mWM;
   nsStyleContext* containerSC = aState.mFrame->StyleContext();
   GridItemCSSOrderIterator& iter = aState.mIter;
   iter.Reset();
   for (; !iter.AtEnd(); iter.Next()) {
     nsIFrame* child = *iter;
-    GridItemInfo& gridItem = aGridItems[iter.GridItemIndex()];
+    GridItemInfo& gridItem = aGridItems[iter.ItemIndex()];
     uint32_t baselineTrack = kAutoLine;
     auto state = ItemState(0);
     auto childWM = child->GetWritingMode();
     const bool isOrthogonal = wm.IsOrthogonalTo(childWM);
     const bool isInlineAxis = mAxis == eLogicalAxisInline; // i.e. columns
     // XXX update the line below to include orthogonal grid/table boxes
     // XXX since they have baselines in both dimensions. And flexbox with
     // XXX reversed main/cross axis?
@@ -4386,17 +4386,17 @@ nsGridContainerFrame::Tracks::ResolveInt
     TrackSize::eIntrinsicMinSizing : TrackSize::eMinOrMaxContentMinSizing;
   // Setup track selector for step 2.3:
   const auto maxContentMinSelector =
     aConstraint == SizingConstraint::eMaxContent ?
     (TrackSize::eMaxContentMinSizing | TrackSize::eAutoMinSizing) :
     TrackSize::eMaxContentMinSizing;
   iter.Reset();
   for (; !iter.AtEnd(); iter.Next()) {
-    auto& gridItem = aGridItems[iter.GridItemIndex()];
+    auto& gridItem = aGridItems[iter.ItemIndex()];
     const GridArea& area = gridItem.mArea;
     const LineRange& lineRange = area.*aRange;
     uint32_t span = lineRange.Extent();
     if (span == 1) {
       // Step 1. Size tracks to fit non-spanning items.
       if (ResolveIntrinsicSizeStep1(aState, aFunctions, aPercentageBasis,
                                     aConstraint, lineRange, gridItem)) {
         gridItem.mState[mAxis] |= ItemState::eIsFlexing;
@@ -4709,17 +4709,17 @@ nsGridContainerFrame::Tracks::FindUsedFl
   }
   WritingMode wm = aState.mWM;
   nsRenderingContext* rc = &aState.mRenderingContext;
   GridItemCSSOrderIterator& iter = aState.mIter;
   iter.Reset();
   // ... the result of 'finding the size of an fr' for each item that spans
   // a flex track with its max-content contribution as 'space to fill'
   for (; !iter.AtEnd(); iter.Next()) {
-    const GridItemInfo& item = aGridItems[iter.GridItemIndex()];
+    const GridItemInfo& item = aGridItems[iter.ItemIndex()];
     if (item.mState[mAxis] & ItemState::eIsFlexing) {
       // XXX optimize: bug 1194446
       nscoord spaceToFill = ContentContribution(item, aState, rc, wm, mAxis,
                                                 nsLayoutUtils::PREF_ISIZE);
       if (spaceToFill <= 0) {
         continue;
       }
       // ... and all its spanned tracks as input.
@@ -5346,17 +5346,17 @@ nsGridContainerFrame::ReflowInFragmentai
   // Collect our grid items and sort them in row order.  Collect placeholders
   // and put them in a separate array.
   nsTArray<const GridItemInfo*> sortedItems(aState.mGridItems.Length());
   nsTArray<nsIFrame*> placeholders(aState.mAbsPosItems.Length());
   aState.mIter.Reset(GridItemCSSOrderIterator::eIncludeAll);
   for (; !aState.mIter.AtEnd(); aState.mIter.Next()) {
     nsIFrame* child = *aState.mIter;
     if (child->GetType() != nsGkAtoms::placeholderFrame) {
-      const GridItemInfo* info = &aState.mGridItems[aState.mIter.GridItemIndex()];
+      const GridItemInfo* info = &aState.mGridItems[aState.mIter.ItemIndex()];
       sortedItems.AppendElement(info);
     } else {
       placeholders.AppendElement(child);
     }
   }
   // NOTE: no need to use stable_sort here, there are no dependencies on
   // having content order between items on the same row in the code below.
   std::sort(sortedItems.begin(), sortedItems.end(),
@@ -5863,17 +5863,17 @@ nsGridContainerFrame::ReflowChildren(Gri
     bSize = ReflowInFragmentainer(aState, aContentArea, aDesiredSize, aStatus,
                                   *fragmentainer, containerSize);
   } else {
     aState.mIter.Reset(GridItemCSSOrderIterator::eIncludeAll);
     for (; !aState.mIter.AtEnd(); aState.mIter.Next()) {
       nsIFrame* child = *aState.mIter;
       const GridItemInfo* info = nullptr;
       if (child->GetType() != nsGkAtoms::placeholderFrame) {
-        info = &aState.mGridItems[aState.mIter.GridItemIndex()];
+        info = &aState.mGridItems[aState.mIter.ItemIndex()];
       }
       ReflowInFlowChild(*aState.mIter, info, containerSize, Nothing(), nullptr,
                         aState, aContentArea, aDesiredSize, aStatus);
       MOZ_ASSERT(aStatus.IsComplete(), "child should be complete "
                  "in unconstrained reflow");
     }
   }
 
@@ -6822,17 +6822,17 @@ nsGridContainerFrame::CalculateBaselines
   } else if (lastBaseline == NS_INTRINSIC_WIDTH_UNKNOWN) {
     // For finding items for the 'last baseline' we need to create a reverse
     // iterator ('aIter' is the forward iterator from the GridReflowInput).
     using Iter = ReverseGridItemCSSOrderIterator;
     auto orderState = aIter->ItemsAreAlreadyInOrder() ?
       Iter::OrderState::eKnownOrdered : Iter::OrderState::eKnownUnordered;
     Iter iter(this, kPrincipalList, Iter::ChildFilter::eSkipPlaceholders,
               orderState);
-    iter.SetGridItemCount(aGridItems->Length());
+    iter.SetItemCount(aGridItems->Length());
     FindItemInGridOrderResult gridOrderLastItem =
       FindLastItemInGridOrder(iter, *aGridItems,
         axis == eLogicalAxisBlock ? &GridArea::mRows : &GridArea::mCols,
         axis == eLogicalAxisBlock ? &GridArea::mCols : &GridArea::mRows,
         aFragmentStartTrack, aFirstExcludedTrack);
     mBaseline[axis][BaselineSharingGroup::eLast] =
       SynthesizeBaseline(gridOrderLastItem,
                          axis,
@@ -6922,17 +6922,17 @@ nsGridContainerFrame::FindFirstItemInGri
   LineRange GridArea::* aMinor,
   uint32_t aFragmentStartTrack)
 {
   FindItemInGridOrderResult result = { nullptr, false };
   uint32_t minMajor = kTranslatedMaxLine + 1;
   uint32_t minMinor = kTranslatedMaxLine + 1;
   aIter.Reset();
   for (; !aIter.AtEnd(); aIter.Next()) {
-    const GridItemInfo& item = aGridItems[aIter.GridItemIndex()];
+    const GridItemInfo& item = aGridItems[aIter.ItemIndex()];
     if ((item.mArea.*aMajor).mEnd <= aFragmentStartTrack) {
       continue; // item doesn't span any track in this fragment
     }
     uint32_t major = (item.mArea.*aMajor).mStart;
     uint32_t minor = (item.mArea.*aMinor).mStart;
     if (major < minMajor || (major == minMajor && minor < minMinor)) {
       minMajor = major;
       minMinor = minor;
@@ -6953,17 +6953,17 @@ nsGridContainerFrame::FindLastItemInGrid
   uint32_t aFirstExcludedTrack)
 {
   FindItemInGridOrderResult result = { nullptr, false };
   int32_t maxMajor = -1;
   int32_t maxMinor = -1;
   aIter.Reset();
   int32_t lastMajorTrack = int32_t(aFirstExcludedTrack) - 1;
   for (; !aIter.AtEnd(); aIter.Next()) {
-    const GridItemInfo& item = aGridItems[aIter.GridItemIndex()];
+    const GridItemInfo& item = aGridItems[aIter.ItemIndex()];
     // Subtract 1 from the end line to get the item's last track index.
     int32_t major = (item.mArea.*aMajor).mEnd - 1;
     // Currently, this method is only called with aFirstExcludedTrack ==
     // the first track in the next fragment, so we take the opportunity
     // to assert this item really belongs to this fragment.
     MOZ_ASSERT((item.mArea.*aMajor).mStart < aFirstExcludedTrack,
                "found an item that belongs to some later fragment");
     if (major < int32_t(aFragmentStartTrack)) {
--- a/layout/generic/nsGridContainerFrame.h
+++ b/layout/generic/nsGridContainerFrame.h
@@ -214,20 +214,20 @@ public:
    * @return nullptr if aFrame has no grid container, or frame was destroyed
    * @note this might destroy layout/style data since it may flush layout
    */
   static nsGridContainerFrame* GetGridFrameWithComputedInfo(nsIFrame* aFrame);
 
   struct TrackSize;
   struct GridItemInfo;
   struct GridReflowInput;
-  template<typename Iterator> class GridItemCSSOrderIteratorT;
-  typedef GridItemCSSOrderIteratorT<nsFrameList::iterator>
+  template<typename Iterator> class CSSOrderAwareFrameIteratorT;
+  typedef CSSOrderAwareFrameIteratorT<nsFrameList::iterator>
     GridItemCSSOrderIterator;
-  typedef GridItemCSSOrderIteratorT<nsFrameList::reverse_iterator>
+  typedef CSSOrderAwareFrameIteratorT<nsFrameList::reverse_iterator>
     ReverseGridItemCSSOrderIterator;
   struct FindItemInGridOrderResult
   {
     // The first(last) item in (reverse) grid order.
     const GridItemInfo* mItem;
     // Does the above item span the first(last) track?
     bool mIsInEdgeTrack;
   };