From f0a1413baf12056870fb86ad234245cb51800ec6 Mon Sep 17 00:00:00 2001 From: Ting-Yu Lin Date: Tue, 8 Feb 2022 22:47:19 +0000 Subject: [PATCH] Bug 1752658 Part 3 - Reduce scope of the struts array in Reflow(). r=dholbert The `struts` array is used only within DoFlexLayout, so we should move it into `if (!GetPrevInFlow()) { ... }` branch. Also, move `nsTArray&` argument on DoFlexLayout() to the second to last place so that the output arguments are grouped together after applying Part 4. Differential Revision: https://phabricator.services.mozilla.com/D137363 --- layout/generic/nsFlexContainerFrame.cpp | 17 +++++++++-------- layout/generic/nsFlexContainerFrame.h | 3 +-- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/layout/generic/nsFlexContainerFrame.cpp b/layout/generic/nsFlexContainerFrame.cpp index 5ec49cf3a3c5..79c7ba567113 100644 --- a/layout/generic/nsFlexContainerFrame.cpp +++ b/layout/generic/nsFlexContainerFrame.cpp @@ -4560,7 +4560,6 @@ void nsFlexContainerFrame::Reflow(nsPresContext* aPresContext, nscoord flexContainerAscent; AutoTArray lines; - AutoTArray struts; AutoTArray placeholders; if (!GetPrevInFlow()) { @@ -4593,9 +4592,10 @@ void nsFlexContainerFrame::Reflow(nsPresContext* aPresContext, // TODO: This line will be removed in a later patch once the output // arguments to DoFlexLayout is removed. contentBoxMainSize = tentativeContentBoxMainSize; + AutoTArray struts; DoFlexLayout(aReflowInput, contentBoxMainSize, contentBoxCrossSize, - flexContainerAscent, lines, struts, placeholders, axisTracker, - mainGapSize, crossGapSize, hasLineClampEllipsis, + flexContainerAscent, lines, placeholders, axisTracker, + mainGapSize, crossGapSize, hasLineClampEllipsis, struts, containerInfo); if (!struts.IsEmpty()) { @@ -4603,8 +4603,8 @@ void nsFlexContainerFrame::Reflow(nsPresContext* aPresContext, lines.Clear(); placeholders.Clear(); DoFlexLayout(aReflowInput, contentBoxMainSize, contentBoxCrossSize, - flexContainerAscent, lines, struts, placeholders, - axisTracker, mainGapSize, crossGapSize, hasLineClampEllipsis, + flexContainerAscent, lines, placeholders, axisTracker, + mainGapSize, crossGapSize, hasLineClampEllipsis, struts, containerInfo); } } else { @@ -5085,9 +5085,10 @@ bool nsFlexContainerFrame::IsUsedFlexBasisContent( void nsFlexContainerFrame::DoFlexLayout( const ReflowInput& aReflowInput, nscoord& aContentBoxMainSize, nscoord& aContentBoxCrossSize, nscoord& aFlexContainerAscent, - nsTArray& aLines, nsTArray& aStruts, - nsTArray& aPlaceholders, const FlexboxAxisTracker& aAxisTracker, - nscoord aMainGapSize, nscoord aCrossGapSize, bool aHasLineClampEllipsis, + nsTArray& aLines, nsTArray& aPlaceholders, + const FlexboxAxisTracker& aAxisTracker, nscoord aMainGapSize, + nscoord aCrossGapSize, bool aHasLineClampEllipsis, + nsTArray& aStruts, ComputedFlexContainerInfo* const aContainerInfo) { MOZ_ASSERT(aLines.IsEmpty(), "Caller should pass an empty array for lines!"); MOZ_ASSERT(aPlaceholders.IsEmpty(), diff --git a/layout/generic/nsFlexContainerFrame.h b/layout/generic/nsFlexContainerFrame.h index 761f473d2f18..ffc391bf393e 100644 --- a/layout/generic/nsFlexContainerFrame.h +++ b/layout/generic/nsFlexContainerFrame.h @@ -318,11 +318,10 @@ class nsFlexContainerFrame final : public nsContainerFrame { void DoFlexLayout(const ReflowInput& aReflowInput, nscoord& aContentBoxMainSize, nscoord& aContentBoxCrossSize, nscoord& aFlexContainerAscent, nsTArray& aLines, - nsTArray& aStruts, nsTArray& aPlaceholders, const FlexboxAxisTracker& aAxisTracker, nscoord aMainGapSize, nscoord aCrossGapSize, - bool aHasLineClampEllipsis, + bool aHasLineClampEllipsis, nsTArray& aStruts, ComputedFlexContainerInfo* const aContainerInfo); /**