diff --git a/extensions/spellcheck/src/mozInlineSpellChecker.cpp b/extensions/spellcheck/src/mozInlineSpellChecker.cpp index f5cd6e7f3f2c..ace8b2ea5677 100644 --- a/extensions/spellcheck/src/mozInlineSpellChecker.cpp +++ b/extensions/spellcheck/src/mozInlineSpellChecker.cpp @@ -44,6 +44,7 @@ #include "mozilla/Logging.h" #include "mozilla/RangeUtils.h" #include "mozilla/Services.h" +#include "mozilla/StaticPrefs_extensions.h" #include "mozilla/TextEvents.h" #include "mozilla/dom/Event.h" #include "mozilla/dom/KeyboardEvent.h" @@ -93,8 +94,6 @@ using namespace mozilla::ipc; static mozilla::LazyLogModule sInlineSpellCheckerLog("InlineSpellChecker"); -static const char kMaxSpellCheckSelectionSize[] = - "extensions.spellcheck.inline.max-misspellings"; static const PRTime kMaxSpellCheckTimeInUsec = INLINESPELL_CHECK_TIMEOUT * PR_USEC_PER_MSEC; @@ -564,18 +563,14 @@ mozInlineSpellChecker::SpellCheckingState mozInlineSpellChecker::mozInlineSpellChecker() : mNumWordsInSpellSelection(0), - mMaxNumWordsInSpellSelection(250), + mMaxNumWordsInSpellSelection( + StaticPrefs::extensions_spellcheck_inline_max_misspellings()), mNumPendingSpellChecks(0), mNumPendingUpdateCurrentDictionary(0), mDisabledAsyncToken(0), mNeedsCheckAfterNavigation(false), mFullSpellCheckScheduled(false), - mIsListeningToEditSubActions(false) { - nsCOMPtr prefs = do_GetService(NS_PREFSERVICE_CONTRACTID); - if (prefs) - prefs->GetIntPref(kMaxSpellCheckSelectionSize, - &mMaxNumWordsInSpellSelection); -} + mIsListeningToEditSubActions(false) {} mozInlineSpellChecker::~mozInlineSpellChecker() {} diff --git a/extensions/spellcheck/src/mozInlineSpellChecker.h b/extensions/spellcheck/src/mozInlineSpellChecker.h index dae736d5147d..e3d0648cd5dd 100644 --- a/extensions/spellcheck/src/mozInlineSpellChecker.h +++ b/extensions/spellcheck/src/mozInlineSpellChecker.h @@ -165,7 +165,7 @@ class mozInlineSpellChecker final : public nsIInlineSpellChecker, RefPtr mPendingSpellCheck; int32_t mNumWordsInSpellSelection; - int32_t mMaxNumWordsInSpellSelection; + const int32_t mMaxNumWordsInSpellSelection; // we need to keep track of the current text position in the document // so we can spell check the old word when the user clicks around the diff --git a/modules/libpref/init/StaticPrefList.yaml b/modules/libpref/init/StaticPrefList.yaml index fed7b657e1d7..b4e4ce1db527 100644 --- a/modules/libpref/init/StaticPrefList.yaml +++ b/modules/libpref/init/StaticPrefList.yaml @@ -4299,6 +4299,12 @@ value: false mirror: once +# Maximum number of misspelled words in a text. +- name: extensions.spellcheck.inline.max-misspellings + type: int32_t + value: 500 + mirror: always + # Whether the extensions can register a service worker on its own. # NOTE: WebExtensions Framework ability to register a background service worker # is not controlled by this pref, only the extension code ability to use diff --git a/modules/libpref/init/all.js b/modules/libpref/init/all.js index b952099c7613..20d57ff2cb3d 100644 --- a/modules/libpref/init/all.js +++ b/modules/libpref/init/all.js @@ -1004,11 +1004,6 @@ pref("print.print_edge_bottom", 0); pref("print.print_in_color", true); #endif -// Pref used by the spellchecker extension to control the -// maximum number of misspelled words that will be underlined -// in a document. -pref("extensions.spellcheck.inline.max-misspellings", 500); - // Whether inserting
when typing Enter in a block element which can // contain
. If false, inserts
instead. pref("editor.use_div_for_default_newlines", true);