Bug 1452383 part 2 - [css-grid] Remove local enum LineRangeSide and use LogicalSide instead (idempotent patch). r=dholbert
authorMats Palmgren <mats@mozilla.com>
Sat, 05 May 2018 22:21:17 +0200
changeset 473179 1b2650f9cc81613012d0221b8f596289bda09652
parent 473178 87a5deedc146c977b98e440ea1b8b57b1feab813
child 473180 1b257ee52e90bc51d36006ec081e3d4a0ead5640
child 473187 698ab4eff5bf1efb1af8ea74e0a8f4f2f906e5ae
push id1728
push userjlund@mozilla.com
push dateMon, 18 Jun 2018 21:12:27 +0000
treeherdermozilla-release@c296fde26f5f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdholbert
bugs1452383
milestone61.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 1452383 part 2 - [css-grid] Remove local enum LineRangeSide and use LogicalSide instead (idempotent patch). r=dholbert
layout/generic/nsGridContainerFrame.cpp
--- a/layout/generic/nsGridContainerFrame.cpp
+++ b/layout/generic/nsGridContainerFrame.cpp
@@ -2138,42 +2138,38 @@ struct MOZ_STACK_CLASS nsGridContainerFr
   void InflateGridFor(const GridArea& aArea)
   {
     mGridColEnd = std::max(mGridColEnd, aArea.mCols.HypotheticalEnd());
     mGridRowEnd = std::max(mGridRowEnd, aArea.mRows.HypotheticalEnd());
     MOZ_ASSERT(mGridColEnd <= kTranslatedMaxLine &&
                mGridRowEnd <= kTranslatedMaxLine);
   }
 
-  enum LineRangeSide {
-    eLineRangeSideStart, eLineRangeSideEnd
-  };
   /**
    * Return a line number for (non-auto) aLine, per:
    * http://dev.w3.org/csswg/css-grid/#line-placement
    * @param aLine style data for the line (must be non-auto)
    * @param aNth a number of lines to find from aFromIndex, negative if the
    *             search should be in reverse order.  In the case aLine has
    *             a specified line name, it's permitted to pass in zero which
    *             will be treated as one.
    * @param aFromIndex the zero-based index to start counting from
    * @param aLineNameList the explicit named lines
-   * @param aAxis the axis we're resolving names in
+   * @param aSide the axis+edge we're resolving names for (e.g. if we're
+                  resolving a grid-row-start line, pass eLogicalSideBStart)
    * @param aExplicitGridEnd the last line in the explicit grid
-   * @param aEdge indicates whether we are resolving a start or end line
    * @param aStyle the StylePosition() for the grid container
    * @return a definite line (1-based), clamped to the kMinLine..kMaxLine range
    */
   int32_t ResolveLine(const nsStyleGridLine& aLine,
                       int32_t aNth,
                       uint32_t aFromIndex,
                       const LineNameMap& aNameMap,
-                      LogicalAxis aAxis,
+                      LogicalSide aSide,
                       uint32_t aExplicitGridEnd,
-                      LineRangeSide aSide,
                       const nsStylePosition* aStyle);
 
   /**
    * Helper method for ResolveLineRange.
    * @see ResolveLineRange
    * @return a pair (start,end) of lines
    */
   typedef std::pair<int32_t, int32_t> LinePair;
