Bug 1260651 part.33 Rename nsEditorController to mozilla::EditorController (and their files too) r?mccr8 draft
authorMasayuki Nakano <masayuki@d-toybox.com>
Fri, 08 Jul 2016 14:26:02 +0900
changeset 385723 ee1f724a1fefdb57a3e9f4dc5cd4440e8c43a853
parent 385722 6adebb8d5dc3f7cb7bed6c5bcadce025d3741cb1
child 385724 34af67d205ccec153580f67e34f7c9871d1728ea
push id22582
push usermasayuki@d-toybox.com
push dateSat, 09 Jul 2016 03:13:39 +0000
reviewersmccr8
bugs1260651
milestone50.0a1
Bug 1260651 part.33 Rename nsEditorController to mozilla::EditorController (and their files too) r?mccr8 MozReview-Commit-ID: 5xedcGTDlq1
editor/libeditor/EditorController.cpp
editor/libeditor/EditorController.h
editor/libeditor/moz.build
editor/libeditor/nsEditorController.cpp
editor/libeditor/nsEditorController.h
layout/build/nsLayoutModule.cpp
rename from editor/libeditor/nsEditorController.cpp
rename to editor/libeditor/EditorController.cpp
--- a/editor/libeditor/nsEditorController.cpp
+++ b/editor/libeditor/EditorController.cpp
@@ -1,52 +1,57 @@
 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
-#include "nsEditorController.h"
+#include "mozilla/EditorController.h"
 
 #include "mozilla/mozalloc.h"
 #include "nsDebug.h"
 #include "nsEditorCommands.h"
 #include "nsError.h"
 #include "nsIControllerCommandTable.h"
 
 class nsIControllerCommand;
 
