diff --git a/mozilla/content/base/src/nsDocumentViewer.cpp b/mozilla/content/base/src/nsDocumentViewer.cpp index 693f4d9a715..de6a7aed964 100644 --- a/mozilla/content/base/src/nsDocumentViewer.cpp +++ b/mozilla/content/base/src/nsDocumentViewer.cpp @@ -372,7 +372,30 @@ public: NS_DECL_ISUPPORTS // nsIContentViewer interface... - NS_DECL_NSICONTENTVIEWER + NS_IMETHOD Init(nsIWidget* aParentWidget, + nsIDeviceContext* aDeviceContext, + const nsRect& aBounds); + NS_IMETHOD SetContainer(nsISupports* aContainer); + NS_IMETHOD GetContainer(nsISupports** aContainerResult); + NS_IMETHOD LoadStart(nsISupports* aDoc); + NS_IMETHOD LoadComplete(nsresult aStatus); + NS_IMETHOD Unload(void); + NS_IMETHOD Destroy(void); + NS_IMETHOD Stop(void); + NS_IMETHOD GetDOMDocument(nsIDOMDocument **aResult); + NS_IMETHOD SetDOMDocument(nsIDOMDocument *aDocument); + NS_IMETHOD GetBounds(nsRect& aResult); + NS_IMETHOD SetBounds(const nsRect& aBounds); + + NS_IMETHOD GetPreviousViewer(nsIContentViewer** aResult); + NS_IMETHOD SetPreviousViewer(nsIContentViewer* aViewer); + + NS_IMETHOD Move(PRInt32 aX, PRInt32 aY); + NS_IMETHOD Show(); + NS_IMETHOD Hide(); + NS_IMETHOD Validate(); + NS_IMETHOD SetEnableRendering(PRBool aOn); + NS_IMETHOD GetEnableRendering(PRBool* aResult); // nsIDocumentViewer interface... NS_IMETHOD SetUAStyleSheet(nsIStyleSheet* aUAStyleSheet); @@ -822,14 +845,6 @@ NS_IMPL_ISUPPORTS5(DocumentViewerImpl, DocumentViewerImpl::~DocumentViewerImpl() { - NS_ASSERTION(!mDocument, "User did not call nsIContentViewer::Close"); - if (mDocument) - Close(); - - NS_ASSERTION(!mPresShell, "User did not call nsIContentViewer::Destroy"); - if (mPresShell) - Destroy(); - if (mPagePrintTimer != nsnull) { mPagePrintTimer->Stop(); delete mPagePrintTimer; @@ -839,8 +854,10 @@ DocumentViewerImpl::~DocumentViewerImpl() mPrt->OnEndPrinting(NS_ERROR_FAILURE); delete mPrt; } - - // XXX(?) Revoke pending invalidate events + // Revoke pending invalidate events + NS_ASSERTION(!mDocument, "User did not call nsIContentViewer::Destroy"); + if (mDocument) + Destroy(); // clear weak references before we go away if (mPresContext) { @@ -853,6 +870,10 @@ DocumentViewerImpl::~DocumentViewerImpl() // stop everything but the chrome. mPresContext->Stop(); } + + // Avoid leaking the old viewer. + if (mPreviousViewer) + SetPreviousViewer(nsnull); } /* @@ -1145,19 +1166,13 @@ DocumentViewerImpl::Unload() } NS_IMETHODIMP -DocumentViewerImpl::Close() +DocumentViewerImpl::Destroy() { - // All callers are supposed to call close to break circular + // All callers are supposed to call destroy to break circular // references. If we do this stuff in the destructor, the // destructor might never be called (especially if we're being // used from JS. - // Close is also needed to disable scripts during paint suppression, - // since we transfer the existing global object to the new document - // that is loaded. In the future, the global object may become a proxy - // for an object that can be switched in and out so that we don't need - // to disable scripts during paint suppression. - nsresult rv; if (mDocument) { @@ -1179,24 +1194,6 @@ DocumentViewerImpl::Close() } } - mDocument = nsnull; - return NS_OK; -} - -NS_IMETHODIMP -DocumentViewerImpl::Destroy() -{ - // All callers are supposed to call destroy to break circular - // references. If we do this stuff in the destructor, the - // destructor might never be called (especially if we're being - // used from JS. - - // Avoid leaking the old viewer. - if (mPreviousViewer) { - mPreviousViewer->Destroy(); - mPreviousViewer = nsnull; - } - if (mDeviceContext) mDeviceContext->FlushFontCache(); @@ -1204,13 +1201,13 @@ DocumentViewerImpl::Destroy() // Break circular reference (or something) mPresShell->EndObservingDocument(); nsCOMPtr selection; - nsresult rv = GetDocumentSelection(getter_AddRefs(selection)); + rv = GetDocumentSelection(getter_AddRefs(selection)); nsCOMPtr selPrivate(do_QueryInterface(selection)); if (NS_SUCCEEDED(rv) && selPrivate && mSelectionListener) selPrivate->RemoveSelectionListener(mSelectionListener); - mPresShell = nsnull; } + mDocument = nsnull; return NS_OK; } @@ -1373,13 +1370,17 @@ DocumentViewerImpl::GetPreviousViewer(nsIContentViewer** aViewer) NS_IMETHODIMP DocumentViewerImpl::SetPreviousViewer(nsIContentViewer* aViewer) { - // NOTE: |Show| sets |mPreviousViewer| to null without calling this - // function. - - if (aViewer) { - NS_ASSERTION(!mPreviousViewer, - "can't set previous viewer when there already is one"); + if (!aViewer) { + // Clearing it out. + mPreviousViewer = nsnull; + // Now we can show, but only if we aren't dead already (which + // can occasionally happen when one page moves to another during the onload + // handler.) + if (mDocument) + Show(); + } + else { // In a multiple chaining situation (which occurs when running a thrashing // test like i-bench or jrgm's tests with no delay), we can build up a // whole chain of viewers. In order to avoid this, we always set our previous @@ -1391,9 +1392,9 @@ DocumentViewerImpl::SetPreviousViewer(nsIContentViewer* aViewer) nsCOMPtr prevViewer; aViewer->GetPreviousViewer(getter_AddRefs(prevViewer)); if (prevViewer) { - aViewer->SetPreviousViewer(nsnull); - aViewer->Destroy(); - return SetPreviousViewer(prevViewer); + SetPreviousViewer(prevViewer); + prevViewer->SetPreviousViewer(nsnull); + return NS_OK; } } @@ -1431,17 +1432,6 @@ DocumentViewerImpl::Show(void) { NS_ENSURE_TRUE(mDocument, NS_ERROR_NOT_AVAILABLE); NS_PRECONDITION(mWindow, "null window"); - - // We don't need the previous viewer anymore since we're not - // displaying it. - if (mPreviousViewer) { - // This little dance *may* only be to keep - // PresShell::EndObservingDocument happy, but I'm not sure. - nsCOMPtr prevViewer(mPreviousViewer); - mPreviousViewer = nsnull; - prevViewer->Destroy(); - } - if (mWindow) { mWindow->Show(PR_TRUE); } diff --git a/mozilla/docshell/base/nsDocShell.cpp b/mozilla/docshell/base/nsDocShell.cpp index 74cce7a6253..04c47b0dd33 100644 --- a/mozilla/docshell/base/nsDocShell.cpp +++ b/mozilla/docshell/base/nsDocShell.cpp @@ -2451,7 +2451,6 @@ nsDocShell::Destroy() docShellParentAsNode->RemoveChild(this); if (mContentViewer) { - mContentViewer->Close(); mContentViewer->Destroy(); mContentViewer = nsnull; } @@ -4107,7 +4106,7 @@ nsDocShell::SetupNewViewer(nsIContentViewer * aNewViewer) } } - mContentViewer->Close(); + mContentViewer->Destroy(); aNewViewer->SetPreviousViewer(mContentViewer); mContentViewer = nsnull; } diff --git a/mozilla/docshell/base/nsIContentViewer.idl b/mozilla/docshell/base/nsIContentViewer.idl index f6d85a30568..de6e6b39807 100644 --- a/mozilla/docshell/base/nsIContentViewer.idl +++ b/mozilla/docshell/base/nsIContentViewer.idl @@ -27,17 +27,7 @@ interface nsIContentViewer : nsISupports void loadComplete(in unsigned long aStatus); void unload(); - /** - * All users of a content viewer are responsible for calling both - * close() and destroy(), in that order. - * - * close() should be called when the load of a new page for the next - * content viewer begins, and destroy() should be called when the next - * content viewer replaces this one. - */ - void close(); void destroy(); - void stop(); attribute nsIDOMDocument DOMDocument; @@ -45,11 +35,8 @@ interface nsIContentViewer : nsISupports [noscript] void getBounds(in nsRectRef aBounds); [noscript] void setBounds([const] in nsRectRef aBounds); - /** - * The previous content viewer, which has been |close|d but not - * |destroy|ed. - */ - [noscript] attribute nsIContentViewer previousViewer; + [noscript] void setPreviousViewer(in nsIContentViewer aViewer); + [noscript] nsIContentViewer getPreviousViewer(); void move(in long aX, in long aY); diff --git a/mozilla/layout/base/nsDocumentViewer.cpp b/mozilla/layout/base/nsDocumentViewer.cpp index 693f4d9a715..de6a7aed964 100644 --- a/mozilla/layout/base/nsDocumentViewer.cpp +++ b/mozilla/layout/base/nsDocumentViewer.cpp @@ -372,7 +372,30 @@ public: NS_DECL_ISUPPORTS // nsIContentViewer interface... - NS_DECL_NSICONTENTVIEWER + NS_IMETHOD Init(nsIWidget* aParentWidget, + nsIDeviceContext* aDeviceContext, + const nsRect& aBounds); + NS_IMETHOD SetContainer(nsISupports* aContainer); + NS_IMETHOD GetContainer(nsISupports** aContainerResult); + NS_IMETHOD LoadStart(nsISupports* aDoc); + NS_IMETHOD LoadComplete(nsresult aStatus); + NS_IMETHOD Unload(void); + NS_IMETHOD Destroy(void); + NS_IMETHOD Stop(void); + NS_IMETHOD GetDOMDocument(nsIDOMDocument **aResult); + NS_IMETHOD SetDOMDocument(nsIDOMDocument *aDocument); + NS_IMETHOD GetBounds(nsRect& aResult); + NS_IMETHOD SetBounds(const nsRect& aBounds); + + NS_IMETHOD GetPreviousViewer(nsIContentViewer** aResult); + NS_IMETHOD SetPreviousViewer(nsIContentViewer* aViewer); + + NS_IMETHOD Move(PRInt32 aX, PRInt32 aY); + NS_IMETHOD Show(); + NS_IMETHOD Hide(); + NS_IMETHOD Validate(); + NS_IMETHOD SetEnableRendering(PRBool aOn); + NS_IMETHOD GetEnableRendering(PRBool* aResult); // nsIDocumentViewer interface... NS_IMETHOD SetUAStyleSheet(nsIStyleSheet* aUAStyleSheet); @@ -822,14 +845,6 @@ NS_IMPL_ISUPPORTS5(DocumentViewerImpl, DocumentViewerImpl::~DocumentViewerImpl() { - NS_ASSERTION(!mDocument, "User did not call nsIContentViewer::Close"); - if (mDocument) - Close(); - - NS_ASSERTION(!mPresShell, "User did not call nsIContentViewer::Destroy"); - if (mPresShell) - Destroy(); - if (mPagePrintTimer != nsnull) { mPagePrintTimer->Stop(); delete mPagePrintTimer; @@ -839,8 +854,10 @@ DocumentViewerImpl::~DocumentViewerImpl() mPrt->OnEndPrinting(NS_ERROR_FAILURE); delete mPrt; } - - // XXX(?) Revoke pending invalidate events + // Revoke pending invalidate events + NS_ASSERTION(!mDocument, "User did not call nsIContentViewer::Destroy"); + if (mDocument) + Destroy(); // clear weak references before we go away if (mPresContext) { @@ -853,6 +870,10 @@ DocumentViewerImpl::~DocumentViewerImpl() // stop everything but the chrome. mPresContext->Stop(); } + + // Avoid leaking the old viewer. + if (mPreviousViewer) + SetPreviousViewer(nsnull); } /* @@ -1145,19 +1166,13 @@ DocumentViewerImpl::Unload() } NS_IMETHODIMP -DocumentViewerImpl::Close() +DocumentViewerImpl::Destroy() { - // All callers are supposed to call close to break circular + // All callers are supposed to call destroy to break circular // references. If we do this stuff in the destructor, the // destructor might never be called (especially if we're being // used from JS. - // Close is also needed to disable scripts during paint suppression, - // since we transfer the existing global object to the new document - // that is loaded. In the future, the global object may become a proxy - // for an object that can be switched in and out so that we don't need - // to disable scripts during paint suppression. - nsresult rv; if (mDocument) { @@ -1179,24 +1194,6 @@ DocumentViewerImpl::Close() } } - mDocument = nsnull; - return NS_OK; -} - -NS_IMETHODIMP -DocumentViewerImpl::Destroy() -{ - // All callers are supposed to call destroy to break circular - // references. If we do this stuff in the destructor, the - // destructor might never be called (especially if we're being - // used from JS. - - // Avoid leaking the old viewer. - if (mPreviousViewer) { - mPreviousViewer->Destroy(); - mPreviousViewer = nsnull; - } - if (mDeviceContext) mDeviceContext->FlushFontCache(); @@ -1204,13 +1201,13 @@ DocumentViewerImpl::Destroy() // Break circular reference (or something) mPresShell->EndObservingDocument(); nsCOMPtr selection; - nsresult rv = GetDocumentSelection(getter_AddRefs(selection)); + rv = GetDocumentSelection(getter_AddRefs(selection)); nsCOMPtr selPrivate(do_QueryInterface(selection)); if (NS_SUCCEEDED(rv) && selPrivate && mSelectionListener) selPrivate->RemoveSelectionListener(mSelectionListener); - mPresShell = nsnull; } + mDocument = nsnull; return NS_OK; } @@ -1373,13 +1370,17 @@ DocumentViewerImpl::GetPreviousViewer(nsIContentViewer** aViewer) NS_IMETHODIMP DocumentViewerImpl::SetPreviousViewer(nsIContentViewer* aViewer) { - // NOTE: |Show| sets |mPreviousViewer| to null without calling this - // function. - - if (aViewer) { - NS_ASSERTION(!mPreviousViewer, - "can't set previous viewer when there already is one"); + if (!aViewer) { + // Clearing it out. + mPreviousViewer = nsnull; + // Now we can show, but only if we aren't dead already (which + // can occasionally happen when one page moves to another during the onload + // handler.) + if (mDocument) + Show(); + } + else { // In a multiple chaining situation (which occurs when running a thrashing // test like i-bench or jrgm's tests with no delay), we can build up a // whole chain of viewers. In order to avoid this, we always set our previous @@ -1391,9 +1392,9 @@ DocumentViewerImpl::SetPreviousViewer(nsIContentViewer* aViewer) nsCOMPtr prevViewer; aViewer->GetPreviousViewer(getter_AddRefs(prevViewer)); if (prevViewer) { - aViewer->SetPreviousViewer(nsnull); - aViewer->Destroy(); - return SetPreviousViewer(prevViewer); + SetPreviousViewer(prevViewer); + prevViewer->SetPreviousViewer(nsnull); + return NS_OK; } } @@ -1431,17 +1432,6 @@ DocumentViewerImpl::Show(void) { NS_ENSURE_TRUE(mDocument, NS_ERROR_NOT_AVAILABLE); NS_PRECONDITION(mWindow, "null window"); - - // We don't need the previous viewer anymore since we're not - // displaying it. - if (mPreviousViewer) { - // This little dance *may* only be to keep - // PresShell::EndObservingDocument happy, but I'm not sure. - nsCOMPtr prevViewer(mPreviousViewer); - mPreviousViewer = nsnull; - prevViewer->Destroy(); - } - if (mWindow) { mWindow->Show(PR_TRUE); } diff --git a/mozilla/layout/base/nsPresShell.cpp b/mozilla/layout/base/nsPresShell.cpp index 1348adcf80d..7fa3ba333fa 100644 --- a/mozilla/layout/base/nsPresShell.cpp +++ b/mozilla/layout/base/nsPresShell.cpp @@ -1482,6 +1482,104 @@ PresShell::QueryInterface(const nsIID& aIID, void** aInstancePtr) PresShell::~PresShell() { +#ifdef MOZ_REFLOW_PERF + DumpReflows(); + if (mReflowCountMgr) { + delete mReflowCountMgr; + mReflowCountMgr = nsnull; + } +#endif + + // If our paint suppression timer is still active, kill it. + if (mPaintSuppressionTimer) { + mPaintSuppressionTimer->Cancel(); + mPaintSuppressionTimer = nsnull; + } + + nsCOMPtr container; + mPresContext->GetContainer(getter_AddRefs(container)); + if (container) { + nsCOMPtr cvc(do_QueryInterface(container)); + if (cvc) { + nsCOMPtr cv; + cvc->GetContentViewer(getter_AddRefs(cv)); + if (cv) + cv->SetPreviousViewer(nsnull); + } + } + + // release our pref style sheet, if we have one still + ClearPreferenceStyleRules(); + + // if we allocated any stack memory free it. + FreeDynamicStack(); + + // free our table of anonymous content + ReleaseAnonymousContent(); + + mIsDestroying = PR_TRUE; + + // Clobber weak leaks in case of re-entrancy during tear down + mHistoryState = nsnull; + + // kill subshell map, if any. It holds only weak references + if (mSubShellMap) + { + delete mSubShellMap; + mSubShellMap = nsnull; + } + + // release current event content and any content on event stack + NS_IF_RELEASE(mCurrentEventContent); + + PRInt32 i, count = mCurrentEventContentStack.Count(); + nsIContent* currentEventContent; + for (i = 0; i < count; i++) { + currentEventContent = (nsIContent*)mCurrentEventContentStack.ElementAt(i); + NS_IF_RELEASE(currentEventContent); + } + + if (mViewManager) { + // Disable paints during tear down of the frame tree + mViewManager->DisableRefresh(); + mViewManager = nsnull; + } + + // This shell must be removed from the document before the frame + // hierarchy is torn down to avoid finding deleted frames through + // this presshell while the frames are being torn down + if (mDocument) { + mDocument->DeleteShell(this); + } + + // Destroy the frame manager. This will destroy the frame hierarchy + if (mFrameManager) { + mFrameManager->Destroy(); + NS_RELEASE(mFrameManager); + } + + // Let the style set do its cleanup. + mStyleSet->Shutdown(); + + // We hold a reference to the pres context, and it holds a weak link back + // to us. To avoid the pres context having a dangling reference, set its + // pres shell to NULL + if (mPresContext) { + mPresContext->SetShell(nsnull); + } + + if (mViewEventListener) { + mViewEventListener->SetPresShell((nsIPresShell*)nsnull); + NS_RELEASE(mViewEventListener); + } + + // Revoke pending reflow events + if (mPendingReflowEvent) { + mPendingReflowEvent = PR_FALSE; + mEventQueue->RevokeEvents(this); + } + + KillResizeEventTimer(); } /** @@ -2349,113 +2447,6 @@ PresShell::EndObservingDocument() return NS_ERROR_UNEXPECTED; mSelection->ShutDown(); } - -#ifdef MOZ_REFLOW_PERF - DumpReflows(); - if (mReflowCountMgr) { - delete mReflowCountMgr; - mReflowCountMgr = nsnull; - } -#endif - - // If our paint suppression timer is still active, kill it. - if (mPaintSuppressionTimer) { - mPaintSuppressionTimer->Cancel(); - mPaintSuppressionTimer = nsnull; - } - -#ifdef DEBUG - { - nsCOMPtr container; - mPresContext->GetContainer(getter_AddRefs(container)); - if (container) { - nsCOMPtr cvc(do_QueryInterface(container)); - if (cvc) { - nsCOMPtr cv; - cvc->GetContentViewer(getter_AddRefs(cv)); - if (cv) { - nsCOMPtr prevViewer; - cv->GetPreviousViewer(getter_AddRefs(prevViewer)); - NS_ASSERTION(!prevViewer, "still have a previous viewer!"); - } - } - } - } -#endif - - // release our pref style sheet, if we have one still - ClearPreferenceStyleRules(); - - // if we allocated any stack memory free it. - FreeDynamicStack(); - - // free our table of anonymous content - ReleaseAnonymousContent(); - - mIsDestroying = PR_TRUE; - - // Clobber weak leaks in case of re-entrancy during tear down - mHistoryState = nsnull; - - // kill subshell map, if any. It holds only weak references - if (mSubShellMap) - { - delete mSubShellMap; - mSubShellMap = nsnull; - } - - // release current event content and any content on event stack - NS_IF_RELEASE(mCurrentEventContent); - - PRInt32 i, count = mCurrentEventContentStack.Count(); - nsIContent* currentEventContent; - for (i = 0; i < count; i++) { - currentEventContent = (nsIContent*)mCurrentEventContentStack.ElementAt(i); - NS_IF_RELEASE(currentEventContent); - } - - if (mViewManager) { - // Disable paints during tear down of the frame tree - mViewManager->DisableRefresh(); - mViewManager = nsnull; - } - - // This shell must be removed from the document before the frame - // hierarchy is torn down to avoid finding deleted frames through - // this presshell while the frames are being torn down - if (mDocument) { - mDocument->DeleteShell(this); - } - - // Destroy the frame manager. This will destroy the frame hierarchy - if (mFrameManager) { - mFrameManager->Destroy(); - NS_RELEASE(mFrameManager); - } - - // Let the style set do its cleanup. - mStyleSet->Shutdown(); - - // We hold a reference to the pres context, and it holds a weak link back - // to us. To avoid the pres context having a dangling reference, set its - // pres shell to NULL - if (mPresContext) { - mPresContext->SetShell(nsnull); - } - - if (mViewEventListener) { - mViewEventListener->SetPresShell((nsIPresShell*)nsnull); - NS_RELEASE(mViewEventListener); - } - - // Revoke pending reflow events - if (mPendingReflowEvent) { - mPendingReflowEvent = PR_FALSE; - mEventQueue->RevokeEvents(this); - } - - KillResizeEventTimer(); - return NS_OK; } @@ -4588,17 +4579,23 @@ PresShell::UnsuppressAndInvalidate() focusController->SetSuppressFocus(PR_TRUE, "PresShell suppression on Web page loads"); nsCOMPtr container; + nsCOMPtr cv; + nsCOMPtr dv; mPresContext->GetContainer(getter_AddRefs(container)); if (container) { nsCOMPtr cvc(do_QueryInterface(container)); if (cvc) { - nsCOMPtr cv; cvc->GetContentViewer(getter_AddRefs(cv)); - if (cv) - cv->Show(); + dv = do_QueryInterface(cv); } } + if (dv) + dv->Show(); + + if (cv) + cv->SetPreviousViewer(nsnull); + mPaintingSuppressed = PR_FALSE; nsIFrame* rootFrame; mFrameManager->GetRootFrame(&rootFrame); diff --git a/mozilla/layout/generic/nsObjectFrame.cpp b/mozilla/layout/generic/nsObjectFrame.cpp index 3ce4aab8f7a..10c0d52b6cd 100644 --- a/mozilla/layout/generic/nsObjectFrame.cpp +++ b/mozilla/layout/generic/nsObjectFrame.cpp @@ -440,7 +440,7 @@ nsObjectFrame::Init(nsIPresContext* aPresContext, nsCOMPtr cv; cvc->GetContentViewer(getter_AddRefs(cv)); if (cv) - cv->Show(); + cv->SetPreviousViewer(nsnull); } } diff --git a/mozilla/layout/html/base/src/nsObjectFrame.cpp b/mozilla/layout/html/base/src/nsObjectFrame.cpp index 3ce4aab8f7a..10c0d52b6cd 100644 --- a/mozilla/layout/html/base/src/nsObjectFrame.cpp +++ b/mozilla/layout/html/base/src/nsObjectFrame.cpp @@ -440,7 +440,7 @@ nsObjectFrame::Init(nsIPresContext* aPresContext, nsCOMPtr cv; cvc->GetContentViewer(getter_AddRefs(cv)); if (cv) - cv->Show(); + cv->SetPreviousViewer(nsnull); } } diff --git a/mozilla/layout/html/base/src/nsPresShell.cpp b/mozilla/layout/html/base/src/nsPresShell.cpp index 1348adcf80d..7fa3ba333fa 100644 --- a/mozilla/layout/html/base/src/nsPresShell.cpp +++ b/mozilla/layout/html/base/src/nsPresShell.cpp @@ -1482,6 +1482,104 @@ PresShell::QueryInterface(const nsIID& aIID, void** aInstancePtr) PresShell::~PresShell() { +#ifdef MOZ_REFLOW_PERF + DumpReflows(); + if (mReflowCountMgr) { + delete mReflowCountMgr; + mReflowCountMgr = nsnull; + } +#endif + + // If our paint suppression timer is still active, kill it. + if (mPaintSuppressionTimer) { + mPaintSuppressionTimer->Cancel(); + mPaintSuppressionTimer = nsnull; + } + + nsCOMPtr container; + mPresContext->GetContainer(getter_AddRefs(container)); + if (container) { + nsCOMPtr cvc(do_QueryInterface(container)); + if (cvc) { + nsCOMPtr cv; + cvc->GetContentViewer(getter_AddRefs(cv)); + if (cv) + cv->SetPreviousViewer(nsnull); + } + } + + // release our pref style sheet, if we have one still + ClearPreferenceStyleRules(); + + // if we allocated any stack memory free it. + FreeDynamicStack(); + + // free our table of anonymous content + ReleaseAnonymousContent(); + + mIsDestroying = PR_TRUE; + + // Clobber weak leaks in case of re-entrancy during tear down + mHistoryState = nsnull; + + // kill subshell map, if any. It holds only weak references + if (mSubShellMap) + { + delete mSubShellMap; + mSubShellMap = nsnull; + } + + // release current event content and any content on event stack + NS_IF_RELEASE(mCurrentEventContent); + + PRInt32 i, count = mCurrentEventContentStack.Count(); + nsIContent* currentEventContent; + for (i = 0; i < count; i++) { + currentEventContent = (nsIContent*)mCurrentEventContentStack.ElementAt(i); + NS_IF_RELEASE(currentEventContent); + } + + if (mViewManager) { + // Disable paints during tear down of the frame tree + mViewManager->DisableRefresh(); + mViewManager = nsnull; + } + + // This shell must be removed from the document before the frame + // hierarchy is torn down to avoid finding deleted frames through + // this presshell while the frames are being torn down + if (mDocument) { + mDocument->DeleteShell(this); + } + + // Destroy the frame manager. This will destroy the frame hierarchy + if (mFrameManager) { + mFrameManager->Destroy(); + NS_RELEASE(mFrameManager); + } + + // Let the style set do its cleanup. + mStyleSet->Shutdown(); + + // We hold a reference to the pres context, and it holds a weak link back + // to us. To avoid the pres context having a dangling reference, set its + // pres shell to NULL + if (mPresContext) { + mPresContext->SetShell(nsnull); + } + + if (mViewEventListener) { + mViewEventListener->SetPresShell((nsIPresShell*)nsnull); + NS_RELEASE(mViewEventListener); + } + + // Revoke pending reflow events + if (mPendingReflowEvent) { + mPendingReflowEvent = PR_FALSE; + mEventQueue->RevokeEvents(this); + } + + KillResizeEventTimer(); } /** @@ -2349,113 +2447,6 @@ PresShell::EndObservingDocument() return NS_ERROR_UNEXPECTED; mSelection->ShutDown(); } - -#ifdef MOZ_REFLOW_PERF - DumpReflows(); - if (mReflowCountMgr) { - delete mReflowCountMgr; - mReflowCountMgr = nsnull; - } -#endif - - // If our paint suppression timer is still active, kill it. - if (mPaintSuppressionTimer) { - mPaintSuppressionTimer->Cancel(); - mPaintSuppressionTimer = nsnull; - } - -#ifdef DEBUG - { - nsCOMPtr container; - mPresContext->GetContainer(getter_AddRefs(container)); - if (container) { - nsCOMPtr cvc(do_QueryInterface(container)); - if (cvc) { - nsCOMPtr cv; - cvc->GetContentViewer(getter_AddRefs(cv)); - if (cv) { - nsCOMPtr prevViewer; - cv->GetPreviousViewer(getter_AddRefs(prevViewer)); - NS_ASSERTION(!prevViewer, "still have a previous viewer!"); - } - } - } - } -#endif - - // release our pref style sheet, if we have one still - ClearPreferenceStyleRules(); - - // if we allocated any stack memory free it. - FreeDynamicStack(); - - // free our table of anonymous content - ReleaseAnonymousContent(); - - mIsDestroying = PR_TRUE; - - // Clobber weak leaks in case of re-entrancy during tear down - mHistoryState = nsnull; - - // kill subshell map, if any. It holds only weak references - if (mSubShellMap) - { - delete mSubShellMap; - mSubShellMap = nsnull; - } - - // release current event content and any content on event stack - NS_IF_RELEASE(mCurrentEventContent); - - PRInt32 i, count = mCurrentEventContentStack.Count(); - nsIContent* currentEventContent; - for (i = 0; i < count; i++) { - currentEventContent = (nsIContent*)mCurrentEventContentStack.ElementAt(i); - NS_IF_RELEASE(currentEventContent); - } - - if (mViewManager) { - // Disable paints during tear down of the frame tree - mViewManager->DisableRefresh(); - mViewManager = nsnull; - } - - // This shell must be removed from the document before the frame - // hierarchy is torn down to avoid finding deleted frames through - // this presshell while the frames are being torn down - if (mDocument) { - mDocument->DeleteShell(this); - } - - // Destroy the frame manager. This will destroy the frame hierarchy - if (mFrameManager) { - mFrameManager->Destroy(); - NS_RELEASE(mFrameManager); - } - - // Let the style set do its cleanup. - mStyleSet->Shutdown(); - - // We hold a reference to the pres context, and it holds a weak link back - // to us. To avoid the pres context having a dangling reference, set its - // pres shell to NULL - if (mPresContext) { - mPresContext->SetShell(nsnull); - } - - if (mViewEventListener) { - mViewEventListener->SetPresShell((nsIPresShell*)nsnull); - NS_RELEASE(mViewEventListener); - } - - // Revoke pending reflow events - if (mPendingReflowEvent) { - mPendingReflowEvent = PR_FALSE; - mEventQueue->RevokeEvents(this); - } - - KillResizeEventTimer(); - return NS_OK; } @@ -4588,17 +4579,23 @@ PresShell::UnsuppressAndInvalidate() focusController->SetSuppressFocus(PR_TRUE, "PresShell suppression on Web page loads"); nsCOMPtr container; + nsCOMPtr cv; + nsCOMPtr dv; mPresContext->GetContainer(getter_AddRefs(container)); if (container) { nsCOMPtr cvc(do_QueryInterface(container)); if (cvc) { - nsCOMPtr cv; cvc->GetContentViewer(getter_AddRefs(cv)); - if (cv) - cv->Show(); + dv = do_QueryInterface(cv); } } + if (dv) + dv->Show(); + + if (cv) + cv->SetPreviousViewer(nsnull); + mPaintingSuppressed = PR_FALSE; nsIFrame* rootFrame; mFrameManager->GetRootFrame(&rootFrame); diff --git a/mozilla/modules/plugin/base/src/nsPluginViewer.cpp b/mozilla/modules/plugin/base/src/nsPluginViewer.cpp index 6873cbe5de1..c0f908419a8 100644 --- a/mozilla/modules/plugin/base/src/nsPluginViewer.cpp +++ b/mozilla/modules/plugin/base/src/nsPluginViewer.cpp @@ -169,7 +169,28 @@ public: NS_IMETHOD StartLoad(nsIRequest* request, nsIStreamListener*& aResult); // nsIContentViewer - NS_DECL_NSICONTENTVIEWER + NS_IMETHOD Init(nsIWidget* aParentWidget, + nsIDeviceContext* aDeviceContext, + const nsRect& aBounds); + NS_IMETHOD SetContainer(nsISupports* aContainer); + NS_IMETHOD GetContainer(nsISupports** aContainerResult); + NS_IMETHOD LoadStart(nsISupports* aDoc); + NS_IMETHOD LoadComplete(nsresult aStatus); + NS_IMETHOD Unload(void); + NS_IMETHOD Destroy(void); + NS_IMETHOD Stop(void); + NS_IMETHOD GetDOMDocument(nsIDOMDocument **aResult); + NS_IMETHOD SetDOMDocument(nsIDOMDocument *aDocument); + NS_IMETHOD GetBounds(nsRect& aResult); + NS_IMETHOD SetBounds(const nsRect& aBounds); + NS_IMETHOD GetPreviousViewer(nsIContentViewer** aViewer); + NS_IMETHOD SetPreviousViewer(nsIContentViewer* aViewer); + NS_IMETHOD Move(PRInt32 aX, PRInt32 aY); + NS_IMETHOD Show(); + NS_IMETHOD Hide(); + NS_IMETHOD Validate(); + NS_IMETHOD SetEnableRendering(PRBool aOn); + NS_IMETHOD GetEnableRendering(PRBool* aResult); // nsIContentViewerEdit NS_DECL_NSICONTENTVIEWEREDIT @@ -414,12 +435,6 @@ PluginViewerImpl::Unload(void) return NS_OK; } -NS_IMETHODIMP -PluginViewerImpl::Close(void) -{ - return NS_OK; -} - NS_IMETHODIMP PluginViewerImpl::Destroy(void) { @@ -543,8 +558,6 @@ PluginViewerImpl::GetPreviousViewer(nsIContentViewer** aViewer) NS_IMETHODIMP PluginViewerImpl::SetPreviousViewer(nsIContentViewer* aViewer) { - if (aViewer) - aViewer->Destroy(); return NS_OK; } diff --git a/mozilla/modules/plugin/nglsrc/nsPluginViewer.cpp b/mozilla/modules/plugin/nglsrc/nsPluginViewer.cpp index 6873cbe5de1..c0f908419a8 100644 --- a/mozilla/modules/plugin/nglsrc/nsPluginViewer.cpp +++ b/mozilla/modules/plugin/nglsrc/nsPluginViewer.cpp @@ -169,7 +169,28 @@ public: NS_IMETHOD StartLoad(nsIRequest* request, nsIStreamListener*& aResult); // nsIContentViewer - NS_DECL_NSICONTENTVIEWER + NS_IMETHOD Init(nsIWidget* aParentWidget, + nsIDeviceContext* aDeviceContext, + const nsRect& aBounds); + NS_IMETHOD SetContainer(nsISupports* aContainer); + NS_IMETHOD GetContainer(nsISupports** aContainerResult); + NS_IMETHOD LoadStart(nsISupports* aDoc); + NS_IMETHOD LoadComplete(nsresult aStatus); + NS_IMETHOD Unload(void); + NS_IMETHOD Destroy(void); + NS_IMETHOD Stop(void); + NS_IMETHOD GetDOMDocument(nsIDOMDocument **aResult); + NS_IMETHOD SetDOMDocument(nsIDOMDocument *aDocument); + NS_IMETHOD GetBounds(nsRect& aResult); + NS_IMETHOD SetBounds(const nsRect& aBounds); + NS_IMETHOD GetPreviousViewer(nsIContentViewer** aViewer); + NS_IMETHOD SetPreviousViewer(nsIContentViewer* aViewer); + NS_IMETHOD Move(PRInt32 aX, PRInt32 aY); + NS_IMETHOD Show(); + NS_IMETHOD Hide(); + NS_IMETHOD Validate(); + NS_IMETHOD SetEnableRendering(PRBool aOn); + NS_IMETHOD GetEnableRendering(PRBool* aResult); // nsIContentViewerEdit NS_DECL_NSICONTENTVIEWEREDIT @@ -414,12 +435,6 @@ PluginViewerImpl::Unload(void) return NS_OK; } -NS_IMETHODIMP -PluginViewerImpl::Close(void) -{ - return NS_OK; -} - NS_IMETHODIMP PluginViewerImpl::Destroy(void) { @@ -543,8 +558,6 @@ PluginViewerImpl::GetPreviousViewer(nsIContentViewer** aViewer) NS_IMETHODIMP PluginViewerImpl::SetPreviousViewer(nsIContentViewer* aViewer) { - if (aViewer) - aViewer->Destroy(); return NS_OK; }