diff --git a/layout/base/nsPresShell.cpp b/layout/base/nsPresShell.cpp index 7100da93718a..171d0536317f 100644 --- a/layout/base/nsPresShell.cpp +++ b/layout/base/nsPresShell.cpp @@ -1028,6 +1028,18 @@ protected: // Utility method to restore the root scrollframe state void RestoreRootScrollPosition(); + void MaybeReleaseCapturingContent() + { + nsCOMPtr frameSelection = FrameSelection(); + if (frameSelection) { + frameSelection->SetMouseDownState(PR_FALSE); + } + if (gCaptureInfo.mContent && + gCaptureInfo.mContent->GetOwnerDoc() == mDocument) { + SetCapturingContent(nsnull, 0); + } + } + nsCOMPtr mPrefStyleSheet; // mStyleSet owns it but we // maintain a ref, may be null #ifdef DEBUG @@ -1832,6 +1844,8 @@ PresShell::Destroy() if (mHaveShutDown) return NS_OK; + MaybeReleaseCapturingContent(); + mContentToScrollTo = nsnull; if (mPresContext) { @@ -7075,6 +7089,8 @@ FreezeSubDocument(nsIDocument *aDocument, void *aData) void PresShell::Freeze() { + MaybeReleaseCapturingContent(); + mDocument->EnumerateFreezableElements(FreezeElement, this); if (mCaret)