Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(117)

Unified Diff: third_party/WebKit/Source/core/editing/spellcheck/HotModeSpellCheckRequester.cpp

Issue 2867393003: [Idle time spell checker] Add paragraph-level heuristic to hot mode requester (Closed)
Patch Set: Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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();
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698