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

Unified Diff: Source/core/editing/Editor.cpp

Issue 22859062: Chunk up the text to spell check also when the text is pasted. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Check if merging checks are needed at all Created 7 years, 4 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
Index: Source/core/editing/Editor.cpp
diff --git a/Source/core/editing/Editor.cpp b/Source/core/editing/Editor.cpp
index b487c8d243b83d1b95f90431143bcee82be08428..2dfe15c1380edf42118974096822f6b1d136930a 100644
--- a/Source/core/editing/Editor.cpp
+++ b/Source/core/editing/Editor.cpp
@@ -419,9 +419,9 @@ void Editor::replaceSelectionWithFragment(PassRefPtr<DocumentFragment> fragment,
Node* nodeToCheck = m_frame->selection()->rootEditableElement();
if (!nodeToCheck)
return;
-
RefPtr<Range> rangeToCheck = Range::create(m_frame->document(), firstPositionInNode(nodeToCheck), lastPositionInNode(nodeToCheck));
- m_spellCheckRequester->requestCheckingFor(SpellCheckRequest::create(resolveTextCheckingTypeMask(TextCheckingTypeSpelling | TextCheckingTypeGrammar), TextCheckingProcessBatch, rangeToCheck, rangeToCheck));
+ TextCheckingParagraph textToCheck(rangeToCheck, rangeToCheck);
+ chunkAndMarkAllMisspellingsAndBadGrammar(resolveTextCheckingTypeMask(TextCheckingTypeSpelling | TextCheckingTypeGrammar), textToCheck, true);
tony 2013/08/29 22:44:45 Please use "bool asynchronous = true" and pass asy
}
void Editor::replaceSelectionWithText(const String& text, bool selectReplacement, bool smartReplace)
@@ -1509,6 +1509,13 @@ void Editor::markAllMisspellingsAndBadGrammarInRanges(TextCheckingTypeMask textC
Range* rangeToCheck = shouldMarkGrammar ? grammarRange : spellingRange;
TextCheckingParagraph fullParagraphToCheck(rangeToCheck);
+
+ bool asynchronous = m_frame && m_frame->settings() && m_frame->settings()->asynchronousSpellCheckingEnabled();
+ chunkAndMarkAllMisspellingsAndBadGrammar(textCheckingOptions, fullParagraphToCheck, asynchronous);
+}
+
+void Editor::chunkAndMarkAllMisspellingsAndBadGrammar(TextCheckingTypeMask textCheckingOptions, const TextCheckingParagraph& fullParagraphToCheck, bool asynchronous)
+{
if (fullParagraphToCheck.isRangeEmpty() || fullParagraphToCheck.isEmpty())
return;
@@ -1518,13 +1525,11 @@ void Editor::markAllMisspellingsAndBadGrammarInRanges(TextCheckingTypeMask textC
int end = fullParagraphToCheck.checkingEnd();
start = std::min(start, end);
end = std::max(start, end);
- bool asynchronous = m_frame && m_frame->settings() && m_frame->settings()->asynchronousSpellCheckingEnabled();
const int kNumChunksToCheck = asynchronous ? (end - start + kChunkSize - 1) / (kChunkSize) : 1;
int currentChunkStart = start;
- RefPtr<Range> checkRange = asynchronous ? fullParagraphToCheck.paragraphRange() : rangeToCheck;
- RefPtr<Range> paragraphRange = fullParagraphToCheck.paragraphRange();
+ RefPtr<Range> checkRange = fullParagraphToCheck.checkingRange();
if (kNumChunksToCheck == 1 && asynchronous) {
- markAllMisspellingsAndBadGrammarInRanges(textCheckingOptions, checkRange.get(), paragraphRange.get(), asynchronous, 0);
+ markAllMisspellingsAndBadGrammarInRanges(textCheckingOptions, checkRange.get(), checkRange.get(), asynchronous, 0);
return;
}
@@ -1532,10 +1537,9 @@ void Editor::markAllMisspellingsAndBadGrammarInRanges(TextCheckingTypeMask textC
checkRange = fullParagraphToCheck.subrange(currentChunkStart, kChunkSize);
setStart(checkRange.get(), startOfSentence(checkRange->startPosition()));
setEnd(checkRange.get(), endOfSentence(checkRange->endPosition()));
- paragraphRange = checkRange;
int checkingLength = 0;
- markAllMisspellingsAndBadGrammarInRanges(textCheckingOptions, checkRange.get(), paragraphRange.get(), asynchronous, iter, &checkingLength);
+ markAllMisspellingsAndBadGrammarInRanges(textCheckingOptions, checkRange.get(), checkRange.get(), asynchronous, iter, &checkingLength);
currentChunkStart += checkingLength;
}
}

Powered by Google App Engine
This is Rietveld 408576698