Bug 1489790 - Part 3: Remove the XPCOM component registration for NS_EDITORCOMMANDTABLE_CID; r=baku

Differential Revision: https://phabricator.services.mozilla.com/D5358
This commit is contained in:
Ehsan Akhgari 2018-09-07 09:42:11 -04:00
parent 2740ea8b35
commit bded29559c
4 changed files with 25 additions and 26 deletions

View File

@ -33,4 +33,8 @@ UNIFIED_SOURCES += [
'nsControllerCommandTable.cpp',
]
LOCAL_INCLUDES += [
'/dom/base',
]
FINAL_LIBRARY = 'xul'

View File

@ -8,6 +8,7 @@
#include "nsIControllerCommand.h"
#include "nsControllerCommandTable.h"
#include "nsGlobalWindowCommands.h"
#include "mozilla/EditorController.h"
#include "mozilla/HTMLEditorController.h"
nsresult NS_NewControllerCommandTable(nsIControllerCommandTable** aResult);
@ -196,6 +197,22 @@ nsControllerCommandTable::GetSupportedCommands(uint32_t* aCount,
return NS_OK;
}
// static
already_AddRefed<nsIControllerCommandTable>
nsControllerCommandTable::CreateEditorCommandTable()
{
nsCOMPtr<nsIControllerCommandTable> commandTable =
new nsControllerCommandTable();
nsresult rv = EditorController::RegisterEditorCommands(commandTable);
if (NS_FAILED(rv)) return nullptr;
// we don't know here whether we're being created as an instance,
// or a service, so we can't become immutable
return commandTable.forget();
}
// static
already_AddRefed<nsIControllerCommandTable>
nsControllerCommandTable::CreateHTMLEditorCommandTable()

View File

@ -23,6 +23,7 @@ public:
NS_DECL_ISUPPORTS
NS_DECL_NSICONTROLLERCOMMANDTABLE
static already_AddRefed<nsIControllerCommandTable> CreateEditorCommandTable();
static already_AddRefed<nsIControllerCommandTable> CreateHTMLEditorCommandTable();
static already_AddRefed<nsIControllerCommandTable> CreateHTMLEditorDocStateCommandTable();
static already_AddRefed<nsIControllerCommandTable> CreateWindowCommandTable();

View File

@ -156,10 +156,6 @@ using mozilla::dom::power::PowerManagerService;
using mozilla::dom::quota::QuotaManagerService;
using mozilla::gmp::GeckoMediaPluginService;
#define NS_EDITORCOMMANDTABLE_CID \
{ 0x4f5e62b8, 0xd659, 0x4156, \
{ 0x84, 0xfc, 0x2f, 0x60, 0x99, 0x40, 0x03, 0x69 } }
#define NS_EDITINGCOMMANDTABLE_CID \
{ 0xcb38a746, 0xbeb8, 0x43f3, \
{ 0x94, 0x29, 0x77, 0x96, 0xe1, 0xa9, 0x3f, 0xb4 } }
@ -501,7 +497,6 @@ 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_EDITORCOMMANDTABLE_CID);
NS_DEFINE_NAMED_CID(NS_EDITINGCOMMANDTABLE_CID);
NS_DEFINE_NAMED_CID(NS_GEOLOCATION_CID);
NS_DEFINE_NAMED_CID(NS_WEBSOCKETEVENT_SERVICE_CID);
@ -579,13 +574,13 @@ EditorControllerConstructor(nsISupports* aOuter, REFNSIID aIID, void** aResult)
{
nsCOMPtr<nsIController> controller = new nsBaseCommandController();
nsresult rv;
nsCOMPtr<nsIControllerCommandTable> editorCommandTable = do_GetService(kNS_EDITORCOMMANDTABLE_CID, &rv);
if (NS_FAILED(rv)) return rv;
nsCOMPtr<nsIControllerCommandTable> editorCommandTable =
nsControllerCommandTable::CreateEditorCommandTable();
// this guy is a singleton, so make it immutable
editorCommandTable->MakeImmutable();
nsresult rv;
nsCOMPtr<nsIControllerContext> controllerContext = do_QueryInterface(controller, &rv);
if (NS_FAILED(rv)) return rv;
@ -619,23 +614,6 @@ nsEditingControllerConstructor(nsISupports *aOuter, REFNSIID aIID,
return controller->QueryInterface(aIID, aResult);
}
// Constructor for a command-table pre-filled with editor commands
static nsresult
nsEditorCommandTableConstructor(nsISupports *aOuter, REFNSIID aIID,
void **aResult)
{
nsCOMPtr<nsIControllerCommandTable> commandTable =
new nsControllerCommandTable();
nsresult 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);
}
// Constructor for a command-table pre-filled with editing commands
static nsresult
nsEditingCommandTableConstructor(nsISupports *aOuter, REFNSIID aIID,
@ -704,7 +682,6 @@ static const mozilla::Module::CIDEntry kLayoutCIDs[] = {
{ &kWORKERDEBUGGERMANAGER_CID, true, nullptr, WorkerDebuggerManagerConstructor },
{ &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_GEOLOCATION_CID, false, nullptr, GeolocationConstructor },
{ &kNS_WEBSOCKETEVENT_SERVICE_CID, false, nullptr, WebSocketEventServiceConstructor },