Bug 1468708 - Part 1. Rename nsComposerController to HTMLEditorController. r?masayuki
nsComposerController is execCommand's command controller now. So it is better
to use mozilla::HTMLEditorController class name instead of nsComposerController.
MozReview-Commit-ID: 7QNFO2dV5Zd
rename from editor/composer/nsComposerController.cpp
rename to editor/composer/HTMLEditorController.cpp
--- a/editor/composer/nsComposerController.cpp
+++ b/editor/composer/HTMLEditorController.cpp
@@ -1,22 +1,25 @@
/* -*- 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 "mozilla/HTMLEditorController.h"
+
#include "mozilla/mozalloc.h" // for operator new
#include "nsComposerCommands.h" // for nsStyleUpdatingCommand, etc
-#include "nsComposerController.h"
#include "nsError.h" // for NS_OK
#include "nsGkAtoms.h" // for nsGkAtoms, nsGkAtoms::a, etc
#include "nsIControllerCommandTable.h" // for nsIControllerCommandTable
class nsIControllerCommand;
+namespace mozilla {
+
#define NS_REGISTER_ONE_COMMAND(_cmdClass, _cmdName) \
{ \
_cmdClass* theCmd = new _cmdClass(); \
inCommandTable->RegisterCommand(_cmdName, \
static_cast<nsIControllerCommand *>(theCmd)); \
}
#define NS_REGISTER_FIRST_COMMAND(_cmdClass, _cmdName) \
@@ -46,17 +49,17 @@ class nsIControllerCommand;
_cmdClass* theCmd = new _cmdClass(_tagName); \
inCommandTable->RegisterCommand(_cmdName, \
static_cast<nsIControllerCommand *>(theCmd)); \
}
// static
nsresult
-nsComposerController::RegisterEditorDocStateCommands(
+HTMLEditorController::RegisterEditorDocStateCommands(
nsIControllerCommandTable *inCommandTable)
{
// observer commands for document state
NS_REGISTER_FIRST_COMMAND(nsDocumentStateCommand, "obs_documentCreated")
NS_REGISTER_NEXT_COMMAND(nsDocumentStateCommand, "obs_documentWillBeDestroyed")
NS_REGISTER_LAST_COMMAND(nsDocumentStateCommand, "obs_documentLocationChanged")
// commands that may get or change state
@@ -70,17 +73,17 @@ nsComposerController::RegisterEditorDocS
NS_REGISTER_ONE_COMMAND(nsSetDocumentOptionsCommand, "cmd_setDocumentOptions")
return NS_OK;
}
// static
nsresult
-nsComposerController::RegisterHTMLEditorCommands(
+HTMLEditorController::RegisterHTMLEditorCommands(
nsIControllerCommandTable *inCommandTable)
{
// Edit menu
NS_REGISTER_ONE_COMMAND(nsPasteNoFormattingCommand, "cmd_pasteNoFormatting");
// indent/outdent
NS_REGISTER_ONE_COMMAND(nsIndentCommand, "cmd_indent");
NS_REGISTER_ONE_COMMAND(nsOutdentCommand, "cmd_outdent");
@@ -134,8 +137,10 @@ nsComposerController::RegisterHTMLEditor
NS_REGISTER_TAG_COMMAND(nsInsertTagCommand, "cmd_insertHR", nsGkAtoms::hr);
NS_REGISTER_ONE_COMMAND(nsAbsolutePositioningCommand, "cmd_absPos");
NS_REGISTER_ONE_COMMAND(nsDecreaseZIndexCommand, "cmd_decreaseZIndex");
NS_REGISTER_ONE_COMMAND(nsIncreaseZIndexCommand, "cmd_increaseZIndex");
return NS_OK;
}
+
+} // namespace mozilla
rename from editor/composer/nsComposerController.h
rename to editor/composer/HTMLEditorController.h
--- a/editor/composer/nsComposerController.h
+++ b/editor/composer/HTMLEditorController.h
@@ -1,15 +1,15 @@
/* -*- 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 nsComposerController_h__
-#define nsComposerController_h__
+#ifndef mozilla_HTMLEditorController_h__
+#define mozilla_HTMLEditorController_h__
#include "nscore.h" // for nsresult
class nsIControllerCommandTable;
// The plaintext editor controller is used for basic text editing and html editing
@@ -18,17 +18,20 @@ class nsIControllerCommandTable;
// and after successfule editor creation it is changed to nsIEditor.
#define NS_EDITORDOCSTATECONTROLLER_CID \
{ 0x50e95301, 0x17a8, 0x11d4, { 0x9f, 0x7e, 0xdd, 0x53, 0x0d, 0x5f, 0x05, 0x7c } }
// The HTMLEditor controller is used only for HTML editors and takes nsIEditor as refCon
#define NS_HTMLEDITORCONTROLLER_CID \
{ 0x62db0002, 0xdbb6, 0x43f4, { 0x8f, 0xb7, 0x9d, 0x25, 0x38, 0xbc, 0x57, 0x47 } }
+namespace mozilla {
-class nsComposerController
+class HTMLEditorController final
{
public:
static nsresult RegisterEditorDocStateCommands(nsIControllerCommandTable* inCommandTable);
static nsresult RegisterHTMLEditorCommands(nsIControllerCommandTable* inCommandTable);
};
-#endif /* nsComposerController_h__ */
+} // namespace mozilla
+
+#endif /* mozllla_HTMLEditorController_h__ */
--- a/editor/composer/moz.build
+++ b/editor/composer/moz.build
@@ -11,25 +11,26 @@ MOCHITEST_CHROME_MANIFESTS += ['test/chr
XPIDL_SOURCES += [
'nsIEditingSession.idl',
]
XPIDL_MODULE = 'composer'
UNIFIED_SOURCES += [
'ComposerCommandsUpdater.cpp',
+ 'HTMLEditorController.cpp',
'nsComposerCommands.cpp',
- 'nsComposerController.cpp',
'nsComposerDocumentCommands.cpp',
'nsComposerRegistration.cpp',
'nsEditingSession.cpp',
]
EXPORTS.mozilla += [
'ComposerCommandsUpdater.h',
+ 'HTMLEditorController.h',
]
# Needed because we include HTMLEditor.h which indirectly includes nsDocument.h
LOCAL_INCLUDES += [
'/dom/base',
'/dom/html', # For nsHTMLDocument
'/editor/spellchecker', # nsComposeTxtSrvFilter.h
'/layout/style', # For things nsHTMLDocument includes.
--- a/editor/composer/nsComposerRegistration.cpp
+++ b/editor/composer/nsComposerRegistration.cpp
@@ -1,21 +1,21 @@
/* -*- 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 "mozilla/EditorSpellCheck.h" // for NS_EDITORSPELLCHECK_CID, etc
+#include "mozilla/HTMLEditorController.h" // for HTMLEditorController, etc
#include "mozilla/Module.h" // for Module, Module::CIDEntry, etc
#include "mozilla/ModuleUtils.h"
#include "mozilla/mozalloc.h" // for operator new
#include "nsCOMPtr.h" // for nsCOMPtr, getter_AddRefs, etc
#include "nsComponentManagerUtils.h" // for do_CreateInstance
#include "nsComposeTxtSrvFilter.h" // for nsComposeTxtSrvFilter, etc
-#include "nsComposerController.h" // for nsComposerController, etc
#include "nsDebug.h" // for NS_ENSURE_SUCCESS
#include "nsEditingSession.h" // for NS_EDITINGSESSION_CID, etc
#include "nsError.h" // for NS_ERROR_NO_AGGREGATION, etc
#include "nsIController.h" // for nsIController
#include "nsIControllerCommandTable.h" // for nsIControllerCommandTable, etc
#include "nsIControllerContext.h" // for nsIControllerContext
#include "nsID.h" // for NS_DEFINE_NAMED_CID, etc
#include "nsISupportsImpl.h"
@@ -151,17 +151,17 @@ static nsresult
nsHTMLEditorCommandTableConstructor(nsISupports *aOuter, REFNSIID aIID,
void **aResult)
{
nsresult rv;
nsCOMPtr<nsIControllerCommandTable> commandTable =
do_CreateInstance(NS_CONTROLLERCOMMANDTABLE_CONTRACTID, &rv);
NS_ENSURE_SUCCESS(rv, rv);
- rv = nsComposerController::RegisterHTMLEditorCommands(commandTable);
+ rv = mozilla::HTMLEditorController::RegisterHTMLEditorCommands(commandTable);
NS_ENSURE_SUCCESS(rv, 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);
}
@@ -171,17 +171,18 @@ static nsresult
nsHTMLEditorDocStateCommandTableConstructor(nsISupports *aOuter, REFNSIID aIID,
void **aResult)
{
nsresult rv;
nsCOMPtr<nsIControllerCommandTable> commandTable =
do_CreateInstance(NS_CONTROLLERCOMMANDTABLE_CONTRACTID, &rv);
NS_ENSURE_SUCCESS(rv, rv);
- rv = nsComposerController::RegisterEditorDocStateCommands(commandTable);
+ rv = mozilla::HTMLEditorController::RegisterEditorDocStateCommands(
+ commandTable);
NS_ENSURE_SUCCESS(rv, 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);
}