From 9c9adadbedb8d2d6b74e1b44119515b8d44fa1a1 Mon Sep 17 00:00:00 2001 From: "bzbarsky%mit.edu" Date: Wed, 28 Jan 2009 01:11:43 +0000 Subject: [PATCH] Bug 474389. Fix the 'set up editor after this load' setup, which hasn't really worked for a while, except for initial loads in the window. r+sr=peterv, a=dveditz git-svn-id: svn://10.0.0.236/trunk@255948 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/docshell/base/nsDocShell.cpp | 22 ++++++++------------ mozilla/docshell/base/nsDocShell.h | 1 - mozilla/docshell/base/nsDocShellEditorData.h | 1 + mozilla/docshell/base/nsIDocShell.idl | 3 ++- 4 files changed, 12 insertions(+), 15 deletions(-) diff --git a/mozilla/docshell/base/nsDocShell.cpp b/mozilla/docshell/base/nsDocShell.cpp index 6cd748263df..807b5578e43 100644 --- a/mozilla/docshell/base/nsDocShell.cpp +++ b/mozilla/docshell/base/nsDocShell.cpp @@ -5355,21 +5355,24 @@ nsDocShell::ReattachEditorToWindow(nsISHEntry *aSHEntry) } void -nsDocShell::DetachEditorFromWindow(nsISHEntry *aSHEntry) +nsDocShell::DetachEditorFromWindow() { - if (!mEditorData) + if (!mEditorData || mEditorData->WaitingForLoad()) { + // If there's nothing to detach, or if the editor data is actually set + // up for the _new_ page that's coming in, don't detach. return; + } - NS_ASSERTION(!aSHEntry || !aSHEntry->HasDetachedEditor(), + NS_ASSERTION(!mOSHE || !mOSHE->HasDetachedEditor(), "Detaching editor when it's already detached."); nsresult res = mEditorData->DetachFromWindow(); NS_ASSERTION(NS_SUCCEEDED(res), "Failed to detach editor"); if (NS_SUCCEEDED(res)) { - // Make aSHEntry hold the owning ref to the editor data. - if (aSHEntry) - aSHEntry->SetEditorData(mEditorData.forget()); + // Make mOSHE hold the owning ref to the editor data. + if (mOSHE) + mOSHE->SetEditorData(mEditorData.forget()); else mEditorData = nsnull; } @@ -5382,13 +5385,6 @@ nsDocShell::DetachEditorFromWindow(nsISHEntry *aSHEntry) "Window is still editable after detaching editor."); } #endif // DEBUG - -} - -void -nsDocShell::DetachEditorFromWindow() -{ - DetachEditorFromWindow(mOSHE); } nsresult diff --git a/mozilla/docshell/base/nsDocShell.h b/mozilla/docshell/base/nsDocShell.h index af26a537473..85a45ed119b 100644 --- a/mozilla/docshell/base/nsDocShell.h +++ b/mozilla/docshell/base/nsDocShell.h @@ -526,7 +526,6 @@ protected: PRBool IsOKToLoadURI(nsIURI* aURI); void ReattachEditorToWindow(nsISHEntry *aSHEntry); - void DetachEditorFromWindow(nsISHEntry *aSHEntry); protected: // Override the parent setter from nsDocLoader diff --git a/mozilla/docshell/base/nsDocShellEditorData.h b/mozilla/docshell/base/nsDocShellEditorData.h index c3d5f7c40dc..e357746aaec 100644 --- a/mozilla/docshell/base/nsDocShellEditorData.h +++ b/mozilla/docshell/base/nsDocShellEditorData.h @@ -73,6 +73,7 @@ public: void TearDownEditor(); nsresult DetachFromWindow(); nsresult ReattachToWindow(nsIDocShell *aDocShell); + PRBool WaitingForLoad() const { return mMakeEditable; } protected: diff --git a/mozilla/docshell/base/nsIDocShell.idl b/mozilla/docshell/base/nsIDocShell.idl index 7d1b733e1f1..2db8dc46d40 100644 --- a/mozilla/docshell/base/nsIDocShell.idl +++ b/mozilla/docshell/base/nsIDocShell.idl @@ -460,7 +460,8 @@ interface nsIDocShell : nsISupports /** * Disconnects this docshell's editor from its window, and stores the - * editor data in the open document's session history entry. + * editor data in the open document's session history entry. This + * should be called only during page transitions. */ [noscript, notxpcom] void DetachEditorFromWindow(); };