@@ -2669,19 +2665,18 @@ nsGridContainerFrame::InitImplicitNamedA
   }
 }
 
 int32_t
 nsGridContainerFrame::Grid::ResolveLine(const nsStyleGridLine& aLine,
                                         int32_t aNth,
                                         uint32_t aFromIndex,
                                         const LineNameMap& aNameMap,
-                                        LogicalAxis aAxis,
+                                        LogicalSide aSide,
                                         uint32_t aExplicitGridEnd,
-                                        LineRangeSide aSide,
                                         const nsStylePosition* aStyle)
 {
   MOZ_ASSERT(!aLine.IsAuto());
   int32_t line = 0;
   if (aLine.mLineName.IsEmpty()) {
     MOZ_ASSERT(aNth != 0, "css-grid 9.2: <integer> must not be zero.");
     line = int32_t(aFromIndex) + aNth;
   } else {
@@ -2693,27 +2688,27 @@ nsGridContainerFrame::Grid::ResolveLine(
     if (isNameOnly) {
       const GridNamedArea* area = FindNamedArea(aLine.mLineName, aStyle);
       if (area || HasImplicitNamedArea(aLine.mLineName)) {
         // The given name is a named area - look for explicit lines named
         // <name>-start/-end depending on which side we're resolving.
         // http://dev.w3.org/csswg/css-grid/#grid-placement-slot
         uint32_t implicitLine = 0;
         nsAutoString lineName(aLine.mLineName);
-        if (aSide == eLineRangeSideStart) {
+        if (IsStart(aSide)) {
           lineName.AppendLiteral("-start");
           if (area) {
-            implicitLine = aAxis == eLogicalAxisBlock ? area->mRowStart
-                                                      : area->mColumnStart;
+            implicitLine =
+              IsBlock(aSide) ? area->mRowStart : area->mColumnStart;
           }
         } else {
           lineName.AppendLiteral("-end");
           if (area) {
-            implicitLine = aAxis == eLogicalAxisBlock ? area->mRowEnd
-                                                      : area->mColumnEnd;
+            implicitLine =
+              IsBlock(aSide) ? area->mRowEnd : area->mColumnEnd;
           }
         }
         line = aNameMap.FindNamedLine(lineName, &aNth, aFromIndex,
                                       implicitLine);
       }
     }
 
     if (line == 0) {
@@ -2722,35 +2717,35 @@ nsGridContainerFrame::Grid::ResolveLine(
       uint32_t index;
       bool useStart = IsNameWithStartSuffix(aLine.mLineName, &index);
       if (useStart || IsNameWithEndSuffix(aLine.mLineName, &index)) {
         const GridNamedArea* area =
           FindNamedArea(nsDependentSubstring(aLine.mLineName, 0, index),
                         aStyle);
         if (area) {
           if (useStart) {
-            implicitLine = aAxis == eLogicalAxisBlock ? area->mRowStart
-                                                      : area->mColumnStart;
+            implicitLine = IsBlock(aSide) ? area->mRowStart
+                                          : area->mColumnStart;
           } else {
-            implicitLine = aAxis == eLogicalAxisBlock ? area->mRowEnd
-                                                      : area->mColumnEnd;
+            implicitLine = IsBlock(aSide) ? area->mRowEnd
+                                          : area->mColumnEnd;
           }
         }
       }
       line = aNameMap.FindNamedLine(aLine.mLineName, &aNth, aFromIndex,
                                     implicitLine);
     }
 
     if (line == 0) {
       MOZ_ASSERT(aNth != 0, "we found all N named lines but 'line' is zero!");
       int32_t edgeLine;
       if (aLine.mHasSpan) {
         // http://dev.w3.org/csswg/css-grid/#grid-placement-span-int
         // 'span <custom-ident> N'
-        edgeLine = aSide == eLineRangeSideStart ? 1 : aExplicitGridEnd;
+        edgeLine = IsStart(aSide) ? 1 : aExplicitGridEnd;
       } else {
         // http://dev.w3.org/csswg/css-grid/#grid-placement-int
         // '<custom-ident> N'
         edgeLine = aNth < 0 ? 1 : aExplicitGridEnd;
       }
       // "If not enough lines with that name exist, all lines in the implicit
       // grid are assumed to have that name..."
       line = edgeLine + aNth;
@@ -2779,27 +2774,29 @@ nsGridContainerFrame::Grid::ResolveLineR
         return LinePair(kAutoLine, aStart.mInteger);
       }
       // span <custom-ident> / span *
       // span <custom-ident> / auto
       return LinePair(kAutoLine, 1); // XXX subgrid explicit size instead of 1?
     }
 
     uint32_t from = aEnd.mInteger < 0 ? aExplicitGridEnd + 1: 0;
-    auto end = ResolveLine(aEnd, aEnd.mInteger, from, aNameMap, aAxis,
-                           aExplicitGridEnd, eLineRangeSideEnd, aStyle);
+    auto end = ResolveLine(aEnd, aEnd.mInteger, from, aNameMap,
+                           MakeLogicalSide(aAxis, eLogicalEdgeEnd),
+                           aExplicitGridEnd, aStyle);
     int32_t span = aStart.mInteger == 0 ? 1 : aStart.mInteger;
     if (end <= 1) {
       // The end is at or before the first explicit line, thus all lines before
       // it match <custom-ident> since they're implicit.
       int32_t start = std::max(end - span, nsStyleGridLine::kMinLine);
       return LinePair(start, end);
     }
-    auto start = ResolveLine(aStart, -span, end, aNameMap, aAxis,
-                             aExplicitGridEnd, eLineRangeSideStart, aStyle);
+    auto start = ResolveLine(aStart, -span, end, aNameMap,
+                             MakeLogicalSide(aAxis, eLogicalEdgeStart),
+                             aExplicitGridEnd, aStyle);
     return LinePair(start, end);
   }
 
   int32_t start = kAutoLine;
   if (aStart.IsAuto()) {
     if (aEnd.IsAuto()) {
       // auto / auto
       return LinePair(start, 1); // XXX subgrid explicit size instead of 1?
@@ -2811,18 +2808,19 @@ nsGridContainerFrame::Grid::ResolveLineR
         return LinePair(start, aEnd.mInteger);
       }
       // http://dev.w3.org/csswg/css-grid/#grid-placement-errors
       // auto / span <custom-ident>
       return LinePair(start, 1); // XXX subgrid explicit size instead of 1?
     }
   } else {
     uint32_t from = aStart.mInteger < 0 ? aExplicitGridEnd + 1: 0;
-    start = ResolveLine(aStart, aStart.mInteger, from, aNameMap, aAxis,
-                        aExplicitGridEnd, eLineRangeSideStart, aStyle);
+    start = ResolveLine(aStart, aStart.mInteger, from, aNameMap,
+                        MakeLogicalSide(aAxis, eLogicalEdgeStart),
+                        aExplicitGridEnd, aStyle);
     if (aEnd.IsAuto()) {
       // A "definite line / auto" should resolve the auto to 'span 1'.
       // The error handling in ResolveLineRange will make that happen and also
       // clamp the end line correctly if we return "start / start".
       return LinePair(start, start);
     }
   }
 
@@ -2840,18 +2838,19 @@ nsGridContainerFrame::Grid::ResolveLineR
         // after it match <custom-ident> since they're implicit.
         return LinePair(start, std::min(start + nth, nsStyleGridLine::kMaxLine));
       }
       from = start;
     }
   } else {
     from = aEnd.mInteger < 0 ? aExplicitGridEnd + 1: 0;
   }
