diff --git a/mozilla/layout/xul/base/src/nsTreeRowGroupFrame.cpp b/mozilla/layout/xul/base/src/nsTreeRowGroupFrame.cpp index 19bffaf47b1..555466a087a 100644 --- a/mozilla/layout/xul/base/src/nsTreeRowGroupFrame.cpp +++ b/mozilla/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/mozilla/layout/xul/base/src/nsTreeRowGroupFrame.h b/mozilla/layout/xul/base/src/nsTreeRowGroupFrame.h index d88cd941f23..a5e165f2dab 100644 --- a/mozilla/layout/xul/base/src/nsTreeRowGroupFrame.h +++ b/mozilla/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.