From 3b12db1071ab74e33d0470d2d4a86222033be32e Mon Sep 17 00:00:00 2001 From: "alecf%netscape.com" Date: Wed, 15 Dec 1999 20:58:32 +0000 Subject: [PATCH] fix for #20508 set parent of anonymous to nsnull before destroying the frames, and remove the frame references from the event state mananger r=hyatt,waterson a=chofmann --- layout/xul/base/src/nsTreeRowGroupFrame.cpp | 31 +++++++++++++++++++++ layout/xul/base/src/nsTreeRowGroupFrame.h | 2 ++ 2 files changed, 33 insertions(+) diff --git a/layout/xul/base/src/nsTreeRowGroupFrame.cpp b/layout/xul/base/src/nsTreeRowGroupFrame.cpp index 19bffaf47b1c..555466a087a4 100644 --- a/layout/xul/base/src/nsTreeRowGroupFrame.cpp +++ b/layout/xul/base/src/nsTreeRowGroupFrame.cpp @@ -1018,6 +1018,13 @@ nsTreeRowGroupFrame::ReflowAfterRowLayout(nsIPresContext* aPresContext, } if (nukeScrollbar || (value == "0" && !mIsFull)) { + + // clear the scrollbar out of the event state manager so that the + // event manager doesn't send events to the destroyed scrollbar frames + nsCOMPtr shell; + aPresContext->GetShell(getter_AddRefs(shell)); + ClearFrameRefs(shell, mScrollbar); + // Nuke the scrollbar. mFrameConstructor->RemoveMappingsForFrameSubtree(aPresContext, mScrollbar, nsnull); mScrollbarList.DestroyFrames(aPresContext); @@ -1961,6 +1968,30 @@ nsTreeRowGroupFrame :: AttributeChanged ( nsIPresContext* aPresContext, nsIConte } // AttributeChanged +void +nsTreeRowGroupFrame::ClearFrameRefs(nsIPresShell *aShell, nsIFrame *aParent) +{ + nsIFrame* child; + aParent->FirstChild(nsnull,&child); + + while (child) { + + // since we're destroying anonymous frames, we should also + // set the parent to null. Otherwise, the event manager holds a + // reference to the anonymous node, but the parent node + // goes away + // we don't do this to aParent because that's the scrollbar node itself + nsCOMPtr content; + child->GetContent(getter_AddRefs(content)); + content->SetParent(nsnull); + + ClearFrameRefs(aShell, child); + child->GetNextSibling(&child); + } + aShell->ClearFrameRefs(aParent); +} + + // // Paint diff --git a/layout/xul/base/src/nsTreeRowGroupFrame.h b/layout/xul/base/src/nsTreeRowGroupFrame.h index d88cd941f23f..a5e165f2dab5 100644 --- a/layout/xul/base/src/nsTreeRowGroupFrame.h +++ b/layout/xul/base/src/nsTreeRowGroupFrame.h @@ -150,6 +150,8 @@ protected: void ComputeTotalRowCount(PRInt32& rowCount, nsIContent* aParent); + static void ClearFrameRefs(nsIPresShell* aPresShell, nsIFrame *aParent); + public: // Helpers that allow access to info. The tree is the primary consumer of this // info.