diff --git a/layout/generic/nsGridContainerFrame.cpp b/layout/generic/nsGridContainerFrame.cpp index f3904094db..0a953d6fff 100644 --- a/layout/generic/nsGridContainerFrame.cpp +++ b/layout/generic/nsGridContainerFrame.cpp @@ -6214,6 +6214,11 @@ nsGridContainerFrame::Reflow(nsPresContext* aPresContext, computedISize, bSize); 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));