зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1540963 - Make nsIControllerCommandTable builtinclass and make its users use nsControllerCommandTable directly r=bzbarsky
`nsIControllerCommandTable` isn't implemented with JS even in comm-central nor BlueGriffon. Therefore, we can make it a builtinclass. Additionally, it's inherited only by nsControllerCommandTable. So, all users in C++ can treat the concrete class directly. Differential Revision: https://phabricator.services.mozilla.com/D25727 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
8329e8382e
Коммит
4204b59128
|
@ -15,8 +15,8 @@
|
|||
#include "mozilla/ArrayUtils.h"
|
||||
#include "mozilla/Preferences.h"
|
||||
|
||||
#include "nsIControllerCommandTable.h"
|
||||
#include "nsICommandParams.h"
|
||||
#include "nsControllerCommandTable.h"
|
||||
#include "nsCommandParams.h"
|
||||
|
||||
#include "nsPIDOMWindow.h"
|
||||
#include "nsIPresShell.h"
|
||||
|
@ -1023,28 +1023,28 @@ nsLookUpDictionaryCommand::DoCommandParams(const char *aCommandName,
|
|||
#define NS_REGISTER_ONE_COMMAND(_cmdClass, _cmdName) \
|
||||
{ \
|
||||
_cmdClass *theCmd = new _cmdClass(); \
|
||||
rv = inCommandTable->RegisterCommand( \
|
||||
rv = aCommandTable->RegisterCommand( \
|
||||
_cmdName, static_cast<nsIControllerCommand *>(theCmd)); \
|
||||
}
|
||||
|
||||
#define NS_REGISTER_FIRST_COMMAND(_cmdClass, _cmdName) \
|
||||
{ \
|
||||
_cmdClass *theCmd = new _cmdClass(); \
|
||||
rv = inCommandTable->RegisterCommand( \
|
||||
rv = aCommandTable->RegisterCommand( \
|
||||
_cmdName, static_cast<nsIControllerCommand *>(theCmd));
|
||||
|
||||
#define NS_REGISTER_NEXT_COMMAND(_cmdClass, _cmdName) \
|
||||
rv = inCommandTable->RegisterCommand( \
|
||||
rv = aCommandTable->RegisterCommand( \
|
||||
_cmdName, static_cast<nsIControllerCommand *>(theCmd));
|
||||
|
||||
#define NS_REGISTER_LAST_COMMAND(_cmdClass, _cmdName) \
|
||||
rv = inCommandTable->RegisterCommand( \
|
||||
rv = aCommandTable->RegisterCommand( \
|
||||
_cmdName, static_cast<nsIControllerCommand *>(theCmd)); \
|
||||
}
|
||||
|
||||
// static
|
||||
nsresult nsWindowCommandRegistration::RegisterWindowCommands(
|
||||
nsIControllerCommandTable *inCommandTable) {
|
||||
nsControllerCommandTable *aCommandTable) {
|
||||
nsresult rv;
|
||||
|
||||
// XXX rework the macros to use a loop is possible, reducing code size
|
||||
|
|
|
@ -15,11 +15,12 @@ struct KeyboardScrollAction;
|
|||
} // namespace layers
|
||||
} // namespace mozilla
|
||||
|
||||
class nsIControllerCommandTable;
|
||||
class nsControllerCommandTable;
|
||||
|
||||
class nsWindowCommandRegistration {
|
||||
public:
|
||||
static nsresult RegisterWindowCommands(nsIControllerCommandTable* ccm);
|
||||
static nsresult RegisterWindowCommands(
|
||||
nsControllerCommandTable* aCommandTable);
|
||||
};
|
||||
|
||||
class nsGlobalWindowCommands {
|
||||
|
|
|
@ -43,6 +43,7 @@
|
|||
#if defined(MOZ_WIDGET_ANDROID)
|
||||
# include "mozilla/dom/WindowOrientationObserver.h"
|
||||
#endif
|
||||
#include "nsBaseCommandController.h"
|
||||
#include "nsError.h"
|
||||
#include "nsISizeOfEventTarget.h"
|
||||
#include "nsDOMJSUtils.h"
|
||||
|
@ -56,7 +57,6 @@
|
|||
#include "nsIScriptContext.h"
|
||||
#include "nsIScriptTimeoutHandler.h"
|
||||
#include "nsITimeoutHandler.h"
|
||||
#include "nsIController.h"
|
||||
#include "nsISlowScriptDebug.h"
|
||||
#include "nsWindowMemoryReporter.h"
|
||||
#include "nsWindowSizes.h"
|
||||
|
@ -145,7 +145,6 @@
|
|||
#include "nsIContentViewer.h"
|
||||
#include "nsIScriptError.h"
|
||||
#include "nsIControllers.h"
|
||||
#include "nsIControllerContext.h"
|
||||
#include "nsGlobalWindowCommands.h"
|
||||
#include "nsQueryObject.h"
|
||||
#include "nsContentUtils.h"
|
||||
|
@ -3195,22 +3194,15 @@ nsIControllers* nsGlobalWindowOuter::GetControllersOuter(ErrorResult& aError) {
|
|||
}
|
||||
|
||||
// Add in the default controller
|
||||
nsCOMPtr<nsIController> controller =
|
||||
RefPtr<nsBaseCommandController> commandController =
|
||||
nsBaseCommandController::CreateWindowController();
|
||||
if (!controller) {
|
||||
if (!commandController) {
|
||||
aError.Throw(NS_ERROR_FAILURE);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
mControllers->InsertControllerAt(0, controller);
|
||||
nsCOMPtr<nsIControllerContext> controllerContext =
|
||||
do_QueryInterface(controller);
|
||||
if (!controllerContext) {
|
||||
aError.Throw(NS_ERROR_FAILURE);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
controllerContext->SetCommandContext(static_cast<nsIDOMWindow*>(this));
|
||||
mControllers->InsertControllerAt(0, commandController);
|
||||
commandController->SetCommandContext(static_cast<nsIDOMWindow*>(this));
|
||||
}
|
||||
|
||||
return mControllers;
|
||||
|
|
|
@ -29,7 +29,7 @@ nsBaseCommandController::~nsBaseCommandController() {}
|
|||
NS_IMETHODIMP
|
||||
nsBaseCommandController::Init(nsIControllerCommandTable* aCommandTable) {
|
||||
if (aCommandTable) {
|
||||
mCommandTable = aCommandTable;
|
||||
mCommandTable = aCommandTable->AsControllerCommandTable();
|
||||
} else {
|
||||
mCommandTable = new nsControllerCommandTable();
|
||||
}
|
||||
|
@ -67,7 +67,10 @@ nsBaseCommandController::GetInterface(const nsIID& aIID, void** aResult) {
|
|||
|
||||
if (aIID.Equals(NS_GET_IID(nsIControllerCommandTable))) {
|
||||
if (mCommandTable) {
|
||||
return mCommandTable->QueryInterface(aIID, aResult);
|
||||
*aResult =
|
||||
do_AddRef(static_cast<nsIControllerCommandTable*>(mCommandTable))
|
||||
.take();
|
||||
return NS_OK;
|
||||
}
|
||||
return NS_ERROR_NOT_INITIALIZED;
|
||||
}
|
||||
|
@ -118,7 +121,7 @@ nsBaseCommandController::DoCommand(const char* aCommand) {
|
|||
if (!context) {
|
||||
context = do_QueryReferent(mCommandContextWeakPtr);
|
||||
}
|
||||
nsCOMPtr<nsIControllerCommandTable> commandTable(mCommandTable);
|
||||
RefPtr<nsControllerCommandTable> commandTable(mCommandTable);
|
||||
return commandTable->DoCommand(aCommand, context);
|
||||
}
|
||||
|
||||
|
@ -132,7 +135,7 @@ nsBaseCommandController::DoCommandWithParams(const char* aCommand,
|
|||
if (!context) {
|
||||
context = do_QueryReferent(mCommandContextWeakPtr);
|
||||
}
|
||||
nsCOMPtr<nsIControllerCommandTable> commandTable(mCommandTable);
|
||||
RefPtr<nsControllerCommandTable> commandTable(mCommandTable);
|
||||
return commandTable->DoCommandParams(aCommand, aParams, context);
|
||||
}
|
||||
|
||||
|
@ -164,54 +167,54 @@ nsBaseCommandController::GetSupportedCommands(uint32_t* aCount,
|
|||
return mCommandTable->GetSupportedCommands(aCount, aCommands);
|
||||
}
|
||||
|
||||
typedef already_AddRefed<nsIControllerCommandTable> (*CommandTableCreatorFn)();
|
||||
typedef already_AddRefed<nsControllerCommandTable> (*CommandTableCreatorFn)();
|
||||
|
||||
static already_AddRefed<nsIController>
|
||||
static already_AddRefed<nsBaseCommandController>
|
||||
CreateControllerWithSingletonCommandTable(CommandTableCreatorFn aCreatorFn) {
|
||||
nsCOMPtr<nsIController> controller = new nsBaseCommandController();
|
||||
RefPtr<nsBaseCommandController> commandController =
|
||||
new nsBaseCommandController();
|
||||
|
||||
nsCOMPtr<nsIControllerCommandTable> commandTable = aCreatorFn();
|
||||
if (!commandTable) return nullptr;
|
||||
RefPtr<nsControllerCommandTable> commandTable = aCreatorFn();
|
||||
if (!commandTable) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
// this is a singleton; make it immutable
|
||||
commandTable->MakeImmutable();
|
||||
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsIControllerContext> controllerContext =
|
||||
do_QueryInterface(controller, &rv);
|
||||
if (NS_FAILED(rv)) return nullptr;
|
||||
nsresult rv = commandController->Init(commandTable);
|
||||
if (NS_FAILED(rv)) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
rv = controllerContext->Init(commandTable);
|
||||
if (NS_FAILED(rv)) return nullptr;
|
||||
|
||||
return controller.forget();
|
||||
return commandController.forget();
|
||||
}
|
||||
|
||||
already_AddRefed<nsIController>
|
||||
already_AddRefed<nsBaseCommandController>
|
||||
nsBaseCommandController::CreateWindowController() {
|
||||
return CreateControllerWithSingletonCommandTable(
|
||||
nsControllerCommandTable::CreateWindowCommandTable);
|
||||
}
|
||||
|
||||
already_AddRefed<nsIController>
|
||||
already_AddRefed<nsBaseCommandController>
|
||||
nsBaseCommandController::CreateEditorController() {
|
||||
return CreateControllerWithSingletonCommandTable(
|
||||
nsControllerCommandTable::CreateEditorCommandTable);
|
||||
}
|
||||
|
||||
already_AddRefed<nsIController>
|
||||
already_AddRefed<nsBaseCommandController>
|
||||
nsBaseCommandController::CreateEditingController() {
|
||||
return CreateControllerWithSingletonCommandTable(
|
||||
nsControllerCommandTable::CreateEditingCommandTable);
|
||||
}
|
||||
|
||||
already_AddRefed<nsIController>
|
||||
already_AddRefed<nsBaseCommandController>
|
||||
nsBaseCommandController::CreateHTMLEditorController() {
|
||||
return CreateControllerWithSingletonCommandTable(
|
||||
nsControllerCommandTable::CreateHTMLEditorCommandTable);
|
||||
}
|
||||
|
||||
already_AddRefed<nsIController>
|
||||
already_AddRefed<nsBaseCommandController>
|
||||
nsBaseCommandController::CreateHTMLEditorDocStateController() {
|
||||
return CreateControllerWithSingletonCommandTable(
|
||||
nsControllerCommandTable::CreateHTMLEditorDocStateCommandTable);
|
||||
|
|
|
@ -9,10 +9,11 @@
|
|||
|
||||
#include "nsIController.h"
|
||||
#include "nsIControllerContext.h"
|
||||
#include "nsIControllerCommandTable.h"
|
||||
#include "nsIInterfaceRequestor.h"
|
||||
#include "nsIWeakReferenceUtils.h"
|
||||
|
||||
class nsControllerCommandTable;
|
||||
|
||||
// The base editor controller is used for both text widgets, and all other text
|
||||
// and html editing
|
||||
class nsBaseCommandController : public nsIController,
|
||||
|
@ -28,11 +29,12 @@ class nsBaseCommandController : public nsIController,
|
|||
NS_DECL_NSICONTROLLERCONTEXT
|
||||
NS_DECL_NSIINTERFACEREQUESTOR
|
||||
|
||||
static already_AddRefed<nsIController> CreateWindowController();
|
||||
static already_AddRefed<nsIController> CreateEditorController();
|
||||
static already_AddRefed<nsIController> CreateEditingController();
|
||||
static already_AddRefed<nsIController> CreateHTMLEditorController();
|
||||
static already_AddRefed<nsIController> CreateHTMLEditorDocStateController();
|
||||
static already_AddRefed<nsBaseCommandController> CreateWindowController();
|
||||
static already_AddRefed<nsBaseCommandController> CreateEditorController();
|
||||
static already_AddRefed<nsBaseCommandController> CreateEditingController();
|
||||
static already_AddRefed<nsBaseCommandController> CreateHTMLEditorController();
|
||||
static already_AddRefed<nsBaseCommandController>
|
||||
CreateHTMLEditorDocStateController();
|
||||
|
||||
protected:
|
||||
virtual ~nsBaseCommandController();
|
||||
|
@ -42,7 +44,7 @@ class nsBaseCommandController : public nsIController,
|
|||
nsISupports* mCommandContextRawPtr;
|
||||
|
||||
// Our reference to the command manager
|
||||
nsCOMPtr<nsIControllerCommandTable> mCommandTable;
|
||||
RefPtr<nsControllerCommandTable> mCommandTable;
|
||||
};
|
||||
|
||||
#endif /* nsBaseCommandController_h_ */
|
||||
|
|
|
@ -11,8 +11,6 @@
|
|||
#include "mozilla/EditorController.h"
|
||||
#include "mozilla/HTMLEditorController.h"
|
||||
|
||||
nsresult NS_NewControllerCommandTable(nsIControllerCommandTable** aResult);
|
||||
|
||||
// this value is used to size the hash table. Just a sensible upper bound
|
||||
#define NUM_COMMANDS_LENGTH 32
|
||||
|
||||
|
@ -186,11 +184,11 @@ nsControllerCommandTable::GetSupportedCommands(uint32_t* aCount,
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
typedef nsresult (*CommandTableRegistrar)(nsIControllerCommandTable*);
|
||||
typedef nsresult (*CommandTableRegistrar)(nsControllerCommandTable*);
|
||||
|
||||
static already_AddRefed<nsIControllerCommandTable>
|
||||
static already_AddRefed<nsControllerCommandTable>
|
||||
CreateCommandTableWithCommands(CommandTableRegistrar aRegistrar) {
|
||||
nsCOMPtr<nsIControllerCommandTable> commandTable =
|
||||
RefPtr<nsControllerCommandTable> commandTable =
|
||||
new nsControllerCommandTable();
|
||||
|
||||
nsresult rv = aRegistrar(commandTable);
|
||||
|
@ -203,48 +201,36 @@ CreateCommandTableWithCommands(CommandTableRegistrar aRegistrar) {
|
|||
}
|
||||
|
||||
// static
|
||||
already_AddRefed<nsIControllerCommandTable>
|
||||
already_AddRefed<nsControllerCommandTable>
|
||||
nsControllerCommandTable::CreateEditorCommandTable() {
|
||||
return CreateCommandTableWithCommands(
|
||||
EditorController::RegisterEditorCommands);
|
||||
}
|
||||
|
||||
// static
|
||||
already_AddRefed<nsIControllerCommandTable>
|
||||
already_AddRefed<nsControllerCommandTable>
|
||||
nsControllerCommandTable::CreateEditingCommandTable() {
|
||||
return CreateCommandTableWithCommands(
|
||||
EditorController::RegisterEditingCommands);
|
||||
}
|
||||
|
||||
// static
|
||||
already_AddRefed<nsIControllerCommandTable>
|
||||
already_AddRefed<nsControllerCommandTable>
|
||||
nsControllerCommandTable::CreateHTMLEditorCommandTable() {
|
||||
return CreateCommandTableWithCommands(
|
||||
HTMLEditorController::RegisterHTMLEditorCommands);
|
||||
}
|
||||
|
||||
// static
|
||||
already_AddRefed<nsIControllerCommandTable>
|
||||
already_AddRefed<nsControllerCommandTable>
|
||||
nsControllerCommandTable::CreateHTMLEditorDocStateCommandTable() {
|
||||
return CreateCommandTableWithCommands(
|
||||
HTMLEditorController::RegisterEditorDocStateCommands);
|
||||
}
|
||||
|
||||
// static
|
||||
already_AddRefed<nsIControllerCommandTable>
|
||||
already_AddRefed<nsControllerCommandTable>
|
||||
nsControllerCommandTable::CreateWindowCommandTable() {
|
||||
return CreateCommandTableWithCommands(
|
||||
nsWindowCommandRegistration::RegisterWindowCommands);
|
||||
}
|
||||
|
||||
nsresult NS_NewControllerCommandTable(nsIControllerCommandTable** aResult) {
|
||||
MOZ_ASSERT(aResult != nullptr, "null ptr");
|
||||
if (!aResult) {
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
}
|
||||
|
||||
nsControllerCommandTable* newCommandTable = new nsControllerCommandTable();
|
||||
NS_ADDREF(newCommandTable);
|
||||
*aResult = newCommandTable;
|
||||
return NS_OK;
|
||||
}
|
||||
|
|
|
@ -21,14 +21,13 @@ class nsControllerCommandTable final : public nsIControllerCommandTable,
|
|||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSICONTROLLERCOMMANDTABLE
|
||||
|
||||
static already_AddRefed<nsIControllerCommandTable> CreateEditorCommandTable();
|
||||
static already_AddRefed<nsIControllerCommandTable>
|
||||
CreateEditingCommandTable();
|
||||
static already_AddRefed<nsIControllerCommandTable>
|
||||
static already_AddRefed<nsControllerCommandTable> CreateEditorCommandTable();
|
||||
static already_AddRefed<nsControllerCommandTable> CreateEditingCommandTable();
|
||||
static already_AddRefed<nsControllerCommandTable>
|
||||
CreateHTMLEditorCommandTable();
|
||||
static already_AddRefed<nsIControllerCommandTable>
|
||||
static already_AddRefed<nsControllerCommandTable>
|
||||
CreateHTMLEditorDocStateCommandTable();
|
||||
static already_AddRefed<nsIControllerCommandTable> CreateWindowCommandTable();
|
||||
static already_AddRefed<nsControllerCommandTable> CreateWindowCommandTable();
|
||||
|
||||
protected:
|
||||
virtual ~nsControllerCommandTable();
|
||||
|
@ -40,4 +39,14 @@ class nsControllerCommandTable final : public nsIControllerCommandTable,
|
|||
bool mMutable;
|
||||
};
|
||||
|
||||
nsControllerCommandTable*
|
||||
nsIControllerCommandTable::AsControllerCommandTable() {
|
||||
return static_cast<nsControllerCommandTable*>(this);
|
||||
}
|
||||
|
||||
const nsControllerCommandTable*
|
||||
nsIControllerCommandTable::AsControllerCommandTable() const {
|
||||
return static_cast<const nsControllerCommandTable*>(this);
|
||||
}
|
||||
|
||||
#endif // nsControllerCommandTable_h_
|
||||
|
|
|
@ -6,6 +6,10 @@
|
|||
#include "nsIControllerCommand.idl"
|
||||
#include "nsICommandParams.idl"
|
||||
|
||||
%{C++
|
||||
class nsControllerCommandTable;
|
||||
%}
|
||||
|
||||
/**
|
||||
* nsIControllerCommandTable
|
||||
*
|
||||
|
@ -18,7 +22,7 @@
|
|||
*
|
||||
*/
|
||||
|
||||
[scriptable, uuid(c847f90e-b8f3-49db-a4df-8867831f2800)]
|
||||
[scriptable, builtinclass, uuid(c847f90e-b8f3-49db-a4df-8867831f2800)]
|
||||
interface nsIControllerCommandTable : nsISupports
|
||||
{
|
||||
/**
|
||||
|
@ -87,5 +91,14 @@ interface nsIControllerCommandTable : nsISupports
|
|||
|
||||
void getSupportedCommands(out unsigned long count,
|
||||
[array, size_is(count), retval] out string commands);
|
||||
|
||||
%{C++
|
||||
/**
|
||||
* In order to avoid circular dependency issues, these methods are defined
|
||||
* in nsControllerCommandTable.h. Consumers need to #include that header.
|
||||
*/
|
||||
inline nsControllerCommandTable* AsControllerCommandTable();
|
||||
inline const nsControllerCommandTable* AsControllerCommandTable() const;
|
||||
%}
|
||||
};
|
||||
|
||||
|
|
|
@ -28,7 +28,7 @@
|
|||
|
||||
#include "HTMLFormSubmissionConstants.h"
|
||||
#include "mozilla/Telemetry.h"
|
||||
#include "nsIControllers.h"
|
||||
#include "nsBaseCommandController.h"
|
||||
#include "nsIStringBundle.h"
|
||||
#include "nsFocusManager.h"
|
||||
#include "nsColorControlFrame.h"
|
||||
|
@ -109,7 +109,6 @@
|
|||
#include "nsIColorPicker.h"
|
||||
#include "nsIStringEnumerator.h"
|
||||
#include "HTMLSplitOnSpacesTokenizer.h"
|
||||
#include "nsIController.h"
|
||||
#include "nsIMIMEInfo.h"
|
||||
#include "nsFrameSelection.h"
|
||||
#include "nsBaseCommandController.h"
|
||||
|
@ -5448,22 +5447,22 @@ nsIControllers* HTMLInputElement::GetControllers(ErrorResult& aRv) {
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIController> controller =
|
||||
RefPtr<nsBaseCommandController> commandController =
|
||||
nsBaseCommandController::CreateEditorController();
|
||||
if (!controller) {
|
||||
if (!commandController) {
|
||||
aRv.Throw(NS_ERROR_FAILURE);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
mControllers->AppendController(controller);
|
||||
mControllers->AppendController(commandController);
|
||||
|
||||
controller = nsBaseCommandController::CreateEditingController();
|
||||
if (!controller) {
|
||||
commandController = nsBaseCommandController::CreateEditingController();
|
||||
if (!commandController) {
|
||||
aRv.Throw(NS_ERROR_FAILURE);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
mControllers->AppendController(controller);
|
||||
mControllers->AppendController(commandController);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
#include "mozilla/MappedDeclarations.h"
|
||||
#include "mozilla/MouseEvents.h"
|
||||
#include "nsAttrValueInlines.h"
|
||||
#include "nsBaseCommandController.h"
|
||||
#include "nsContentCID.h"
|
||||
#include "nsContentCreatorFunctions.h"
|
||||
#include "nsError.h"
|
||||
|
@ -39,7 +40,6 @@
|
|||
#include "nsReadableUtils.h"
|
||||
#include "nsStyleConsts.h"
|
||||
#include "nsTextEditorState.h"
|
||||
#include "nsIController.h"
|
||||
#include "nsBaseCommandController.h"
|
||||
#include "nsXULControllers.h"
|
||||
|
||||
|
@ -558,22 +558,22 @@ nsIControllers* HTMLTextAreaElement::GetControllers(ErrorResult& aError) {
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIController> controller =
|
||||
RefPtr<nsBaseCommandController> commandController =
|
||||
nsBaseCommandController::CreateEditorController();
|
||||
if (!controller) {
|
||||
if (!commandController) {
|
||||
aError.Throw(NS_ERROR_FAILURE);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
mControllers->AppendController(controller);
|
||||
mControllers->AppendController(commandController);
|
||||
|
||||
controller = nsBaseCommandController::CreateEditingController();
|
||||
if (!controller) {
|
||||
commandController = nsBaseCommandController::CreateEditingController();
|
||||
if (!commandController) {
|
||||
aError.Throw(NS_ERROR_FAILURE);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
mControllers->AppendController(controller);
|
||||
mControllers->AppendController(commandController);
|
||||
}
|
||||
|
||||
return mControllers;
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
#include "mozilla/mozalloc.h" // for operator new
|
||||
#include "mozilla/PresShell.h" // for PresShell
|
||||
#include "nsAString.h"
|
||||
#include "nsBaseCommandController.h" // for nsBaseCommandController
|
||||
#include "nsCommandManager.h" // for nsCommandManager
|
||||
#include "nsComponentManagerUtils.h" // for do_CreateInstance
|
||||
#include "nsContentUtils.h"
|
||||
|
@ -21,8 +22,6 @@
|
|||
#include "nsError.h" // for NS_ERROR_FAILURE, NS_OK, etc
|
||||
#include "nsIChannel.h" // for nsIChannel
|
||||
#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 "nsHTMLDocument.h" // for nsHTMLDocument
|
||||
|
@ -1071,17 +1070,17 @@ nsresult nsEditingSession::SetupEditorCommandController(
|
|||
// We only have to create each singleton controller once
|
||||
// We know this has happened once we have a controllerId value
|
||||
if (!*aControllerId) {
|
||||
nsCOMPtr<nsIController> controller = aControllerCreatorFn();
|
||||
NS_ENSURE_TRUE(controller, NS_ERROR_FAILURE);
|
||||
RefPtr<nsBaseCommandController> commandController = aControllerCreatorFn();
|
||||
NS_ENSURE_TRUE(commandController, NS_ERROR_FAILURE);
|
||||
|
||||
// We must insert at head of the list to be sure our
|
||||
// controller is found before other implementations
|
||||
// (e.g., not-implemented versions by browser)
|
||||
rv = controllers->InsertControllerAt(0, controller);
|
||||
rv = controllers->InsertControllerAt(0, commandController);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
// Remember the ID for the controller
|
||||
rv = controllers->GetControllerId(controller, aControllerId);
|
||||
rv = controllers->GetControllerId(commandController, aControllerId);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
}
|
||||
|
||||
|
|
|
@ -23,6 +23,7 @@
|
|||
#include "nsString.h" // for nsCString
|
||||
|
||||
class mozIDOMWindowProxy;
|
||||
class nsBaseCommandController;
|
||||
class nsIDOMWindow;
|
||||
class nsISupports;
|
||||
class nsITimer;
|
||||
|
@ -55,7 +56,7 @@ class nsEditingSession final : public nsIEditingSession,
|
|||
protected:
|
||||
virtual ~nsEditingSession();
|
||||
|
||||
typedef already_AddRefed<nsIController> (*ControllerCreatorFn)();
|
||||
typedef already_AddRefed<nsBaseCommandController> (*ControllerCreatorFn)();
|
||||
|
||||
nsresult SetupEditorCommandController(
|
||||
ControllerCreatorFn aControllerCreatorFn, mozIDOMWindowProxy* aWindow,
|
||||
|
|
|
@ -7,9 +7,9 @@
|
|||
|
||||
#include "EditorCommands.h"
|
||||
#include "mozilla/mozalloc.h"
|
||||
#include "nsControllerCommandTable.h"
|
||||
#include "nsDebug.h"
|
||||
#include "nsError.h"
|
||||
#include "nsIControllerCommandTable.h"
|
||||
|
||||
class nsIControllerCommand;
|
||||
|
||||
|
@ -41,7 +41,7 @@ namespace mozilla {
|
|||
|
||||
// static
|
||||
nsresult EditorController::RegisterEditingCommands(
|
||||
nsIControllerCommandTable* aCommandTable) {
|
||||
nsControllerCommandTable* aCommandTable) {
|
||||
// now register all our commands
|
||||
// These are commands that will be used in text widgets, and in composer
|
||||
|
||||
|
@ -79,7 +79,7 @@ nsresult EditorController::RegisterEditingCommands(
|
|||
|
||||
// static
|
||||
nsresult EditorController::RegisterEditorCommands(
|
||||
nsIControllerCommandTable* aCommandTable) {
|
||||
nsControllerCommandTable* aCommandTable) {
|
||||
// These are commands that will be used in text widgets only.
|
||||
|
||||
NS_REGISTER_FIRST_COMMAND(SelectionMoveCommands, "cmd_scrollTop");
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
|
||||
#include "nscore.h"
|
||||
|
||||
class nsIControllerCommandTable;
|
||||
class nsControllerCommandTable;
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
|
@ -19,9 +19,9 @@ namespace mozilla {
|
|||
class EditorController final {
|
||||
public:
|
||||
static nsresult RegisterEditorCommands(
|
||||
nsIControllerCommandTable* aCommandTable);
|
||||
nsControllerCommandTable* aCommandTable);
|
||||
static nsresult RegisterEditingCommands(
|
||||
nsIControllerCommandTable* aCommandTable);
|
||||
nsControllerCommandTable* aCommandTable);
|
||||
};
|
||||
|
||||
} // namespace mozilla
|
||||
|
|
|
@ -7,53 +7,51 @@
|
|||
|
||||
#include "mozilla/HTMLEditorCommands.h" // for StyleUpdatingCommand, etc
|
||||
#include "mozilla/mozalloc.h" // for operator new
|
||||
#include "nsControllerCommandTable.h" // for nsControllerCommandTable
|
||||
#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( \
|
||||
aCommandTable->RegisterCommand( \
|
||||
_cmdName, static_cast<nsIControllerCommand *>(theCmd)); \
|
||||
}
|
||||
|
||||
#define NS_REGISTER_FIRST_COMMAND(_cmdClass, _cmdName) \
|
||||
{ \
|
||||
_cmdClass *theCmd = new _cmdClass(); \
|
||||
inCommandTable->RegisterCommand( \
|
||||
aCommandTable->RegisterCommand( \
|
||||
_cmdName, static_cast<nsIControllerCommand *>(theCmd));
|
||||
|
||||
#define NS_REGISTER_NEXT_COMMAND(_cmdClass, _cmdName) \
|
||||
inCommandTable->RegisterCommand( \
|
||||
_cmdName, static_cast<nsIControllerCommand *>(theCmd));
|
||||
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)); \
|
||||
}
|
||||
|
||||
#define NS_REGISTER_STYLE_COMMAND(_cmdClass, _cmdName, _styleTag) \
|
||||
{ \
|
||||
_cmdClass *theCmd = new _cmdClass(_styleTag); \
|
||||
inCommandTable->RegisterCommand( \
|
||||
aCommandTable->RegisterCommand( \
|
||||
_cmdName, static_cast<nsIControllerCommand *>(theCmd)); \
|
||||
}
|
||||
|
||||
#define NS_REGISTER_TAG_COMMAND(_cmdClass, _cmdName, _tagName) \
|
||||
{ \
|
||||
_cmdClass *theCmd = new _cmdClass(_tagName); \
|
||||
inCommandTable->RegisterCommand( \
|
||||
aCommandTable->RegisterCommand( \
|
||||
_cmdName, static_cast<nsIControllerCommand *>(theCmd)); \
|
||||
}
|
||||
|
||||
// static
|
||||
nsresult HTMLEditorController::RegisterEditorDocStateCommands(
|
||||
nsIControllerCommandTable *inCommandTable) {
|
||||
nsControllerCommandTable *aCommandTable) {
|
||||
// observer commands for document state
|
||||
NS_REGISTER_FIRST_COMMAND(DocumentStateCommand, "obs_documentCreated")
|
||||
NS_REGISTER_NEXT_COMMAND(DocumentStateCommand, "obs_documentWillBeDestroyed")
|
||||
|
@ -77,7 +75,7 @@ nsresult HTMLEditorController::RegisterEditorDocStateCommands(
|
|||
|
||||
// static
|
||||
nsresult HTMLEditorController::RegisterHTMLEditorCommands(
|
||||
nsIControllerCommandTable *inCommandTable) {
|
||||
nsControllerCommandTable *aCommandTable) {
|
||||
// Edit menu
|
||||
NS_REGISTER_ONE_COMMAND(PasteNoFormattingCommand, "cmd_pasteNoFormatting");
|
||||
|
||||
|
|
|
@ -8,16 +8,16 @@
|
|||
|
||||
#include "nscore.h" // for nsresult
|
||||
|
||||
class nsIControllerCommandTable;
|
||||
class nsControllerCommandTable;
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
class HTMLEditorController final {
|
||||
public:
|
||||
static nsresult RegisterEditorDocStateCommands(
|
||||
nsIControllerCommandTable* inCommandTable);
|
||||
nsControllerCommandTable* aCommandTable);
|
||||
static nsresult RegisterHTMLEditorCommands(
|
||||
nsIControllerCommandTable* inCommandTable);
|
||||
nsControllerCommandTable* aCommandTable);
|
||||
};
|
||||
|
||||
} // namespace mozilla
|
||||
|
|
Загрузка…
Ссылка в новой задаче