Bug 1489790 - Part 10: Remove the XPCOM component registration for @mozilla.org/editor/editordocstatecontroller;1; r=baku

Differential Revision: https://phabricator.services.mozilla.com/D5365
This commit is contained in:
Ehsan Akhgari 2018-09-08 12:06:48 -04:00
Родитель f3142db64e
Коммит 751c62d2ae
5 изменённых файлов: 23 добавлений и 60 удалений

Просмотреть файл

@ -265,3 +265,23 @@ nsBaseCommandController::CreateHTMLEditorController()
return controller.forget();
}
already_AddRefed<nsIController>
nsBaseCommandController::CreateHTMLEditorDocStateController()
{
nsCOMPtr<nsIController> controller = new nsBaseCommandController();
nsCOMPtr<nsIControllerCommandTable> composerCommandTable =
nsControllerCommandTable::CreateHTMLEditorDocStateCommandTable();
// this guy is a singleton, so make it immutable
composerCommandTable->MakeImmutable();
nsresult rv;
nsCOMPtr<nsIControllerContext> controllerContext = do_QueryInterface(controller, &rv);
NS_ENSURE_SUCCESS(rv, nullptr);
rv = controllerContext->Init(composerCommandTable);
NS_ENSURE_SUCCESS(rv, nullptr);
return controller.forget();
}

Просмотреть файл

@ -34,6 +34,7 @@ public:
static already_AddRefed<nsIController> CreateEditorController();
static already_AddRefed<nsIController> CreateEditingController();
static already_AddRefed<nsIController> CreateHTMLEditorController();
static already_AddRefed<nsIController> CreateHTMLEditorDocStateController();
protected:
virtual ~nsBaseCommandController();

Просмотреть файл

@ -34,64 +34,14 @@ class nsISupports;
NS_GENERIC_FACTORY_CONSTRUCTOR(EditorSpellCheck)
// Constructor for a controller set up with a command table specified
// by the CID passed in. This function uses do_GetService to get the
// command table, so that every controller shares a single command
// table, for space-efficiency.
//
// The only reason to go via the service manager for the command table
// is that it holds onto the singleton for us, avoiding static variables here.
static nsresult
CreateControllerWithSingletonCommandTable(
already_AddRefed<nsIControllerCommandTable> aComposerCommandTable,
nsIController **aResult)
{
nsCOMPtr<nsIController> controller = new nsBaseCommandController();
nsCOMPtr<nsIControllerCommandTable> composerCommandTable(aComposerCommandTable);
// this guy is a singleton, so make it immutable
composerCommandTable->MakeImmutable();
nsresult rv;
nsCOMPtr<nsIControllerContext> controllerContext = do_QueryInterface(controller, &rv);
NS_ENSURE_SUCCESS(rv, rv);
rv = controllerContext->Init(composerCommandTable);
NS_ENSURE_SUCCESS(rv, rv);
*aResult = controller;
NS_ADDREF(*aResult);
return NS_OK;
}
// Here we make an instance of the controller that holds doc state commands.
// We set it up with a singleton command table.
static nsresult
nsHTMLEditorDocStateControllerConstructor(nsISupports *aOuter, REFNSIID aIID,
void **aResult)
{
nsCOMPtr<nsIController> controller;
nsresult rv = CreateControllerWithSingletonCommandTable(
nsControllerCommandTable::CreateHTMLEditorDocStateCommandTable(),
getter_AddRefs(controller));
NS_ENSURE_SUCCESS(rv, rv);
return controller->QueryInterface(aIID, aResult);
}
NS_DEFINE_NAMED_CID(NS_EDITORDOCSTATECONTROLLER_CID);
NS_DEFINE_NAMED_CID(NS_EDITORSPELLCHECK_CID);
static const mozilla::Module::CIDEntry kComposerCIDs[] = {
{ &kNS_EDITORDOCSTATECONTROLLER_CID, false, nullptr, nsHTMLEditorDocStateControllerConstructor },
{ &kNS_EDITORSPELLCHECK_CID, false, nullptr, EditorSpellCheckConstructor },
{ nullptr }
};
static const mozilla::Module::ContractIDEntry kComposerContracts[] = {
{ "@mozilla.org/editor/editordocstatecontroller;1", &kNS_EDITORDOCSTATECONTROLLER_CID },
{ "@mozilla.org/editor/editorspellchecker;1", &kNS_EDITORSPELLCHECK_CID },
{ nullptr }
};

Просмотреть файл

@ -165,7 +165,7 @@ nsEditingSession::MakeWindowEditable(mozIDOMWindowProxy* aWindow,
// The second is a controller to monitor doc state,
// such as creation and "dirty flag"
rv = SetupEditorCommandController("@mozilla.org/editor/editordocstatecontroller;1",
rv = SetupEditorCommandController(nsBaseCommandController::CreateHTMLEditorDocStateController,
aWindow,
static_cast<nsIEditingSession*>(this),
&mDocStateControllerId);
@ -1379,7 +1379,7 @@ nsEditingSession::ReattachToWindow(mozIDOMWindowProxy* aWindow)
&mBaseCommandControllerId);
NS_ENSURE_SUCCESS(rv, rv);
rv = SetupEditorCommandController("@mozilla.org/editor/editordocstatecontroller;1",
rv = SetupEditorCommandController(nsBaseCommandController::CreateHTMLEditorDocStateController,
aWindow,
static_cast<nsIEditingSession*>(this),
&mDocStateControllerId);

Просмотреть файл

@ -11,14 +11,6 @@
class nsIControllerCommandTable;
// The plaintext editor controller is used for basic text editing and html editing
// commands in composer
// The refCon that gets passed to its commands is initially nsIEditingSession,
// 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 } }
namespace mozilla {
class HTMLEditorController final