Bug 1489790 - Part 7: Remove the XPCOM component registration for @mozilla.org/editor/editingcontroller;1; r=baku
authorEhsan Akhgari <ehsan@mozilla.com>
Fri, 07 Sep 2018 09:39:36 -0400
changeset 435704 8b0247a1496add1fc732cee8a7e9828e370c9874
parent 435703 c578fb3304f1ad33519465e8c645ad7eda47bb02
child 435705 8b97390b3b8c04479a866cff0a17c27826d889bf
push id34618
push userbtara@mozilla.com
push dateTue, 11 Sep 2018 22:13:11 +0000
treeherdermozilla-central@1169e8a4ca2b [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbaku
bugs1489790
milestone64.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 1489790 - Part 7: Remove the XPCOM component registration for @mozilla.org/editor/editingcontroller;1; r=baku Differential Revision: https://phabricator.services.mozilla.com/D5362
dom/commandhandler/nsBaseCommandController.cpp
dom/commandhandler/nsBaseCommandController.h
dom/html/HTMLInputElement.cpp
dom/html/HTMLTextAreaElement.cpp
editor/composer/nsEditingSession.cpp
editor/libeditor/EditorController.h
layout/build/nsLayoutModule.cpp
--- a/dom/commandhandler/nsBaseCommandController.cpp
+++ b/dom/commandhandler/nsBaseCommandController.cpp
@@ -196,8 +196,29 @@ nsBaseCommandController::CreateWindowCon
   nsCOMPtr<nsIControllerContext> controllerContext = do_QueryInterface(controller, &rv);
   if (NS_FAILED(rv)) return nullptr;
 
   rv = controllerContext->Init(windowCommandTable);
   if (NS_FAILED(rv)) return nullptr;
 
   return controller.forget();
 }
+
+already_AddRefed<nsIController>
+nsBaseCommandController::CreateEditingController()
+{
+  nsCOMPtr<nsIController> controller = new nsBaseCommandController();
+
+  nsCOMPtr<nsIControllerCommandTable> editingCommandTable =
+    nsControllerCommandTable::CreateEditingCommandTable();
+
+  // this guy is a singleton, so make it immutable
+  editingCommandTable->MakeImmutable();
+
+  nsresult rv;
+  nsCOMPtr<nsIControllerContext> controllerContext = do_QueryInterface(controller, &rv);
+  if (NS_FAILED(rv)) return nullptr;
+
+  rv = controllerContext->Init(editingCommandTable);
+  if (NS_FAILED(rv)) return nullptr;
+
+  return controller.forget();
+}
--- a/dom/commandhandler/nsBaseCommandController.h
+++ b/dom/commandhandler/nsBaseCommandController.h
@@ -26,16 +26,17 @@ public:
 
   NS_DECL_ISUPPORTS
   NS_DECL_NSICONTROLLER
   NS_DECL_NSICOMMANDCONTROLLER
   NS_DECL_NSICONTROLLERCONTEXT
   NS_DECL_NSIINTERFACEREQUESTOR
 
   static already_AddRefed<nsIController> CreateWindowController();
+  static already_AddRefed<nsIController> CreateEditingController();
 
 protected:
   virtual ~nsBaseCommandController();
 
 private:
   nsWeakPtr mCommandContextWeakPtr;
   nsISupports* mCommandContextRawPtr;
 
--- a/dom/html/HTMLInputElement.cpp
+++ b/dom/html/HTMLInputElement.cpp
@@ -109,16 +109,17 @@
 #include <limits>
 
 #include "nsIColorPicker.h"
 #include "nsIStringEnumerator.h"
 #include "HTMLSplitOnSpacesTokenizer.h"
 #include "nsIController.h"
 #include "nsIMIMEInfo.h"
 #include "nsFrameSelection.h"
+#include "nsBaseCommandController.h"
 
 // input type=date
 #include "js/Date.h"
 
 NS_IMPL_NS_NEW_HTML_ELEMENT_CHECK_PARSER(Input)
 
 // XXX align=left, hspace, vspace, border? other nav4 attrs
 
@@ -5809,20 +5810,19 @@ HTMLInputElement::GetControllers(ErrorRe
                                      &rv));
       if (NS_FAILED(rv)) {
         aRv.Throw(rv);
         return nullptr;
       }
 
       mControllers->AppendController(controller);
 
