Bug 1687227 [wpt PR 27213] - [TablesNG] Fix background painting for COLGROUP/COL...
[gecko.git] / editor / spellchecker / EditorSpellCheck.h
blob0188d7ddfe51ab14d424d40e22727ea0c8b2d700
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6 #ifndef mozilla_EditorSpellCheck_h
7 #define mozilla_EditorSpellCheck_h
9 #include "mozilla/mozSpellChecker.h" // for mozilla::CheckWordPromise
10 #include "nsCOMPtr.h" // for nsCOMPtr
11 #include "nsCycleCollectionParticipant.h"
12 #include "nsIEditorSpellCheck.h" // for NS_DECL_NSIEDITORSPELLCHECK, etc
13 #include "nsISupportsImpl.h"
14 #include "nsString.h" // for nsString
15 #include "nsTArray.h" // for nsTArray
16 #include "nscore.h" // for nsresult
18 class mozSpellChecker;
19 class nsIEditor;
21 namespace mozilla {
23 class DictionaryFetcher;
24 class EditorBase;
26 enum dictCompare {
27 DICT_NORMAL_COMPARE,
28 DICT_COMPARE_CASE_INSENSITIVE,
29 DICT_COMPARE_DASHMATCH
32 class EditorSpellCheck final : public nsIEditorSpellCheck {
33 friend class DictionaryFetcher;
35 public:
36 EditorSpellCheck();
38 NS_DECL_CYCLE_COLLECTING_ISUPPORTS
39 NS_DECL_CYCLE_COLLECTION_CLASS(EditorSpellCheck)
41 /* Declare all methods in the nsIEditorSpellCheck interface */
42 NS_DECL_NSIEDITORSPELLCHECK
44 mozSpellChecker* GetSpellChecker();
46 /**
47 * Like CheckCurrentWord, checks the word you give it, returning true via
48 * promise if it's misspelled.
49 * This is faster than CheckCurrentWord because it does not compute
50 * any suggestions.
52 * Watch out: this does not clear any suggestions left over from previous
53 * calls to CheckCurrentWord, so there may be suggestions, but they will be
54 * invalid.
56 RefPtr<mozilla::CheckWordPromise> CheckCurrentWordsNoSuggest(
57 const nsTArray<nsString>& aSuggestedWords);
59 protected:
60 virtual ~EditorSpellCheck();
62 RefPtr<mozSpellChecker> mSpellChecker;
63 RefPtr<EditorBase> mEditor;
65 nsTArray<nsString> mSuggestedWordList;
67 // these are the words in the current personal dictionary,
68 // GetPersonalDictionary must be called to load them.
69 nsTArray<nsString> mDictionaryList;
71 nsCString mPreferredLang;
73 uint32_t mTxtSrvFilterType;
74 int32_t mSuggestedWordIndex;
75 int32_t mDictionaryIndex;
76 uint32_t mDictionaryFetcherGroup;
78 bool mUpdateDictionaryRunning;
80 nsresult DeleteSuggestedWordList();
82 void BuildDictionaryList(const nsACString& aDictName,
83 const nsTArray<nsCString>& aDictList,
84 enum dictCompare aCompareType,
85 nsTArray<nsCString>& aOutList);
87 nsresult DictionaryFetched(DictionaryFetcher* aFetchState);
89 void SetFallbackDictionary(DictionaryFetcher* aFetcher);
91 public:
92 void BeginUpdateDictionary() { mUpdateDictionaryRunning = true; }
93 void EndUpdateDictionary() { mUpdateDictionaryRunning = false; }
96 } // namespace mozilla
98 #endif // mozilla_EditorSpellCheck_h