From 77ba6cde90a52bb31174fab2bc9ca764292cb0ce Mon Sep 17 00:00:00 2001 From: Narcis Beleuzu Date: Thu, 7 Sep 2023 02:42:25 +0300 Subject: [PATCH] Backed out changeset 55052ae7d067 (bug 1851868) for reftest failure on 1153695.html . CLOSED TREE --- layout/base/nsFrameManager.cpp | 3 +- layout/forms/nsColorControlFrame.cpp | 7 +- layout/forms/nsColorControlFrame.h | 3 +- layout/forms/nsComboboxControlFrame.cpp | 9 +- layout/forms/nsComboboxControlFrame.h | 4 +- layout/forms/nsFileControlFrame.cpp | 9 +- layout/forms/nsFileControlFrame.h | 3 +- layout/forms/nsGfxButtonControlFrame.cpp | 7 +- layout/forms/nsGfxButtonControlFrame.h | 3 +- layout/forms/nsListControlFrame.cpp | 5 +- layout/forms/nsListControlFrame.h | 3 +- layout/forms/nsMeterFrame.cpp | 7 +- layout/forms/nsMeterFrame.h | 3 +- layout/forms/nsNumberControlFrame.cpp | 7 +- layout/forms/nsNumberControlFrame.h | 2 +- layout/forms/nsProgressFrame.cpp | 7 +- layout/forms/nsProgressFrame.h | 3 +- layout/forms/nsRangeFrame.cpp | 11 +-- layout/forms/nsRangeFrame.h | 3 +- layout/forms/nsSearchControlFrame.cpp | 7 +- layout/forms/nsSearchControlFrame.h | 3 +- layout/forms/nsTextControlFrame.cpp | 13 +-- layout/forms/nsTextControlFrame.h | 16 ++-- layout/generic/MiddleCroppingBlockFrame.cpp | 7 +- layout/generic/MiddleCroppingBlockFrame.h | 3 +- layout/generic/nsAbsoluteContainingBlock.cpp | 6 +- layout/generic/nsAbsoluteContainingBlock.h | 5 +- layout/generic/nsBlockFrame.cpp | 52 +++++------ layout/generic/nsBlockFrame.h | 21 +++-- layout/generic/nsCanvasFrame.cpp | 9 +- layout/generic/nsCanvasFrame.h | 3 +- layout/generic/nsContainerFrame.cpp | 47 +++++----- layout/generic/nsContainerFrame.h | 28 +++--- layout/generic/nsFrameList.cpp | 13 +-- layout/generic/nsFrameList.h | 19 +++-- layout/generic/nsGfxScrollFrame.cpp | 15 ++-- layout/generic/nsGfxScrollFrame.h | 2 +- layout/generic/nsHTMLCanvasFrame.cpp | 5 +- layout/generic/nsHTMLCanvasFrame.h | 2 +- layout/generic/nsIFrame.cpp | 20 +++-- layout/generic/nsIFrame.h | 90 ++++++++++---------- layout/generic/nsImageFrame.cpp | 5 +- layout/generic/nsImageFrame.h | 2 +- layout/generic/nsInlineFrame.cpp | 5 +- layout/generic/nsInlineFrame.h | 4 +- layout/generic/nsLineBox.cpp | 5 +- layout/generic/nsLineBox.h | 5 +- layout/generic/nsPlaceholderFrame.cpp | 11 +-- layout/generic/nsPlaceholderFrame.h | 3 +- layout/generic/nsRubyFrame.cpp | 3 +- layout/generic/nsSplittableFrame.cpp | 5 +- layout/generic/nsSplittableFrame.h | 3 +- layout/generic/nsSubDocumentFrame.cpp | 5 +- layout/generic/nsSubDocumentFrame.h | 3 +- layout/generic/nsTextFrame.cpp | 16 ++-- layout/generic/nsTextFrame.h | 3 +- layout/generic/nsVideoFrame.cpp | 9 +- layout/generic/nsVideoFrame.h | 3 +- layout/mathml/nsMathMLmunderoverFrame.cpp | 5 +- layout/mathml/nsMathMLmunderoverFrame.h | 2 +- layout/svg/SVGFEImageFrame.cpp | 8 +- layout/svg/SVGImageFrame.cpp | 5 +- layout/svg/SVGImageFrame.h | 4 +- layout/svg/SVGOuterSVGFrame.cpp | 5 +- layout/svg/SVGOuterSVGFrame.h | 3 +- layout/tables/nsTableCellFrame.cpp | 8 +- layout/tables/nsTableCellFrame.h | 3 +- layout/tables/nsTableFrame.cpp | 7 +- layout/tables/nsTableFrame.h | 3 +- layout/tables/nsTableRowFrame.cpp | 8 +- layout/tables/nsTableRowFrame.h | 3 +- layout/tables/nsTableRowGroupFrame.cpp | 8 +- layout/tables/nsTableRowGroupFrame.h | 3 +- layout/tables/nsTableWrapperFrame.cpp | 9 +- layout/tables/nsTableWrapperFrame.h | 3 +- layout/xul/nsMenuPopupFrame.cpp | 5 +- layout/xul/nsMenuPopupFrame.h | 3 +- layout/xul/nsScrollbarButtonFrame.cpp | 5 +- layout/xul/nsScrollbarButtonFrame.h | 3 +- layout/xul/nsScrollbarFrame.cpp | 15 ++-- layout/xul/nsScrollbarFrame.h | 3 +- layout/xul/nsSliderFrame.cpp | 5 +- layout/xul/nsSliderFrame.h | 3 +- layout/xul/nsSplitterFrame.cpp | 5 +- layout/xul/nsSplitterFrame.h | 3 +- layout/xul/tree/nsTreeBodyFrame.cpp | 5 +- layout/xul/tree/nsTreeBodyFrame.h | 3 +- 87 files changed, 409 insertions(+), 311 deletions(-) diff --git a/layout/base/nsFrameManager.cpp b/layout/base/nsFrameManager.cpp index 8c5204672a07..75f1c6327318 100644 --- a/layout/base/nsFrameManager.cpp +++ b/layout/base/nsFrameManager.cpp @@ -50,8 +50,7 @@ void nsFrameManager::Destroy() { mPresShell->SetIgnoreFrameDestruction(true); if (mRootFrame) { - FrameDestroyContext context(mRootFrame); - mRootFrame->Destroy(context); + mRootFrame->Destroy(); mRootFrame = nullptr; } diff --git a/layout/forms/nsColorControlFrame.cpp b/layout/forms/nsColorControlFrame.cpp index f921016d0605..038c08a60e19 100644 --- a/layout/forms/nsColorControlFrame.cpp +++ b/layout/forms/nsColorControlFrame.cpp @@ -38,9 +38,10 @@ NS_QUERYFRAME_HEAD(nsColorControlFrame) NS_QUERYFRAME_ENTRY(nsIAnonymousContentCreator) NS_QUERYFRAME_TAIL_INHERITING(nsHTMLButtonControlFrame) -void nsColorControlFrame::Destroy(DestroyContext& aContext) { - aContext.AddAnonymousContent(mColorContent.forget()); - nsHTMLButtonControlFrame::Destroy(aContext); +void nsColorControlFrame::DestroyFrom(nsIFrame* aDestructRoot, + PostDestroyData& aPostDestroyData) { + aPostDestroyData.AddAnonymousContent(mColorContent.forget()); + nsHTMLButtonControlFrame::DestroyFrom(aDestructRoot, aPostDestroyData); } #ifdef DEBUG_FRAME_DUMP diff --git a/layout/forms/nsColorControlFrame.h b/layout/forms/nsColorControlFrame.h index a85816324f80..bd454284b810 100644 --- a/layout/forms/nsColorControlFrame.h +++ b/layout/forms/nsColorControlFrame.h @@ -27,7 +27,8 @@ class nsColorControlFrame final : public nsHTMLButtonControlFrame, friend nsIFrame* NS_NewColorControlFrame(mozilla::PresShell* aPresShell, ComputedStyle* aStyle); - void Destroy(DestroyContext&) override; + virtual void DestroyFrom(nsIFrame* aDestructRoot, + PostDestroyData& aPostDestroyData) override; NS_DECL_QUERYFRAME NS_DECL_FRAMEARENA_HELPERS(nsColorControlFrame) diff --git a/layout/forms/nsComboboxControlFrame.cpp b/layout/forms/nsComboboxControlFrame.cpp index ea27a20d3d90..38143c41e168 100644 --- a/layout/forms/nsComboboxControlFrame.cpp +++ b/layout/forms/nsComboboxControlFrame.cpp @@ -845,16 +845,17 @@ nsIFrame* nsComboboxControlFrame::CreateFrameForDisplayNode() { return mDisplayFrame; } -void nsComboboxControlFrame::Destroy(DestroyContext& aContext) { +void nsComboboxControlFrame::DestroyFrom(nsIFrame* aDestructRoot, + PostDestroyData& aPostDestroyData) { // Revoke any pending RedisplayTextEvent mRedisplayTextEvent.Revoke(); mEventListener->Detach(); // Cleanup frames in popup child list - aContext.AddAnonymousContent(mDisplayContent.forget()); - aContext.AddAnonymousContent(mButtonContent.forget()); - nsBlockFrame::Destroy(aContext); + aPostDestroyData.AddAnonymousContent(mDisplayContent.forget()); + aPostDestroyData.AddAnonymousContent(mButtonContent.forget()); + nsBlockFrame::DestroyFrom(aDestructRoot, aPostDestroyData); } const nsFrameList& nsComboboxControlFrame::GetChildList( diff --git a/layout/forms/nsComboboxControlFrame.h b/layout/forms/nsComboboxControlFrame.h index a34652bebef5..434106636ebb 100644 --- a/layout/forms/nsComboboxControlFrame.h +++ b/layout/forms/nsComboboxControlFrame.h @@ -105,8 +105,8 @@ class nsComboboxControlFrame final : public nsBlockFrame, #ifdef DEBUG_FRAME_DUMP nsresult GetFrameName(nsAString& aResult) const final; #endif - void Destroy(DestroyContext&) final; - + void DestroyFrom(nsIFrame* aDestructRoot, + PostDestroyData& aPostDestroyData) final; void SetInitialChildList(ChildListID aListID, nsFrameList&& aChildList) final; const nsFrameList& GetChildList(ChildListID aListID) const final; void GetChildLists(nsTArray* aLists) const final; diff --git a/layout/forms/nsFileControlFrame.cpp b/layout/forms/nsFileControlFrame.cpp index d987a91e07ac..cdbf266e1e43 100644 --- a/layout/forms/nsFileControlFrame.cpp +++ b/layout/forms/nsFileControlFrame.cpp @@ -59,7 +59,8 @@ void nsFileControlFrame::Init(nsIContent* aContent, nsContainerFrame* aParent, mMouseListener = new DnDListener(this); } -void nsFileControlFrame::Destroy(DestroyContext& aContext) { +void nsFileControlFrame::DestroyFrom(nsIFrame* aDestructRoot, + PostDestroyData& aPostDestroyData) { NS_ENSURE_TRUE_VOID(mContent); // Remove the events. @@ -68,11 +69,11 @@ void nsFileControlFrame::Destroy(DestroyContext& aContext) { mContent->RemoveSystemEventListener(u"dragover"_ns, mMouseListener, false); } - aContext.AddAnonymousContent(mTextContent.forget()); - aContext.AddAnonymousContent(mBrowseFilesOrDirs.forget()); + aPostDestroyData.AddAnonymousContent(mTextContent.forget()); + aPostDestroyData.AddAnonymousContent(mBrowseFilesOrDirs.forget()); mMouseListener->ForgetFrame(); - nsBlockFrame::Destroy(aContext); + nsBlockFrame::DestroyFrom(aDestructRoot, aPostDestroyData); } static already_AddRefed MakeAnonButton( diff --git a/layout/forms/nsFileControlFrame.h b/layout/forms/nsFileControlFrame.h index 085cab98a357..b8a8469a6818 100644 --- a/layout/forms/nsFileControlFrame.h +++ b/layout/forms/nsFileControlFrame.h @@ -39,7 +39,8 @@ class nsFileControlFrame final : public nsBlockFrame, nsresult SetFormProperty(nsAtom* aName, const nsAString& aValue) override; void SetFocus(bool aOn, bool aRepaint) override; - void Destroy(DestroyContext&) override; + void DestroyFrom(nsIFrame* aDestructRoot, + PostDestroyData& aPostDestroyData) override; #ifdef DEBUG_FRAME_DUMP nsresult GetFrameName(nsAString& aResult) const override; diff --git a/layout/forms/nsGfxButtonControlFrame.cpp b/layout/forms/nsGfxButtonControlFrame.cpp index 37aa996c27c9..06b27bae945d 100644 --- a/layout/forms/nsGfxButtonControlFrame.cpp +++ b/layout/forms/nsGfxButtonControlFrame.cpp @@ -26,9 +26,10 @@ nsContainerFrame* NS_NewGfxButtonControlFrame(PresShell* aPresShell, NS_IMPL_FRAMEARENA_HELPERS(nsGfxButtonControlFrame) -void nsGfxButtonControlFrame::Destroy(DestroyContext& aContext) { - aContext.AddAnonymousContent(mTextContent.forget()); - nsHTMLButtonControlFrame::Destroy(aContext); +void nsGfxButtonControlFrame::DestroyFrom(nsIFrame* aDestructRoot, + PostDestroyData& aPostDestroyData) { + aPostDestroyData.AddAnonymousContent(mTextContent.forget()); + nsHTMLButtonControlFrame::DestroyFrom(aDestructRoot, aPostDestroyData); } #ifdef DEBUG_FRAME_DUMP diff --git a/layout/forms/nsGfxButtonControlFrame.h b/layout/forms/nsGfxButtonControlFrame.h index b9e1b409843f..222c3c0b3d7a 100644 --- a/layout/forms/nsGfxButtonControlFrame.h +++ b/layout/forms/nsGfxButtonControlFrame.h @@ -27,7 +27,8 @@ class nsGfxButtonControlFrame final : public nsHTMLButtonControlFrame, explicit nsGfxButtonControlFrame(ComputedStyle* aStyle, nsPresContext* aPresContext); - void Destroy(DestroyContext&) override; + virtual void DestroyFrom(nsIFrame* aDestructRoot, + PostDestroyData& aPostDestroyData) override; virtual nsresult HandleEvent(nsPresContext* aPresContext, mozilla::WidgetGUIEvent* aEvent, diff --git a/layout/forms/nsListControlFrame.cpp b/layout/forms/nsListControlFrame.cpp index 44ce9fde1324..f3c7008134c0 100644 --- a/layout/forms/nsListControlFrame.cpp +++ b/layout/forms/nsListControlFrame.cpp @@ -77,7 +77,8 @@ Maybe nsListControlFrame::GetNaturalBaselineBOffset( return Nothing{}; } // for Bug 47302 (remove this comment later) -void nsListControlFrame::Destroy(DestroyContext& aContext) { +void nsListControlFrame::DestroyFrom(nsIFrame* aDestructRoot, + PostDestroyData& aPostDestroyData) { // get the receiver interface from the browser button's content node NS_ENSURE_TRUE_VOID(mContent); @@ -85,7 +86,7 @@ void nsListControlFrame::Destroy(DestroyContext& aContext) { // event listener can outlive the frame. mEventListener->Detach(); - nsHTMLScrollFrame::Destroy(aContext); + nsHTMLScrollFrame::DestroyFrom(aDestructRoot, aPostDestroyData); } void nsListControlFrame::BuildDisplayList(nsDisplayListBuilder* aBuilder, diff --git a/layout/forms/nsListControlFrame.h b/layout/forms/nsListControlFrame.h index f0c6d2d6651f..7a9ade08e9bd 100644 --- a/layout/forms/nsListControlFrame.h +++ b/layout/forms/nsListControlFrame.h @@ -77,7 +77,8 @@ class nsListControlFrame final : public nsHTMLScrollFrame, void DidReflow(nsPresContext* aPresContext, const ReflowInput* aReflowInput) final; - void Destroy(DestroyContext&) override; + void DestroyFrom(nsIFrame* aDestructRoot, + PostDestroyData& aPostDestroyData) final; void BuildDisplayList(nsDisplayListBuilder* aBuilder, const nsDisplayListSet& aLists) final; diff --git a/layout/forms/nsMeterFrame.cpp b/layout/forms/nsMeterFrame.cpp index 76e569226c7b..400c1d74a2db 100644 --- a/layout/forms/nsMeterFrame.cpp +++ b/layout/forms/nsMeterFrame.cpp @@ -38,12 +38,13 @@ nsMeterFrame::nsMeterFrame(ComputedStyle* aStyle, nsPresContext* aPresContext) nsMeterFrame::~nsMeterFrame() = default; -void nsMeterFrame::Destroy(DestroyContext& aContext) { +void nsMeterFrame::DestroyFrom(nsIFrame* aDestructRoot, + PostDestroyData& aPostDestroyData) { NS_ASSERTION(!GetPrevContinuation(), "nsMeterFrame should not have continuations; if it does we " "need to call RegUnregAccessKey only for the first."); - aContext.AddAnonymousContent(mBarDiv.forget()); - nsContainerFrame::Destroy(aContext); + aPostDestroyData.AddAnonymousContent(mBarDiv.forget()); + nsContainerFrame::DestroyFrom(aDestructRoot, aPostDestroyData); } nsresult nsMeterFrame::CreateAnonymousContent( diff --git a/layout/forms/nsMeterFrame.h b/layout/forms/nsMeterFrame.h index fb6200a4cd82..04fd4634ac02 100644 --- a/layout/forms/nsMeterFrame.h +++ b/layout/forms/nsMeterFrame.h @@ -26,7 +26,8 @@ class nsMeterFrame final : public nsContainerFrame, explicit nsMeterFrame(ComputedStyle* aStyle, nsPresContext* aPresContext); virtual ~nsMeterFrame(); - void Destroy(DestroyContext&) override; + virtual void DestroyFrom(nsIFrame* aDestructRoot, + PostDestroyData& aPostDestroyData) override; virtual void Reflow(nsPresContext* aCX, ReflowOutput& aDesiredSize, const ReflowInput& aReflowInput, diff --git a/layout/forms/nsNumberControlFrame.cpp b/layout/forms/nsNumberControlFrame.cpp index e8ed87c8f3d5..6a742526dc28 100644 --- a/layout/forms/nsNumberControlFrame.cpp +++ b/layout/forms/nsNumberControlFrame.cpp @@ -41,9 +41,10 @@ nsNumberControlFrame::nsNumberControlFrame(ComputedStyle* aStyle, nsPresContext* aPresContext) : nsTextControlFrame(aStyle, aPresContext, kClassID) {} -void nsNumberControlFrame::Destroy(DestroyContext& aContext) { - aContext.AddAnonymousContent(mSpinBox.forget()); - nsTextControlFrame::Destroy(aContext); +void nsNumberControlFrame::DestroyFrom(nsIFrame* aDestructRoot, + PostDestroyData& aPostDestroyData) { + aPostDestroyData.AddAnonymousContent(mSpinBox.forget()); + nsTextControlFrame::DestroyFrom(aDestructRoot, aPostDestroyData); } nsresult nsNumberControlFrame::CreateAnonymousContent( diff --git a/layout/forms/nsNumberControlFrame.h b/layout/forms/nsNumberControlFrame.h index d7201ea1e13c..f8437f49f76c 100644 --- a/layout/forms/nsNumberControlFrame.h +++ b/layout/forms/nsNumberControlFrame.h @@ -49,7 +49,7 @@ class nsNumberControlFrame final : public nsTextControlFrame { NS_DECL_QUERYFRAME NS_DECL_FRAMEARENA_HELPERS(nsNumberControlFrame) - void Destroy(DestroyContext&) override; + void DestroyFrom(nsIFrame* aDestructRoot, PostDestroyData&) override; #ifdef ACCESSIBILITY mozilla::a11y::AccType AccessibleType() override; diff --git a/layout/forms/nsProgressFrame.cpp b/layout/forms/nsProgressFrame.cpp index e91a7be62c11..2f638cdaacd8 100644 --- a/layout/forms/nsProgressFrame.cpp +++ b/layout/forms/nsProgressFrame.cpp @@ -37,12 +37,13 @@ nsProgressFrame::nsProgressFrame(ComputedStyle* aStyle, nsProgressFrame::~nsProgressFrame() = default; -void nsProgressFrame::Destroy(DestroyContext& aContext) { +void nsProgressFrame::DestroyFrom(nsIFrame* aDestructRoot, + PostDestroyData& aPostDestroyData) { NS_ASSERTION(!GetPrevContinuation(), "nsProgressFrame should not have continuations; if it does we " "need to call RegUnregAccessKey only for the first."); - aContext.AddAnonymousContent(mBarDiv.forget()); - nsContainerFrame::Destroy(aContext); + aPostDestroyData.AddAnonymousContent(mBarDiv.forget()); + nsContainerFrame::DestroyFrom(aDestructRoot, aPostDestroyData); } nsresult nsProgressFrame::CreateAnonymousContent( diff --git a/layout/forms/nsProgressFrame.h b/layout/forms/nsProgressFrame.h index 5f4e604313c8..2e14fda10947 100644 --- a/layout/forms/nsProgressFrame.h +++ b/layout/forms/nsProgressFrame.h @@ -28,7 +28,8 @@ class nsProgressFrame final : public nsContainerFrame, explicit nsProgressFrame(ComputedStyle* aStyle, nsPresContext* aPresContext); virtual ~nsProgressFrame(); - void Destroy(DestroyContext&) override; + virtual void DestroyFrom(nsIFrame* aDestructRoot, + PostDestroyData& aPostDestroyData) override; virtual void BuildDisplayList(nsDisplayListBuilder* aBuilder, const nsDisplayListSet& aLists) override; diff --git a/layout/forms/nsRangeFrame.cpp b/layout/forms/nsRangeFrame.cpp index 54bbffdea279..c5db5ba51af7 100644 --- a/layout/forms/nsRangeFrame.cpp +++ b/layout/forms/nsRangeFrame.cpp @@ -69,7 +69,8 @@ NS_QUERYFRAME_HEAD(nsRangeFrame) NS_QUERYFRAME_ENTRY(nsIAnonymousContentCreator) NS_QUERYFRAME_TAIL_INHERITING(nsContainerFrame) -void nsRangeFrame::Destroy(DestroyContext& aContext) { +void nsRangeFrame::DestroyFrom(nsIFrame* aDestructRoot, + PostDestroyData& aPostDestroyData) { NS_ASSERTION(!GetPrevContinuation() && !GetNextContinuation(), "nsRangeFrame should not have continuations; if it does we " "need to call RegUnregAccessKey only for the first."); @@ -77,10 +78,10 @@ void nsRangeFrame::Destroy(DestroyContext& aContext) { if (mListMutationObserver) { mListMutationObserver->Detach(); } - aContext.AddAnonymousContent(mTrackDiv.forget()); - aContext.AddAnonymousContent(mProgressDiv.forget()); - aContext.AddAnonymousContent(mThumbDiv.forget()); - nsContainerFrame::Destroy(aContext); + aPostDestroyData.AddAnonymousContent(mTrackDiv.forget()); + aPostDestroyData.AddAnonymousContent(mProgressDiv.forget()); + aPostDestroyData.AddAnonymousContent(mThumbDiv.forget()); + nsContainerFrame::DestroyFrom(aDestructRoot, aPostDestroyData); } nsresult nsRangeFrame::MakeAnonymousDiv(Element** aResult, diff --git a/layout/forms/nsRangeFrame.h b/layout/forms/nsRangeFrame.h index 7e41f1a3f005..4c153d93ecd3 100644 --- a/layout/forms/nsRangeFrame.h +++ b/layout/forms/nsRangeFrame.h @@ -48,7 +48,8 @@ class nsRangeFrame final : public nsContainerFrame, NS_DECL_FRAMEARENA_HELPERS(nsRangeFrame) // nsIFrame overrides - void Destroy(DestroyContext&) override; + virtual void DestroyFrom(nsIFrame* aDestructRoot, + PostDestroyData& aPostDestroyData) override; void BuildDisplayList(nsDisplayListBuilder* aBuilder, const nsDisplayListSet& aLists) override; diff --git a/layout/forms/nsSearchControlFrame.cpp b/layout/forms/nsSearchControlFrame.cpp index e9249cca77bf..02480d4eaa0f 100644 --- a/layout/forms/nsSearchControlFrame.cpp +++ b/layout/forms/nsSearchControlFrame.cpp @@ -39,9 +39,10 @@ nsSearchControlFrame::nsSearchControlFrame(ComputedStyle* aStyle, nsPresContext* aPresContext) : nsTextControlFrame(aStyle, aPresContext, kClassID) {} -void nsSearchControlFrame::Destroy(DestroyContext& aContext) { - aContext.AddAnonymousContent(mClearButton.forget()); - nsTextControlFrame::Destroy(aContext); +void nsSearchControlFrame::DestroyFrom(nsIFrame* aDestructRoot, + PostDestroyData& aPostDestroyData) { + aPostDestroyData.AddAnonymousContent(mClearButton.forget()); + nsTextControlFrame::DestroyFrom(aDestructRoot, aPostDestroyData); } nsresult nsSearchControlFrame::CreateAnonymousContent( diff --git a/layout/forms/nsSearchControlFrame.h b/layout/forms/nsSearchControlFrame.h index 0499fa84ea51..3083821614e9 100644 --- a/layout/forms/nsSearchControlFrame.h +++ b/layout/forms/nsSearchControlFrame.h @@ -40,7 +40,8 @@ class nsSearchControlFrame final : public nsTextControlFrame { NS_DECL_QUERYFRAME NS_DECL_FRAMEARENA_HELPERS(nsSearchControlFrame) - void Destroy(DestroyContext&) override; + void DestroyFrom(nsIFrame* aDestructRoot, + PostDestroyData& aPostDestroyData) override; // nsIAnonymousContentCreator nsresult CreateAnonymousContent(nsTArray& aElements) override; diff --git a/layout/forms/nsTextControlFrame.cpp b/layout/forms/nsTextControlFrame.cpp index 9e38c7a04527..4dfb7c4b5d62 100644 --- a/layout/forms/nsTextControlFrame.cpp +++ b/layout/forms/nsTextControlFrame.cpp @@ -126,7 +126,8 @@ nsIScrollableFrame* nsTextControlFrame::GetScrollTargetFrame() const { return do_QueryFrame(mRootNode->GetPrimaryFrame()); } -void nsTextControlFrame::Destroy(DestroyContext& aContext) { +void nsTextControlFrame::DestroyFrom(nsIFrame* aDestructRoot, + PostDestroyData& aPostDestroyData) { RemoveProperty(TextControlInitializer()); // Unbind the text editor state object from the frame. The editor will live @@ -165,12 +166,12 @@ void nsTextControlFrame::Destroy(DestroyContext& aContext) { // If we're a subclass like nsNumberControlFrame, then it owns the root of the // anonymous subtree where mRootNode is. - aContext.AddAnonymousContent(mRootNode.forget()); - aContext.AddAnonymousContent(mPlaceholderDiv.forget()); - aContext.AddAnonymousContent(mPreviewDiv.forget()); - aContext.AddAnonymousContent(mRevealButton.forget()); + aPostDestroyData.AddAnonymousContent(mRootNode.forget()); + aPostDestroyData.AddAnonymousContent(mPlaceholderDiv.forget()); + aPostDestroyData.AddAnonymousContent(mPreviewDiv.forget()); + aPostDestroyData.AddAnonymousContent(mRevealButton.forget()); - nsContainerFrame::Destroy(aContext); + nsContainerFrame::DestroyFrom(aDestructRoot, aPostDestroyData); } LogicalSize nsTextControlFrame::CalcIntrinsicSize( diff --git a/layout/forms/nsTextControlFrame.h b/layout/forms/nsTextControlFrame.h index 99c5a6fd7f74..eef84aa6464b 100644 --- a/layout/forms/nsTextControlFrame.h +++ b/layout/forms/nsTextControlFrame.h @@ -49,14 +49,16 @@ class nsTextControlFrame : public nsContainerFrame, virtual ~nsTextControlFrame(); /** - * Destroy() causes preparing to destroy editor and that may cause running - * selection listeners of spellchecker selection and document state listeners. - * Not sure whether the former does something or not, but nobody should run - * content script. The latter is currently only FinderHighlighter to clean up - * its fields at destruction. Thus, the latter won't run content script too. - * Therefore, this won't run unsafe script. + * DestroyFrom() causes preparing to destroy editor and that may cause + * running selection listeners of specllchecker selection and document + * state listeners. Not sure whether the former does something or not, + * but nobody should run content script. The latter is currently only + * FinderHighlighter to clean up its fields at destruction. Thus, the + * latter won't run content script too. Therefore, this won't run + * unsafe script. */ - MOZ_CAN_RUN_SCRIPT_BOUNDARY void Destroy(DestroyContext&) override; + MOZ_CAN_RUN_SCRIPT_BOUNDARY void DestroyFrom(nsIFrame* aDestructRoot, + PostDestroyData&) override; nsIScrollableFrame* GetScrollTargetFrame() const override; diff --git a/layout/generic/MiddleCroppingBlockFrame.cpp b/layout/generic/MiddleCroppingBlockFrame.cpp index 4cbbb684aab4..a456c06e187c 100644 --- a/layout/generic/MiddleCroppingBlockFrame.cpp +++ b/layout/generic/MiddleCroppingBlockFrame.cpp @@ -210,9 +210,10 @@ void MiddleCroppingBlockFrame::AppendAnonymousContentTo( aContent.AppendElement(mTextNode); } -void MiddleCroppingBlockFrame::Destroy(DestroyContext& aContext) { - aContext.AddAnonymousContent(mTextNode.forget()); - nsBlockFrame::Destroy(aContext); +void MiddleCroppingBlockFrame::DestroyFrom(nsIFrame* aDestructRoot, + PostDestroyData& aPostDestroyData) { + aPostDestroyData.AddAnonymousContent(mTextNode.forget()); + nsBlockFrame::DestroyFrom(aDestructRoot, aPostDestroyData); } } // namespace mozilla diff --git a/layout/generic/MiddleCroppingBlockFrame.h b/layout/generic/MiddleCroppingBlockFrame.h index 666b73440e2a..0f297369dc0a 100644 --- a/layout/generic/MiddleCroppingBlockFrame.h +++ b/layout/generic/MiddleCroppingBlockFrame.h @@ -53,7 +53,8 @@ class MiddleCroppingBlockFrame : public nsBlockFrame, */ void UpdateDisplayedValue(const nsAString& aValue, bool aIsCropped, bool aNotify); - void Destroy(DestroyContext&) override; + void DestroyFrom(nsIFrame* aDestructRoot, + PostDestroyData& aPostDestroyData) override; RefPtr mTextNode; bool mCropped = false; diff --git a/layout/generic/nsAbsoluteContainingBlock.cpp b/layout/generic/nsAbsoluteContainingBlock.cpp index 742ddd55f216..296fc8deae19 100644 --- a/layout/generic/nsAbsoluteContainingBlock.cpp +++ b/layout/generic/nsAbsoluteContainingBlock.cpp @@ -396,8 +396,10 @@ bool nsAbsoluteContainingBlock::FrameDependsOnContainer(nsIFrame* f, return false; } -void nsAbsoluteContainingBlock::DestroyFrames(DestroyContext& aContext) { - mAbsoluteFrames.DestroyFrames(aContext); +void nsAbsoluteContainingBlock::DestroyFrames( + nsIFrame* aDelegatingFrame, nsIFrame* aDestructRoot, + PostDestroyData& aPostDestroyData) { + mAbsoluteFrames.DestroyFramesFrom(aDestructRoot, aPostDestroyData); } void nsAbsoluteContainingBlock::MarkSizeDependentFramesDirty() { diff --git a/layout/generic/nsAbsoluteContainingBlock.h b/layout/generic/nsAbsoluteContainingBlock.h index 64fe462acb47..2f2f872fc56f 100644 --- a/layout/generic/nsAbsoluteContainingBlock.h +++ b/layout/generic/nsAbsoluteContainingBlock.h @@ -95,8 +95,9 @@ class nsAbsoluteContainingBlock { const nsRect& aContainingBlock, AbsPosReflowFlags aFlags, mozilla::OverflowAreas* aOverflowAreas); - using DestroyContext = nsIFrame::DestroyContext; - void DestroyFrames(DestroyContext&); + using PostDestroyData = nsIFrame::PostDestroyData; + void DestroyFrames(nsIFrame* aDelegatingFrame, nsIFrame* aDestructRoot, + PostDestroyData& aPostDestroyData); bool HasAbsoluteFrames() const { return mAbsoluteFrames.NotEmpty(); } diff --git a/layout/generic/nsBlockFrame.cpp b/layout/generic/nsBlockFrame.cpp index aaaeb72233ec..252d91d50a29 100644 --- a/layout/generic/nsBlockFrame.cpp +++ b/layout/generic/nsBlockFrame.cpp @@ -472,39 +472,43 @@ void nsBlockFrame::AddSizeOfExcludingThisForTree( } } -void nsBlockFrame::Destroy(DestroyContext& aContext) { +void nsBlockFrame::DestroyFrom(nsIFrame* aDestructRoot, + PostDestroyData& aPostDestroyData) { ClearLineCursors(); - DestroyAbsoluteFrames(aContext); - mFloats.DestroyFrames(aContext); + DestroyAbsoluteFrames(aDestructRoot, aPostDestroyData); + mFloats.DestroyFramesFrom(aDestructRoot, aPostDestroyData); nsPresContext* presContext = PresContext(); mozilla::PresShell* presShell = presContext->PresShell(); - nsLineBox::DeleteLineList(presContext, mLines, &mFrames, aContext); + nsLineBox::DeleteLineList(presContext, mLines, aDestructRoot, &mFrames, + aPostDestroyData); if (HasPushedFloats()) { - SafelyDestroyFrameListProp(aContext, presShell, PushedFloatProperty()); + SafelyDestroyFrameListProp(aDestructRoot, aPostDestroyData, presShell, + PushedFloatProperty()); RemoveStateBits(NS_BLOCK_HAS_PUSHED_FLOATS); } // destroy overflow lines now FrameLines* overflowLines = RemoveOverflowLines(); if (overflowLines) { - nsLineBox::DeleteLineList(presContext, overflowLines->mLines, - &overflowLines->mFrames, aContext); + nsLineBox::DeleteLineList(presContext, overflowLines->mLines, aDestructRoot, + &overflowLines->mFrames, aPostDestroyData); delete overflowLines; } if (HasAnyStateBits(NS_BLOCK_HAS_OVERFLOW_OUT_OF_FLOWS)) { - SafelyDestroyFrameListProp(aContext, presShell, + SafelyDestroyFrameListProp(aDestructRoot, aPostDestroyData, presShell, OverflowOutOfFlowsProperty()); RemoveStateBits(NS_BLOCK_HAS_OVERFLOW_OUT_OF_FLOWS); } if (HasOutsideMarker()) { - SafelyDestroyFrameListProp(aContext, presShell, OutsideMarkerProperty()); + SafelyDestroyFrameListProp(aDestructRoot, aPostDestroyData, presShell, + OutsideMarkerProperty()); RemoveStateBits(NS_BLOCK_FRAME_HAS_OUTSIDE_MARKER); } - nsContainerFrame::Destroy(aContext); + nsContainerFrame::DestroyFrom(aDestructRoot, aPostDestroyData); } /* virtual */ @@ -5852,10 +5856,9 @@ void nsBlockFrame::RemoveFrame(ChildListID aListID, nsIFrame* aOldFrame) { printf("\n"); #endif - DestroyContext context(aOldFrame); if (aListID == FrameChildListID::Principal) { bool hasFloats = BlockHasAnyFloats(aOldFrame); - DoRemoveFrame(aOldFrame, REMOVE_FIXED_CONTINUATIONS, context); + DoRemoveFrame(aOldFrame, REMOVE_FIXED_CONTINUATIONS); if (hasFloats) { MarkSameFloatManagerLinesDirty(this); } @@ -5871,10 +5874,10 @@ void nsBlockFrame::RemoveFrame(ChildListID aListID, nsIFrame* aOldFrame) { MarkSameFloatManagerLinesDirty( static_cast(f->GetParent())); } - DoRemoveOutOfFlowFrame(aOldFrame, context); + DoRemoveOutOfFlowFrame(aOldFrame); } else if (FrameChildListID::NoReflowPrincipal == aListID) { // Skip the call to |FrameNeedsReflow| below by returning now. - DoRemoveFrame(aOldFrame, REMOVE_FIXED_CONTINUATIONS, context); + DoRemoveFrame(aOldFrame, REMOVE_FIXED_CONTINUATIONS); return; } else { MOZ_CRASH("unexpected child list"); @@ -6128,8 +6131,7 @@ void nsBlockFrame::RemoveFloat(nsIFrame* aFloat) { } } -void nsBlockFrame::DoRemoveOutOfFlowFrame(nsIFrame* aFrame, - DestroyContext& aContext) { +void nsBlockFrame::DoRemoveOutOfFlowFrame(nsIFrame* aFrame) { // The containing block is always the parent of aFrame. nsBlockFrame* block = (nsBlockFrame*)aFrame->GetParent(); @@ -6147,7 +6149,7 @@ void nsBlockFrame::DoRemoveOutOfFlowFrame(nsIFrame* aFrame, // Now remove aFrame from its child list and Destroy it. block->RemoveFloatFromFloatCache(aFrame); block->RemoveFloat(aFrame); - aFrame->Destroy(aContext); + aFrame->Destroy(); } } @@ -6429,8 +6431,9 @@ bool nsBlockInFlowLineIterator::FindValidLine() { // aDeletedFrame and remove aDeletedFrame from that line. But here we // start by locating aDeletedFrame and then scanning from that point // on looking for continuations. -void nsBlockFrame::DoRemoveFrame(nsIFrame* aDeletedFrame, uint32_t aFlags, - DestroyContext& aContext) { +void nsBlockFrame::DoRemoveFrameInternal(nsIFrame* aDeletedFrame, + uint32_t aFlags, + PostDestroyData& aPostDestroyData) { // Clear our line cursor, since our lines may change. ClearLineCursors(); @@ -6439,9 +6442,8 @@ void nsBlockFrame::DoRemoveFrame(nsIFrame* aDeletedFrame, uint32_t aFlags, if (!aDeletedFrame->GetPrevInFlow()) { NS_ASSERTION(aDeletedFrame->HasAnyStateBits(NS_FRAME_OUT_OF_FLOW), "Expected out-of-flow frame"); - DoRemoveOutOfFlowFrame(aDeletedFrame, aContext); + DoRemoveOutOfFlowFrame(aDeletedFrame); } else { - // FIXME(emilio): aContext is lost here, maybe it's not a big deal? nsContainerFrame::DeleteNextInFlowChild(aDeletedFrame, (aFlags & FRAMES_ARE_EMPTY) != 0); } @@ -6557,7 +6559,7 @@ void nsBlockFrame::DoRemoveFrame(nsIFrame* aDeletedFrame, uint32_t aFlags, deletedNextContinuation = nullptr; } - aDeletedFrame->Destroy(aContext); + aDeletedFrame->DestroyFrom(aDeletedFrame, aPostDestroyData); aDeletedFrame = deletedNextContinuation; bool haveAdvancedToNextLine = false; @@ -6664,7 +6666,7 @@ void nsBlockFrame::DoRemoveFrame(nsIFrame* aDeletedFrame, uint32_t aFlags, nsBlockFrame* nextBlock = do_QueryFrame(aDeletedFrame->GetParent()); NS_ASSERTION(nextBlock, "Our child's continuation's parent is not a block?"); uint32_t flags = (aFlags & REMOVE_FIXED_CONTINUATIONS); - nextBlock->DoRemoveFrame(aDeletedFrame, flags, aContext); + nextBlock->DoRemoveFrameInternal(aDeletedFrame, flags, aPostDestroyData); } static bool FindBlockLineFor(nsIFrame* aChild, nsLineList::iterator aBegin, @@ -6778,9 +6780,7 @@ void nsBlockFrame::DeleteNextInFlowChild(nsIFrame* aNextInFlow, nsLayoutUtils::AssertTreeOnlyEmptyNextInFlows(aNextInFlow); } #endif - DestroyContext context(aNextInFlow); - DoRemoveFrame(aNextInFlow, aDeletingEmptyFrames ? FRAMES_ARE_EMPTY : 0, - context); + DoRemoveFrame(aNextInFlow, aDeletingEmptyFrames ? FRAMES_ARE_EMPTY : 0); } } diff --git a/layout/generic/nsBlockFrame.h b/layout/generic/nsBlockFrame.h index 72899888fee4..8323d0235bd0 100644 --- a/layout/generic/nsBlockFrame.h +++ b/layout/generic/nsBlockFrame.h @@ -136,8 +136,8 @@ class nsBlockFrame : public nsContainerFrame { mozilla::WritingMode aWM, BaselineSharingGroup aBaselineGroup, BaselineExportContext aExportContext) const override; nscoord GetCaretBaseline() const override; - void Destroy(DestroyContext&) override; - + void DestroyFrom(nsIFrame* aDestructRoot, + PostDestroyData& aPostDestroyData) override; bool IsFloatContainingBlock() const override; void BuildDisplayList(nsDisplayListBuilder* aBuilder, const nsDisplayListSet& aLists) override; @@ -551,14 +551,19 @@ class nsBlockFrame : public nsContainerFrame { * -- destroys all removed frames */ enum { REMOVE_FIXED_CONTINUATIONS = 0x02, FRAMES_ARE_EMPTY = 0x04 }; - void DoRemoveFrame(nsIFrame* aDeletedFrame, uint32_t aFlags, DestroyContext&); + void DoRemoveFrame(nsIFrame* aDeletedFrame, uint32_t aFlags) { + AutoPostDestroyData data(PresContext()); + DoRemoveFrameInternal(aDeletedFrame, aFlags, data.mData); + } void ReparentFloats(nsIFrame* aFirstFrame, nsBlockFrame* aOldParent, bool aReparentSiblings); - bool ComputeCustomOverflow(mozilla::OverflowAreas&) override; + virtual bool ComputeCustomOverflow( + mozilla::OverflowAreas& aOverflowAreas) override; - void UnionChildOverflow(mozilla::OverflowAreas&) override; + virtual void UnionChildOverflow( + mozilla::OverflowAreas& aOverflowAreas) override; /** * Load all of aFrame's floats into the float manager iff aFrame is not a @@ -596,6 +601,10 @@ class nsBlockFrame : public nsContainerFrame { bool IsInLineClampContext() const; protected: + /** @see DoRemoveFrame */ + void DoRemoveFrameInternal(nsIFrame* aDeletedFrame, uint32_t aFlags, + PostDestroyData& data); + /** grab overflow lines from this block's prevInFlow, and make them * part of this block's mLines list. * @return true if any lines were drained. @@ -668,7 +677,7 @@ class nsBlockFrame : public nsContainerFrame { bool aCollectFromSiblings); // Remove a float, abs, rel positioned frame from the appropriate block's list - static void DoRemoveOutOfFlowFrame(nsIFrame* aFrame, DestroyContext&); + static void DoRemoveOutOfFlowFrame(nsIFrame* aFrame); /** set up the conditions necessary for an resize reflow * the primary task is to mark the minimumly sufficient lines dirty. diff --git a/layout/generic/nsCanvasFrame.cpp b/layout/generic/nsCanvasFrame.cpp index aeb87330f3d2..62d74e909369 100644 --- a/layout/generic/nsCanvasFrame.cpp +++ b/layout/generic/nsCanvasFrame.cpp @@ -203,18 +203,19 @@ void nsCanvasFrame::AppendAnonymousContentTo(nsTArray& aElements, } } -void nsCanvasFrame::Destroy(DestroyContext& aContext) { +void nsCanvasFrame::DestroyFrom(nsIFrame* aDestructRoot, + PostDestroyData& aPostDestroyData) { nsIScrollableFrame* sf = PresContext()->GetPresShell()->GetRootScrollFrameAsScrollable(); if (sf) { sf->RemoveScrollPositionListener(this); } - aContext.AddAnonymousContent(mCustomContentContainer.forget()); + aPostDestroyData.AddAnonymousContent(mCustomContentContainer.forget()); if (mTooltipContent) { - aContext.AddAnonymousContent(mTooltipContent.forget()); + aPostDestroyData.AddAnonymousContent(mTooltipContent.forget()); } - nsContainerFrame::Destroy(aContext); + nsContainerFrame::DestroyFrom(aDestructRoot, aPostDestroyData); } void nsCanvasFrame::ScrollPositionWillChange(nscoord aX, nscoord aY) { diff --git a/layout/generic/nsCanvasFrame.h b/layout/generic/nsCanvasFrame.h index c9e495a77cb0..09540d18bc17 100644 --- a/layout/generic/nsCanvasFrame.h +++ b/layout/generic/nsCanvasFrame.h @@ -46,7 +46,8 @@ class nsCanvasFrame final : public nsContainerFrame, Element* GetDefaultTooltip() override; - void Destroy(DestroyContext&) override; + void DestroyFrom(nsIFrame* aDestructRoot, + PostDestroyData& aPostDestroyData) override; void SetInitialChildList(ChildListID aListID, nsFrameList&& aChildList) override; diff --git a/layout/generic/nsContainerFrame.cpp b/layout/generic/nsContainerFrame.cpp index 60fad4e789ce..24a75884df5e 100644 --- a/layout/generic/nsContainerFrame.cpp +++ b/layout/generic/nsContainerFrame.cpp @@ -183,8 +183,7 @@ void nsContainerFrame::RemoveFrame(ChildListID aListID, nsIFrame* aOldFrame) { // We really MUST use StealFrame() and nothing else here. // @see nsInlineFrame::StealFrame for details. parent->StealFrame(continuation); - DestroyContext context(continuation); - continuation->Destroy(context); + continuation->Destroy(); if (generateReflowCommand && parent != lastParent) { presShell->FrameNeedsReflow(parent, IntrinsicDirty::FrameAndAncestors, NS_FRAME_HAS_DIRTY_CHILDREN); @@ -193,23 +192,25 @@ void nsContainerFrame::RemoveFrame(ChildListID aListID, nsIFrame* aOldFrame) { } } -void nsContainerFrame::DestroyAbsoluteFrames(DestroyContext& aContext) { +void nsContainerFrame::DestroyAbsoluteFrames( + nsIFrame* aDestructRoot, PostDestroyData& aPostDestroyData) { if (IsAbsoluteContainer()) { - GetAbsoluteContainingBlock()->DestroyFrames(aContext); + GetAbsoluteContainingBlock()->DestroyFrames(this, aDestructRoot, + aPostDestroyData); MarkAsNotAbsoluteContainingBlock(); } } void nsContainerFrame::SafelyDestroyFrameListProp( - DestroyContext& aContext, mozilla::PresShell* aPresShell, - FrameListPropertyDescriptor aProp) { + nsIFrame* aDestructRoot, PostDestroyData& aPostDestroyData, + mozilla::PresShell* aPresShell, FrameListPropertyDescriptor aProp) { // Note that the last frame can be removed through another route and thus // delete the property -- that's why we fetch the property again before // removing each frame rather than fetching it once and iterating the list. while (nsFrameList* frameList = GetProperty(aProp)) { nsIFrame* frame = frameList->RemoveFirstChild(); if (MOZ_LIKELY(frame)) { - frame->Destroy(aContext); + frame->DestroyFrom(aDestructRoot, aPostDestroyData); } else { Unused << TakeProperty(aProp); frameList->Delete(aPresShell); @@ -218,16 +219,17 @@ void nsContainerFrame::SafelyDestroyFrameListProp( } } -void nsContainerFrame::Destroy(DestroyContext& aContext) { +void nsContainerFrame::DestroyFrom(nsIFrame* aDestructRoot, + PostDestroyData& aPostDestroyData) { // Prevent event dispatch during destruction. if (HasView()) { GetView()->SetFrame(nullptr); } - DestroyAbsoluteFrames(aContext); + DestroyAbsoluteFrames(aDestructRoot, aPostDestroyData); // Destroy frames on the principal child list. - mFrames.DestroyFrames(aContext); + mFrames.DestroyFramesFrom(aDestructRoot, aPostDestroyData); // If we have any IB split siblings, clear their references to us. if (HasAnyStateBits(NS_FRAME_PART_OF_IBSPLIT)) { @@ -273,18 +275,19 @@ void nsContainerFrame::Destroy(DestroyContext& aContext) { nsPresContext* pc = PresContext(); mozilla::PresShell* presShell = pc->PresShell(); if (hasO) { - SafelyDestroyFrameListProp(aContext, presShell, OverflowProperty()); + SafelyDestroyFrameListProp(aDestructRoot, aPostDestroyData, presShell, + OverflowProperty()); } MOZ_ASSERT( IsFrameOfType(eCanContainOverflowContainers) || !(hasOC || hasEOC), "this type of frame shouldn't have overflow containers"); if (hasOC) { - SafelyDestroyFrameListProp(aContext, presShell, + SafelyDestroyFrameListProp(aDestructRoot, aPostDestroyData, presShell, OverflowContainersProperty()); } if (hasEOC) { - SafelyDestroyFrameListProp(aContext, presShell, + SafelyDestroyFrameListProp(aDestructRoot, aPostDestroyData, presShell, ExcessOverflowContainersProperty()); } @@ -292,11 +295,12 @@ void nsContainerFrame::Destroy(DestroyContext& aContext) { StyleDisplay()->mTopLayer != StyleTopLayer::None, "only top layer frame may have backdrop"); if (hasBackdrop) { - SafelyDestroyFrameListProp(aContext, presShell, BackdropProperty()); + SafelyDestroyFrameListProp(aDestructRoot, aPostDestroyData, presShell, + BackdropProperty()); } } - nsSplittableFrame::Destroy(aContext); + nsSplittableFrame::DestroyFrom(aDestructRoot, aPostDestroyData); } ///////////////////////////////////////////////////////////////////////////// @@ -892,7 +896,8 @@ void nsContainerFrame::ReflowChild( // but only if the NoDeleteNextInFlowChild flag isn't set. if (!aStatus.IsInlineBreakBefore() && aStatus.IsFullyComplete() && !(aFlags & ReflowChildFlags::NoDeleteNextInFlowChild)) { - if (nsIFrame* kidNextInFlow = aKidFrame->GetNextInFlow()) { + nsIFrame* kidNextInFlow = aKidFrame->GetNextInFlow(); + if (kidNextInFlow) { // Remove all of the childs next-in-flows. Make sure that we ask // the right parent to do the removal (it's possible that the // parent is not this because we are executing pullup code) @@ -931,7 +936,8 @@ void nsContainerFrame::ReflowChild(nsIFrame* aKidFrame, // but only if the NoDeleteNextInFlowChild flag isn't set. if (aStatus.IsFullyComplete() && !(aFlags & ReflowChildFlags::NoDeleteNextInFlowChild)) { - if (nsIFrame* kidNextInFlow = aKidFrame->GetNextInFlow()) { + nsIFrame* kidNextInFlow = aKidFrame->GetNextInFlow(); + if (kidNextInFlow) { // Remove all of the childs next-in-flows. Make sure that we ask // the right parent to do the removal (it's possible that the // parent is not this because we are executing pullup code) @@ -1375,8 +1381,8 @@ void nsContainerFrame::DeleteNextInFlowChild(nsIFrame* aNextInFlow, frames.AppendElement(f); } for (nsIFrame* delFrame : Reversed(frames)) { - nsContainerFrame* parent = delFrame->GetParent(); - parent->DeleteNextInFlowChild(delFrame, aDeletingEmptyFrames); + delFrame->GetParent()->DeleteNextInFlowChild(delFrame, + aDeletingEmptyFrames); } } @@ -1391,8 +1397,7 @@ void nsContainerFrame::DeleteNextInFlowChild(nsIFrame* aNextInFlow, // Delete the next-in-flow frame and its descendants. This will also // remove it from its next-in-flow/prev-in-flow chain. - DestroyContext context(aNextInFlow); - aNextInFlow->Destroy(context); + aNextInFlow->Destroy(); MOZ_ASSERT(!prevInFlow->GetNextInFlow(), "non null next-in-flow"); } diff --git a/layout/generic/nsContainerFrame.h b/layout/generic/nsContainerFrame.h index 2ad23190244f..73d04bbc3918 100644 --- a/layout/generic/nsContainerFrame.h +++ b/layout/generic/nsContainerFrame.h @@ -46,19 +46,19 @@ class nsContainerFrame : public nsSplittableFrame { NS_DECL_QUERYFRAME // nsIFrame overrides - void Init(nsIContent* aContent, nsContainerFrame* aParent, - nsIFrame* aPrevInFlow) override; - nsContainerFrame* GetContentInsertionFrame() override { return this; } + virtual void Init(nsIContent* aContent, nsContainerFrame* aParent, + nsIFrame* aPrevInFlow) override; + virtual nsContainerFrame* GetContentInsertionFrame() override { return this; } - const nsFrameList& GetChildList(ChildListID aList) const override; - void GetChildLists(nsTArray* aLists) const override; - void Destroy(DestroyContext&) override; + virtual const nsFrameList& GetChildList(ChildListID aList) const override; + virtual void GetChildLists(nsTArray* aLists) const override; + virtual void DestroyFrom(nsIFrame* aDestructRoot, + PostDestroyData& aPostDestroyData) override; + virtual void ChildIsDirty(nsIFrame* aChild) override; - void ChildIsDirty(nsIFrame* aChild) override; - - FrameSearchResult PeekOffsetNoAmount(bool aForward, - int32_t* aOffset) override; - FrameSearchResult PeekOffsetCharacter( + virtual FrameSearchResult PeekOffsetNoAmount(bool aForward, + int32_t* aOffset) override; + virtual FrameSearchResult PeekOffsetCharacter( bool aForward, int32_t* aOffset, PeekOffsetCharacterOptions aOptions = PeekOffsetCharacterOptions()) override; @@ -523,7 +523,8 @@ class nsContainerFrame : public nsSplittableFrame { * Derived classes must do that too, if they destroy such frame lists. * See nsBlockFrame::DestroyFrom for an example. */ - void DestroyAbsoluteFrames(DestroyContext&); + void DestroyAbsoluteFrames(nsIFrame* aDestructRoot, + PostDestroyData& aPostDestroyData); /** * Helper for StealFrame. Returns true if aChild was removed from its list. @@ -851,7 +852,8 @@ class nsContainerFrame : public nsSplittableFrame { * frame then remove the property and delete the frame list. * Nothing happens if the property doesn't exist. */ - void SafelyDestroyFrameListProp(DestroyContext&, + void SafelyDestroyFrameListProp(nsIFrame* aDestructRoot, + PostDestroyData& aPostDestroyData, mozilla::PresShell* aPresShell, FrameListPropertyDescriptor aProp); diff --git a/layout/generic/nsFrameList.cpp b/layout/generic/nsFrameList.cpp index 0abcbcbfd061..9f9c6959c91b 100644 --- a/layout/generic/nsFrameList.cpp +++ b/layout/generic/nsFrameList.cpp @@ -37,15 +37,17 @@ void nsFrameList::Delete(mozilla::PresShell* aPresShell) { void nsFrameList::DestroyFrames() { while (nsIFrame* frame = RemoveFirstChild()) { - FrameDestroyContext context(frame); - frame->Destroy(context); + frame->Destroy(); } mLastChild = nullptr; } -void nsFrameList::DestroyFrames(FrameDestroyContext& aContext) { +void nsFrameList::DestroyFramesFrom(nsIFrame* aDestructRoot, + PostFrameDestroyData& aPostDestroyData) { + MOZ_ASSERT(aDestructRoot, "Missing destruct root"); + while (nsIFrame* frame = RemoveFirstChild()) { - frame->Destroy(aContext); + frame->DestroyFrom(aDestructRoot, aPostDestroyData); } mLastChild = nullptr; } @@ -106,8 +108,7 @@ nsIFrame* nsFrameList::RemoveFirstChild() { void nsFrameList::DestroyFrame(nsIFrame* aFrame) { MOZ_ASSERT(aFrame, "null ptr"); RemoveFrame(aFrame); - FrameDestroyContext context(aFrame); - aFrame->Destroy(context); + aFrame->Destroy(); } nsFrameList::Slice nsFrameList::InsertFrames(nsContainerFrame* aParent, diff --git a/layout/generic/nsFrameList.h b/layout/generic/nsFrameList.h index 0759b84f1f6e..02c64348d739 100644 --- a/layout/generic/nsFrameList.h +++ b/layout/generic/nsFrameList.h @@ -26,9 +26,6 @@ class nsIFrame; class nsPresContext; namespace mozilla { - -struct FrameDestroyContext; - class PresShell; class FrameChildList; enum class FrameChildListID { @@ -52,6 +49,17 @@ enum class FrameChildListID { NoReflowPrincipal, }; +// A helper class for nsIFrame::Destroy[From]. It's defined here because +// nsFrameList needs it and we can't use nsIFrame here. +struct PostFrameDestroyData { + PostFrameDestroyData(const PostFrameDestroyData&) = delete; + PostFrameDestroyData() = default; + + AutoTArray, 100> mAnonymousContent; + void AddAnonymousContent(already_AddRefed&& aContent) { + mAnonymousContent.AppendElement(aContent); + } +}; } // namespace mozilla // Uncomment this to enable expensive frame-list integrity checking @@ -133,9 +141,10 @@ class nsFrameList { /** * For each frame in this list: remove it from the list then call - * Destroy() on it with the passed context as an argument. + * DestroyFrom(aDestructRoot, aPostDestroyData) on it. */ - void DestroyFrames(mozilla::FrameDestroyContext&); + void DestroyFramesFrom(nsIFrame* aDestructRoot, + mozilla::PostFrameDestroyData& aPostDestroyData); void Clear() { mFirstChild = mLastChild = nullptr; } diff --git a/layout/generic/nsGfxScrollFrame.cpp b/layout/generic/nsGfxScrollFrame.cpp index bd82f83fe508..3713efb71975 100644 --- a/layout/generic/nsGfxScrollFrame.cpp +++ b/layout/generic/nsGfxScrollFrame.cpp @@ -315,8 +315,9 @@ void nsHTMLScrollFrame::ScrollbarActivityStopped() const { } } -void nsHTMLScrollFrame::Destroy(DestroyContext& aContext) { - DestroyAbsoluteFrames(aContext); +void nsHTMLScrollFrame::DestroyFrom(nsIFrame* aDestructRoot, + PostDestroyData& aPostDestroyData) { + DestroyAbsoluteFrames(aDestructRoot, aPostDestroyData); if (mIsRoot) { PresShell()->ResetVisualViewportOffset(); } @@ -329,10 +330,10 @@ void nsHTMLScrollFrame::Destroy(DestroyContext& aContext) { } // Unbind the content created in CreateAnonymousContent later... - aContext.AddAnonymousContent(mHScrollbarContent.forget()); - aContext.AddAnonymousContent(mVScrollbarContent.forget()); - aContext.AddAnonymousContent(mScrollCornerContent.forget()); - aContext.AddAnonymousContent(mResizerContent.forget()); + aPostDestroyData.AddAnonymousContent(mHScrollbarContent.forget()); + aPostDestroyData.AddAnonymousContent(mVScrollbarContent.forget()); + aPostDestroyData.AddAnonymousContent(mScrollCornerContent.forget()); + aPostDestroyData.AddAnonymousContent(mResizerContent.forget()); if (mPostedReflowCallback) { PresShell()->CancelReflowCallback(this); @@ -361,7 +362,7 @@ void nsHTMLScrollFrame::Destroy(DestroyContext& aContext) { if (mScrollEndEvent) { mScrollEndEvent->Revoke(); } - nsContainerFrame::Destroy(aContext); + nsContainerFrame::DestroyFrom(aDestructRoot, aPostDestroyData); } void nsHTMLScrollFrame::SetInitialChildList(ChildListID aListID, diff --git a/layout/generic/nsGfxScrollFrame.h b/layout/generic/nsGfxScrollFrame.h index cede2a26b4fe..5c14bac2c9d4 100644 --- a/layout/generic/nsGfxScrollFrame.h +++ b/layout/generic/nsGfxScrollFrame.h @@ -150,7 +150,7 @@ class nsHTMLScrollFrame : public nsContainerFrame, void DidSetComputedStyle(ComputedStyle* aOldComputedStyle) final; - void Destroy(DestroyContext&) override; + void DestroyFrom(nsIFrame* aDestructRoot, PostDestroyData&) override; nsIScrollableFrame* GetScrollTargetFrame() const final { return const_cast(this); diff --git a/layout/generic/nsHTMLCanvasFrame.cpp b/layout/generic/nsHTMLCanvasFrame.cpp index 2ccb6f0b20c1..ce66c87d1436 100644 --- a/layout/generic/nsHTMLCanvasFrame.cpp +++ b/layout/generic/nsHTMLCanvasFrame.cpp @@ -346,11 +346,12 @@ NS_QUERYFRAME_TAIL_INHERITING(nsContainerFrame) NS_IMPL_FRAMEARENA_HELPERS(nsHTMLCanvasFrame) -void nsHTMLCanvasFrame::Destroy(DestroyContext& aContext) { +void nsHTMLCanvasFrame::DestroyFrom(nsIFrame* aDestroyRoot, + PostDestroyData& aPostDestroyData) { if (IsPrimaryFrame()) { HTMLCanvasElement::FromNode(*mContent)->ResetPrintCallback(); } - nsContainerFrame::Destroy(aContext); + nsContainerFrame::DestroyFrom(aDestroyRoot, aPostDestroyData); } nsHTMLCanvasFrame::~nsHTMLCanvasFrame() = default; diff --git a/layout/generic/nsHTMLCanvasFrame.h b/layout/generic/nsHTMLCanvasFrame.h index 40a81a205b10..7c04b360c7f0 100644 --- a/layout/generic/nsHTMLCanvasFrame.h +++ b/layout/generic/nsHTMLCanvasFrame.h @@ -43,7 +43,7 @@ class nsHTMLCanvasFrame final : public nsContainerFrame { virtual void BuildDisplayList(nsDisplayListBuilder* aBuilder, const nsDisplayListSet& aLists) override; - void Destroy(DestroyContext&) override; + void DestroyFrom(nsIFrame*, PostDestroyData&) override; bool UpdateWebRenderCanvasData(nsDisplayListBuilder* aBuilder, WebRenderCanvasData* aCanvasData); diff --git a/layout/generic/nsIFrame.cpp b/layout/generic/nsIFrame.cpp index 687da3ecfc08..2a488975ef20 100644 --- a/layout/generic/nsIFrame.cpp +++ b/layout/generic/nsIFrame.cpp @@ -217,10 +217,11 @@ static void SetOrUpdateRectValuedProperty( } } -FrameDestroyContext::~FrameDestroyContext() { - auto* ps = mPresContext->PresShell(); - for (auto& content : mozilla::Reversed(mAnonymousContent)) { - ps->NativeAnonymousContentRemoved(content); +/* static */ +void nsIFrame::DestroyAnonymousContent( + nsPresContext* aPresContext, already_AddRefed&& aContent) { + if (nsCOMPtr content = aContent) { + aPresContext->PresShell()->NativeAnonymousContentRemoved(content); content->UnbindFromTree(); } } @@ -763,12 +764,13 @@ void nsIFrame::InitPrimaryFrame() { HandleLastRememberedSize(); } -void nsIFrame::Destroy(DestroyContext& aContext) { +void nsIFrame::DestroyFrom(nsIFrame* aDestructRoot, + PostDestroyData& aPostDestroyData) { NS_ASSERTION(!nsContentUtils::IsSafeToRunScript(), "destroy called on frame while scripts not blocked"); NS_ASSERTION(!GetNextSibling() && !GetPrevSibling(), "Frames should be removed before destruction."); - NS_ASSERTION(aContext.DestructRoot(), "Must specify destruct root"); + NS_ASSERTION(aDestructRoot, "Must specify destruct root"); MOZ_ASSERT(!HasAbsolutelyPositionedChildren()); MOZ_ASSERT(!HasAnyStateBits(NS_FRAME_PART_OF_IBSPLIT), "NS_FRAME_PART_OF_IBSPLIT set on non-nsContainerFrame?"); @@ -794,10 +796,10 @@ void nsIFrame::Destroy(DestroyContext& aContext) { if (HasAnyStateBits(NS_FRAME_OUT_OF_FLOW)) { nsPlaceholderFrame* placeholder = GetPlaceholderFrame(); NS_ASSERTION( - !placeholder || aContext.DestructRoot() != this, + !placeholder || (aDestructRoot != this), "Don't call Destroy() on OOFs, call Destroy() on the placeholder."); NS_ASSERTION(!placeholder || nsLayoutUtils::IsProperAncestorFrame( - aContext.DestructRoot(), placeholder), + aDestructRoot, placeholder), "Placeholder relationship should have been torn down already; " "this might mean we have a stray placeholder in the tree."); if (placeholder) { @@ -867,7 +869,7 @@ void nsIFrame::Destroy(DestroyContext& aContext) { // aPostDestroyData to unbind it after frame destruction is done. if (HasAnyStateBits(NS_FRAME_GENERATED_CONTENT) && mContent->IsRootOfNativeAnonymousSubtree()) { - aContext.AddAnonymousContent(mContent.forget()); + aPostDestroyData.AddAnonymousContent(mContent.forget()); } } diff --git a/layout/generic/nsIFrame.h b/layout/generic/nsIFrame.h index 96ffa3c1fce4..525412f5bba4 100644 --- a/layout/generic/nsIFrame.h +++ b/layout/generic/nsIFrame.h @@ -493,37 +493,6 @@ static void ReleaseValue(T* aPropertyValue) { //---------------------------------------------------------------------- -namespace mozilla { - -// A simple class to group stuff that we need to keep around when tearing down -// a frame tree. -// -// Native anonymous content created by the frames need to get unbound _after_ -// the frame has been destroyed, see bug 1400618. -// -// We destroy the anonymous content bottom-up (so, in reverse order), because -// it's a bit simpler, though we generally don't have that much nested anonymous -// content (except for scrollbars). -struct MOZ_RAII FrameDestroyContext { - explicit FrameDestroyContext(nsIFrame* aRoot); - - nsIFrame* DestructRoot() const { return mDestructRoot; } - void AddAnonymousContent(already_AddRefed&& aContent) { - if (RefPtr content = aContent) { - mAnonymousContent.AppendElement(std::move(content)); - } - } - - ~FrameDestroyContext(); - - private: - nsIFrame* const mDestructRoot; - nsPresContext* const mPresContext; - AutoTArray, 100> mAnonymousContent; -}; - -} // namespace mozilla - /** * A frame in the layout model. This interface is supported by all frame * objects. @@ -662,7 +631,31 @@ class nsIFrame : public nsQueryFrame { void* operator new(size_t, mozilla::PresShell*) MOZ_MUST_OVERRIDE; - using DestroyContext = mozilla::FrameDestroyContext; + using PostDestroyData = mozilla::PostFrameDestroyData; + struct MOZ_RAII AutoPostDestroyData { + explicit AutoPostDestroyData(nsPresContext* aPresContext) + : mPresContext(aPresContext) {} + ~AutoPostDestroyData() { + for (auto& content : mozilla::Reversed(mData.mAnonymousContent)) { + nsIFrame::DestroyAnonymousContent(mPresContext, content.forget()); + } + } + nsPresContext* mPresContext; + PostDestroyData mData; + }; + /** + * Destroys this frame and each of its child frames (recursively calls + * Destroy() for each child). If this frame is a first-continuation, this + * also removes the frame from the primary frame map and clears undisplayed + * content for its content node. + * If the frame is a placeholder, it also ensures the out-of-flow frame's + * removal and destruction. + */ + void Destroy() { + AutoPostDestroyData data(PresContext()); + DestroyFrom(this, data.mData); + // Note that |this| is deleted at this point. + } /** * Flags for PeekOffsetCharacter, PeekOffsetNoAmount, PeekOffsetWord return @@ -696,19 +689,32 @@ class nsIFrame : public nsQueryFrame { : mRespectClusters(true), mIgnoreUserStyleAll(false) {} }; - virtual void Destroy(DestroyContext&); - protected: + friend class nsBlockFrame; // for access to DestroyFrom + /** * Return true if the frame is part of a Selection. * Helper method to implement the public IsSelected() API. */ virtual bool IsFrameSelected() const; + /** + * Implements Destroy(). Do not call this directly except from within a + * DestroyFrom() implementation. + * + * @note This will always be called, so it is not necessary to override + * Destroy() in subclasses of nsFrame, just DestroyFrom(). + * + * @param aDestructRoot is the root of the subtree being destroyed + */ + virtual void DestroyFrom(nsIFrame* aDestructRoot, + PostDestroyData& aPostDestroyData); + friend class nsFrameList; // needed to pass aDestructRoot through to children + friend class nsLineBox; // needed to pass aDestructRoot through to children + friend class nsContainerFrame; // needed to pass aDestructRoot through to + // children template friend class do_QueryFrameHelper; // to read mClass - friend class nsBlockFrame; // for GetCaretBaseline - friend class nsContainerFrame; // for ReparentFrameViewTo virtual ~nsIFrame(); @@ -4894,6 +4900,9 @@ class nsIFrame : public nsQueryFrame { void HandleLastRememberedSize(); protected: + static void DestroyAnonymousContent(nsPresContext* aPresContext, + already_AddRefed&& aContent); + /** * Reparent this frame's view if it has one. */ @@ -5615,13 +5624,4 @@ inline nsIFrame* nsFrameList::BackwardFrameTraversal::Prev(nsIFrame* aFrame) { return aFrame->GetNextSibling(); } -namespace mozilla { - -inline FrameDestroyContext::FrameDestroyContext(nsIFrame* aRoot) - : mDestructRoot(aRoot), mPresContext(aRoot->PresContext()) { - MOZ_ASSERT(mDestructRoot); -} - -} // namespace mozilla - #endif /* nsIFrame_h___ */ diff --git a/layout/generic/nsImageFrame.cpp b/layout/generic/nsImageFrame.cpp index fe57bab871df..e2f72b3a76ae 100644 --- a/layout/generic/nsImageFrame.cpp +++ b/layout/generic/nsImageFrame.cpp @@ -485,7 +485,8 @@ void nsImageFrame::DisconnectMap() { #endif } -void nsImageFrame::Destroy(DestroyContext& aContext) { +void nsImageFrame::DestroyFrom(nsIFrame* aDestructRoot, + PostDestroyData& aPostDestroyData) { MaybeSendIntrinsicSizeAndRatioToEmbedder(Nothing(), Nothing()); if (mReflowCallbackPosted) { @@ -523,7 +524,7 @@ void nsImageFrame::Destroy(DestroyContext& aContext) { BrokenImageIcon::RemoveObserver(this); } - nsAtomicContainerFrame::Destroy(aContext); + nsAtomicContainerFrame::DestroyFrom(aDestructRoot, aPostDestroyData); } void nsImageFrame::DeinitOwnedRequest() { diff --git a/layout/generic/nsImageFrame.h b/layout/generic/nsImageFrame.h index be14cb82c651..5d2a08f68810 100644 --- a/layout/generic/nsImageFrame.h +++ b/layout/generic/nsImageFrame.h @@ -70,7 +70,7 @@ class nsImageFrame : public nsAtomicContainerFrame, public nsIReflowCallback { NS_DECL_FRAMEARENA_HELPERS(nsImageFrame) NS_DECL_QUERYFRAME - void Destroy(DestroyContext&) override; + void DestroyFrom(nsIFrame* aDestructRoot, PostDestroyData&) override; void DidSetComputedStyle(ComputedStyle* aOldStyle) final; void Init(nsIContent* aContent, nsContainerFrame* aParent, diff --git a/layout/generic/nsInlineFrame.cpp b/layout/generic/nsInlineFrame.cpp index 7a99ecbe5d32..37122545299d 100644 --- a/layout/generic/nsInlineFrame.cpp +++ b/layout/generic/nsInlineFrame.cpp @@ -166,7 +166,8 @@ nsIFrame::FrameSearchResult nsInlineFrame::PeekOffsetCharacter( return CONTINUE; } -void nsInlineFrame::Destroy(DestroyContext& aContext) { +void nsInlineFrame::DestroyFrom(nsIFrame* aDestructRoot, + PostDestroyData& aPostDestroyData) { nsFrameList* overflowFrames = GetOverflowFrames(); if (overflowFrames) { // Fixup the parent pointers for any child frames on the OverflowList. @@ -174,7 +175,7 @@ void nsInlineFrame::Destroy(DestroyContext& aContext) { // container (an ancestor). overflowFrames->ApplySetParent(this); } - nsContainerFrame::Destroy(aContext); + nsContainerFrame::DestroyFrom(aDestructRoot, aPostDestroyData); } void nsInlineFrame::StealFrame(nsIFrame* aChild) { diff --git a/layout/generic/nsInlineFrame.h b/layout/generic/nsInlineFrame.h index 9cb63c401646..748bd546a84f 100644 --- a/layout/generic/nsInlineFrame.h +++ b/layout/generic/nsInlineFrame.h @@ -68,8 +68,8 @@ class nsInlineFrame : public nsContainerFrame { PeekOffsetCharacterOptions aOptions = PeekOffsetCharacterOptions()) override; - void Destroy(DestroyContext&) override; - + virtual void DestroyFrom(nsIFrame* aDestructRoot, + PostDestroyData& aPostDestroyData) override; void StealFrame(nsIFrame* aChild) override; // nsIHTMLReflow overrides diff --git a/layout/generic/nsLineBox.cpp b/layout/generic/nsLineBox.cpp index 7afbd1630565..5cfd38aebdff 100644 --- a/layout/generic/nsLineBox.cpp +++ b/layout/generic/nsLineBox.cpp @@ -348,7 +348,8 @@ bool nsLineBox::CachedIsEmpty() { } void nsLineBox::DeleteLineList(nsPresContext* aPresContext, nsLineList& aLines, - nsFrameList* aFrames, DestroyContext& aContext) { + nsIFrame* aDestructRoot, nsFrameList* aFrames, + PostDestroyData& aPostDestroyData) { PresShell* presShell = aPresContext->PresShell(); // Keep our line list and frame list up to date as we @@ -365,7 +366,7 @@ void nsLineBox::DeleteLineList(nsPresContext* aPresContext, nsLineList& aLines, MOZ_DIAGNOSTIC_ASSERT(child == line->mFirstChild, "Lines out of sync"); line->mFirstChild = aFrames->FirstChild(); line->NoteFrameRemoved(child); - child->Destroy(aContext); + child->DestroyFrom(aDestructRoot, aPostDestroyData); } MOZ_DIAGNOSTIC_ASSERT(line == aLines.front(), "destroying child frames messed up our lines!"); diff --git a/layout/generic/nsLineBox.h b/layout/generic/nsLineBox.h index f11c58267879..19ff1bd556cb 100644 --- a/layout/generic/nsLineBox.h +++ b/layout/generic/nsLineBox.h @@ -396,9 +396,10 @@ class nsLineBox final : public nsLineLink { mBounds.BSize(mWritingMode) = 0; } - using DestroyContext = nsIFrame::DestroyContext; + using PostDestroyData = nsIFrame::PostDestroyData; static void DeleteLineList(nsPresContext* aPresContext, nsLineList& aLines, - nsFrameList* aFrames, DestroyContext&); + nsIFrame* aDestructRoot, nsFrameList* aFrames, + PostDestroyData& aPostDestroyData); // search from end to beginning of [aBegin, aEnd) // Returns true if it found the line and false if not. diff --git a/layout/generic/nsPlaceholderFrame.cpp b/layout/generic/nsPlaceholderFrame.cpp index 39362e310112..63635ea68492 100644 --- a/layout/generic/nsPlaceholderFrame.cpp +++ b/layout/generic/nsPlaceholderFrame.cpp @@ -146,18 +146,19 @@ static FrameChildListID ChildListIDForOutOfFlow(nsFrameState aPlaceholderState, return FrameChildListID::Float; } -void nsPlaceholderFrame::Destroy(DestroyContext& aContext) { +void nsPlaceholderFrame::DestroyFrom(nsIFrame* aDestructRoot, + PostDestroyData& aPostDestroyData) { nsIFrame* oof = mOutOfFlowFrame; if (oof) { mOutOfFlowFrame = nullptr; oof->RemoveProperty(nsIFrame::PlaceholderFrameProperty()); - // If the destruct root is not an ancestor of the out-of-flow frame, then - // call RemoveFrame on it here. + // If aDestructRoot is not an ancestor of the out-of-flow frame, + // then call RemoveFrame on it here. // Also destroy it here if it's a popup frame. (Bug 96291) // FIXME(emilio): Is the popup special-case still needed? if (oof->IsMenuPopupFrame() || - !nsLayoutUtils::IsProperAncestorFrame(aContext.DestructRoot(), oof)) { + !nsLayoutUtils::IsProperAncestorFrame(aDestructRoot, oof)) { ChildListID listId = ChildListIDForOutOfFlow(GetStateBits(), oof); nsFrameManager* fm = PresContext()->FrameConstructor(); fm->RemoveFrame(listId, oof); @@ -165,7 +166,7 @@ void nsPlaceholderFrame::Destroy(DestroyContext& aContext) { // else oof will be destroyed by its parent } - nsIFrame::Destroy(aContext); + nsIFrame::DestroyFrom(aDestructRoot, aPostDestroyData); } /* virtual */ diff --git a/layout/generic/nsPlaceholderFrame.h b/layout/generic/nsPlaceholderFrame.h index 4cbb54259a07..5132ea64b27e 100644 --- a/layout/generic/nsPlaceholderFrame.h +++ b/layout/generic/nsPlaceholderFrame.h @@ -102,7 +102,8 @@ class nsPlaceholderFrame final : public nsIFrame { const ReflowInput& aReflowInput, nsReflowStatus& aStatus) override; - void Destroy(DestroyContext&) override; + void DestroyFrom(nsIFrame* aDestructRoot, + PostDestroyData& aPostDestroyData) override; #if defined(DEBUG) || (defined(MOZ_REFLOW_PERF_DSP) && defined(MOZ_REFLOW_PERF)) void BuildDisplayList(nsDisplayListBuilder* aBuilder, diff --git a/layout/generic/nsRubyFrame.cpp b/layout/generic/nsRubyFrame.cpp index b3b8f9c8fb33..e52b5594b12f 100644 --- a/layout/generic/nsRubyFrame.cpp +++ b/layout/generic/nsRubyFrame.cpp @@ -260,7 +260,8 @@ void nsRubyFrame::ReflowSegment(nsPresContext* aPresContext, // line layout is not aware of the ruby text containers, hence // it is necessary to remove them here. for (uint32_t i = 0; i < rtcCount; i++) { - if (nsIFrame* nextRTC = textContainers[i]->GetNextInFlow()) { + nsIFrame* nextRTC = textContainers[i]->GetNextInFlow(); + if (nextRTC) { nextRTC->GetParent()->DeleteNextInFlowChild(nextRTC, true); } } diff --git a/layout/generic/nsSplittableFrame.cpp b/layout/generic/nsSplittableFrame.cpp index 1978c7d2d149..5e6b3c3b4011 100644 --- a/layout/generic/nsSplittableFrame.cpp +++ b/layout/generic/nsSplittableFrame.cpp @@ -26,14 +26,15 @@ void nsSplittableFrame::Init(nsIContent* aContent, nsContainerFrame* aParent, nsIFrame::Init(aContent, aParent, aPrevInFlow); } -void nsSplittableFrame::Destroy(DestroyContext& aContext) { +void nsSplittableFrame::DestroyFrom(nsIFrame* aDestructRoot, + PostDestroyData& aPostDestroyData) { // Disconnect from the flow list if (mPrevContinuation || mNextContinuation) { RemoveFromFlow(this); } // Let the base class destroy the frame - nsIFrame::Destroy(aContext); + nsIFrame::DestroyFrom(aDestructRoot, aPostDestroyData); } nsIFrame* nsSplittableFrame::GetPrevContinuation() const { diff --git a/layout/generic/nsSplittableFrame.h b/layout/generic/nsSplittableFrame.h index be1d9faaf2fd..32a1399b8a54 100644 --- a/layout/generic/nsSplittableFrame.h +++ b/layout/generic/nsSplittableFrame.h @@ -23,7 +23,8 @@ class nsSplittableFrame : public nsIFrame { void Init(nsIContent* aContent, nsContainerFrame* aParent, nsIFrame* aPrevInFlow) override; - void Destroy(DestroyContext&) override; + void DestroyFrom(nsIFrame* aDestructRoot, + PostDestroyData& aPostDestroyData) override; /* * Frame continuations can be either fluid or non-fluid. diff --git a/layout/generic/nsSubDocumentFrame.cpp b/layout/generic/nsSubDocumentFrame.cpp index 5c2b92f4252f..52ad96432b1d 100644 --- a/layout/generic/nsSubDocumentFrame.cpp +++ b/layout/generic/nsSubDocumentFrame.cpp @@ -937,7 +937,8 @@ class nsHideViewer : public Runnable { static nsView* BeginSwapDocShellsForViews(nsView* aSibling); -void nsSubDocumentFrame::Destroy(DestroyContext& aContext) { +void nsSubDocumentFrame::DestroyFrom(nsIFrame* aDestructRoot, + PostDestroyData& aPostDestroyData) { PropagateIsUnderHiddenEmbedderElementToSubView(true); if (mPostedReflowCallback) { PresShell()->CancelReflowCallback(this); @@ -970,7 +971,7 @@ void nsSubDocumentFrame::Destroy(DestroyContext& aContext) { } } - nsAtomicContainerFrame::Destroy(aContext); + nsAtomicContainerFrame::DestroyFrom(aDestructRoot, aPostDestroyData); } nsFrameLoader* nsSubDocumentFrame::FrameLoader() const { diff --git a/layout/generic/nsSubDocumentFrame.h b/layout/generic/nsSubDocumentFrame.h index da91548c8ef6..5d98de167c5c 100644 --- a/layout/generic/nsSubDocumentFrame.h +++ b/layout/generic/nsSubDocumentFrame.h @@ -53,7 +53,8 @@ class nsSubDocumentFrame final : public nsAtomicContainerFrame, void Init(nsIContent* aContent, nsContainerFrame* aParent, nsIFrame* aPrevInFlow) override; - void Destroy(DestroyContext&) override; + void DestroyFrom(nsIFrame* aDestructRoot, + PostDestroyData& aPostDestroyData) override; nscoord GetMinISize(gfxContext* aRenderingContext) override; nscoord GetPrefISize(gfxContext* aRenderingContext) override; diff --git a/layout/generic/nsTextFrame.cpp b/layout/generic/nsTextFrame.cpp index 7e0420766ff0..94a4973f813d 100644 --- a/layout/generic/nsTextFrame.cpp +++ b/layout/generic/nsTextFrame.cpp @@ -3868,7 +3868,8 @@ void nsTextFrame::ClearFrameOffsetCache() { } } -void nsTextFrame::Destroy(DestroyContext& aContext) { +void nsTextFrame::DestroyFrom(nsIFrame* aDestructRoot, + PostDestroyData& aPostDestroyData) { ClearFrameOffsetCache(); // We might want to clear NS_CREATE_FRAME_IF_NON_WHITESPACE or @@ -3879,7 +3880,7 @@ void nsTextFrame::Destroy(DestroyContext& aContext) { mNextContinuation->SetPrevInFlow(nullptr); } // Let the base class destroy the frame - nsIFrame::Destroy(aContext); + nsIFrame::DestroyFrom(aDestructRoot, aPostDestroyData); } nsTArray* nsTextFrame::GetContinuations() { @@ -3921,7 +3922,8 @@ class nsContinuingTextFrame final : public nsTextFrame { void Init(nsIContent* aContent, nsContainerFrame* aParent, nsIFrame* aPrevInFlow) final; - void Destroy(DestroyContext&) override; + void DestroyFrom(nsIFrame* aDestructRoot, + PostDestroyData& aPostDestroyData) final; nsTextFrame* GetPrevContinuation() const final { return mPrevContinuation; } @@ -4087,7 +4089,8 @@ void nsContinuingTextFrame::Init(nsIContent* aContent, } // prev frame is bidi } -void nsContinuingTextFrame::Destroy(DestroyContext& aContext) { +void nsContinuingTextFrame::DestroyFrom(nsIFrame* aDestructRoot, + PostDestroyData& aPostDestroyData) { ClearFrameOffsetCache(); // The text associated with this frame will become associated with our @@ -4110,7 +4113,7 @@ void nsContinuingTextFrame::Destroy(DestroyContext& aContext) { } nsSplittableFrame::RemoveFromFlow(this); // Let the base class destroy the frame - nsIFrame::Destroy(aContext); + nsIFrame::DestroyFrom(aDestructRoot, aPostDestroyData); } nsIFrame* nsContinuingTextFrame::FirstInFlow() const { @@ -8893,8 +8896,7 @@ static void RemoveEmptyInFlows(nsTextFrame* aFrame, // Manually call DoRemoveFrame so we can tell it that we're // removing empty frames; this will keep it from blowing away // text runs. - nsIFrame::DestroyContext context(aFrame); - parentBlock->DoRemoveFrame(aFrame, nsBlockFrame::FRAMES_ARE_EMPTY, context); + parentBlock->DoRemoveFrame(aFrame, nsBlockFrame::FRAMES_ARE_EMPTY); } else { // Just remove it normally; use FrameChildListID::NoReflowPrincipal to avoid // posting new reflows. diff --git a/layout/generic/nsTextFrame.h b/layout/generic/nsTextFrame.h index 883bf3819ccd..2a7fe052cd16 100644 --- a/layout/generic/nsTextFrame.h +++ b/layout/generic/nsTextFrame.h @@ -222,7 +222,8 @@ class nsTextFrame : public nsIFrame { void Init(nsIContent* aContent, nsContainerFrame* aParent, nsIFrame* aPrevInFlow) override; - void Destroy(DestroyContext&) override; + void DestroyFrom(nsIFrame* aDestructRoot, + PostDestroyData& aPostDestroyData) override; mozilla::Maybe GetCursor(const nsPoint&) final; diff --git a/layout/generic/nsVideoFrame.cpp b/layout/generic/nsVideoFrame.cpp index 1ebf719b2534..cdd65659309e 100644 --- a/layout/generic/nsVideoFrame.cpp +++ b/layout/generic/nsVideoFrame.cpp @@ -147,13 +147,14 @@ nsIContent* nsVideoFrame::GetVideoControls() const { return mContent->GetShadowRoot()->GetFirstChild(); } -void nsVideoFrame::Destroy(DestroyContext& aContext) { +void nsVideoFrame::DestroyFrom(nsIFrame* aDestructRoot, + PostDestroyData& aPostDestroyData) { if (mReflowCallbackPosted) { PresShell()->CancelReflowCallback(this); } - aContext.AddAnonymousContent(mCaptionDiv.forget()); - aContext.AddAnonymousContent(mPosterImage.forget()); - nsContainerFrame::Destroy(aContext); + aPostDestroyData.AddAnonymousContent(mCaptionDiv.forget()); + aPostDestroyData.AddAnonymousContent(mPosterImage.forget()); + nsContainerFrame::DestroyFrom(aDestructRoot, aPostDestroyData); } class DispatchResizeEvent : public Runnable { diff --git a/layout/generic/nsVideoFrame.h b/layout/generic/nsVideoFrame.h index c8283aac4613..e225e4354004 100644 --- a/layout/generic/nsVideoFrame.h +++ b/layout/generic/nsVideoFrame.h @@ -58,7 +58,8 @@ class nsVideoFrame final : public nsContainerFrame, mozilla::ComputeSizeFlags aFlags) override; nscoord GetMinISize(gfxContext* aRenderingContext) override; nscoord GetPrefISize(gfxContext* aRenderingContext) override; - void Destroy(DestroyContext&) override; + void DestroyFrom(nsIFrame* aDestructRoot, + PostDestroyData& aPostDestroyData) override; void Reflow(nsPresContext* aPresContext, ReflowOutput& aDesiredSize, const ReflowInput& aReflowInput, diff --git a/layout/mathml/nsMathMLmunderoverFrame.cpp b/layout/mathml/nsMathMLmunderoverFrame.cpp index 05bf1d288679..772542aaae59 100644 --- a/layout/mathml/nsMathMLmunderoverFrame.cpp +++ b/layout/mathml/nsMathMLmunderoverFrame.cpp @@ -75,11 +75,12 @@ nsMathMLmunderoverFrame::InheritAutomaticData(nsIFrame* aParent) { return NS_OK; } -void nsMathMLmunderoverFrame::Destroy(DestroyContext& aContext) { +void nsMathMLmunderoverFrame::DestroyFrom(nsIFrame* aDestroyRoot, + PostDestroyData& aPostDestroyData) { if (!mPostReflowIncrementScriptLevelCommands.IsEmpty()) { PresShell()->CancelReflowCallback(this); } - nsMathMLContainerFrame::Destroy(aContext); + nsMathMLContainerFrame::DestroyFrom(aDestroyRoot, aPostDestroyData); } uint8_t nsMathMLmunderoverFrame::ScriptIncrement(nsIFrame* aFrame) { diff --git a/layout/mathml/nsMathMLmunderoverFrame.h b/layout/mathml/nsMathMLmunderoverFrame.h index 1282464ed367..e2258979fb60 100644 --- a/layout/mathml/nsMathMLmunderoverFrame.h +++ b/layout/mathml/nsMathMLmunderoverFrame.h @@ -37,7 +37,7 @@ class nsMathMLmunderoverFrame final : public nsMathMLContainerFrame, NS_IMETHOD UpdatePresentationData(uint32_t aFlagsValues, uint32_t aFlagsToUpdate) override; - void Destroy(DestroyContext&) override; + void DestroyFrom(nsIFrame* aRoot, PostDestroyData& aPostDestroyData) override; nsresult AttributeChanged(int32_t aNameSpaceID, nsAtom* aAttribute, int32_t aModType) override; diff --git a/layout/svg/SVGFEImageFrame.cpp b/layout/svg/SVGFEImageFrame.cpp index 1cfe788d89bf..2b8fd4a2eb63 100644 --- a/layout/svg/SVGFEImageFrame.cpp +++ b/layout/svg/SVGFEImageFrame.cpp @@ -42,7 +42,8 @@ class SVGFEImageFrame final : public nsIFrame { virtual void Init(nsIContent* aContent, nsContainerFrame* aParent, nsIFrame* aPrevInFlow) override; - void Destroy(DestroyContext&) override; + virtual void DestroyFrom(nsIFrame* aDestructRoot, + PostDestroyData& aPostDestroyData) override; bool IsFrameOfType(uint32_t aFlags) const override { if (aFlags & eSupportsContainLayoutAndPaint) { @@ -84,7 +85,8 @@ namespace mozilla { NS_IMPL_FRAMEARENA_HELPERS(SVGFEImageFrame) /* virtual */ -void SVGFEImageFrame::Destroy(DestroyContext& aContext) { +void SVGFEImageFrame::DestroyFrom(nsIFrame* aDestructRoot, + PostDestroyData& aPostDestroyData) { DecApproximateVisibleCount(); nsCOMPtr imageLoader = @@ -93,7 +95,7 @@ void SVGFEImageFrame::Destroy(DestroyContext& aContext) { imageLoader->FrameDestroyed(this); } - nsIFrame::Destroy(aContext); + nsIFrame::DestroyFrom(aDestructRoot, aPostDestroyData); } void SVGFEImageFrame::Init(nsIContent* aContent, nsContainerFrame* aParent, diff --git a/layout/svg/SVGImageFrame.cpp b/layout/svg/SVGImageFrame.cpp index da04beee71bd..390f3717d3c3 100644 --- a/layout/svg/SVGImageFrame.cpp +++ b/layout/svg/SVGImageFrame.cpp @@ -121,7 +121,8 @@ void SVGImageFrame::Init(nsIContent* aContent, nsContainerFrame* aParent, } /* virtual */ -void SVGImageFrame::Destroy(DestroyContext& aContext) { +void SVGImageFrame::DestroyFrom(nsIFrame* aDestructRoot, + PostDestroyData& aPostDestroyData) { if (HasAnyStateBits(NS_FRAME_IS_NONDISPLAY)) { DecApproximateVisibleCount(); } @@ -138,7 +139,7 @@ void SVGImageFrame::Destroy(DestroyContext& aContext) { imageLoader->FrameDestroyed(this); } - nsIFrame::Destroy(aContext); + nsIFrame::DestroyFrom(aDestructRoot, aPostDestroyData); } /* virtual */ diff --git a/layout/svg/SVGImageFrame.h b/layout/svg/SVGImageFrame.h index 71e291e57953..3650dc9e5cd1 100644 --- a/layout/svg/SVGImageFrame.h +++ b/layout/svg/SVGImageFrame.h @@ -89,8 +89,8 @@ class SVGImageFrame final : public nsIFrame, void Init(nsIContent* aContent, nsContainerFrame* aParent, nsIFrame* aPrevInFlow) override; - void Destroy(DestroyContext&) override; - + void DestroyFrom(nsIFrame* aDestructRoot, + PostDestroyData& aPostDestroyData) override; void DidSetComputedStyle(ComputedStyle* aOldStyle) final; bool IsSVGTransformed(Matrix* aOwnTransforms = nullptr, diff --git a/layout/svg/SVGOuterSVGFrame.cpp b/layout/svg/SVGOuterSVGFrame.cpp index a43e6815cdb6..9398f64e5209 100644 --- a/layout/svg/SVGOuterSVGFrame.cpp +++ b/layout/svg/SVGOuterSVGFrame.cpp @@ -774,14 +774,15 @@ void SVGOuterSVGFrame::DidSetComputedStyle(ComputedStyle* aOldComputedStyle) { } } -void SVGOuterSVGFrame::Destroy(DestroyContext& aContext) { +void SVGOuterSVGFrame::DestroyFrom(nsIFrame* aDestructRoot, + PostDestroyData& aPostDestroyData) { // This handles both the case when the root element is made display:none // (and thus loses its intrinsic size and aspect ratio), and when the frame // is navigated elsewhere & we need to reset parent /'s // recorded intrinsic size/ratio values. MaybeSendIntrinsicSizeAndRatioToEmbedder(Nothing(), Nothing()); - SVGDisplayContainerFrame::Destroy(aContext); + SVGDisplayContainerFrame::DestroyFrom(aDestructRoot, aPostDestroyData); } } // namespace mozilla diff --git a/layout/svg/SVGOuterSVGFrame.h b/layout/svg/SVGOuterSVGFrame.h index 82c207934868..71dd02f4c237 100644 --- a/layout/svg/SVGOuterSVGFrame.h +++ b/layout/svg/SVGOuterSVGFrame.h @@ -88,7 +88,8 @@ class SVGOuterSVGFrame final : public SVGDisplayContainerFrame, void DidSetComputedStyle(ComputedStyle* aOldComputedStyle) override; - void Destroy(DestroyContext&) override; + void DestroyFrom(nsIFrame* aDestructRoot, + PostDestroyData& aPostDestroyData) override; nsresult AttributeChanged(int32_t aNameSpaceID, nsAtom* aAttribute, int32_t aModType) override; diff --git a/layout/tables/nsTableCellFrame.cpp b/layout/tables/nsTableCellFrame.cpp index 28d55f80ad59..faee6f0d816e 100644 --- a/layout/tables/nsTableCellFrame.cpp +++ b/layout/tables/nsTableCellFrame.cpp @@ -81,10 +81,10 @@ void nsTableCellFrame::Init(nsIContent* aContent, nsContainerFrame* aParent, } } -void nsTableCellFrame::Destroy(DestroyContext& aContext) { - nsTableFrame::MaybeUnregisterPositionedTablePart(this, - aContext.DestructRoot()); - nsContainerFrame::Destroy(aContext); +void nsTableCellFrame::DestroyFrom(nsIFrame* aDestructRoot, + PostDestroyData& aPostDestroyData) { + nsTableFrame::MaybeUnregisterPositionedTablePart(this, aDestructRoot); + nsContainerFrame::DestroyFrom(aDestructRoot, aPostDestroyData); } // nsIPercentBSizeObserver methods diff --git a/layout/tables/nsTableCellFrame.h b/layout/tables/nsTableCellFrame.h index 192dacfce90b..2cb9e826b49a 100644 --- a/layout/tables/nsTableCellFrame.h +++ b/layout/tables/nsTableCellFrame.h @@ -66,7 +66,8 @@ class nsTableCellFrame : public nsContainerFrame, void Init(nsIContent* aContent, nsContainerFrame* aParent, nsIFrame* aPrevInFlow) override; - void Destroy(DestroyContext&) override; + void DestroyFrom(nsIFrame* aDestructRoot, + PostDestroyData& aPostDestroyData) override; #ifdef ACCESSIBILITY mozilla::a11y::AccType AccessibleType() override; diff --git a/layout/tables/nsTableFrame.cpp b/layout/tables/nsTableFrame.cpp index d307dec982b7..d91922b12190 100644 --- a/layout/tables/nsTableFrame.cpp +++ b/layout/tables/nsTableFrame.cpp @@ -210,9 +210,10 @@ void nsTableFrame::Init(nsIContent* aContent, nsContainerFrame* aParent, // the header only has forward declarations of them. nsTableFrame::~nsTableFrame() = default; -void nsTableFrame::Destroy(DestroyContext& aContext) { - mColGroups.DestroyFrames(aContext); - nsContainerFrame::Destroy(aContext); +void nsTableFrame::DestroyFrom(nsIFrame* aDestructRoot, + PostDestroyData& aPostDestroyData) { + mColGroups.DestroyFramesFrom(aDestructRoot, aPostDestroyData); + nsContainerFrame::DestroyFrom(aDestructRoot, aPostDestroyData); } // Make sure any views are positioned properly diff --git a/layout/tables/nsTableFrame.h b/layout/tables/nsTableFrame.h index 4fd7f09700a6..f5bb89c8e8cc 100644 --- a/layout/tables/nsTableFrame.h +++ b/layout/tables/nsTableFrame.h @@ -197,7 +197,8 @@ class nsTableFrame : public nsContainerFrame { void RowOrColSpanChanged(nsTableCellFrame* aCellFrame); /** @see nsIFrame::DestroyFrom */ - void Destroy(DestroyContext&) override; + virtual void DestroyFrom(nsIFrame* aDestructRoot, + PostDestroyData& aPostDestroyData) override; /** @see nsIFrame::DidSetComputedStyle */ virtual void DidSetComputedStyle(ComputedStyle* aOldComputedStyle) override; diff --git a/layout/tables/nsTableRowFrame.cpp b/layout/tables/nsTableRowFrame.cpp index 58ad680d9825..6a35c088a919 100644 --- a/layout/tables/nsTableRowFrame.cpp +++ b/layout/tables/nsTableRowFrame.cpp @@ -154,10 +154,10 @@ void nsTableRowFrame::Init(nsIContent* aContent, nsContainerFrame* aParent, } } -void nsTableRowFrame::Destroy(DestroyContext& aContext) { - nsTableFrame::MaybeUnregisterPositionedTablePart(this, - aContext.DestructRoot()); - nsContainerFrame::Destroy(aContext); +void nsTableRowFrame::DestroyFrom(nsIFrame* aDestructRoot, + PostDestroyData& aPostDestroyData) { + nsTableFrame::MaybeUnregisterPositionedTablePart(this, aDestructRoot); + nsContainerFrame::DestroyFrom(aDestructRoot, aPostDestroyData); } /* virtual */ diff --git a/layout/tables/nsTableRowFrame.h b/layout/tables/nsTableRowFrame.h index 06e665357105..6ca6d78bdaa3 100644 --- a/layout/tables/nsTableRowFrame.h +++ b/layout/tables/nsTableRowFrame.h @@ -39,7 +39,8 @@ class nsTableRowFrame : public nsContainerFrame { void Init(nsIContent* aContent, nsContainerFrame* aParent, nsIFrame* aPrevInFlow) override; - void Destroy(DestroyContext&) override; + void DestroyFrom(nsIFrame* aDestructRoot, + PostDestroyData& aPostDestroyData) override; void DidSetComputedStyle(ComputedStyle* aOldComputedStyle) override; diff --git a/layout/tables/nsTableRowGroupFrame.cpp b/layout/tables/nsTableRowGroupFrame.cpp index 85b859846ea6..e5b88bcf22b3 100644 --- a/layout/tables/nsTableRowGroupFrame.cpp +++ b/layout/tables/nsTableRowGroupFrame.cpp @@ -62,10 +62,10 @@ nsTableRowGroupFrame::nsTableRowGroupFrame(ComputedStyle* aStyle, nsTableRowGroupFrame::~nsTableRowGroupFrame() = default; -void nsTableRowGroupFrame::Destroy(DestroyContext& aContext) { - nsTableFrame::MaybeUnregisterPositionedTablePart(this, - aContext.DestructRoot()); - nsContainerFrame::Destroy(aContext); +void nsTableRowGroupFrame::DestroyFrom(nsIFrame* aDestructRoot, + PostDestroyData& aPostDestroyData) { + nsTableFrame::MaybeUnregisterPositionedTablePart(this, aDestructRoot); + nsContainerFrame::DestroyFrom(aDestructRoot, aPostDestroyData); } NS_QUERYFRAME_HEAD(nsTableRowGroupFrame) diff --git a/layout/tables/nsTableRowGroupFrame.h b/layout/tables/nsTableRowGroupFrame.h index ddbecfccc7bb..8f904df0b20d 100644 --- a/layout/tables/nsTableRowGroupFrame.h +++ b/layout/tables/nsTableRowGroupFrame.h @@ -57,7 +57,8 @@ class nsTableRowGroupFrame final : public nsContainerFrame, } } - void Destroy(DestroyContext&) override; + void DestroyFrom(nsIFrame* aDestructRoot, + PostDestroyData& aPostDestroyData) override; /** @see nsIFrame::DidSetComputedStyle */ void DidSetComputedStyle(ComputedStyle* aOldComputedStyle) override; diff --git a/layout/tables/nsTableWrapperFrame.cpp b/layout/tables/nsTableWrapperFrame.cpp index 6d2ed101f6aa..85b4ce091851 100644 --- a/layout/tables/nsTableWrapperFrame.cpp +++ b/layout/tables/nsTableWrapperFrame.cpp @@ -82,10 +82,11 @@ a11y::AccType nsTableWrapperFrame::AccessibleType() { } #endif -void nsTableWrapperFrame::Destroy(DestroyContext& aContext) { - DestroyAbsoluteFrames(aContext); - mCaptionFrames.DestroyFrames(aContext); - nsContainerFrame::Destroy(aContext); +void nsTableWrapperFrame::DestroyFrom(nsIFrame* aDestructRoot, + PostDestroyData& aPostDestroyData) { + DestroyAbsoluteFrames(aDestructRoot, aPostDestroyData); + mCaptionFrames.DestroyFramesFrom(aDestructRoot, aPostDestroyData); + nsContainerFrame::DestroyFrom(aDestructRoot, aPostDestroyData); } const nsFrameList& nsTableWrapperFrame::GetChildList( diff --git a/layout/tables/nsTableWrapperFrame.h b/layout/tables/nsTableWrapperFrame.h index 89b3fb219035..641ded6a5225 100644 --- a/layout/tables/nsTableWrapperFrame.h +++ b/layout/tables/nsTableWrapperFrame.h @@ -36,7 +36,8 @@ class nsTableWrapperFrame : public nsContainerFrame { // nsIFrame overrides - see there for a description - void Destroy(DestroyContext&) override; + virtual void DestroyFrom(nsIFrame* aDestructRoot, + PostDestroyData& aPostDestroyData) override; virtual const nsFrameList& GetChildList(ChildListID aListID) const override; virtual void GetChildLists(nsTArray* aLists) const override; diff --git a/layout/xul/nsMenuPopupFrame.cpp b/layout/xul/nsMenuPopupFrame.cpp index c431ff3967c4..76ded4a6c583 100644 --- a/layout/xul/nsMenuPopupFrame.cpp +++ b/layout/xul/nsMenuPopupFrame.cpp @@ -2159,7 +2159,8 @@ void nsMenuPopupFrame::MoveToAttributePosition() { this, IntrinsicDirty::FrameAncestorsAndDescendants, NS_FRAME_IS_DIRTY); } -void nsMenuPopupFrame::Destroy(DestroyContext& aContext) { +void nsMenuPopupFrame::DestroyFrom(nsIFrame* aDestructRoot, + PostDestroyData& aPostDestroyData) { // XXX: Currently we don't fire popuphidden for these popups, that seems wrong // but alas, also pre-existing. HidePopup(/* aDeselectMenu = */ false, ePopupClosed, @@ -2169,7 +2170,7 @@ void nsMenuPopupFrame::Destroy(DestroyContext& aContext) { pm->PopupDestroyed(this); } - nsBlockFrame::Destroy(aContext); + nsBlockFrame::DestroyFrom(aDestructRoot, aPostDestroyData); } nsMargin nsMenuPopupFrame::GetMargin() const { diff --git a/layout/xul/nsMenuPopupFrame.h b/layout/xul/nsMenuPopupFrame.h index e9f0b2a52176..84c96e35582c 100644 --- a/layout/xul/nsMenuPopupFrame.h +++ b/layout/xul/nsMenuPopupFrame.h @@ -195,7 +195,8 @@ class nsMenuPopupFrame final : public nsBlockFrame { int32_t aModType) override; // FIXME: This shouldn't run script (this can end up calling HidePopup). - MOZ_CAN_RUN_SCRIPT_BOUNDARY void Destroy(DestroyContext&) override; + MOZ_CAN_RUN_SCRIPT_BOUNDARY void DestroyFrom( + nsIFrame* aDestructRoot, PostDestroyData& aPostDestroyData) override; bool HasRemoteContent() const; diff --git a/layout/xul/nsScrollbarButtonFrame.cpp b/layout/xul/nsScrollbarButtonFrame.cpp index e9bb69016a9f..608e6c80242d 100644 --- a/layout/xul/nsScrollbarButtonFrame.cpp +++ b/layout/xul/nsScrollbarButtonFrame.cpp @@ -264,9 +264,10 @@ nsresult nsScrollbarButtonFrame::GetParentWithTag(nsAtom* toFind, return NS_OK; } -void nsScrollbarButtonFrame::Destroy(DestroyContext& aContext) { +void nsScrollbarButtonFrame::DestroyFrom(nsIFrame* aDestructRoot, + PostDestroyData& aPostDestroyData) { // Ensure our repeat service isn't going... it's possible that a scrollbar can // disappear out from under you while you're in the process of scrolling. StopRepeat(); - SimpleXULLeafFrame::Destroy(aContext); + SimpleXULLeafFrame::DestroyFrom(aDestructRoot, aPostDestroyData); } diff --git a/layout/xul/nsScrollbarButtonFrame.h b/layout/xul/nsScrollbarButtonFrame.h index 0f2d2ab56c6b..b3e4caf44b8e 100644 --- a/layout/xul/nsScrollbarButtonFrame.h +++ b/layout/xul/nsScrollbarButtonFrame.h @@ -32,7 +32,8 @@ class nsScrollbarButtonFrame final : public mozilla::SimpleXULLeafFrame { : mozilla::SimpleXULLeafFrame(aStyle, aPresContext, kClassID) {} // Overrides - void Destroy(DestroyContext&) override; + void DestroyFrom(nsIFrame* aDestructRoot, + PostDestroyData& aPostDestroyData) override; friend nsIFrame* NS_NewScrollbarButtonFrame(mozilla::PresShell* aPresShell, ComputedStyle* aStyle); diff --git a/layout/xul/nsScrollbarFrame.cpp b/layout/xul/nsScrollbarFrame.cpp index 76304bf50273..9a9fbc4aa932 100644 --- a/layout/xul/nsScrollbarFrame.cpp +++ b/layout/xul/nsScrollbarFrame.cpp @@ -58,13 +58,14 @@ void nsScrollbarFrame::Init(nsIContent* aContent, nsContainerFrame* aParent, AddStateBits(NS_FRAME_REFLOW_ROOT); } -void nsScrollbarFrame::Destroy(DestroyContext& aContext) { - aContext.AddAnonymousContent(mUpTopButton.forget()); - aContext.AddAnonymousContent(mDownTopButton.forget()); - aContext.AddAnonymousContent(mSlider.forget()); - aContext.AddAnonymousContent(mUpBottomButton.forget()); - aContext.AddAnonymousContent(mDownBottomButton.forget()); - nsContainerFrame::Destroy(aContext); +void nsScrollbarFrame::DestroyFrom(nsIFrame* aDestructRoot, + PostDestroyData& aPostDestroyData) { + aPostDestroyData.AddAnonymousContent(mUpTopButton.forget()); + aPostDestroyData.AddAnonymousContent(mDownTopButton.forget()); + aPostDestroyData.AddAnonymousContent(mSlider.forget()); + aPostDestroyData.AddAnonymousContent(mUpBottomButton.forget()); + aPostDestroyData.AddAnonymousContent(mDownBottomButton.forget()); + nsContainerFrame::DestroyFrom(aDestructRoot, aPostDestroyData); } void nsScrollbarFrame::Reflow(nsPresContext* aPresContext, diff --git a/layout/xul/nsScrollbarFrame.h b/layout/xul/nsScrollbarFrame.h index 4b48295f027e..485acc6881d6 100644 --- a/layout/xul/nsScrollbarFrame.h +++ b/layout/xul/nsScrollbarFrame.h @@ -83,7 +83,8 @@ class nsScrollbarFrame final : public nsContainerFrame, nsSize ScrollbarMinSize() const; bool IsHorizontal() const; - void Destroy(DestroyContext&) override; + void DestroyFrom(nsIFrame* aDestructRoot, + PostDestroyData& aPostDestroyData) override; void Init(nsIContent* aContent, nsContainerFrame* aParent, nsIFrame* aPrevInFlow) override; diff --git a/layout/xul/nsSliderFrame.cpp b/layout/xul/nsSliderFrame.cpp index 468b98d0e61d..fc6e77cd2722 100644 --- a/layout/xul/nsSliderFrame.cpp +++ b/layout/xul/nsSliderFrame.cpp @@ -1437,7 +1437,8 @@ nsSliderFrame::HandleRelease(nsPresContext* aPresContext, return NS_OK; } -void nsSliderFrame::Destroy(DestroyContext& aContext) { +void nsSliderFrame::DestroyFrom(nsIFrame* aDestructRoot, + PostDestroyData& aPostDestroyData) { // tell our mediator if we have one we are gone. if (mMediator) { mMediator->SetSlider(nullptr); @@ -1446,7 +1447,7 @@ void nsSliderFrame::Destroy(DestroyContext& aContext) { StopRepeat(); // call base class Destroy() - nsContainerFrame::Destroy(aContext); + nsContainerFrame::DestroyFrom(aDestructRoot, aPostDestroyData); } void nsSliderFrame::Notify() { diff --git a/layout/xul/nsSliderFrame.h b/layout/xul/nsSliderFrame.h index bcf7a7a8abe9..5b48fab75454 100644 --- a/layout/xul/nsSliderFrame.h +++ b/layout/xul/nsSliderFrame.h @@ -73,7 +73,8 @@ class nsSliderFrame final : public nsContainerFrame { nsReflowStatus& aStatus) override; // nsIFrame overrides - void Destroy(DestroyContext&) override; + void DestroyFrom(nsIFrame* aDestructRoot, + PostDestroyData& aPostDestroyData) override; void BuildDisplayList(nsDisplayListBuilder* aBuilder, const nsDisplayListSet& aLists) override; diff --git a/layout/xul/nsSplitterFrame.cpp b/layout/xul/nsSplitterFrame.cpp index 89d3ac1c25e8..3dcbc058a6df 100644 --- a/layout/xul/nsSplitterFrame.cpp +++ b/layout/xul/nsSplitterFrame.cpp @@ -216,13 +216,14 @@ nsSplitterFrame::nsSplitterFrame(ComputedStyle* aStyle, nsPresContext* aPresContext) : SimpleXULLeafFrame(aStyle, aPresContext, kClassID) {} -void nsSplitterFrame::Destroy(DestroyContext& aContext) { +void nsSplitterFrame::DestroyFrom(nsIFrame* aDestructRoot, + PostDestroyData& aPostDestroyData) { if (mInner) { mInner->RemoveListener(); mInner->Disconnect(); mInner = nullptr; } - SimpleXULLeafFrame::Destroy(aContext); + SimpleXULLeafFrame::DestroyFrom(aDestructRoot, aPostDestroyData); } nsresult nsSplitterFrame::AttributeChanged(int32_t aNameSpaceID, diff --git a/layout/xul/nsSplitterFrame.h b/layout/xul/nsSplitterFrame.h index 72e1f4c51bd4..7c582cb45177 100644 --- a/layout/xul/nsSplitterFrame.h +++ b/layout/xul/nsSplitterFrame.h @@ -29,7 +29,8 @@ class nsSplitterFrame final : public mozilla::SimpleXULLeafFrame { NS_DECL_FRAMEARENA_HELPERS(nsSplitterFrame) explicit nsSplitterFrame(ComputedStyle* aStyle, nsPresContext* aPresContext); - void Destroy(DestroyContext&) override; + void DestroyFrom(nsIFrame* aDestructRoot, + PostDestroyData& aPostDestroyData) override; #ifdef DEBUG_FRAME_DUMP nsresult GetFrameName(nsAString& aResult) const override { diff --git a/layout/xul/tree/nsTreeBodyFrame.cpp b/layout/xul/tree/nsTreeBodyFrame.cpp index 3511d05593e0..2ca5983f421c 100644 --- a/layout/xul/tree/nsTreeBodyFrame.cpp +++ b/layout/xul/tree/nsTreeBodyFrame.cpp @@ -298,7 +298,8 @@ void nsTreeBodyFrame::Init(nsIContent* aContent, nsContainerFrame* aParent, } } -void nsTreeBodyFrame::Destroy(DestroyContext& aContext) { +void nsTreeBodyFrame::DestroyFrom(nsIFrame* aDestructRoot, + PostDestroyData& aPostDestroyData) { if (mScrollbarActivity) { mScrollbarActivity->Destroy(); mScrollbarActivity = nullptr; @@ -333,7 +334,7 @@ void nsTreeBodyFrame::Destroy(DestroyContext& aContext) { mTree->BodyDestroyed(mTopRowIndex); } - SimpleXULLeafFrame::Destroy(aContext); + SimpleXULLeafFrame::DestroyFrom(aDestructRoot, aPostDestroyData); } void nsTreeBodyFrame::EnsureView() { diff --git a/layout/xul/tree/nsTreeBodyFrame.h b/layout/xul/tree/nsTreeBodyFrame.h index 35fa7eb1f03d..14f1d0b7fac0 100644 --- a/layout/xul/tree/nsTreeBodyFrame.h +++ b/layout/xul/tree/nsTreeBodyFrame.h @@ -157,7 +157,8 @@ class nsTreeBodyFrame final : public mozilla::SimpleXULLeafFrame, // Overridden from nsIFrame to cache our pres context. void Init(nsIContent* aContent, nsContainerFrame* aParent, nsIFrame* aPrevInFlow) override; - void Destroy(DestroyContext&) override; + void DestroyFrom(nsIFrame* aDestructRoot, + PostDestroyData& aPostDestroyData) override; mozilla::Maybe GetCursor(const nsPoint&) override;