commit 2fe4a381eb1d70e17c1d0d034051cd02be7ff0ca
parent 99972bee1bec9d4a5fd2f030b201e7c3f53996b2
Author: Ting-Yu Lin <tlin@mozilla.com>
Date: Fri, 24 Oct 2025 16:19:47 +0000
Bug 1996146 Part 4 - Store positioned table parts using nsContainerFrame pointer. r=layout-reviewers,dshin
Table parts are all `nsContainerFrame`. This is a preparation for a later patch
to avoid type-casting.
Differential Revision: https://phabricator.services.mozilla.com/D269902
Diffstat:
2 files changed, 18 insertions(+), 19 deletions(-)
diff --git a/layout/tables/nsTableFrame.cpp b/layout/tables/nsTableFrame.cpp
@@ -247,7 +247,7 @@ bool nsTableFrame::PageBreakAfter(nsIFrame* aSourceFrame,
}
/* static */
-void nsTableFrame::PositionedTablePartMaybeChanged(nsIFrame* aFrame,
+void nsTableFrame::PositionedTablePartMaybeChanged(nsContainerFrame* aFrame,
ComputedStyle* aOldStyle) {
const bool wasPositioned =
aOldStyle && aOldStyle->IsAbsPosContainingBlock(aFrame);
@@ -262,13 +262,13 @@ void nsTableFrame::PositionedTablePartMaybeChanged(nsIFrame* aFrame,
tableFrame = static_cast<nsTableFrame*>(tableFrame->FirstContinuation());
// Retrieve the positioned parts array for this table.
- FrameTArray* positionedParts =
- tableFrame->GetProperty(PositionedTablePartArray());
+ TablePartsArray* positionedParts =
+ tableFrame->GetProperty(PositionedTablePartsProperty());
// Lazily create the array if it doesn't exist yet.
if (!positionedParts) {
- positionedParts = new FrameTArray;
- tableFrame->SetProperty(PositionedTablePartArray(), positionedParts);
+ positionedParts = new TablePartsArray;
+ tableFrame->SetProperty(PositionedTablePartsProperty(), positionedParts);
}
if (isPositioned) {
@@ -280,7 +280,8 @@ void nsTableFrame::PositionedTablePartMaybeChanged(nsIFrame* aFrame,
}
/* static */
-void nsTableFrame::MaybeUnregisterPositionedTablePart(nsIFrame* aFrame) {
+void nsTableFrame::MaybeUnregisterPositionedTablePart(
+ nsContainerFrame* aFrame) {
if (!aFrame->IsAbsPosContainingBlock()) {
return;
}
@@ -292,8 +293,8 @@ void nsTableFrame::MaybeUnregisterPositionedTablePart(nsIFrame* aFrame) {
}
// Retrieve the positioned parts array for this table.
- FrameTArray* positionedParts =
- tableFrame->GetProperty(PositionedTablePartArray());
+ TablePartsArray* positionedParts =
+ tableFrame->GetProperty(PositionedTablePartsProperty());
// Remove the frame.
MOZ_ASSERT(
@@ -1826,7 +1827,8 @@ void nsTableFrame::Reflow(nsPresContext* aPresContext,
void nsTableFrame::FixupPositionedTableParts(nsPresContext* aPresContext,
ReflowOutput& aDesiredSize,
const ReflowInput& aReflowInput) {
- FrameTArray* positionedParts = GetProperty(PositionedTablePartArray());
+ TablePartsArray* positionedParts =
+ GetProperty(PositionedTablePartsProperty());
if (!positionedParts) {
return;
}
@@ -1834,9 +1836,7 @@ void nsTableFrame::FixupPositionedTableParts(nsPresContext* aPresContext,
OverflowChangedTracker overflowTracker;
overflowTracker.SetSubtreeRoot(this);
- for (size_t i = 0; i < positionedParts->Length(); ++i) {
- nsIFrame* positionedPart = positionedParts->ElementAt(i);
-
+ for (nsContainerFrame* positionedPart : *positionedParts) {
// As we've already finished reflow, positionedParts's size and overflow
// areas have already been assigned, so we just pull them back out.
const WritingMode wm = positionedPart->GetWritingMode();
diff --git a/layout/tables/nsTableFrame.h b/layout/tables/nsTableFrame.h
@@ -143,8 +143,9 @@ class nsTableFrame : public nsContainerFrame {
public:
NS_DECL_FRAMEARENA_HELPERS(nsTableFrame)
- typedef nsTArray<nsIFrame*> FrameTArray;
- NS_DECLARE_FRAME_PROPERTY_DELETABLE(PositionedTablePartArray, FrameTArray)
+ using TablePartsArray = nsTArray<nsContainerFrame*>;
+ NS_DECLARE_FRAME_PROPERTY_DELETABLE(PositionedTablePartsProperty,
+ TablePartsArray)
/** nsTableWrapperFrame has intimate knowledge of the inner table frame */
friend class nsTableWrapperFrame;
@@ -184,14 +185,12 @@ class nsTableFrame : public nsContainerFrame {
// Register or deregister a positioned table part with its nsTableFrame.
// These objects will be visited by FixupPositionedTableParts after reflow is
// complete. (See that function for more explanation.) Should be called
- // during frame construction or style recalculation.
- //
- // @return true if the frame is a registered positioned table part.
+ // during style recalculation.
static void PositionedTablePartMaybeChanged(
- nsIFrame*, mozilla::ComputedStyle* aOldStyle);
+ nsContainerFrame*, mozilla::ComputedStyle* aOldStyle);
// Unregister a positioned table part with its nsTableFrame, if needed.
- static void MaybeUnregisterPositionedTablePart(nsIFrame* aFrame);
+ static void MaybeUnregisterPositionedTablePart(nsContainerFrame* aFrame);
/*
* Notification that rowspan or colspan has changed for content inside a