Bug 1421510 - Part 2. Use nsComposeTxtSrvFilter directly. r?masayuki
nsITextServicesFilter is builtin class, so we can store nsComposeTxtSrvFilter
instead of nsITextServicesFilter.
MozReview-Commit-ID: ErZQwWC0Wjx
--- a/editor/spellchecker/EditorSpellCheck.cpp
+++ b/editor/spellchecker/EditorSpellCheck.cpp
@@ -13,16 +13,17 @@
#include "mozilla/dom/Selection.h"
#include "mozilla/intl/LocaleService.h" // for retrieving app locale
#include "mozilla/mozalloc.h" // for operator delete, etc
#include "mozilla/mozSpellChecker.h" // for mozSpellChecker
#include "mozilla/Preferences.h" // for Preferences
#include "mozilla/TextServicesDocument.h" // for TextServicesDocument
#include "nsAString.h" // for nsAString::IsEmpty, etc
#include "nsComponentManagerUtils.h" // for do_CreateInstance
+#include "nsComposeTxtSrvFilter.h"
#include "nsDebug.h" // for NS_ENSURE_TRUE, etc
#include "nsDependentSubstring.h" // for Substring
#include "nsError.h" // for NS_ERROR_NOT_INITIALIZED, etc
#include "nsIContent.h" // for nsIContent
#include "nsIContentPrefService2.h" // for nsIContentPrefService2, etc
#include "nsIDocument.h" // for nsIDocument
#include "nsIEditor.h" // for nsIEditor
#include "nsILoadContext.h"
@@ -689,17 +690,17 @@ EditorSpellCheck::UninitSpellChecker()
mSpellChecker = nullptr;
return NS_OK;
}
NS_IMETHODIMP
EditorSpellCheck::SetFilter(nsITextServicesFilter *aFilter)
{
- mTxtSrvFilter = aFilter;
+ mTxtSrvFilter = reinterpret_cast<nsComposeTxtSrvFilter*>(aFilter);
return NS_OK;
}
nsresult
EditorSpellCheck::DeleteSuggestedWordList()
{
mSuggestedWordList.Clear();
mSuggestedWordIndex = 0;
--- a/editor/spellchecker/EditorSpellCheck.h
+++ b/editor/spellchecker/EditorSpellCheck.h
@@ -11,16 +11,17 @@
#include "nsCycleCollectionParticipant.h"
#include "nsIEditorSpellCheck.h" // for NS_DECL_NSIEDITORSPELLCHECK, etc
#include "nsISupportsImpl.h"
#include "nsString.h" // for nsString
#include "nsTArray.h" // for nsTArray
#include "nscore.h" // for nsresult
class mozSpellChecker;
+class nsComposeTxtSrvFilter;
class nsIEditor;
class nsISpellChecker;
class nsITextServicesFilter;
#define NS_EDITORSPELLCHECK_CID \
{ /* {75656ad9-bd13-4c5d-939a-ec6351eea0cc} */ \
0x75656ad9, 0xbd13, 0x4c5d, \
{ 0x93, 0x9a, 0xec, 0x63, 0x51, 0xee, 0xa0, 0xcc }\
@@ -52,17 +53,17 @@ public:
NS_DECL_NSIEDITORSPELLCHECK
mozSpellChecker* GetSpellChecker();
protected:
virtual ~EditorSpellCheck();
RefPtr<mozSpellChecker> mSpellChecker;
- nsCOMPtr<nsITextServicesFilter> mTxtSrvFilter;
+ RefPtr<nsComposeTxtSrvFilter> mTxtSrvFilter;
RefPtr<EditorBase> mEditor;
nsTArray<nsString> mSuggestedWordList;
// these are the words in the current personal dictionary,
// GetPersonalDictionary must be called to load them.
nsTArray<nsString> mDictionaryList;
--- a/editor/spellchecker/TextServicesDocument.cpp
+++ b/editor/spellchecker/TextServicesDocument.cpp
@@ -7,31 +7,31 @@
#include "mozilla/Assertions.h" // for MOZ_ASSERT, etc
#include "mozilla/dom/Element.h"
#include "mozilla/dom/Selection.h"
#include "mozilla/mozalloc.h" // for operator new, etc
#include "mozilla/TextEditor.h" // for TextEditor
#include "nsAString.h" // for nsAString::Length, etc
#include "nsContentUtils.h" // for nsContentUtils
+#include "nsComposeTxtSrvFilter.h"
#include "nsDebug.h" // for NS_ENSURE_TRUE, etc
#include "nsDependentSubstring.h" // for Substring
#include "nsError.h" // for NS_OK, NS_ERROR_FAILURE, etc
#include "nsFilteredContentIterator.h" // for nsFilteredContentIterator
#include "nsGenericHTMLElement.h" // for nsGenericHTMLElement
#include "nsIContent.h" // for nsIContent, etc
#include "nsIContentIterator.h" // for nsIContentIterator
#include "nsID.h" // for NS_GET_IID
#include "nsIEditor.h" // for nsIEditor, etc
#include "nsINode.h" // for nsINode
#include "nsIPlaintextEditor.h" // for nsIPlaintextEditor
#include "nsISelectionController.h" // for nsISelectionController, etc
#include "nsISupportsBase.h" // for nsISupports
#include "nsISupportsUtils.h" // for NS_IF_ADDREF, NS_ADDREF, etc
-#include "nsITextServicesFilter.h" // for nsITextServicesFilter
#include "mozilla/intl/WordBreaker.h" // for WordRange, WordBreaker
#include "nsRange.h" // for nsRange
#include "nsString.h" // for nsString, nsAutoString
#include "nscore.h" // for nsresult, NS_IMETHODIMP, etc
#define LOCK_DOC(doc)
#define UNLOCK_DOC(doc)
@@ -354,17 +354,17 @@ TextServicesDocument::ExpandRangeToWordB
rngEndNode, rngEndOffset);
if (NS_WARN_IF(NS_FAILED(rv))) {
return rv;
}
return NS_OK;
}
nsresult
-TextServicesDocument::SetFilter(nsITextServicesFilter* aFilter)
+TextServicesDocument::SetFilter(nsComposeTxtSrvFilter* aFilter)
{
// Hang on to the filter so we can set it into the filtered iterator.
mTxtSvcFilter = aFilter;
return NS_OK;
}
nsresult
--- a/editor/spellchecker/TextServicesDocument.h
+++ b/editor/spellchecker/TextServicesDocument.h
@@ -9,22 +9,22 @@
#include "nsCOMPtr.h"
#include "nsCycleCollectionParticipant.h"
#include "nsIEditActionListener.h"
#include "nsISupportsImpl.h"
#include "nsStringFwd.h"
#include "nsTArray.h"
#include "nscore.h"
+class nsComposeTxtSrvFilter;
class nsIContent;
class nsIContentIterator;
class nsIEditor;
class nsINode;
class nsISelectionController;
-class nsITextServicesFilter;
class nsRange;
namespace mozilla {
class OffsetEntry;
class TextEditor;
namespace dom {
@@ -53,17 +53,17 @@ private:
nsCOMPtr<nsIDocument> mDocument;
nsCOMPtr<nsISelectionController> mSelCon;
RefPtr<TextEditor> mTextEditor;
nsCOMPtr<nsIContentIterator> mIterator;
nsCOMPtr<nsIContent> mPrevTextBlock;
nsCOMPtr<nsIContent> mNextTextBlock;
nsTArray<OffsetEntry*> mOffsetTable;
RefPtr<nsRange> mExtent;
- nsCOMPtr<nsITextServicesFilter> mTxtSvcFilter;
+ RefPtr<nsComposeTxtSrvFilter> mTxtSvcFilter;
int32_t mSelStartIndex;
int32_t mSelStartOffset;
int32_t mSelEndIndex;
int32_t mSelEndOffset;
IteratorStatus mIteratorStatus;
@@ -105,17 +105,17 @@ public:
nsresult ExpandRangeToWordBoundaries(nsRange* aRange);
/**
* Sets the filter to be used while iterating over content.
*
* @param aFilter The filter to be used while iterating over
* content.
*/
- nsresult SetFilter(nsITextServicesFilter* aFilter);
+ nsresult SetFilter(nsComposeTxtSrvFilter* aFilter);
/**
* Returns the text in the current text block.
*
* @param aStr [OUT] This will contain the text.
*/
nsresult GetCurrentTextBlock(nsString* aStr);
--- a/editor/spellchecker/nsFilteredContentIterator.cpp
+++ b/editor/spellchecker/nsFilteredContentIterator.cpp
@@ -1,33 +1,33 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "mozilla/mozalloc.h"
#include "mozilla/Move.h"
#include "nsComponentManagerUtils.h"
+#include "nsComposeTxtSrvFilter.h"
#include "nsContentUtils.h"
#include "nsDebug.h"
#include "nsError.h"
#include "nsFilteredContentIterator.h"
#include "nsAtom.h"
#include "nsIContent.h"
#include "nsIContentIterator.h"
#include "nsINode.h"
#include "nsISupportsBase.h"
#include "nsISupportsUtils.h"
-#include "nsITextServicesFilter.h"
#include "nsRange.h"
using namespace mozilla;
//------------------------------------------------------------
-nsFilteredContentIterator::nsFilteredContentIterator(nsITextServicesFilter* aFilter) :
+nsFilteredContentIterator::nsFilteredContentIterator(nsComposeTxtSrvFilter* aFilter) :
mFilter(aFilter),
mDidSkip(false),
mIsOutOfRange(false),
mDirection(eDirNotSet)
{
mIterator = do_CreateInstance("@mozilla.org/content/post-content-iterator;1");
mPreIterator = do_CreateInstance("@mozilla.org/content/pre-content-iterator;1");
}
--- a/editor/spellchecker/nsFilteredContentIterator.h
+++ b/editor/spellchecker/nsFilteredContentIterator.h
@@ -8,29 +8,29 @@
#include "nsCOMPtr.h"
#include "nsCycleCollectionParticipant.h"
#include "nsIContentIterator.h"
#include "nsISupportsImpl.h"
#include "nscore.h"
class nsAtom;
+class nsComposeTxtSrvFilter;
class nsINode;
-class nsITextServicesFilter;
class nsRange;
class nsFilteredContentIterator final : public nsIContentIterator
{
public:
// nsISupports interface...
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
NS_DECL_CYCLE_COLLECTION_CLASS(nsFilteredContentIterator)
- explicit nsFilteredContentIterator(nsITextServicesFilter* aFilter);
+ explicit nsFilteredContentIterator(nsComposeTxtSrvFilter* aFilter);
/* nsIContentIterator */
virtual nsresult Init(nsINode* aRoot) override;
virtual nsresult Init(nsRange* aRange) override;
virtual nsresult Init(nsINode* aStartContainer, uint32_t aStartOffset,
nsINode* aEndContainer, uint32_t aEndOffset) override;
virtual nsresult Init(const mozilla::RawRangeBoundary& aStart,
const mozilla::RawRangeBoundary& aEnd) override;
@@ -72,16 +72,16 @@ protected:
nsCOMPtr<nsIContentIterator> mPreIterator;
RefPtr<nsAtom> mBlockQuoteAtom;
RefPtr<nsAtom> mScriptAtom;
RefPtr<nsAtom> mTextAreaAtom;
RefPtr<nsAtom> mSelectAreaAtom;
RefPtr<nsAtom> mMapAtom;
- nsCOMPtr<nsITextServicesFilter> mFilter;
+ RefPtr<nsComposeTxtSrvFilter> mFilter;
RefPtr<nsRange> mRange;
bool mDidSkip;
bool mIsOutOfRange;
eDirectionType mDirection;
};
#endif