commit 225aa81b0271ab1c983102683cc5379dd96503ad
parent 8217236cccae84afe73e93814de8c23970bea0a2
Author: Andrew McCreight <continuation@gmail.com>
Date: Fri, 3 Oct 2025 19:33:35 +0000
Bug 1880093 - part 6: Use nsTArray for nsFrameSetFrame::mChildFrameborder and mChildBorderColors. r=layout-reviewers,emilio
This is a little weird because we need to track whether the reflow processing has been
done already.
Differential Revision: https://phabricator.services.mozilla.com/D267085
Diffstat:
2 files changed, 19 insertions(+), 9 deletions(-)
diff --git a/layout/generic/nsFrameSetFrame.cpp b/layout/generic/nsFrameSetFrame.cpp
@@ -255,8 +255,11 @@ void nsHTMLFramesetFrame::Init(nsIContent* aContent, nsContainerFrame* aParent,
static_assert(NS_MAX_FRAMESET_SPEC_COUNT < UINT_MAX / sizeof(nsBorderColor) /
NS_MAX_FRAMESET_SPEC_COUNT,
"Should not overflow numCells");
- mChildFrameborder = MakeUnique<nsFrameborder[]>(numCells);
- mChildBorderColors = MakeUnique<nsBorderColor[]>(numCells);
+ mNeedFirstReflowWork = true;
+ mChildFrameborder.Clear();
+ mChildFrameborder.SetLength(numCells);
+ mChildBorderColors.Clear();
+ mChildBorderColors.SetLength(numCells);
// create the children frames; skip content which isn't <frameset> or <frame>
mChildCount = 0; // number of <frame> or <frameset> children
@@ -782,9 +785,12 @@ void nsHTMLFramesetFrame::Reflow(nsPresContext* aPresContext,
// that's allowed. (Though it will only happen for misuse of frameset
// that includes it within other content.) So measure firstTime by
// what we care about, which is whether we've processed the data we
- // process below if firstTime is true.
- MOZ_ASSERT(!mChildFrameborder == !mChildBorderColors);
- bool firstTime = !!mChildFrameborder;
+ // process below if firstTime is true. We can't assert that IsEmpty()
+ // is the same for the 2 child arrays, because they can also end up
+ // empty in Init() if they hit an error state.
+ MOZ_ASSERT_IF(!mChildFrameborder.IsEmpty(), mNeedFirstReflowWork);
+ MOZ_ASSERT_IF(!mChildBorderColors.IsEmpty(), mNeedFirstReflowWork);
+ bool firstTime = mNeedFirstReflowWork;
// subtract out the width of all of the potential borders. There are
// only borders between <frame>s. There are none on the edges (e.g the
@@ -1043,8 +1049,9 @@ void nsHTMLFramesetFrame::Reflow(nsPresContext* aPresContext,
}
}
- mChildFrameborder.reset();
- mChildBorderColors.reset();
+ mNeedFirstReflowWork = false;
+ mChildFrameborder.Clear();
+ mChildBorderColors.Clear();
}
mDrag.UnSet();
diff --git a/layout/generic/nsFrameSetFrame.h b/layout/generic/nsFrameSetFrame.h
@@ -176,9 +176,9 @@ class nsHTMLFramesetFrame final : public nsContainerFrame {
nsHTMLFramesetFrame* mTopLevelFrameset;
nsTArray<nsHTMLFramesetBorderFrame*> mVerBorders; // vertical borders
nsTArray<nsHTMLFramesetBorderFrame*> mHorBorders; // horizontal borders
- UniquePtr<nsFrameborder[]>
+ nsTArray<nsFrameborder>
mChildFrameborder; // the frameborder attr of children
- UniquePtr<nsBorderColor[]> mChildBorderColors;
+ nsTArray<nsBorderColor> mChildBorderColors;
nsTArray<nscoord> mRowSizes; // currently computed row sizes
nsTArray<nscoord> mColSizes; // currently computed col sizes
mozilla::LayoutDeviceIntPoint mFirstDragPoint;
@@ -188,6 +188,9 @@ class nsHTMLFramesetFrame final : public nsContainerFrame {
int32_t mNonBlankChildCount;
int32_t mEdgeVisibility;
nsFrameborder mParentFrameborder;
+ // If this is true, then we've been Init()'d, but haven't been reflowed, so
+ // there's some extra work to do in the first reflow.
+ bool mNeedFirstReflowWork = false;
nscolor mParentBorderColor;
int32_t mParentBorderWidth;
int32_t mPrevNeighborOrigSize; // used during resize