Bug 1700051: part 17) Add `mozInlineSpellChecker::GetDisabledAsyncToken()`. r=smaug

Allows unfriending some class from `mozInlineSpellChecker`.

Depends on D109881

Differential Revision: https://phabricator.services.mozilla.com/D109882
This commit is contained in:
Mirko Brodesser 2021-03-29 08:03:10 +00:00
Родитель 2eaf6f3625
Коммит 9fbe592b0f
2 изменённых файлов: 8 добавлений и 5 удалений

Просмотреть файл

@ -488,7 +488,8 @@ class mozInlineSpellResume : public Runnable {
NS_IMETHOD Run() override {
// Discard the resumption if the spell checker was disabled after the
// resumption was scheduled.
if (mDisabledAsyncToken == mStatus->mSpellChecker->mDisabledAsyncToken) {
if (mDisabledAsyncToken ==
mStatus->mSpellChecker->GetDisabledAsyncToken()) {
mStatus->mSpellChecker->ResumeCheck(std::move(mStatus));
}
return NS_OK;
@ -1481,7 +1482,7 @@ void mozInlineSpellChecker::CheckCurrentWordsNoSuggest(
GetMainThreadSerialEventTarget(), __func__,
[self, spellCheckerSelection, ranges = std::move(aRanges),
token](const nsTArray<bool>& aIsMisspelled) {
if (token != self->mDisabledAsyncToken) {
if (token != self->GetDisabledAsyncToken()) {
// This result is never used
return;
}
@ -1515,7 +1516,7 @@ void mozInlineSpellChecker::CheckCurrentWordsNoSuggest(
return;
}
if (token != self->mDisabledAsyncToken) {
if (token != self->GetDisabledAsyncToken()) {
// This result is never used
return;
}
@ -1848,7 +1849,7 @@ class UpdateCurrentDictionaryCallback final
NS_IMETHOD EditorSpellCheckDone() override {
// Ignore this callback if SetEnableRealTimeSpell(false) was called after
// the UpdateCurrentDictionary call that triggered it.
return mSpellChecker->mDisabledAsyncToken > mDisabledAsyncToken
return mSpellChecker->GetDisabledAsyncToken() > mDisabledAsyncToken
? NS_OK
: mSpellChecker->CurrentDictionaryUpdated();
}

Просмотреть файл

@ -138,7 +138,6 @@ class mozInlineSpellChecker final : public nsIInlineSpellChecker,
friend class InitEditorSpellCheckCallback;
friend class UpdateCurrentDictionaryCallback;
friend class AutoChangeNumPendingSpellChecks;
friend class mozInlineSpellResume;
// Access with CanEnableInlineSpellChecking
enum SpellCheckingState {
@ -200,6 +199,9 @@ class mozInlineSpellChecker final : public nsIInlineSpellChecker,
mozilla::EditorSpellCheck* GetEditorSpellCheck();
// See `mDisabledAsyncToken`.
uint32_t GetDisabledAsyncToken() const { return mDisabledAsyncToken; }
// returns true if there are any spell checking dictionaries available
static bool CanEnableInlineSpellChecking();
// update the cached value whenever the list of available dictionaries changes