Bug 1687263: part 4) Defer and in some cases avoid removing spellchecking-ranges...
commitf271c866cfe7da6307190191f544ed091733cc85
authorMirko Brodesser <mbrodesser@mozilla.com>
Fri, 28 May 2021 07:56:13 +0000 (28 07:56 +0000)
committerMirko Brodesser <mbrodesser@mozilla.com>
Fri, 28 May 2021 07:56:13 +0000 (28 07:56 +0000)
tree6cb473e4189b7ff194cd9da5162f76188e5ac1fa
parent81d2b2a2d988e4b7f66d86b549d6ced2743241b1
Bug 1687263: part 4) Defer and in some cases avoid removing spellchecking-ranges. r=smaug

Removing ranges is expensive. This reduces flickering of the spelling
mistakes and prevents 100% CPU usage of 1 core on slower machines.

The essence of this patch is, that when text doesn't change, all
existing spellchecking ranges are reused.

Before this patch, removing ranges was done as part of the time slice in
`mozInlineSpellChecker::SpellCheckSlice`. That is, slow removals of
ranges contributed to the amount of words to be spellchecked
asynchronously.
Therefore, the amount of words to be spellchecked in one chunk could
increase from the minimum, `INLINESPELL_MINIMUM_WORDS_BEFORE_TIMEOUT` to
the maxium `INLINESPELL_MAXIMUM_CHUNKED_WORDS_PER_TASK`.
Consequently, the asynchronous checking might take longer. If that turns
out to be problematic, reducing
`INLINESPELL_MAXIMUM_CHUNKED_WORDS_PER_TASK` could be a fix.

Differential Revision: https://phabricator.services.mozilla.com/D116096
extensions/spellcheck/src/mozInlineSpellChecker.cpp
extensions/spellcheck/src/mozInlineSpellChecker.h