Bug 604493 - Composition Window broken on trunk builds due to tracemonkey landing. r=mrbkap, a=beltzner
authorNeil Rashbrook <neil@parkwaycc.co.uk>
Fri, 15 Oct 2010 13:59:00 -0400
changeset 56162 8012dab3b01ce8cbbb5749c9afd807f3904974c9
parent 56161 227b2a6ecdde3d377b7082b16533812814118ea0
child 56163 8e185433c1471b0f53cb96199ed31ab2466424f5
push idunknown
push userunknown
push dateunknown
reviewersmrbkap, beltzner
bugs604493
milestone2.0b8pre
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 604493 - Composition Window broken on trunk builds due to tracemonkey landing. r=mrbkap, a=beltzner
editor/composer/src/nsEditingSession.cpp
editor/composer/src/nsEditingSession.h
--- a/editor/composer/src/nsEditingSession.cpp
+++ b/editor/composer/src/nsEditingSession.cpp
@@ -140,22 +140,22 @@ NS_IMETHODIMP
 nsEditingSession::MakeWindowEditable(nsIDOMWindow *aWindow,
                                      const char *aEditorType, 
                                      PRBool aDoAfterUriLoad,
                                      PRBool aMakeWholeDocumentEditable,
                                      PRBool aInteractive)
 {
   mEditorType.Truncate();
   mEditorFlags = 0;
-  mWindowToBeEdited = do_GetWeakReference(aWindow);
 
   // disable plugins
   nsIDocShell *docShell = GetDocShellFromWindow(aWindow);
   NS_ENSURE_TRUE(docShell, NS_ERROR_FAILURE);
 
+  mDocShell = do_GetWeakReference(docShell);
   mInteractive = aInteractive;
   mMakeWholeDocumentEditable = aMakeWholeDocumentEditable;
 
   nsresult rv;
   if (!mInteractive) {
     rv = DisableJSAndPlugins(aWindow);
     NS_ENSURE_SUCCESS(rv, rv);
   }
@@ -904,22 +904,18 @@ nsEditingSession::OnSecurityChange(nsIWe
   IsProgressForTargetDocument
 
   Check that this notification is for our document.
 ----------------------------------------------------------------------------*/
 
 PRBool
 nsEditingSession::IsProgressForTargetDocument(nsIWebProgress *aWebProgress)
 {
-  nsCOMPtr<nsIDOMWindow> domWindow;
-  if (aWebProgress)
-    aWebProgress->GetDOMWindow(getter_AddRefs(domWindow));
-  nsCOMPtr<nsIDOMWindow> editedDOMWindow = do_QueryReferent(mWindowToBeEdited);
-
-  return (domWindow && (domWindow == editedDOMWindow));
+  nsCOMPtr<nsIWebProgress> editedWebProgress = do_QueryReferent(mDocShell);
+  return editedWebProgress == aWebProgress;
 }
 
 
 /*---------------------------------------------------------------------------
 
   GetEditorStatus
 
   Called during GetCommandStateParams("obs_documentCreated"...) 
@@ -1055,17 +1051,16 @@ nsEditingSession::EndDocumentLoad(nsIWeb
             mLoadBlankDocTimer->Cancel();
             mLoadBlankDocTimer = NULL;
           }
   
           mLoadBlankDocTimer = do_CreateInstance("@mozilla.org/timer;1", &rv);
           NS_ENSURE_SUCCESS(rv, rv);
 
           mEditorStatus = eEditorCreationInProgress;
-          mDocShell = do_GetWeakReference(docShell);
           mLoadBlankDocTimer->InitWithFuncCallback(
                                           nsEditingSession::TimerCallback,
                                           static_cast<void*> (mDocShell.get()),
                                           10, nsITimer::TYPE_ONE_SHOT);
         }
       }
     }
   }
@@ -1421,33 +1416,35 @@ nsEditingSession::DetachFromWindow(nsIDO
   // make things the way they were before we started editing.
   RemoveEditorControllers(aWindow);
   RemoveWebProgressListener(aWindow);
   RestoreJSAndPlugins(aWindow);
   RestoreAnimationMode(aWindow);
 
   // Kill our weak reference to our original window, in case
   // it changes on restore, or otherwise dies.
-  mWindowToBeEdited = nsnull;
+  mDocShell = nsnull;
 
   return NS_OK;
 }
 
 nsresult
 nsEditingSession::ReattachToWindow(nsIDOMWindow* aWindow)
 {
   NS_ENSURE_TRUE(mDoneSetup, NS_OK);
 
   NS_ASSERTION(mStateMaintainer, "mStateMaintainer should exist.");
 
   // Imitate nsEditorDocShell::MakeEditable() to reattach the
   // old editor ot the window.
   nsresult rv;
 
-  mWindowToBeEdited = do_GetWeakReference(aWindow);
+  nsIDocShell *docShell = GetDocShellFromWindow(aWindow);
+  NS_ENSURE_TRUE(docShell, NS_ERROR_FAILURE);
+  mDocShell = do_GetWeakReference(docShell);
 
   // Disable plugins.
   if (!mInteractive)
   {
     rv = DisableJSAndPlugins(aWindow);
     NS_ENSURE_SUCCESS(rv, rv);
   }
 
--- a/editor/composer/src/nsEditingSession.h
+++ b/editor/composer/src/nsEditingSession.h
@@ -153,18 +153,16 @@ protected:
 
   // The image animation mode before it was turned off.
   PRUint16        mImageAnimationMode;
 
   // THE REMAINING MEMBER VARIABLES WILL BECOME A SET WHEN WE EDIT
   // MORE THAN ONE EDITOR PER EDITING SESSION
   nsRefPtr<nsComposerCommandsUpdater> mStateMaintainer;
   
-  nsWeakPtr       mWindowToBeEdited;
-
   // Save the editor type so we can create the editor after loading uri
   nsCString       mEditorType; 
   PRUint32        mEditorFlags;
   PRUint32        mEditorStatus;
   PRUint32        mBaseCommandControllerId;
   PRUint32        mDocStateControllerId;
   PRUint32        mHTMLCommandControllerId;