-      controller = do_CreateInstance("@mozilla.org/editor/editingcontroller;1",
-                                     &rv);
-      if (NS_FAILED(rv)) {
-        aRv.Throw(rv);
+      controller = nsBaseCommandController::CreateEditingController();
+      if (!controller) {
+        aRv.Throw(NS_ERROR_FAILURE);
         return nullptr;
       }
 
       mControllers->AppendController(controller);
     }
   }
 
   return mControllers;
--- a/dom/html/HTMLTextAreaElement.cpp
+++ b/dom/html/HTMLTextAreaElement.cpp
@@ -35,16 +35,17 @@
 #include "nsMappedAttributes.h"
 #include "nsPIDOMWindow.h"
 #include "nsPresContext.h"
 #include "mozilla/PresState.h"
 #include "nsReadableUtils.h"
 #include "nsStyleConsts.h"
 #include "nsTextEditorState.h"
 #include "nsIController.h"
+#include "nsBaseCommandController.h"
 
 static NS_DEFINE_CID(kXULControllersCID,  NS_XULCONTROLLERS_CID);
 
 #define NS_NO_CONTENT_DISPATCH (1 << 0)
 
 NS_IMPL_NS_NEW_HTML_ELEMENT_CHECK_PARSER(TextArea)
 
 namespace mozilla {
@@ -633,19 +634,19 @@ HTMLTextAreaElement::GetControllers(Erro
     nsCOMPtr<nsIController> controller = do_CreateInstance("@mozilla.org/editor/editorcontroller;1", &rv);
     if (NS_FAILED(rv)) {
       aError.Throw(rv);
       return nullptr;
     }
 
     mControllers->AppendController(controller);
 
-    controller = do_CreateInstance("@mozilla.org/editor/editingcontroller;1", &rv);
-    if (NS_FAILED(rv)) {
-      aError.Throw(rv);
+    controller = nsBaseCommandController::CreateEditingController();
+    if (!controller) {
+      aError.Throw(NS_ERROR_FAILURE);
       return nullptr;
     }
 
     mControllers->AppendController(controller);
   }
 
   return mControllers;
 }
--- a/editor/composer/nsEditingSession.cpp
+++ b/editor/composer/nsEditingSession.cpp
@@ -44,16 +44,17 @@
 #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 nsString
 #include "mozilla/dom/Selection.h"      // for AutoHideSelectionChanges, etc
 #include "nsFrameSelection.h"           // for nsFrameSelection
+#include "nsBaseCommandController.h"    // for nsBaseCommandController
 
 class nsISupports;
 class nsIURI;
 
 using namespace mozilla;
 using namespace mozilla::dom;
 
 /*---------------------------------------------------------------------------
@@ -151,17 +152,17 @@ nsEditingSession::MakeWindowEditable(moz
 
   // set the flag on the docShell to say that it's editable
   rv = docShell->MakeEditable(aDoAfterUriLoad);
   NS_ENSURE_SUCCESS(rv, rv);
 
   // Setup commands common to plaintext and html editors,
   //  including the document creation observers
   // the first is an editing controller
-  rv = SetupEditorCommandController("@mozilla.org/editor/editingcontroller;1",
+  rv = SetupEditorCommandController(nsBaseCommandController::CreateEditingController,
                                     aWindow,
                                     static_cast<nsIEditingSession*>(this),
                                     &mBaseCommandControllerId);
   NS_ENSURE_SUCCESS(rv, rv);
 
   // The second is a controller to monitor doc state,
   // such as creation and "dirty flag"
   rv = SetupEditorCommandController("@mozilla.org/editor/editordocstatecontroller;1",
@@ -1367,17 +1368,17 @@ nsEditingSession::ReattachToWindow(mozID
   // Tells embedder that startup is in progress.
   mEditorStatus = eEditorCreationInProgress;
 
   // Adds back web progress listener.
   rv = PrepareForEditing(window);
   NS_ENSURE_SUCCESS(rv, rv);
 
   // Setup the command controllers again.
-  rv = SetupEditorCommandController("@mozilla.org/editor/editingcontroller;1",
+  rv = SetupEditorCommandController(nsBaseCommandController::CreateEditingController,
                                     aWindow,
                                     static_cast<nsIEditingSession*>(this),
                                     &mBaseCommandControllerId);
   NS_ENSURE_SUCCESS(rv, rv);
 
   rv = SetupEditorCommandController("@mozilla.org/editor/editordocstatecontroller;1",
                                     aWindow,
                                     static_cast<nsIEditingSession*>(this),
--- a/editor/libeditor/EditorController.h
+++ b/editor/libeditor/EditorController.h
@@ -7,20 +7,16 @@
 #define mozilla_EditorController_h
 
 #include "nscore.h"
 
 #define NS_EDITORCONTROLLER_CID \
 { 0x26fb965c, 0x9de6, 0x11d3, \
   { 0xbc, 0xcc, 0x0, 0x60, 0xb0, 0xfc, 0x76, 0xbd } }
 
-#define NS_EDITINGCONTROLLER_CID \
-{ 0x2c5a5cdd, 0xe742, 0x4dfe, \
-  { 0x86, 0xb8, 0x06, 0x93, 0x09, 0xbf, 0x6c, 0x91 } }
-
 class nsIControllerCommandTable;
 
 namespace mozilla {
 
 // the editor controller is used for both text widgets, and basic text editing
 // commands in composer. The refCon that gets passed to its commands is an nsIEditor.
 
 class EditorController final
--- a/layout/build/nsLayoutModule.cpp
+++ b/layout/build/nsLayoutModule.cpp
@@ -486,17 +486,16 @@ NS_DEFINE_NAMED_CID(NS_DOMLOCALSTORAGEMA
 NS_DEFINE_NAMED_CID(DOMREQUEST_SERVICE_CID);
 NS_DEFINE_NAMED_CID(QUOTAMANAGER_SERVICE_CID);
 NS_DEFINE_NAMED_CID(SERVICEWORKERMANAGER_CID);
 NS_DEFINE_NAMED_CID(STORAGEACTIVITYSERVICE_CID);
 NS_DEFINE_NAMED_CID(NOTIFICATIONTELEMETRYSERVICE_CID);
 NS_DEFINE_NAMED_CID(PUSHNOTIFIER_CID);
 NS_DEFINE_NAMED_CID(WORKERDEBUGGERMANAGER_CID);
 NS_DEFINE_NAMED_CID(NS_EDITORCONTROLLER_CID);
-NS_DEFINE_NAMED_CID(NS_EDITINGCONTROLLER_CID);
 NS_DEFINE_NAMED_CID(NS_GEOLOCATION_CID);
 NS_DEFINE_NAMED_CID(NS_WEBSOCKETEVENT_SERVICE_CID);
 NS_DEFINE_NAMED_CID(NS_FOCUSMANAGER_CID);
 NS_DEFINE_NAMED_CID(NS_CONTENTSECURITYMANAGER_CID);
 NS_DEFINE_NAMED_CID(CSPSERVICE_CID);
 NS_DEFINE_NAMED_CID(NS_CSPCONTEXT_CID);
 NS_DEFINE_NAMED_CID(NS_MIXEDCONTENTBLOCKER_CID);
 NS_DEFINE_NAMED_CID(NS_EVENTLISTENERSERVICE_CID);
@@ -558,40 +557,16 @@ EditorControllerConstructor(nsISupports*
   if (NS_FAILED(rv)) return rv;
 
   rv = controllerContext->Init(editorCommandTable);
   if (NS_FAILED(rv)) return rv;
 
   return controller->QueryInterface(aIID, aResult);
 }
 
-// Constructor of a controller which is set up to use, internally, a
-// singleton command-table pre-filled with editing commands.
-static nsresult
-nsEditingControllerConstructor(nsISupports *aOuter, REFNSIID aIID,
-                                void **aResult)
-{
-  nsCOMPtr<nsIController> controller = new nsBaseCommandController();
-
-  nsCOMPtr<nsIControllerCommandTable> editingCommandTable =
-    nsControllerCommandTable::CreateEditingCommandTable();
-
-  // this guy is a singleton, so make it immutable
-  editingCommandTable->MakeImmutable();
-
-  nsresult rv;
-  nsCOMPtr<nsIControllerContext> controllerContext = do_QueryInterface(controller, &rv);
-  if (NS_FAILED(rv)) return rv;
-
-  rv = controllerContext->Init(editingCommandTable);
-  if (NS_FAILED(rv)) return rv;
-
-  return controller->QueryInterface(aIID, aResult);
-}
-
 static const mozilla::Module::CIDEntry kLayoutCIDs[] = {
   XPCONNECT_CIDENTRIES
 #ifdef DEBUG
   { &kNS_LAYOUT_DEBUGGER_CID, false, nullptr, CreateNewLayoutDebugger },
 #endif
   { &kNS_FRAMETRAVERSAL_CID, false, nullptr, CreateNewFrameTraversal },
   { &kIN_DEEPTREEWALKER_CID, false, nullptr, inDeepTreeWalkerConstructor },
   { &kNS_CONTENT_VIEWER_CID, false, nullptr, CreateContentViewer },
@@ -631,17 +606,16 @@ static const mozilla::Module::CIDEntry k
   { &kDOMREQUEST_SERVICE_CID, false, nullptr, DOMRequestServiceConstructor },
   { &kQUOTAMANAGER_SERVICE_CID, false, nullptr, QuotaManagerServiceConstructor },
   { &kSERVICEWORKERMANAGER_CID, false, nullptr, ServiceWorkerManagerConstructor },
   { &kSTORAGEACTIVITYSERVICE_CID, false, nullptr, StorageActivityServiceConstructor },
   { &kNOTIFICATIONTELEMETRYSERVICE_CID, false, nullptr, NotificationTelemetryServiceConstructor },
   { &kPUSHNOTIFIER_CID, false, nullptr, PushNotifierConstructor },
   { &kWORKERDEBUGGERMANAGER_CID, true, nullptr, WorkerDebuggerManagerConstructor },
   { &kNS_EDITORCONTROLLER_CID, false, nullptr, EditorControllerConstructor },
-  { &kNS_EDITINGCONTROLLER_CID, false, nullptr, nsEditingControllerConstructor },
   { &kNS_GEOLOCATION_CID, false, nullptr, GeolocationConstructor },
   { &kNS_WEBSOCKETEVENT_SERVICE_CID, false, nullptr, WebSocketEventServiceConstructor },
   { &kNS_FOCUSMANAGER_CID, false, nullptr, CreateFocusManager },
 #ifdef MOZ_WEBSPEECH_TEST_BACKEND
   { &kNS_FAKE_SPEECH_RECOGNITION_SERVICE_CID, false, nullptr, FakeSpeechRecognitionServiceConstructor },
 #endif
 #ifdef MOZ_WEBSPEECH
   { &kNS_SYNTHVOICEREGISTRY_CID, true, nullptr, nsSynthVoiceRegistryConstructor },
@@ -719,17 +693,16 @@ static const mozilla::Module::ContractID
   { DOMREQUEST_SERVICE_CONTRACTID, &kDOMREQUEST_SERVICE_CID },
   { QUOTAMANAGER_SERVICE_CONTRACTID, &kQUOTAMANAGER_SERVICE_CID },
   { SERVICEWORKERMANAGER_CONTRACTID, &kSERVICEWORKERMANAGER_CID },
   { STORAGE_ACTIVITY_SERVICE_CONTRACTID, &kSTORAGEACTIVITYSERVICE_CID },
   { NOTIFICATIONTELEMETRYSERVICE_CONTRACTID, &kNOTIFICATIONTELEMETRYSERVICE_CID },
   { PUSHNOTIFIER_CONTRACTID, &kPUSHNOTIFIER_CID },
   { WORKERDEBUGGERMANAGER_CONTRACTID, &kWORKERDEBUGGERMANAGER_CID },
   { "@mozilla.org/editor/editorcontroller;1", &kNS_EDITORCONTROLLER_CID },
-  { "@mozilla.org/editor/editingcontroller;1", &kNS_EDITINGCONTROLLER_CID },
   { "@mozilla.org/geolocation;1", &kNS_GEOLOCATION_CID },
   { "@mozilla.org/websocketevent/service;1", &kNS_WEBSOCKETEVENT_SERVICE_CID },
   { "@mozilla.org/focus-manager;1", &kNS_FOCUSMANAGER_CID },
 #ifdef MOZ_WEBSPEECH_TEST_BACKEND
   { NS_SPEECH_RECOGNITION_SERVICE_CONTRACTID_PREFIX "fake", &kNS_FAKE_SPEECH_RECOGNITION_SERVICE_CID },
 #endif
 #ifdef MOZ_WEBSPEECH
   { NS_SYNTHVOICEREGISTRY_CONTRACTID, &kNS_SYNTHVOICEREGISTRY_CID },