Bug 1229999 - [css-grid] Clamp auto-placed lines to where kMaxLine is in the translated grid. r=dholbert
authorMats Palmgren <mats@mozilla.com>
Wed, 09 Dec 2015 23:46:58 +0100
changeset 310163 ef6fa56c99ca6c3db253d2a227928a3c6dccd061
parent 310162 5138ad90e360d3145e3991d188c420ee167d9578
child 310164 d01ad4aa08d5562a2babccdf96ed5e7cebde38da
push id5513
push userraliiev@mozilla.com
push dateMon, 25 Jan 2016 13:55:34 +0000
treeherdermozilla-beta@5ee97dd05b5c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdholbert
bugs1229999
milestone45.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 1229999 - [css-grid] Clamp auto-placed lines to where kMaxLine is in the translated grid. r=dholbert
layout/generic/nsGridContainerFrame.cpp
layout/generic/nsGridContainerFrame.h
--- a/layout/generic/nsGridContainerFrame.cpp
+++ b/layout/generic/nsGridContainerFrame.cpp
@@ -24,17 +24,17 @@
 #include "nsRenderingContext.h"
 #include "nsReadableUtils.h"
 #include "nsRuleNode.h"
 #include "nsStyleContext.h"
 
 using namespace mozilla;
 typedef nsGridContainerFrame::TrackSize TrackSize;
 const uint32_t nsGridContainerFrame::kTranslatedMaxLine =
-  uint32_t(nsStyleGridLine::kMaxLine - nsStyleGridLine::kMinLine - 1);
+  uint32_t(nsStyleGridLine::kMaxLine - nsStyleGridLine::kMinLine);
 const uint32_t nsGridContainerFrame::kAutoLine = kTranslatedMaxLine + 3457U;
 
 MOZ_MAKE_ENUM_CLASS_BITWISE_OPERATORS(TrackSize::StateBits)
 
 class nsGridContainerFrame::GridItemCSSOrderIterator
 {
 public:
   enum OrderState { eUnknownOrder, eKnownOrdered, eKnownUnordered };
@@ -1576,17 +1576,17 @@ nsGridContainerFrame::PlaceAbsPos(nsIFra
                            aStyle));
 }
 
 void
 nsGridContainerFrame::PlaceAutoCol(uint32_t aStartCol, GridArea* aArea) const
 {
   MOZ_ASSERT(aArea->mRows.IsDefinite() && aArea->mCols.IsAuto());
   uint32_t col = FindAutoCol(aStartCol, aArea->mRows.mStart, aArea);
-  aArea->mCols.ResolveAutoPosition(col);
+  aArea->mCols.ResolveAutoPosition(col, mExplicitGridOffsetCol);
   MOZ_ASSERT(aArea->IsDefinite());
 }
 
 uint32_t
 nsGridContainerFrame::FindAutoRow(uint32_t aLockedCol, uint32_t aStartRow,
                                   const GridArea* aArea) const
 {
   const uint32_t extent = aArea->mRows.Extent();
@@ -1614,17 +1614,17 @@ nsGridContainerFrame::FindAutoRow(uint32
   return candidate;
 }
 
 void
 nsGridContainerFrame::PlaceAutoRow(uint32_t aStartRow, GridArea* aArea) const
 {
   MOZ_ASSERT(aArea->mCols.IsDefinite() && aArea->mRows.IsAuto());
   uint32_t row = FindAutoRow(aArea->mCols.mStart, aStartRow, aArea);
-  aArea->mRows.ResolveAutoPosition(row);
+  aArea->mRows.ResolveAutoPosition(row, mExplicitGridOffsetRow);
   MOZ_ASSERT(aArea->IsDefinite());
 }
 
 void
 nsGridContainerFrame::PlaceAutoAutoInRowOrder(uint32_t aStartCol,
                                               uint32_t aStartRow,
                                               GridArea* aArea) const
 {
@@ -1638,18 +1638,18 @@ nsGridContainerFrame::PlaceAutoAutoInRow
     col = FindAutoCol(col, row, aArea);
     if (col + colExtent <= gridColEnd) {
       break;
     }
     col = 0;
   }
   MOZ_ASSERT(row < gridRowEnd || col == 0,
              "expected column 0 for placing in a new row");
-  aArea->mCols.ResolveAutoPosition(col);
-  aArea->mRows.ResolveAutoPosition(row);
+  aArea->mCols.ResolveAutoPosition(col, mExplicitGridOffsetCol);
+  aArea->mRows.ResolveAutoPosition(row, mExplicitGridOffsetRow);
   MOZ_ASSERT(aArea->IsDefinite());
 }
 
 void
 nsGridContainerFrame::PlaceAutoAutoInColOrder(uint32_t aStartCol,
                                               uint32_t aStartRow,
                                               GridArea* aArea) const
 {
@@ -1663,18 +1663,18 @@ nsGridContainerFrame::PlaceAutoAutoInCol
     row = FindAutoRow(col, row, aArea);
     if (row + rowExtent <= gridRowEnd) {
       break;
     }
     row = 0;
   }
   MOZ_ASSERT(col < gridColEnd || row == 0,
              "expected row 0 for placing in a new column");
-  aArea->mCols.ResolveAutoPosition(col);
-  aArea->mRows.ResolveAutoPosition(row);
+  aArea->mCols.ResolveAutoPosition(col, mExplicitGridOffsetCol);
+  aArea->mRows.ResolveAutoPosition(row, mExplicitGridOffsetRow);
   MOZ_ASSERT(aArea->IsDefinite());
 }
 
 void
 nsGridContainerFrame::InitializeGridBounds(const nsStylePosition* aStyle)
 {
   // http://dev.w3.org/csswg/css-grid/#grid-definition
   // Note that this is for a grid with a 1,1 origin.  We'll change that
--- a/layout/generic/nsGridContainerFrame.h
+++ b/layout/generic/nsGridContainerFrame.h
@@ -170,27 +170,29 @@ protected:
         return mEnd;
       }
       return mEnd - mStart;
     }
     /**
      * Resolve this auto range to start at aStart, making it definite.
      * Precondition: this range IsAuto()
      */
-    void ResolveAutoPosition(uint32_t aStart)
+    void ResolveAutoPosition(uint32_t aStart, uint32_t aExplicitGridOffset)
     {
       MOZ_ASSERT(IsAuto(), "Why call me?");
       mStart = aStart;
       mEnd += aStart;
-      // Clamping per http://dev.w3.org/csswg/css-grid/#overlarge-grids :
-      if (MOZ_UNLIKELY(mStart >= kTranslatedMaxLine)) {
-        mEnd = kTranslatedMaxLine;
+      // Clamping to where kMaxLine is in the explicit grid, per
+      // http://dev.w3.org/csswg/css-grid/#overlarge-grids :
+      uint32_t translatedMax = aExplicitGridOffset + nsStyleGridLine::kMaxLine;
+      if (MOZ_UNLIKELY(mStart >= translatedMax)) {
+        mEnd = translatedMax;
         mStart = mEnd - 1;
-      } else if (MOZ_UNLIKELY(mEnd > kTranslatedMaxLine)) {
-        mEnd = kTranslatedMaxLine;
+      } else if (MOZ_UNLIKELY(mEnd > translatedMax)) {
+        mEnd = translatedMax;
       }
     }
     /**
      * Return the contribution of this line range for step 2 in
      * http://dev.w3.org/csswg/css-grid/#auto-placement-algo
      */
     uint32_t HypotheticalEnd() const { return mEnd; }
     /**