| Index: third_party/WebKit/Source/core/editing/spellcheck/HotModeSpellCheckRequester.cpp
|
| diff --git a/third_party/WebKit/Source/core/editing/spellcheck/HotModeSpellCheckRequester.cpp b/third_party/WebKit/Source/core/editing/spellcheck/HotModeSpellCheckRequester.cpp
|
| index b8a8f1422264577e148bd5c5c3f0265958cda2f2..801413ff3fa5aa1b658fd4d5754213303e3a1a0e 100644
|
| --- a/third_party/WebKit/Source/core/editing/spellcheck/HotModeSpellCheckRequester.cpp
|
| +++ b/third_party/WebKit/Source/core/editing/spellcheck/HotModeSpellCheckRequester.cpp
|
| @@ -19,6 +19,7 @@ namespace blink {
|
|
|
| namespace {
|
|
|
| +const int kHotModeCheckAllThreshold = 128;
|
| const int kHotModeChunkSize = 1024;
|
|
|
| EphemeralRange AdjacentWordIfExists(const Position& pos) {
|
| @@ -65,12 +66,25 @@ bool IsUnderActiveEditing(const Element& editable, const Position& position) {
|
|
|
| EphemeralRange CalculateHotModeCheckingRange(const Element& editable,
|
| const Position& position) {
|
| + // Check everything in |editable| if its total length is short.
|
| const EphemeralRange& full_range = EphemeralRange::RangeOfContents(editable);
|
| const int full_length = TextIterator::RangeLength(full_range.StartPosition(),
|
| full_range.EndPosition());
|
| - if (full_length <= kHotModeChunkSize)
|
| + // TODO(xiaochengh): There is no need to check if |full_length <= 2|, since
|
| + // we don't consider two characters as misspelled. However, a lot of layout
|
| + // tests depend on "zz" as misspelled, which should be changed.
|
| + if (full_length <= kHotModeCheckAllThreshold)
|
| return full_range;
|
|
|
| + // Otherwise, if |position| is in a short paragraph, check the paragraph.
|
| + const EphemeralRange& paragraph_range =
|
| + ExpandToParagraphBoundary(EphemeralRange(position));
|
| + const int paragraph_length = TextIterator::RangeLength(
|
| + paragraph_range.StartPosition(), paragraph_range.EndPosition());
|
| + if (paragraph_length <= kHotModeChunkSize)
|
| + return paragraph_range;
|
| +
|
| + // Otherwise, check a chunk of text centered at |position|.
|
| TextIteratorBehavior behavior = TextIteratorBehavior::Builder()
|
| .SetEmitsObjectReplacementCharacter(true)
|
| .Build();
|
|
|