Skip to content

Commit

Permalink
Bug 1489790 - Part 4: Remove the XPCOM component registration for NS_…
Browse files Browse the repository at this point in the history
…EDITINGCOMMANDTABLE_CID; r=baku

Differential Revision: https://phabricator.services.mozilla.com/D5359
  • Loading branch information
ehsan committed Sep 11, 2018
1 parent cfc9220 commit c481ce9
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 26 deletions.
16 changes: 16 additions & 0 deletions dom/commandhandler/nsControllerCommandTable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,22 @@ nsControllerCommandTable::CreateEditorCommandTable()
return commandTable.forget();
}

// static
already_AddRefed<nsIControllerCommandTable>
nsControllerCommandTable::CreateEditingCommandTable()
{
nsCOMPtr<nsIControllerCommandTable> commandTable =
new nsControllerCommandTable();

nsresult rv = EditorController::RegisterEditingCommands(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()
Expand Down
1 change: 1 addition & 0 deletions dom/commandhandler/nsControllerCommandTable.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ class nsControllerCommandTable final
NS_DECL_NSICONTROLLERCOMMANDTABLE

static already_AddRefed<nsIControllerCommandTable> CreateEditorCommandTable();
static already_AddRefed<nsIControllerCommandTable> CreateEditingCommandTable();
static already_AddRefed<nsIControllerCommandTable> CreateHTMLEditorCommandTable();
static already_AddRefed<nsIControllerCommandTable> CreateHTMLEditorDocStateCommandTable();
static already_AddRefed<nsIControllerCommandTable> CreateWindowCommandTable();
Expand Down
29 changes: 3 additions & 26 deletions layout/build/nsLayoutModule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -156,10 +156,6 @@ using mozilla::dom::power::PowerManagerService;
using mozilla::dom::quota::QuotaManagerService;
using mozilla::gmp::GeckoMediaPluginService;

#define NS_EDITINGCOMMANDTABLE_CID \
{ 0xcb38a746, 0xbeb8, 0x43f3, \
{ 0x94, 0x29, 0x77, 0x96, 0xe1, 0xa9, 0x3f, 0xb4 } }

#define NS_HAPTICFEEDBACK_CID \
{ 0x1f15dbc8, 0xbfaa, 0x45de, \
{ 0x8a, 0x46, 0x08, 0xe2, 0xe2, 0x63, 0x26, 0xb0 } }
Expand Down Expand Up @@ -497,7 +493,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_EDITINGCOMMANDTABLE_CID);
NS_DEFINE_NAMED_CID(NS_GEOLOCATION_CID);
NS_DEFINE_NAMED_CID(NS_WEBSOCKETEVENT_SERVICE_CID);
NS_DEFINE_NAMED_CID(NS_FOCUSMANAGER_CID);
Expand Down Expand Up @@ -598,13 +593,13 @@ nsEditingControllerConstructor(nsISupports *aOuter, REFNSIID aIID,
{
nsCOMPtr<nsIController> controller = new nsBaseCommandController();

nsresult rv;
nsCOMPtr<nsIControllerCommandTable> editingCommandTable = do_GetService(kNS_EDITINGCOMMANDTABLE_CID, &rv);
if (NS_FAILED(rv)) return rv;
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;

Expand All @@ -614,23 +609,6 @@ nsEditingControllerConstructor(nsISupports *aOuter, REFNSIID aIID,
return controller->QueryInterface(aIID, aResult);
}

// Constructor for a command-table pre-filled with editing commands
static nsresult
nsEditingCommandTableConstructor(nsISupports *aOuter, REFNSIID aIID,
void **aResult)
{
nsCOMPtr<nsIControllerCommandTable> commandTable =
new nsControllerCommandTable();

nsresult 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);
}

static const mozilla::Module::CIDEntry kLayoutCIDs[] = {
XPCONNECT_CIDENTRIES
#ifdef DEBUG
Expand Down Expand Up @@ -682,7 +660,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_EDITINGCOMMANDTABLE_CID, false, nullptr, nsEditingCommandTableConstructor },
{ &kNS_GEOLOCATION_CID, false, nullptr, GeolocationConstructor },
{ &kNS_WEBSOCKETEVENT_SERVICE_CID, false, nullptr, WebSocketEventServiceConstructor },
{ &kNS_FOCUSMANAGER_CID, false, nullptr, CreateFocusManager },
Expand Down

0 comments on commit c481ce9

Please sign in to comment.