Bug 1464882 - [css-grid] Pass the content size relevant for the specific axis rather than requiring both only to discard one value. r=dholbert
authorMats Palmgren <mats@mozilla.com>
Mon, 04 Jun 2018 23:18:56 +0200
changeset 421250 2acc5be853afe7e3ede8e7a8a9896bfea48bf8cf
parent 421249 e920b9c3d553097ccd593d9136ab7ff56d836164
child 421251 c4c90903c8e9ca2e76edc680dde3b231d1f3f447
push id34090
push userbtara@mozilla.com
push dateTue, 05 Jun 2018 09:30:51 +0000
treeherdermozilla-central@a358755643e9 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdholbert
bugs1464882
milestone62.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 1464882 - [css-grid] Pass the content size relevant for the specific axis rather than requiring both only to discard one value. r=dholbert
layout/generic/nsGridContainerFrame.cpp
--- a/layout/generic/nsGridContainerFrame.cpp
+++ b/layout/generic/nsGridContainerFrame.cpp
@@ -1573,17 +1573,17 @@ struct nsGridContainerFrame::Tracks
                       SizingConstraint            aConstraint);
 
   /**
    * Apply 'align/justify-content', whichever is relevant for this axis.
    * https://drafts.csswg.org/css-align-3/#propdef-align-content
    */
   void AlignJustifyContent(const nsStylePosition* aStyle,
                            WritingMode            aWM,
-                           const LogicalSize&     aContainerSize);
+                           nscoord                aContentSize);
 
   nscoord GridLineEdge(uint32_t aLine, GridLineSide aSide) const
   {
     if (MOZ_UNLIKELY(mSizes.IsEmpty())) {
       // https://drafts.csswg.org/css-grid/#grid-definition
       // "... the explicit grid still contains one grid line in each axis."
       MOZ_ASSERT(aLine == 0, "We should only resolve line 1 in an empty grid");
       return nscoord(0);
@@ -2380,17 +2380,17 @@ nsGridContainerFrame::GridReflowInput::C
   mCols.Initialize(mColFunctions, mGridStyle->mColumnGap,
                    aGrid.mGridColEnd, aContentBox.ISize(mWM));
   mRows.Initialize(mRowFunctions, mGridStyle->mRowGap,
                    aGrid.mGridRowEnd, aContentBox.BSize(mWM));
 
   mCols.CalculateSizes(*this, mGridItems, mColFunctions,
                        aContentBox.ISize(mWM), &GridArea::mCols,
                        aConstraint);
-  mCols.AlignJustifyContent(mGridStyle, mWM, aContentBox);
+  mCols.AlignJustifyContent(mGridStyle, mWM, aContentBox.ISize(mWM));
   // Column positions and sizes are now final.
   mCols.mCanResolveLineRangeSize = true;
 
   mRows.CalculateSizes(*this, mGridItems, mRowFunctions,
                        aContentBox.BSize(mWM), &GridArea::mRows,
                        aConstraint);
 }
 
@@ -4629,17 +4629,17 @@ nsGridContainerFrame::Tracks::StretchFle
     break;
   }
 }
 
 void
 nsGridContainerFrame::Tracks::AlignJustifyContent(
   const nsStylePosition* aStyle,
   WritingMode            aWM,
-  const LogicalSize&     aContainerSize)
+  nscoord                aContentSize)
 {
   if (mSizes.IsEmpty()) {
     return;
   }
 
   const bool isAlign = mAxis == eLogicalAxisBlock;
   auto valueAndFallback = isAlign ? aStyle->mAlignContent :
                                     aStyle->mJustifyContent;
@@ -4659,19 +4659,17 @@ nsGridContainerFrame::Tracks::AlignJusti
   if (alignment != NS_STYLE_ALIGN_START) {
     nscoord trackSizeSum = 0;
     for (const TrackSize& sz : mSizes) {
       trackSizeSum += sz.mBase;
       if (sz.mState & TrackSize::eAutoMaxSizing) {
         ++numAutoTracks;
       }
     }
-    nscoord cbSize = isAlign ? aContainerSize.BSize(aWM)
-                             : aContainerSize.ISize(aWM);
-    space = cbSize - trackSizeSum - SumOfGridGaps();
+    space = aContentSize - trackSizeSum - SumOfGridGaps();
     // Use the fallback value instead when applicable.
     if (space < 0 ||
         (alignment == NS_STYLE_ALIGN_SPACE_BETWEEN && mSizes.Length() == 1)) {
       auto fallback = ::GetAlignJustifyFallbackIfAny(valueAndFallback, aWM,
                                                      isAlign, &overflowSafe);
       if (fallback) {
         alignment = fallback;
       }
@@ -5992,17 +5990,17 @@ nsGridContainerFrame::Reflow(nsPresConte
   if (!prevInFlow) {
     if (computedBSize == NS_AUTOHEIGHT && stylePos->mRowGap.HasPercent()) {
       // Re-resolve the row-gap now that we know our intrinsic block-size.
       gridReflowInput.mRows.mGridGap =
         nsLayoutUtils::ResolveGapToLength(stylePos->mRowGap, bSize);
     }
     // Apply 'align/justify-content' to the grid.
     // CalculateTrackSizes did the columns.
-    gridReflowInput.mRows.AlignJustifyContent(stylePos, wm, contentArea.Size(wm));
+    gridReflowInput.mRows.AlignJustifyContent(stylePos, wm, bSize);
   }
 
   bSize = ReflowChildren(gridReflowInput, contentArea, aDesiredSize, aStatus);
   bSize = std::max(bSize - consumedBSize, 0);
 
   // Skip our block-end border if we're INCOMPLETE.
   if (!aStatus.IsComplete() &&
       !gridReflowInput.mSkipSides.BEnd() &&