-
+namespace mozilla {
 
-#define NS_REGISTER_ONE_COMMAND(_cmdClass, _cmdName)                                      \
-  {                                                                                       \
-    _cmdClass* theCmd = new _cmdClass();                                                  \
-    NS_ENSURE_TRUE(theCmd, NS_ERROR_OUT_OF_MEMORY);                                       \
-    inCommandTable->RegisterCommand(_cmdName,                                             \
-                                   static_cast<nsIControllerCommand *>(theCmd));          \
+#define NS_REGISTER_ONE_COMMAND(_cmdClass, _cmdName)                           \
+  {                                                                            \
+    _cmdClass* theCmd = new _cmdClass();                                       \
+    NS_ENSURE_TRUE(theCmd, NS_ERROR_OUT_OF_MEMORY);                            \
+    aCommandTable->RegisterCommand(                                            \
+                     _cmdName,                                                 \
+                     static_cast<nsIControllerCommand *>(theCmd));             \
   }
 
-#define NS_REGISTER_FIRST_COMMAND(_cmdClass, _cmdName)                                    \
-  {                                                                                       \
-    _cmdClass* theCmd = new _cmdClass();                                                  \
-    NS_ENSURE_TRUE(theCmd, NS_ERROR_OUT_OF_MEMORY);                                       \
-    inCommandTable->RegisterCommand(_cmdName,                                             \
-                                   static_cast<nsIControllerCommand *>(theCmd));
+#define NS_REGISTER_FIRST_COMMAND(_cmdClass, _cmdName)                         \
+  {                                                                            \
+    _cmdClass* theCmd = new _cmdClass();                                       \
+    NS_ENSURE_TRUE(theCmd, NS_ERROR_OUT_OF_MEMORY);                            \
+    aCommandTable->RegisterCommand(                                            \
+                     _cmdName,                                                 \
+                     static_cast<nsIControllerCommand *>(theCmd));
 
-#define NS_REGISTER_NEXT_COMMAND(_cmdClass, _cmdName)                                     \
-    inCommandTable->RegisterCommand(_cmdName,                                             \
-                                   static_cast<nsIControllerCommand *>(theCmd));
+#define NS_REGISTER_NEXT_COMMAND(_cmdClass, _cmdName)                          \
+    aCommandTable->RegisterCommand(                                            \
+                     _cmdName,                                                 \
+                     static_cast<nsIControllerCommand *>(theCmd));
 
-#define NS_REGISTER_LAST_COMMAND(_cmdClass, _cmdName)                                     \
-    inCommandTable->RegisterCommand(_cmdName,                                             \
-                                   static_cast<nsIControllerCommand *>(theCmd));          \
+#define NS_REGISTER_LAST_COMMAND(_cmdClass, _cmdName)                          \
+    aCommandTable->RegisterCommand(                                            \
+                     _cmdName,                                                 \
+                     static_cast<nsIControllerCommand *>(theCmd));             \
   }
 
-
 // static
-nsresult nsEditorController::RegisterEditingCommands(nsIControllerCommandTable *inCommandTable)
+nsresult
+EditorController::RegisterEditingCommands(
+                    nsIControllerCommandTable* aCommandTable)
 {
   // now register all our commands
   // These are commands that will be used in text widgets, and in composer
 
   NS_REGISTER_ONE_COMMAND(nsUndoCommand, "cmd_undo");
   NS_REGISTER_ONE_COMMAND(nsRedoCommand, "cmd_redo");
   NS_REGISTER_ONE_COMMAND(nsClearUndoCommand, "cmd_clearUndo");
 
@@ -73,19 +78,20 @@ nsresult nsEditorController::RegisterEdi
 
   // Insert content
   NS_REGISTER_ONE_COMMAND(nsInsertPlaintextCommand, "cmd_insertText");
   NS_REGISTER_ONE_COMMAND(nsPasteQuotationCommand,  "cmd_pasteQuote");
 
   return NS_OK;
 }
 
-
 // static
-nsresult nsEditorController::RegisterEditorCommands(nsIControllerCommandTable *inCommandTable)
+nsresult
+EditorController::RegisterEditorCommands(
+                    nsIControllerCommandTable* aCommandTable)
 {
   // These are commands that will be used in text widgets only.
 
   NS_REGISTER_FIRST_COMMAND(nsSelectionMoveCommands, "cmd_scrollTop");
   NS_REGISTER_NEXT_COMMAND(nsSelectionMoveCommands, "cmd_scrollBottom");
   NS_REGISTER_NEXT_COMMAND(nsSelectionMoveCommands, "cmd_moveTop");
   NS_REGISTER_NEXT_COMMAND(nsSelectionMoveCommands, "cmd_moveBottom");
   NS_REGISTER_NEXT_COMMAND(nsSelectionMoveCommands, "cmd_selectTop");
@@ -129,8 +135,9 @@ nsresult nsEditorController::RegisterEdi
   NS_REGISTER_NEXT_COMMAND(nsSelectionMoveCommands, "cmd_selectLeft2");
   NS_REGISTER_NEXT_COMMAND(nsSelectionMoveCommands, "cmd_selectRight2");
   NS_REGISTER_NEXT_COMMAND(nsSelectionMoveCommands, "cmd_selectUp2");
   NS_REGISTER_LAST_COMMAND(nsSelectionMoveCommands, "cmd_selectDown2");
 
   return NS_OK;
 }
 
+} // namespace mozilla
rename from editor/libeditor/nsEditorController.h
rename to editor/libeditor/EditorController.h
--- a/editor/libeditor/nsEditorController.h
+++ b/editor/libeditor/EditorController.h
@@ -1,31 +1,37 @@
 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
-#ifndef nsEditorController_h__
-#define nsEditorController_h__
+#ifndef mozilla_EditorController_h
+#define mozilla_EditorController_h
 
 #include "nscore.h"
 
 #define NS_EDITORCONTROLLER_CID \
-{ 0x26fb965c, 0x9de6, 0x11d3, { 0xbc, 0xcc, 0x0, 0x60, 0xb0, 0xfc, 0x76, 0xbd } }
+{ 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 } }
+{ 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 nsEditorController
+class EditorController final
 {
 public:
-  static nsresult RegisterEditorCommands(nsIControllerCommandTable* inCommandTable);
-  static nsresult RegisterEditingCommands(nsIControllerCommandTable* inCommandTable);
+  static nsresult RegisterEditorCommands(
+                    nsIControllerCommandTable* aCommandTable);
+  static nsresult RegisterEditingCommands(
+                    nsIControllerCommandTable* aCommandTable);
 };
 
-#endif /* nsEditorController_h__ */
+} // namespace mozilla
 
+#endif // #ifndef mozilla_EditorController_h
--- a/editor/libeditor/moz.build
+++ b/editor/libeditor/moz.build
@@ -8,34 +8,38 @@ MOCHITEST_MANIFESTS += [
     'tests/browserscope/mochitest.ini',
     'tests/mochitest.ini',
 ]
 
 MOCHITEST_CHROME_MANIFESTS += ['tests/chrome.ini']
 
 BROWSER_CHROME_MANIFESTS += ['tests/browser.ini']
 
+EXPORTS.mozilla += [
+    'EditorController.h',
+]
+
 UNIFIED_SOURCES += [
     'ChangeAttributeTransaction.cpp',
     'ChangeStyleTransaction.cpp',
     'CompositionTransaction.cpp',
     'CreateElementTransaction.cpp',
     'DeleteNodeTransaction.cpp',
     'DeleteRangeTransaction.cpp',
     'DeleteTextTransaction.cpp',
     'EditAggregateTransaction.cpp',
+    'EditorController.cpp',
     'EditorUtils.cpp',
     'EditTransactionBase.cpp',
     'HTMLEditUtils.cpp',
     'InsertNodeTransaction.cpp',
     'InsertTextTransaction.cpp',
     'JoinNodeTransaction.cpp',
     'nsEditor.cpp',
     'nsEditorCommands.cpp',
-    'nsEditorController.cpp',
     'nsEditorEventListener.cpp',
     'nsHTMLAbsPosition.cpp',
     'nsHTMLAnonymousUtils.cpp',
     'nsHTMLCSSUtils.cpp',
     'nsHTMLDataTransfer.cpp',
     'nsHTMLEditor.cpp',
     'nsHTMLEditorEventListener.cpp',
     'nsHTMLEditorStyle.cpp',
--- a/layout/build/nsLayoutModule.cpp
+++ b/layout/build/nsLayoutModule.cpp
@@ -133,17 +133,17 @@ using mozilla::dom::PushNotifier;
 
 #include "AudioChannelAgent.h"
 using mozilla::dom::AudioChannelAgent;
 
 // Editor stuff
 #include "nsEditorCID.h"
 #include "nsEditor.h"
 #include "nsPlaintextEditor.h"
-#include "nsEditorController.h" //CID
+#include "mozilla/EditorController.h" //CID
 
 #include "nsHTMLEditor.h"
 #include "nsTextServicesDocument.h"
 #include "nsTextServicesCID.h"
 
 #include "nsScriptSecurityManager.h"
 #include "nsPrincipal.h"
 #include "nsSystemPrincipal.h"
@@ -906,18 +906,17 @@ CreateWindowControllerWithSingletonComma
   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 editor commands.
 static nsresult
-nsEditorControllerConstructor(nsISupports *aOuter, REFNSIID aIID,
-                              void **aResult)
+EditorControllerConstructor(nsISupports* aOuter, REFNSIID aIID, void** aResult)
 {
   nsresult rv;
   nsCOMPtr<nsIController> controller = do_CreateInstance("@mozilla.org/embedcomp/base-command-controller;1", &rv);
   if (NS_FAILED(rv)) return rv;
 
   nsCOMPtr<nsIControllerCommandTable> editorCommandTable = do_GetService(kNS_EDITORCOMMANDTABLE_CID, &rv);
   if (NS_FAILED(rv)) return rv;
 
@@ -963,17 +962,17 @@ static nsresult
 nsEditorCommandTableConstructor(nsISupports *aOuter, REFNSIID aIID,
                                             void **aResult)
 {
   nsresult rv;
   nsCOMPtr<nsIControllerCommandTable> commandTable =
       do_CreateInstance(NS_CONTROLLERCOMMANDTABLE_CONTRACTID, &rv);
   if (NS_FAILED(rv)) return rv;
 
-  rv = nsEditorController::RegisterEditorCommands(commandTable);
+  rv = EditorController::RegisterEditorCommands(commandTable);
   if (NS_FAILED(rv)) return rv;
 
   // we don't know here whether we're being created as an instance,
   // or a service, so we can't become immutable
 
   return commandTable->QueryInterface(aIID, aResult);
 }
 
@@ -982,17 +981,17 @@ static nsresult
 nsEditingCommandTableConstructor(nsISupports *aOuter, REFNSIID aIID,
                                               void **aResult)
 {
   nsresult rv;
   nsCOMPtr<nsIControllerCommandTable> commandTable =
       do_CreateInstance(NS_CONTROLLERCOMMANDTABLE_CONTRACTID, &rv);
   if (NS_FAILED(rv)) return rv;
 
-  rv = nsEditorController::RegisterEditingCommands(commandTable);
+  rv = EditorController::RegisterEditingCommands(commandTable);
   if (NS_FAILED(rv)) return rv;
 
   // we don't know here whether we're being created as an instance,
   // or a service, so we can't become immutable
 
   return commandTable->QueryInterface(aIID, aResult);
 }
 
@@ -1083,17 +1082,17 @@ static const mozilla::Module::CIDEntry k
   { &kBLUETOOTHSERVICE_CID, true, nullptr, BluetoothServiceConstructor },
 #endif
 #ifdef MOZ_WIDGET_GONK
   { &kNS_AUDIOMANAGER_CID, true, nullptr, AudioManagerConstructor },
   { &kNS_VOLUMESERVICE_CID, true, nullptr, nsVolumeServiceConstructor },
 #endif
   { &kNS_AUDIOCHANNELAGENT_CID, true, nullptr, AudioChannelAgentConstructor },
   { &kNS_HTMLEDITOR_CID, false, nullptr, nsHTMLEditorConstructor },
-  { &kNS_EDITORCONTROLLER_CID, false, nullptr, nsEditorControllerConstructor },
+  { &kNS_EDITORCONTROLLER_CID, false, nullptr, EditorControllerConstructor },
   { &kNS_EDITINGCONTROLLER_CID, false, nullptr, nsEditingControllerConstructor },
   { &kNS_EDITORCOMMANDTABLE_CID, false, nullptr, nsEditorCommandTableConstructor },
   { &kNS_EDITINGCOMMANDTABLE_CID, false, nullptr, nsEditingCommandTableConstructor },
   { &kNS_TEXTSERVICESDOCUMENT_CID, false, nullptr, nsTextServicesDocumentConstructor },
   { &kNS_GEOLOCATION_SERVICE_CID, false, nullptr, nsGeolocationServiceConstructor },
   { &kNS_GEOLOCATION_CID, false, nullptr, GeolocationConstructor },
   { &kNS_AUDIOCHANNEL_SERVICE_CID, false, nullptr, AudioChannelServiceConstructor },
   { &kNS_WEBSOCKETEVENT_SERVICE_CID, false, nullptr, WebSocketEventServiceConstructor },