commit 5c04a9395033766adb7011f79f12b23a204036f6
parent aa4350d2b0cffedee056749f9fc0db171ce85759
Author: Andrew McCreight <continuation@gmail.com>
Date: Fri, 3 Oct 2025 19:33:35 +0000
Bug 1880093 - part 4: Use nsTArray for nsFrameSetFrame::mRowSizes and ::mColSizes. r=layout-reviewers,dholbert
Differential Revision: https://phabricator.services.mozilla.com/D267083
Diffstat:
2 files changed, 18 insertions(+), 14 deletions(-)
diff --git a/layout/generic/nsFrameSetFrame.cpp b/layout/generic/nsFrameSetFrame.cpp
@@ -219,8 +219,10 @@ void nsHTMLFramesetFrame::Init(nsIContent* aContent, nsContainerFrame* aParent,
static_assert(
NS_MAX_FRAMESET_SPEC_COUNT < UINT_MAX / sizeof(nscoord),
"Maximum value of mNumRows and mNumCols is NS_MAX_FRAMESET_SPEC_COUNT");
- mRowSizes = MakeUnique<nscoord[]>(mNumRows);
- mColSizes = MakeUnique<nscoord[]>(mNumCols);
+ mRowSizes.Clear();
+ mRowSizes.SetLength(mNumRows);
+ mColSizes.Clear();
+ mColSizes.SetLength(mNumCols);
static_assert(
NS_MAX_FRAMESET_SPEC_COUNT < INT32_MAX / NS_MAX_FRAMESET_SPEC_COUNT,
@@ -350,7 +352,7 @@ 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,
- int32_t* aItems) {
+ nsTArray<int32_t>& aItems) {
int32_t actual = 0;
// get the actual total
for (int32_t i = 0; i < aNumIndicies; i++) {
@@ -398,7 +400,7 @@ void nsHTMLFramesetFrame::Scale(nscoord aDesired, int32_t aNumIndicies,
void nsHTMLFramesetFrame::CalculateRowCol(nsPresContext* aPresContext,
nscoord aSize, int32_t aNumSpecs,
const nsFramesetSpec* aSpecs,
- nscoord* aValues) {
+ nsTArray<nscoord>& aValues) {
static_assert(NS_MAX_FRAMESET_SPEC_COUNT < UINT_MAX / sizeof(int32_t),
"aNumSpecs maximum value is NS_MAX_FRAMESET_SPEC_COUNT");
@@ -490,7 +492,8 @@ void nsHTMLFramesetFrame::CalculateRowCol(nsPresContext* aPresContext,
void nsHTMLFramesetFrame::GenerateRowCol(nsPresContext* aPresContext,
nscoord aSize, int32_t aNumSpecs,
const nsFramesetSpec* aSpecs,
- nscoord* aValues, nsString& aNewAttr) {
+ const nsTArray<nscoord>& aValues,
+ nsString& aNewAttr) {
for (int32_t i = 0; i < aNumSpecs; i++) {
if (!aNewAttr.IsEmpty()) {
aNewAttr.Append(char16_t(','));
@@ -813,8 +816,8 @@ void nsHTMLFramesetFrame::Reflow(nsPresContext* aPresContext,
return;
}
- CalculateRowCol(aPresContext, width, mNumCols, colSpecs, mColSizes.get());
- CalculateRowCol(aPresContext, height, mNumRows, rowSpecs, mRowSizes.get());
+ CalculateRowCol(aPresContext, width, mNumCols, colSpecs, mColSizes);
+ CalculateRowCol(aPresContext, height, mNumRows, rowSpecs, mRowSizes);
UniquePtr<bool[]> verBordersVis; // vertical borders visibility
UniquePtr<nscolor[]> verBorderColors;
@@ -1208,7 +1211,7 @@ void nsHTMLFramesetFrame::MouseDrag(nsPresContext* aPresContext,
const nsFramesetSpec* colSpecs = nullptr;
ourContent->GetColSpec(&mNumCols, &colSpecs);
nsAutoString newColAttr;
- GenerateRowCol(aPresContext, width, mNumCols, colSpecs, mColSizes.get(),
+ GenerateRowCol(aPresContext, width, mNumCols, colSpecs, mColSizes,
newColAttr);
// Setting the attr will trigger a reflow
mContent->AsElement()->SetAttr(kNameSpaceID_None, nsGkAtoms::cols,
@@ -1234,7 +1237,7 @@ void nsHTMLFramesetFrame::MouseDrag(nsPresContext* aPresContext,
const nsFramesetSpec* rowSpecs = nullptr;
ourContent->GetRowSpec(&mNumRows, &rowSpecs);
nsAutoString newRowAttr;
- GenerateRowCol(aPresContext, height, mNumRows, rowSpecs, mRowSizes.get(),
+ GenerateRowCol(aPresContext, height, mNumRows, rowSpecs, mRowSizes,
newRowAttr);
// Setting the attr will trigger a reflow
mContent->AsElement()->SetAttr(kNameSpaceID_None, nsGkAtoms::rows,
diff --git a/layout/generic/nsFrameSetFrame.h b/layout/generic/nsFrameSetFrame.h
@@ -13,6 +13,7 @@
#include "mozilla/UniquePtr.h"
#include "nsColor.h"
#include "nsContainerFrame.h"
+#include "nsTArray.h"
class nsIContent;
class nsPresContext;
@@ -121,15 +122,15 @@ class nsHTMLFramesetFrame final : public nsContainerFrame {
protected:
void Scale(nscoord aDesired, int32_t aNumIndicies, int32_t* aIndicies,
- int32_t aNumItems, int32_t* aItems);
+ int32_t aNumItems, nsTArray<int32_t>& aItems);
void CalculateRowCol(nsPresContext* aPresContext, nscoord aSize,
int32_t aNumSpecs, const nsFramesetSpec* aSpecs,
- nscoord* aValues);
+ nsTArray<nscoord>& aValues);
void GenerateRowCol(nsPresContext* aPresContext, nscoord aSize,
int32_t aNumSpecs, const nsFramesetSpec* aSpecs,
- nscoord* aValues, nsString& aNewAttr);
+ const nsTArray<nscoord>& aValues, nsString& aNewAttr);
virtual void GetDesiredSize(nsPresContext* aPresContext,
const ReflowInput& aReflowInput,
@@ -178,8 +179,8 @@ class nsHTMLFramesetFrame final : public nsContainerFrame {
UniquePtr<nsFrameborder[]>
mChildFrameborder; // the frameborder attr of children
UniquePtr<nsBorderColor[]> mChildBorderColors;
- UniquePtr<nscoord[]> mRowSizes; // currently computed row sizes
- UniquePtr<nscoord[]> mColSizes; // currently computed col sizes
+ nsTArray<nscoord> mRowSizes; // currently computed row sizes
+ nsTArray<nscoord> mColSizes; // currently computed col sizes
mozilla::LayoutDeviceIntPoint mFirstDragPoint;
int32_t mNumRows;
int32_t mNumCols;