mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-11 12:25:53 +00:00
Bug 1489787 - Part 2: Remove the XPCOM component registration for nsComposeTxtSrvFilter; r=masayuki
Differential Revision: https://phabricator.services.mozilla.com/D5354
This commit is contained in:
parent
d212ff2809
commit
72c28b2f81
@ -11,7 +11,6 @@
|
||||
#include "nsCOMPtr.h" // for nsCOMPtr, getter_AddRefs, etc
|
||||
#include "nsBaseCommandController.h" // for nsBaseCommandController
|
||||
#include "nsComponentManagerUtils.h" // for do_CreateInstance
|
||||
#include "nsComposeTxtSrvFilter.h" // for nsComposeTxtSrvFilter, etc
|
||||
#include "nsDebug.h" // for NS_ENSURE_SUCCESS
|
||||
#include "nsError.h" // for NS_ERROR_NO_AGGREGATION, etc
|
||||
#include "nsIController.h" // for nsIController
|
||||
@ -46,48 +45,6 @@ static NS_DEFINE_CID(kHTMLEditorDocStateCommandTableCID, NS_HTMLEDITOR_DOCSTATE_
|
||||
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(EditorSpellCheck)
|
||||
|
||||
// There are no macros that enable us to have 2 constructors
|
||||
// for the same object
|
||||
//
|
||||
// Here we are creating the same object with two different contract IDs
|
||||
// and then initializing it different.
|
||||
// Basically, we need to tell the filter whether it is doing mail or not
|
||||
static nsresult
|
||||
nsComposeTxtSrvFilterConstructor(nsISupports *aOuter, REFNSIID aIID,
|
||||
void **aResult, bool aIsForMail)
|
||||
{
|
||||
*aResult = nullptr;
|
||||
if (aOuter) {
|
||||
return NS_ERROR_NO_AGGREGATION;
|
||||
}
|
||||
nsComposeTxtSrvFilter * inst = new nsComposeTxtSrvFilter();
|
||||
if (!inst) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
NS_ADDREF(inst);
|
||||
inst->Init(aIsForMail);
|
||||
nsresult rv = inst->QueryInterface(aIID, aResult);
|
||||
NS_RELEASE(inst);
|
||||
return rv;
|
||||
}
|
||||
|
||||
static nsresult
|
||||
nsComposeTxtSrvFilterConstructorForComposer(nsISupports *aOuter,
|
||||
REFNSIID aIID,
|
||||
void **aResult)
|
||||
{
|
||||
return nsComposeTxtSrvFilterConstructor(aOuter, aIID, aResult, false);
|
||||
}
|
||||
|
||||
static nsresult
|
||||
nsComposeTxtSrvFilterConstructorForMail(nsISupports *aOuter,
|
||||
REFNSIID aIID,
|
||||
void **aResult)
|
||||
{
|
||||
return nsComposeTxtSrvFilterConstructor(aOuter, aIID, aResult, true);
|
||||
}
|
||||
|
||||
|
||||
// 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
|
||||
@ -189,9 +146,6 @@ NS_DEFINE_NAMED_CID(NS_EDITORDOCSTATECONTROLLER_CID);
|
||||
NS_DEFINE_NAMED_CID(NS_HTMLEDITOR_COMMANDTABLE_CID);
|
||||
NS_DEFINE_NAMED_CID(NS_HTMLEDITOR_DOCSTATE_COMMANDTABLE_CID);
|
||||
NS_DEFINE_NAMED_CID(NS_EDITORSPELLCHECK_CID);
|
||||
NS_DEFINE_NAMED_CID(NS_COMPOSERTXTSRVFILTER_CID);
|
||||
NS_DEFINE_NAMED_CID(NS_COMPOSERTXTSRVFILTERMAIL_CID);
|
||||
|
||||
|
||||
static const mozilla::Module::CIDEntry kComposerCIDs[] = {
|
||||
{ &kNS_HTMLEDITORCONTROLLER_CID, false, nullptr, nsHTMLEditorControllerConstructor },
|
||||
@ -199,8 +153,6 @@ static const mozilla::Module::CIDEntry kComposerCIDs[] = {
|
||||
{ &kNS_HTMLEDITOR_COMMANDTABLE_CID, false, nullptr, nsHTMLEditorCommandTableConstructor },
|
||||
{ &kNS_HTMLEDITOR_DOCSTATE_COMMANDTABLE_CID, false, nullptr, nsHTMLEditorDocStateCommandTableConstructor },
|
||||
{ &kNS_EDITORSPELLCHECK_CID, false, nullptr, EditorSpellCheckConstructor },
|
||||
{ &kNS_COMPOSERTXTSRVFILTER_CID, false, nullptr, nsComposeTxtSrvFilterConstructorForComposer },
|
||||
{ &kNS_COMPOSERTXTSRVFILTERMAIL_CID, false, nullptr, nsComposeTxtSrvFilterConstructorForMail },
|
||||
{ nullptr }
|
||||
};
|
||||
|
||||
@ -208,8 +160,6 @@ static const mozilla::Module::ContractIDEntry kComposerContracts[] = {
|
||||
{ "@mozilla.org/editor/htmleditorcontroller;1", &kNS_HTMLEDITORCONTROLLER_CID },
|
||||
{ "@mozilla.org/editor/editordocstatecontroller;1", &kNS_EDITORDOCSTATECONTROLLER_CID },
|
||||
{ "@mozilla.org/editor/editorspellchecker;1", &kNS_EDITORSPELLCHECK_CID },
|
||||
{ COMPOSER_TXTSRVFILTER_CONTRACTID, &kNS_COMPOSERTXTSRVFILTER_CID },
|
||||
{ COMPOSER_TXTSRVFILTERMAIL_CONTRACTID, &kNS_COMPOSERTXTSRVFILTERMAIL_CID },
|
||||
{ nullptr }
|
||||
};
|
||||
|
||||
|
@ -345,24 +345,20 @@ nsresult
|
||||
TextServicesDocument::SetFilterType(uint32_t aFilterType)
|
||||
{
|
||||
// Hang on to the filter so we can set it into the filtered iterator.
|
||||
const char* contractID = nullptr;
|
||||
switch (aFilterType) {
|
||||
case nsIEditorSpellCheck::FILTERTYPE_NORMAL:
|
||||
contractID = "@mozilla.org/editor/txtsrvfilter;1";
|
||||
mTxtSvcFilter = nsComposeTxtSrvFilter::CreateNormalFilter();
|
||||
break;
|
||||
case nsIEditorSpellCheck::FILTERTYPE_MAIL:
|
||||
contractID = "@mozilla.org/editor/txtsrvfiltermail;1";
|
||||
mTxtSvcFilter = nsComposeTxtSrvFilter::CreateMailFilter();
|
||||
break;
|
||||
default:
|
||||
// Treat an invalid value as resetting out filter.
|
||||
mTxtSvcFilter = nullptr;
|
||||
return NS_OK;
|
||||
break;
|
||||
}
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsISupports> supports = do_CreateInstance(contractID, &rv);
|
||||
mTxtSvcFilter = reinterpret_cast<nsComposeTxtSrvFilter*>(supports.get());
|
||||
|
||||
return rv;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
|
@ -72,3 +72,12 @@ nsComposeTxtSrvFilter::Skip(nsINode* aNode) const
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
// static
|
||||
already_AddRefed<nsComposeTxtSrvFilter>
|
||||
nsComposeTxtSrvFilter::CreateHelper(bool aIsForMail)
|
||||
{
|
||||
RefPtr<nsComposeTxtSrvFilter> filter = new nsComposeTxtSrvFilter();
|
||||
filter->Init(aIsForMail);
|
||||
return filter.forget();
|
||||
}
|
||||
|
@ -7,6 +7,7 @@
|
||||
#define nsComposeTxtSrvFilter_h__
|
||||
|
||||
#include "nsISupportsImpl.h" // for NS_DECL_ISUPPORTS
|
||||
#include "mozilla/AlreadyAddRefed.h"
|
||||
|
||||
/**
|
||||
* This class implements a filter interface, that enables
|
||||
@ -18,13 +19,17 @@
|
||||
class nsComposeTxtSrvFilter final : public nsISupports
|
||||
{
|
||||
public:
|
||||
nsComposeTxtSrvFilter();
|
||||
|
||||
// nsISupports interface...
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
// Helper - Intializer
|
||||
void Init(bool aIsForMail) { mIsForMail = aIsForMail; }
|
||||
static already_AddRefed<nsComposeTxtSrvFilter> CreateNormalFilter()
|
||||
{
|
||||
return CreateHelper(false);
|
||||
}
|
||||
static already_AddRefed<nsComposeTxtSrvFilter> CreateMailFilter()
|
||||
{
|
||||
return CreateHelper(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Indicates whether the content node should be skipped by the iterator
|
||||
@ -33,25 +38,15 @@ public:
|
||||
bool Skip(nsINode* aNode) const;
|
||||
|
||||
private:
|
||||
nsComposeTxtSrvFilter();
|
||||
~nsComposeTxtSrvFilter() {}
|
||||
|
||||
// Helper - Intializer
|
||||
void Init(bool aIsForMail) { mIsForMail = aIsForMail; }
|
||||
|
||||
static already_AddRefed<nsComposeTxtSrvFilter> CreateHelper(bool aIsForMail);
|
||||
|
||||
bool mIsForMail;
|
||||
};
|
||||
|
||||
#define NS_COMPOSERTXTSRVFILTER_CID \
|
||||
{/* {171E72DB-0F8A-412a-8461-E4C927A3A2AC}*/ \
|
||||
0x171e72db, 0xf8a, 0x412a, \
|
||||
{ 0x84, 0x61, 0xe4, 0xc9, 0x27, 0xa3, 0xa2, 0xac} }
|
||||
|
||||
#define NS_COMPOSERTXTSRVFILTERMAIL_CID \
|
||||
{/* {7FBD2146-5FF4-4674-B069-A7BBCE66E773}*/ \
|
||||
0x7fbd2146, 0x5ff4, 0x4674, \
|
||||
{ 0xb0, 0x69, 0xa7, 0xbb, 0xce, 0x66, 0xe7, 0x73} }
|
||||
|
||||
// Generic for the editor
|
||||
#define COMPOSER_TXTSRVFILTER_CONTRACTID "@mozilla.org/editor/txtsrvfilter;1"
|
||||
|
||||
// This is the same but includes "cite" typed blocked quotes
|
||||
#define COMPOSER_TXTSRVFILTERMAIL_CONTRACTID "@mozilla.org/editor/txtsrvfiltermail;1"
|
||||
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user