diff --git a/mozilla/docshell/base/nsDocShell.cpp b/mozilla/docshell/base/nsDocShell.cpp index 4ac4e27d8d7..40f3100d18f 100644 --- a/mozilla/docshell/base/nsDocShell.cpp +++ b/mozilla/docshell/base/nsDocShell.cpp @@ -5576,6 +5576,7 @@ nsDocShell::SetupNewViewer(nsIContentViewer * aNewViewer) PRBool styleDisabled; // |newMUDV| also serves as a flag to set the data from the above vars nsCOMPtr newMUDV; + PRBool savePresentation = mSavingOldViewer; if (mContentViewer || parent) { nsCOMPtr oldMUDV; @@ -5584,6 +5585,16 @@ nsDocShell::SetupNewViewer(nsIContentViewer * aNewViewer) // XXX: it would be far better to just reuse the document viewer , // since we know we're just displaying the same document as before oldMUDV = do_QueryInterface(mContentViewer); + + // Tell the old content viewer to hibernate in session history when + // it is destroyed. + + if (savePresentation && NS_FAILED(CaptureState())) { + if (mOSHE) { + mOSHE->SyncPresentationState(); + } + savePresentation = PR_FALSE; + } } else { // No old content viewer, so get state from parent's content viewer @@ -5707,17 +5718,6 @@ nsDocShell::SetupNewViewer(nsIContentViewer * aNewViewer) } } - // Tell the old content viewer to hibernate in session history when - // it is destroyed. - - PRBool savePresentation = mSavingOldViewer; - if (savePresentation && NS_FAILED(CaptureState())) { - if (mOSHE) { - mOSHE->SyncPresentationState(); - } - savePresentation = PR_FALSE; - } - mContentViewer->Close(savePresentation ? mOSHE.get() : nsnull); aNewViewer->SetPreviousViewer(mContentViewer);