Bug 1073213 - Do not use nsIDOMWindowUtils in editor/; r=roc
authorEhsan Akhgari <ehsan@mozilla.com>
Fri, 26 Sep 2014 09:19:56 -0400
changeset 207498 9c5207c5565f9bd7f308e6fa8d17f0d0bf878533
parent 207497 61e654fd063755e0981db315ecd1b60edb7c15ed
child 207499 6f0fc0040c56a7ef922e2a21e2b52e1e7231f110
push id27556
push userryanvm@gmail.com
push dateFri, 26 Sep 2014 20:54:36 +0000
treeherdermozilla-central@16ff803b47a9 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersroc
bugs1073213
milestone35.0a1
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 1073213 - Do not use nsIDOMWindowUtils in editor/; r=roc
editor/composer/nsEditingSession.cpp
--- a/editor/composer/nsEditingSession.cpp
+++ b/editor/composer/nsEditingSession.cpp
@@ -20,36 +20,37 @@
 #include "nsIContentViewer.h"           // for nsIContentViewer
 #include "nsIController.h"              // for nsIController
 #include "nsIControllerContext.h"       // for nsIControllerContext
 #include "nsIControllers.h"             // for nsIControllers
 #include "nsID.h"                       // for NS_GET_IID, etc
 #include "nsIDOMDocument.h"             // for nsIDOMDocument
 #include "nsIDOMHTMLDocument.h"         // for nsIDOMHTMLDocument
 #include "nsIDOMWindow.h"               // for nsIDOMWindow
-#include "nsIDOMWindowUtils.h"          // for nsIDOMWindowUtils
 #include "nsIDocShell.h"                // for nsIDocShell
 #include "nsIDocument.h"                // for nsIDocument
 #include "nsIDocumentStateListener.h"
 #include "nsIEditor.h"                  // for nsIEditor
 #include "nsIHTMLDocument.h"            // for nsIHTMLDocument, etc
 #include "nsIInterfaceRequestorUtils.h"  // for do_GetInterface
 #include "nsIPlaintextEditor.h"         // for nsIPlaintextEditor, etc
+#include "nsIPresShell.h"               // for nsIPresShell
 #include "nsIRefreshURI.h"              // for nsIRefreshURI
 #include "nsIRequest.h"                 // for nsIRequest
 #include "nsISelection.h"               // for nsISelection
 #include "nsISelectionPrivate.h"        // for nsISelectionPrivate
 #include "nsITimer.h"                   // for nsITimer, etc
 #include "nsITransactionManager.h"      // for nsITransactionManager
 #include "nsIWeakReference.h"           // for nsISupportsWeakReference, etc
 #include "nsIWebNavigation.h"           // for nsIWebNavigation
 #include "nsIWebProgress.h"             // for nsIWebProgress, etc
 #include "nsLiteralString.h"            // for NS_LITERAL_STRING
 #include "nsPICommandUpdater.h"         // for nsPICommandUpdater
 #include "nsPIDOMWindow.h"              // for nsPIDOMWindow
+#include "nsPresContext.h"              // for nsPresContext
 #include "nsReadableUtils.h"            // for AppendUTF16toUTF8
 #include "nsStringFwd.h"                // for nsAFlatString
 
 class nsISupports;
 class nsIURI;
 
 /*---------------------------------------------------------------------------
 
@@ -391,22 +392,23 @@ nsEditingSession::SetupEditorOnWindow(ns
 
   // Create editor and do other things 
   //  only if we haven't found some error above,
   nsCOMPtr<nsIDocShell> docShell = GetDocShellFromWindow(aWindow);
   NS_ENSURE_TRUE(docShell, NS_ERROR_FAILURE);  
 
   if (!mInteractive) {
     // Disable animation of images in this document:
-    nsCOMPtr<nsIDOMWindowUtils> utils(do_GetInterface(aWindow));
-    NS_ENSURE_TRUE(utils, NS_ERROR_FAILURE);
+    nsCOMPtr<nsIPresShell> presShell = docShell->GetPresShell();
+    NS_ENSURE_TRUE(presShell, NS_ERROR_FAILURE);
+    nsPresContext* presContext = presShell->GetPresContext();
+    NS_ENSURE_TRUE(presContext, NS_ERROR_FAILURE);
 
-    rv = utils->GetImageAnimationMode(&mImageAnimationMode);
-    NS_ENSURE_SUCCESS(rv, rv);
-    utils->SetImageAnimationMode(imgIContainer::kDontAnimMode);
+    mImageAnimationMode = presContext->ImageAnimationMode();
+    presContext->SetImageAnimationMode(imgIContainer::kDontAnimMode);
   }
 
   // create and set editor
   // Try to reuse an existing editor
   nsCOMPtr<nsIEditor> editor = do_QueryReferent(mExistingEditor);
   if (editor) {
     editor->PreDestroy(false);
   } else {
@@ -1298,19 +1300,24 @@ nsEditingSession::RemoveWebProgressListe
   }
 }
 
 void
 nsEditingSession::RestoreAnimationMode(nsIDOMWindow *aWindow)
 {
   if (!mInteractive)
   {
-    nsCOMPtr<nsIDOMWindowUtils> utils(do_GetInterface(aWindow));
-    if (utils)
-      utils->SetImageAnimationMode(mImageAnimationMode);
+    nsCOMPtr<nsIDocShell> docShell = GetDocShellFromWindow(aWindow);
+    NS_ENSURE_TRUE(docShell, );
+    nsCOMPtr<nsIPresShell> presShell = docShell->GetPresShell();
+    NS_ENSURE_TRUE(presShell, );
+    nsPresContext* presContext = presShell->GetPresContext();
+    NS_ENSURE_TRUE(presContext, );
+
+    presContext->SetImageAnimationMode(mImageAnimationMode);
   }
 }
 
 nsresult
 nsEditingSession::DetachFromWindow(nsIDOMWindow* aWindow)
 {
   NS_ENSURE_TRUE(mDoneSetup, NS_OK);
 
@@ -1385,22 +1392,23 @@ nsEditingSession::ReattachToWindow(nsIDO
   // Get editor
   nsCOMPtr<nsIEditor> editor;
   rv = GetEditorForWindow(aWindow, getter_AddRefs(editor));
   NS_ENSURE_TRUE(editor, NS_ERROR_FAILURE);
 
   if (!mInteractive)
   {
     // Disable animation of images in this document:
-    nsCOMPtr<nsIDOMWindowUtils> utils(do_GetInterface(aWindow));
-    NS_ENSURE_TRUE(utils, NS_ERROR_FAILURE);
+    nsCOMPtr<nsIPresShell> presShell = docShell->GetPresShell();
+    NS_ENSURE_TRUE(presShell, NS_ERROR_FAILURE);
+    nsPresContext* presContext = presShell->GetPresContext();
+    NS_ENSURE_TRUE(presContext, NS_ERROR_FAILURE);
 
-    rv = utils->GetImageAnimationMode(&mImageAnimationMode);
-    NS_ENSURE_SUCCESS(rv, rv);
-    utils->SetImageAnimationMode(imgIContainer::kDontAnimMode);
+    mImageAnimationMode = presContext->ImageAnimationMode();
+    presContext->SetImageAnimationMode(imgIContainer::kDontAnimMode);
   }
 
   // The third controller takes an nsIEditor as the context
   rv = SetupEditorCommandController("@mozilla.org/editor/htmleditorcontroller;1",
                                     aWindow, editor,
                                     &mHTMLCommandControllerId);
   NS_ENSURE_SUCCESS(rv, rv);