From 57d616da4c29f93f74fcfc378fbfc40a1c9e7214 Mon Sep 17 00:00:00 2001 From: FranklinDM Date: Sat, 2 Apr 2022 20:11:59 +0800 Subject: [PATCH] Issue #1838 - Part 5: Address follow-up issues to initial flexbox layout for `(column|row)-gap` properties Notes: * Bug 1473044 - Make flexbox cross size take row/column gap into account https://bugzilla.mozilla.org/show_bug.cgi?id=1473044 * Bug 1473047 - Re-resolve row-gap percentages after intrinsic block size calculated https://bugzilla.mozilla.org/show_bug.cgi?id=1473047 * Bug 1612401 - Prevent absolute-positioned children from contributing gap size to flexbox's inline-size https://bugzilla.mozilla.org/show_bug.cgi?id=1612401 * Bug 1639627 - Make flex-container percent 'row-gap' values resolve to 0, when they're resolved against an indefinite block-size (essentially reverts Bug 1473047) --- layout/generic/nsFlexContainerFrame.cpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/layout/generic/nsFlexContainerFrame.cpp b/layout/generic/nsFlexContainerFrame.cpp index 9b5372832c..4429111e46 100644 --- a/layout/generic/nsFlexContainerFrame.cpp +++ b/layout/generic/nsFlexContainerFrame.cpp @@ -2330,7 +2330,7 @@ private: // XXX this should be uint16_t when we add explicit fallback handling uint8_t mAlignContent; - nscoord mCrossGapSize = 0; + const nscoord mCrossGapSize; }; // Utility class for managing our position along the cross axis, *within* a @@ -4473,6 +4473,11 @@ nsFlexContainerFrame::DoFlexLayout(nsPresContext* aPresContext, // Now that we've finished with this line's items, size the line itself: line->ComputeCrossSizeAndBaseline(aAxisTracker); sumLineCrossSizes += line->GetLineCrossSize(); + + // Add the cross axis gap space if this is not the last line + if (line->getNext()) { + sumLineCrossSizes += aCrossGapSize; + } } bool isCrossSizeDefinite; @@ -4934,6 +4939,11 @@ nsFlexContainerFrame::GetIntrinsicISize(nsRenderingContext* aRenderingContext, bool onFirstChild = true; for (nsIFrame* childFrame : mFrames) { + // Skip out-of-flow children because they don't participate in flex layout. + if (childFrame->GetType() == nsGkAtoms::placeholderFrame) { + continue; + } + nscoord childISize = nsLayoutUtils::IntrinsicForContainer( aRenderingContext, childFrame, aType); // * For a row-oriented single-line flex container, the intrinsic