Bug 1430982 - part 9: Create accessors for each member of mozSpellChecker, EditorSpellCheck, mozInlineSpellChecker r?m_kato
mozSpellChecker stores TextServicesDocument, EditorSpellCheck stores
mozSpellChecker and mozInlineSpellChecker stores EditorSpellCheck.
So, they should have accessors for their member. Then, EditorBase can
access all of them.
MozReview-Commit-ID: Igphm8nRqve
--- a/editor/composer/EditorSpellCheck.cpp
+++ b/editor/composer/EditorSpellCheck.cpp
@@ -316,16 +316,22 @@ EditorSpellCheck::EditorSpellCheck()
EditorSpellCheck::~EditorSpellCheck()
{
// Make sure we blow the spellchecker away, just in
// case it hasn't been destroyed already.
mSpellChecker = nullptr;
}
+mozSpellChecker*
+EditorSpellCheck::GetSpellChecker()
+{
+ return mSpellChecker;
+}
+
// The problem is that if the spell checker does not exist, we can not tell
// which dictionaries are installed. This function works around the problem,
// allowing callers to ask if we can spell check without actually doing so (and
// enabling or disabling UI as necessary). This just creates a spellcheck
// object if needed and asks it for the dictionary list.
NS_IMETHODIMP
EditorSpellCheck::CanSpellCheck(bool* aCanSpellCheck)
{
--- a/editor/composer/EditorSpellCheck.h
+++ b/editor/composer/EditorSpellCheck.h
@@ -45,16 +45,18 @@ public:
EditorSpellCheck();
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
NS_DECL_CYCLE_COLLECTION_CLASS(EditorSpellCheck)
/* Declare all methods in the nsIEditorSpellCheck interface */
NS_DECL_NSIEDITORSPELLCHECK
+ mozSpellChecker* GetSpellChecker();
+
protected:
virtual ~EditorSpellCheck();
RefPtr<mozSpellChecker> mSpellChecker;
nsCOMPtr<nsITextServicesFilter> mTxtSrvFilter;
nsCOMPtr<nsIEditor> mEditor;
nsTArray<nsString> mSuggestedWordList;
--- a/extensions/spellcheck/src/mozInlineSpellChecker.cpp
+++ b/extensions/spellcheck/src/mozInlineSpellChecker.cpp
@@ -561,16 +561,22 @@ mozInlineSpellChecker::mozInlineSpellChe
prefs->GetIntPref(kMaxSpellCheckSelectionSize, &mMaxNumWordsInSpellSelection);
mMaxMisspellingsPerCheck = mMaxNumWordsInSpellSelection * 3 / 4;
}
mozInlineSpellChecker::~mozInlineSpellChecker()
{
}
+EditorSpellCheck*
+mozInlineSpellChecker::GetEditorSpellCheck()
+{
+ return mSpellCheck ? mSpellCheck : mPendingSpellCheck;
+}
+
NS_IMETHODIMP
mozInlineSpellChecker::GetSpellChecker(nsIEditorSpellCheck **aSpellCheck)
{
*aSpellCheck = mSpellCheck;
NS_IF_ADDREF(*aSpellCheck);
return NS_OK;
}
--- a/extensions/spellcheck/src/mozInlineSpellChecker.h
+++ b/extensions/spellcheck/src/mozInlineSpellChecker.h
@@ -179,16 +179,18 @@ private:
public:
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
NS_DECL_NSIEDITACTIONLISTENER
NS_DECL_NSIINLINESPELLCHECKER
NS_DECL_NSIDOMEVENTLISTENER
NS_DECL_CYCLE_COLLECTION_CLASS_AMBIGUOUS(mozInlineSpellChecker, nsIDOMEventListener)
+ mozilla::EditorSpellCheck* GetEditorSpellCheck();
+
// returns true if there are any spell checking dictionaries available
static bool CanEnableInlineSpellChecking();
// update the cached value whenever the list of available dictionaries changes
static void UpdateCanEnableInlineSpellChecking();
nsresult OnBlur(nsIDOMEvent* aEvent);
nsresult OnMouseClick(nsIDOMEvent* aMouseEvent);
nsresult OnKeyPress(nsIDOMEvent* aKeyEvent);
--- a/extensions/spellcheck/src/mozSpellChecker.cpp
+++ b/extensions/spellcheck/src/mozSpellChecker.cpp
@@ -69,16 +69,22 @@ mozSpellChecker::Init()
contentChild->SendPRemoteSpellcheckEngineConstructor(mEngine);
} else {
mPersonalDictionary = do_GetService("@mozilla.org/spellchecker/personaldictionary;1");
}
return NS_OK;
}
+TextServicesDocument*
+mozSpellChecker::GetTextServicesDocument()
+{
+ return mTextServicesDocument;
+}
+
NS_IMETHODIMP
mozSpellChecker::SetDocument(TextServicesDocument* aTextServicesDocument,
bool aFromStartofDoc)
{
mTextServicesDocument = aTextServicesDocument;
mFromStart = aFromStartofDoc;
return NS_OK;
}
--- a/extensions/spellcheck/src/mozSpellChecker.h
+++ b/extensions/spellcheck/src/mozSpellChecker.h
@@ -48,16 +48,18 @@ public:
NS_IMETHOD SetCurrentDictionary(const nsAString &aDictionary) override;
NS_IMETHOD_(RefPtr<mozilla::GenericPromise>)
SetCurrentDictionaryFromList(const nsTArray<nsString>& aList) override;
void DeleteRemoteEngine() {
mEngine = nullptr;
}
+ mozilla::TextServicesDocument* GetTextServicesDocument();
+
protected:
virtual ~mozSpellChecker();
nsCOMPtr<mozISpellI18NUtil> mConverter;
RefPtr<mozilla::TextServicesDocument> mTextServicesDocument;
nsCOMPtr<mozIPersonalDictionary> mPersonalDictionary;
nsCOMPtr<mozISpellCheckingEngine> mSpellCheckingEngine;