-  auto end = ResolveLine(aEnd, nth, from, aNameMap, aAxis, aExplicitGridEnd,
-                         eLineRangeSideEnd, aStyle);
+  auto end = ResolveLine(aEnd, nth, from, aNameMap,
+                         MakeLogicalSide(aAxis, eLogicalEdgeEnd),
+                         aExplicitGridEnd, aStyle);
   if (start == int32_t(kAutoLine)) {
     // auto / definite line
     start = std::max(nsStyleGridLine::kMinLine, end - 1);
   }
   return LinePair(start, end);
 }
 
 nsGridContainerFrame::LineRange
@@ -2914,31 +2913,33 @@ nsGridContainerFrame::Grid::ResolveAbsPo
   const nsStylePosition* aStyle)
 {
   if (aStart.IsAuto()) {
     if (aEnd.IsAuto()) {
       return LineRange(kAutoLine, kAutoLine);
     }
     uint32_t from = aEnd.mInteger < 0 ? aExplicitGridEnd + 1: 0;
     int32_t end =
-      ResolveLine(aEnd, aEnd.mInteger, from, aNameMap, aAxis,
-                  aExplicitGridEnd, eLineRangeSideEnd, aStyle);
+      ResolveLine(aEnd, aEnd.mInteger, from, aNameMap,
+                  MakeLogicalSide(aAxis, eLogicalEdgeEnd),
+                  aExplicitGridEnd, aStyle);
     if (aEnd.mHasSpan) {
       ++end;
     }
     // A line outside the existing grid is treated as 'auto' for abs.pos (10.1).
     end = AutoIfOutside(end, aGridStart, aGridEnd);
     return LineRange(kAutoLine, end);
   }
 
   if (aEnd.IsAuto()) {
     uint32_t from = aStart.mInteger < 0 ? aExplicitGridEnd + 1: 0;
     int32_t start =
-      ResolveLine(aStart, aStart.mInteger, from, aNameMap, aAxis,
-                  aExplicitGridEnd, eLineRangeSideStart, aStyle);
+      ResolveLine(aStart, aStart.mInteger, from, aNameMap,
+                  MakeLogicalSide(aAxis, eLogicalEdgeStart),
+                  aExplicitGridEnd, aStyle);
     if (aStart.mHasSpan) {
       start = std::max(aGridEnd - start, aGridStart);
     }
     start = AutoIfOutside(start, aGridStart, aGridEnd);
     return LineRange(start, kAutoLine);
   }
 
   LineRange r = ResolveLineRange(aStart, aEnd, aNameMap, aAxis,