commit f786affdc7afdd03c816b79d4abb30818959bf03
parent 764938320efc67b5e82ad34dff5334f68a6fc308
Author: Emilio Cobos Álvarez <emilio@crisal.io>
Date: Thu, 9 Oct 2025 11:23:05 +0000
Bug 1993353 - Remove view reparenting code that has been disabled forever. r=tnikkel,layout-reviewers
The subdocument frame caller is a no-op because nsSubdocumentFrame is a
leaf frame.
Differential Revision: https://phabricator.services.mozilla.com/D268104
Diffstat:
12 files changed, 0 insertions(+), 217 deletions(-)
diff --git a/layout/base/nsBidiPresUtils.cpp b/layout/base/nsBidiPresUtils.cpp
@@ -633,9 +633,6 @@ static void SplitInlineAncestors(nsContainerFrame* aParent,
nsFrameList tail = parent->StealFramesAfter(frame);
- // Reparent views as necessary
- nsContainerFrame::ReparentFrameViewList(tail, parent, newParent);
-
// The parent's continuation adopts the siblings after the split.
MOZ_ASSERT(!newParent->IsBlockFrameOrSubclass(),
"blocks should not be IsBidiSplittable");
diff --git a/layout/base/nsCSSFrameConstructor.cpp b/layout/base/nsCSSFrameConstructor.cpp
@@ -1342,14 +1342,6 @@ nsFrameConstructorSaveState::~nsFrameConstructorSaveState() {
// views, which would make most of this function go away.
static void MoveChildrenTo(nsIFrame* aOldParent, nsContainerFrame* aNewParent,
nsFrameList& aFrameList) {
-#ifdef DEBUG
- bool sameGrandParent = aOldParent->GetParent() == aNewParent->GetParent();
- if (aNewParent->GetView() || aOldParent->GetView() || !sameGrandParent) {
- // Move the frames into the new view
- nsContainerFrame::ReparentFrameViewList(aFrameList, aOldParent, aNewParent);
- }
-#endif
-
aFrameList.ApplySetParent(aNewParent);
if (aNewParent->PrincipalChildList().IsEmpty() &&
diff --git a/layout/forms/nsFieldSetFrame.cpp b/layout/forms/nsFieldSetFrame.cpp
@@ -377,8 +377,6 @@ void nsFieldSetFrame::Reflow(nsPresContext* aPresContext,
AutoFrameListPtr prevOverflowFrames(PresContext(),
prevInFlow->StealOverflowFrames());
if (prevOverflowFrames) {
- nsContainerFrame::ReparentFrameViewList(*prevOverflowFrames, prevInFlow,
- this);
mFrames.InsertFrames(this, nullptr, std::move(*prevOverflowFrames));
}
}
diff --git a/layout/generic/nsCanvasFrame.cpp b/layout/generic/nsCanvasFrame.cpp
@@ -420,7 +420,6 @@ void nsCanvasFrame::Reflow(nsPresContext* aPresContext,
if (overflow) {
NS_ASSERTION(overflow->OnlyChild(),
"must have doc root as canvas frame's only child");
- nsContainerFrame::ReparentFrameViewList(*overflow, prevCanvasFrame, this);
// Prepend overflow to the our child list. There may already be
// children placeholders for fixed-pos elements, which don't get
// reflowed but must not be lost until the canvas frame is destroyed.
diff --git a/layout/generic/nsColumnSetFrame.cpp b/layout/generic/nsColumnSetFrame.cpp
@@ -967,8 +967,6 @@ void nsColumnSetFrame::DrainOverflowColumns() {
if (prev) {
AutoFrameListPtr overflows(presContext, prev->StealOverflowFrames());
if (overflows) {
- nsContainerFrame::ReparentFrameViewList(*overflows, prev, this);
-
mFrames.InsertFrames(this, nullptr, std::move(*overflows));
}
}
diff --git a/layout/generic/nsContainerFrame.cpp b/layout/generic/nsContainerFrame.cpp
@@ -593,125 +593,6 @@ void nsContainerFrame::PositionFrameView(nsIFrame* aKidFrame) {
vm->MoveViewTo(view, pt.x, pt.y);
}
-void nsContainerFrame::ReparentFrameView(nsIFrame* aChildFrame,
- nsIFrame* aOldParentFrame,
- nsIFrame* aNewParentFrame) {
-#ifdef DEBUG
- MOZ_ASSERT(aChildFrame, "null child frame pointer");
- MOZ_ASSERT(aOldParentFrame, "null old parent frame pointer");
- MOZ_ASSERT(aNewParentFrame, "null new parent frame pointer");
- MOZ_ASSERT(aOldParentFrame != aNewParentFrame,
- "same old and new parent frame");
-
- // See if either the old parent frame or the new parent frame have a view
- while (!aOldParentFrame->GetView() && !aNewParentFrame->GetView()) {
- // Walk up both the old parent frame and the new parent frame nodes
- // stopping when we either find a common parent or views for one
- // or both of the frames.
- //
- // This works well in the common case where we push/pull and the old parent
- // frame and the new parent frame are part of the same flow. They will
- // typically be the same distance (height wise) from the
- aOldParentFrame = aOldParentFrame->GetParent();
- aNewParentFrame = aNewParentFrame->GetParent();
-
- // We should never walk all the way to the root frame without finding
- // a view
- NS_ASSERTION(aOldParentFrame && aNewParentFrame, "didn't find view");
-
- // See if we reached a common ancestor
- if (aOldParentFrame == aNewParentFrame) {
- break;
- }
- }
-
- // See if we found a common parent frame
- if (aOldParentFrame == aNewParentFrame) {
- // We found a common parent and there are no views between the old parent
- // and the common parent or the new parent frame and the common parent.
- // Because neither the old parent frame nor the new parent frame have views,
- // then any child views don't need reparenting
- return;
- }
-
- // We found views for one or both of the ancestor frames before we
- // found a common ancestor.
- nsView* oldParentView = aOldParentFrame->GetClosestView();
- nsView* newParentView = aNewParentFrame->GetClosestView();
-
- // See if the old parent frame and the new parent frame are in the
- // same view sub-hierarchy. If they are then we don't have to do
- // anything
- if (oldParentView != newParentView) {
- MOZ_ASSERT_UNREACHABLE("can't move frames between views");
- // They're not so we need to reparent any child views
- aChildFrame->ReparentFrameViewTo(oldParentView->GetViewManager(),
- newParentView);
- }
-#endif
-}
-
-void nsContainerFrame::ReparentFrameViewList(const nsFrameList& aChildFrameList,
- nsIFrame* aOldParentFrame,
- nsIFrame* aNewParentFrame) {
-#ifdef DEBUG
- MOZ_ASSERT(aChildFrameList.NotEmpty(), "empty child frame list");
- MOZ_ASSERT(aOldParentFrame, "null old parent frame pointer");
- MOZ_ASSERT(aNewParentFrame, "null new parent frame pointer");
- MOZ_ASSERT(aOldParentFrame != aNewParentFrame,
- "same old and new parent frame");
-
- // See if either the old parent frame or the new parent frame have a view
- while (!aOldParentFrame->GetView() && !aNewParentFrame->GetView()) {
- // Walk up both the old parent frame and the new parent frame nodes
- // stopping when we either find a common parent or views for one
- // or both of the frames.
- //
- // This works well in the common case where we push/pull and the old parent
- // frame and the new parent frame are part of the same flow. They will
- // typically be the same distance (height wise) from the
- aOldParentFrame = aOldParentFrame->GetParent();
- aNewParentFrame = aNewParentFrame->GetParent();
-
- // We should never walk all the way to the root frame without finding
- // a view
- NS_ASSERTION(aOldParentFrame && aNewParentFrame, "didn't find view");
-
- // See if we reached a common ancestor
- if (aOldParentFrame == aNewParentFrame) {
- break;
- }
- }
-
- // See if we found a common parent frame
- if (aOldParentFrame == aNewParentFrame) {
- // We found a common parent and there are no views between the old parent
- // and the common parent or the new parent frame and the common parent.
- // Because neither the old parent frame nor the new parent frame have views,
- // then any child views don't need reparenting
- return;
- }
-
- // We found views for one or both of the ancestor frames before we
- // found a common ancestor.
- nsView* oldParentView = aOldParentFrame->GetClosestView();
- nsView* newParentView = aNewParentFrame->GetClosestView();
-
- // See if the old parent frame and the new parent frame are in the
- // same view sub-hierarchy. If they are then we don't have to do
- // anything
- if (oldParentView != newParentView) {
- MOZ_ASSERT_UNREACHABLE("can't move frames between views");
- nsViewManager* viewManager = oldParentView->GetViewManager();
-
- // They're not so we need to reparent any child views
- for (nsIFrame* f : aChildFrameList) {
- f->ReparentFrameViewTo(viewManager, newParentView);
- }
- }
-#endif
-}
-
void nsContainerFrame::ReparentFrame(nsIFrame* aFrame,
nsContainerFrame* aOldParent,
nsContainerFrame* aNewParent) {
@@ -719,10 +600,6 @@ void nsContainerFrame::ReparentFrame(nsIFrame* aFrame,
"Parent not consistent with expectations");
aFrame->SetParent(aNewParent);
-
- // When pushing and pulling frames we need to check for whether any
- // views need to be reparented
- ReparentFrameView(aFrame, aOldParent, aNewParent);
}
void nsContainerFrame::ReparentFrames(nsFrameList& aFrameList,
@@ -1798,10 +1675,6 @@ bool nsContainerFrame::MoveOverflowToChildList() {
// Tables are special; they can have repeated header/footer
// frames on mFrames at this point.
NS_ASSERTION(mFrames.IsEmpty() || IsTableFrame(), "bad overflow list");
- // When pushing and pulling frames we need to check for whether any
- // views need to be reparented.
- nsContainerFrame::ReparentFrameViewList(*prevOverflowFrames, prevInFlow,
- this);
mFrames.AppendFrames(this, std::move(*prevOverflowFrames));
result = true;
}
@@ -1971,10 +1844,6 @@ bool nsContainerFrame::MoveInlineOverflowToChildList(nsIFrame* aLineContainer) {
ReparentFloatsForInlineChild(aLineContainer,
prevOverflowFrames->FirstChild(), true);
}
- // When pushing and pulling frames we need to check for whether
- // any views need to be reparented.
- nsContainerFrame::ReparentFrameViewList(*prevOverflowFrames, prevInFlow,
- this);
// Prepend overflow frames to the list.
mFrames.InsertFrames(this, nullptr, std::move(*prevOverflowFrames));
result = true;
@@ -2026,7 +1895,6 @@ nsFrameList* nsContainerFrame::DrainExcessOverflowContainersList(
prev->StealExcessOverflowContainers());
if (excessFrames) {
excessFrames->ApplySetParent(this);
- nsContainerFrame::ReparentFrameViewList(*excessFrames, prev, this);
if (overflowContainers) {
// The default merge function is AppendFrames, so we use excessFrames as
// the destination and then assign the result to overflowContainers.
@@ -2118,9 +1986,6 @@ nsIFrame* nsContainerFrame::PullNextInFlowChild(
// Move the frame to the principal frame list of this container
mFrames.AppendFrame(this, frame);
- // AppendFrame has reparented the frame, we need
- // to reparent the frame view then.
- nsContainerFrame::ReparentFrameView(frame, nextInFlow, this);
}
return frame;
}
@@ -2879,8 +2744,6 @@ nsresult nsOverflowContinuationTracker::Insert(nsIFrame* aOverflowCont,
SetUpListWalker();
}
if (aOverflowCont->GetParent() != mParent) {
- nsContainerFrame::ReparentFrameView(aOverflowCont,
- aOverflowCont->GetParent(), mParent);
reparented = true;
}
diff --git a/layout/generic/nsContainerFrame.h b/layout/generic/nsContainerFrame.h
@@ -153,14 +153,6 @@ class nsContainerFrame : public nsSplittableFrame {
// Positions the frame's view based on the frame's origin
static void PositionFrameView(nsIFrame* aKidFrame);
- static void ReparentFrameView(nsIFrame* aChildFrame,
- nsIFrame* aOldParentFrame,
- nsIFrame* aNewParentFrame);
-
- static void ReparentFrameViewList(const nsFrameList& aChildFrameList,
- nsIFrame* aOldParentFrame,
- nsIFrame* aNewParentFrame);
-
/**
* Reparent aFrame from aOldParent to aNewParent.
*/
diff --git a/layout/generic/nsFirstLetterFrame.cpp b/layout/generic/nsFirstLetterFrame.cpp
@@ -437,11 +437,6 @@ void nsFirstLetterFrame::DrainOverflowFrames(nsPresContext* aPresContext) {
prevInFlow->StealOverflowFrames());
if (overflowFrames) {
NS_ASSERTION(mFrames.IsEmpty(), "bad overflow list");
-
- // When pushing and pulling frames we need to check for whether any
- // views need to be reparented.
- nsContainerFrame::ReparentFrameViewList(*overflowFrames, prevInFlow,
- this);
mFrames.InsertFrames(this, nullptr, std::move(*overflowFrames));
}
}
diff --git a/layout/generic/nsIFrame.cpp b/layout/generic/nsIFrame.cpp
@@ -1517,32 +1517,6 @@ void nsIFrame::AssertNewStyleIsSane(ComputedStyle& aNewStyle) {
}
#endif
-void nsIFrame::ReparentFrameViewTo(nsViewManager* aViewManager,
- nsView* aNewParentView) {
- if (auto* view = GetView()) {
- if (IsMenuPopupFrame()) {
- // This view must be parented by the root view, don't reparent it.
- return;
- }
- aViewManager->RemoveChild(view);
-
- // The view will remember the Z-order and other attributes that have been
- // set on it.
- nsView* insertBefore =
- nsLayoutUtils::FindSiblingViewFor(aNewParentView, this);
- aViewManager->InsertChild(aNewParentView, view, insertBefore,
- insertBefore != nullptr);
- } else if (HasAnyStateBits(NS_FRAME_HAS_CHILD_WITH_VIEW)) {
- for (const auto& childList : ChildLists()) {
- // Iterate the child frames, and check each child frame to see if it has
- // a view
- for (nsIFrame* child : childList.mList) {
- child->ReparentFrameViewTo(aViewManager, aNewParentView);
- }
- }
- }
-}
-
void nsIFrame::SyncFrameViewProperties(nsView* aView) {
if (!aView) {
aView = GetView();
diff --git a/layout/generic/nsIFrame.h b/layout/generic/nsIFrame.h
@@ -851,7 +851,6 @@ class nsIFrame : public nsQueryFrame {
template <class Source>
friend class do_QueryFrameHelper; // to read mClass
friend class nsBlockFrame; // for GetCaretBaseline
- friend class nsContainerFrame; // for ReparentFrameViewTo
virtual ~nsIFrame();
@@ -5222,11 +5221,6 @@ class nsIFrame : public nsQueryFrame {
void HandleLastRememberedSize();
protected:
- /**
- * Reparent this frame's view if it has one.
- */
- void ReparentFrameViewTo(nsViewManager* aViewManager, nsView* aNewParentView);
-
// Members
nsRect mRect;
nsCOMPtr<nsIContent> mContent;
diff --git a/layout/generic/nsInlineFrame.cpp b/layout/generic/nsInlineFrame.cpp
@@ -315,11 +315,6 @@ void nsInlineFrame::Reflow(nsPresContext* aPresContext,
AutoFrameListPtr prevOverflowFrames(aPresContext,
prevInFlow->StealOverflowFrames());
if (prevOverflowFrames) {
- // When pushing and pulling frames we need to check for whether any
- // views need to be reparented.
- nsContainerFrame::ReparentFrameViewList(*prevOverflowFrames, prevInFlow,
- this);
-
// Check if we should do the lazilySetParentPointer optimization.
// Only do it in simple cases where we're being reflowed for the
// first time, nothing (e.g. bidi resolution) has already given
@@ -459,9 +454,6 @@ void nsInlineFrame::PullOverflowsFromPrevInFlow() {
AutoFrameListPtr prevOverflowFrames(presContext,
prevInFlow->StealOverflowFrames());
if (prevOverflowFrames) {
- // Assume that our prev-in-flow has the same line container that we do.
- nsContainerFrame::ReparentFrameViewList(*prevOverflowFrames, prevInFlow,
- this);
mFrames.InsertFrames(this, nullptr, std::move(*prevOverflowFrames));
}
}
@@ -786,7 +778,6 @@ nsIFrame* nsInlineFrame::PullOneFrame(nsPresContext* aPresContext,
if (irs.mLineLayout) {
irs.mLineLayout->SetDirtyNextLine();
}
- nsContainerFrame::ReparentFrameView(frame, nextInFlow, this);
break;
}
nextInFlow = static_cast<nsInlineFrame*>(nextInFlow->GetNextInFlow());
diff --git a/layout/generic/nsSubDocumentFrame.cpp b/layout/generic/nsSubDocumentFrame.cpp
@@ -231,16 +231,6 @@ void nsSubDocumentFrame::CreateView() {
viewManager->InsertChild(parentView, view, insertBefore,
insertBefore != nullptr);
- // REVIEW: Don't create a widget for fixed-pos elements anymore.
- // ComputeRepaintRegionForCopy will calculate the right area to repaint
- // when we scroll.
- // Reparent views on any child frames (or their descendants) to this
- // view. We can just call ReparentFrameViewTo on this frame because
- // we know this frame has no view, so it will crawl the children. Also,
- // we know that any descendants with views must have 'parentView' as their
- // parent view.
- ReparentFrameViewTo(viewManager, view);
-
// Remember our view
SetView(view);