tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

commit 39f53db991d8fcfcbaf53cd2b3ec709cc9ab7e23
parent 225aa81b0271ab1c983102683cc5379dd96503ad
Author: Andrew McCreight <continuation@gmail.com>
Date:   Fri,  3 Oct 2025 19:33:36 +0000

Bug 1880093 - part 7: Use nsTArray for local vars in nsHTMLFramesetFrame::CalculateRowCol. r=layout-reviewers,dholbert

Differential Revision: https://phabricator.services.mozilla.com/D267086

Diffstat:
Mlayout/generic/nsFrameSetFrame.cpp | 23+++++++++++------------
Mlayout/generic/nsFrameSetFrame.h | 5+++--
2 files changed, 14 insertions(+), 14 deletions(-)

diff --git a/layout/generic/nsFrameSetFrame.cpp b/layout/generic/nsFrameSetFrame.cpp @@ -354,8 +354,8 @@ void nsHTMLFramesetFrame::SetInitialChildList(ChildListID aListID, // XXX should this try to allocate twips based on an even pixel boundary? void nsHTMLFramesetFrame::Scale(nscoord aDesired, int32_t aNumIndicies, - int32_t* aIndicies, int32_t aNumItems, - nsTArray<int32_t>& aItems) { + const nsTArray<int32_t>& aIndicies, + int32_t aNumItems, nsTArray<int32_t>& aItems) { int32_t actual = 0; // get the actual total for (int32_t i = 0; i < aNumIndicies; i++) { @@ -409,16 +409,15 @@ void nsHTMLFramesetFrame::CalculateRowCol(nsPresContext* aPresContext, int32_t fixedTotal = 0; int32_t numFixed = 0; - auto fixed = MakeUnique<int32_t[]>(aNumSpecs); + nsTArray<int32_t> fixed; + fixed.SetLength(aNumSpecs); int32_t numPercent = 0; - auto percent = MakeUnique<int32_t[]>(aNumSpecs); + nsTArray<int32_t> percent; + percent.SetLength(aNumSpecs); int32_t relativeSums = 0; int32_t numRelative = 0; - auto relative = MakeUnique<int32_t[]>(aNumSpecs); - - if (MOZ_UNLIKELY(!fixed || !percent || !relative)) { - return; // NS_ERROR_OUT_OF_MEMORY - } + nsTArray<int32_t> relative; + relative.SetLength(aNumSpecs); // initialize the fixed, percent, relative indices, allocate the fixed sizes // and zero the others @@ -447,7 +446,7 @@ void nsHTMLFramesetFrame::CalculateRowCol(nsPresContext* aPresContext, // aren't any percent or relative) if ((fixedTotal > aSize) || ((fixedTotal < aSize) && (0 == numPercent) && (0 == numRelative))) { - Scale(aSize, numFixed, fixed.get(), aNumSpecs, aValues); + Scale(aSize, numFixed, fixed, aNumSpecs, aValues); return; } @@ -466,7 +465,7 @@ void nsHTMLFramesetFrame::CalculateRowCol(nsPresContext* aPresContext, // aren't any relative) if ((percentTotal > percentMax) || ((percentTotal < percentMax) && (0 == numRelative))) { - Scale(percentMax, numPercent, percent.get(), aNumSpecs, aValues); + Scale(percentMax, numPercent, percent, aNumSpecs, aValues); return; } @@ -483,7 +482,7 @@ void nsHTMLFramesetFrame::CalculateRowCol(nsPresContext* aPresContext, // scale the relative sizes if they take up too much or too little if (relativeTotal != relativeMax) { - Scale(relativeMax, numRelative, relative.get(), aNumSpecs, aValues); + Scale(relativeMax, numRelative, relative, aNumSpecs, aValues); } } diff --git a/layout/generic/nsFrameSetFrame.h b/layout/generic/nsFrameSetFrame.h @@ -121,8 +121,9 @@ class nsHTMLFramesetFrame final : public nsContainerFrame { void RecalculateBorderResize(); protected: - void Scale(nscoord aDesired, int32_t aNumIndicies, int32_t* aIndicies, - int32_t aNumItems, nsTArray<int32_t>& aItems); + void Scale(nscoord aDesired, int32_t aNumIndicies, + const nsTArray<int32_t>& aIndicies, int32_t aNumItems, + nsTArray<int32_t>& aItems); void CalculateRowCol(nsPresContext* aPresContext, nscoord aSize, int32_t aNumSpecs, const nsFramesetSpec* aSpecs,