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

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

Issue 23297002: Revert "Trigger spell check/remove markers if spell checker gets enabled/disabled." (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: 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 6b3491229c15f596a120cf1d0a1a6f2b73d9df13..40578184b66df0a6282de71bf7025c4ce5ce702b 100644
--- a/Source/core/editing/Editor.cpp
+++ b/Source/core/editing/Editor.cpp
@@ -1503,38 +1503,24 @@ void Editor::markAllMisspellingsAndBadGrammarInRanges(TextCheckingTypeMask textC
return;
Range* rangeToCheck = shouldMarkGrammar ? grammarRange : spellingRange;
- TextCheckingParagraph fullParagraphToCheck(rangeToCheck);
- if (fullParagraphToCheck.isRangeEmpty() || fullParagraphToCheck.isEmpty())
+ TextCheckingParagraph paragraphToCheck(rangeToCheck);
+ if (paragraphToCheck.isRangeEmpty() || paragraphToCheck.isEmpty())
return;
+ RefPtr<Range> paragraphRange = paragraphToCheck.paragraphRange();
- // Since the text may be quite big chunk it up and adjust to the sentence boundary.
- const int kChunkSize = 16 * 1024;
- int start = fullParagraphToCheck.checkingStart();
- 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;
- for (int iter = 0; iter < kNumChunksToCheck; ++iter) {
- RefPtr<Range> checkRange = fullParagraphToCheck.subrange(currentChunkStart, kChunkSize);
- setStart(checkRange.get(), startOfSentence(checkRange->startPosition()));
- setEnd(checkRange.get(), endOfSentence(checkRange->endPosition()));
- TextCheckingParagraph sentenceToCheck(checkRange, checkRange);
- currentChunkStart += sentenceToCheck.checkingLength();
+ // In asynchronous mode, we intentionally check paragraph-wide sentence.
+ RefPtr<SpellCheckRequest> request = SpellCheckRequest::create(resolveTextCheckingTypeMask(textCheckingOptions), TextCheckingProcessIncremental, asynchronous ? paragraphRange : rangeToCheck, paragraphRange);
- RefPtr<SpellCheckRequest> request = SpellCheckRequest::create(resolveTextCheckingTypeMask(textCheckingOptions), TextCheckingProcessBatch, checkRange, checkRange, iter);
-
- if (asynchronous) {
- m_spellCheckRequester->requestCheckingFor(request);
- continue;
- }
-
- Vector<TextCheckingResult> results;
- checkTextOfParagraph(textChecker(), sentenceToCheck.text(), resolveTextCheckingTypeMask(textCheckingOptions), results);
- markAndReplaceFor(request, results);
+ if (asynchronous) {
+ m_spellCheckRequester->requestCheckingFor(request);
+ return;
}
+
+ Vector<TextCheckingResult> results;
+ checkTextOfParagraph(textChecker(), paragraphToCheck.text(), resolveTextCheckingTypeMask(textCheckingOptions), results);
+ markAndReplaceFor(request, results);
}
void Editor::markAndReplaceFor(PassRefPtr<SpellCheckRequest> request, const Vector<TextCheckingResult>& results)
@@ -1570,7 +1556,7 @@ void Editor::markAndReplaceFor(PassRefPtr<SpellCheckRequest> request, const Vect
for (unsigned i = 0; i < results.size(); i++) {
int spellingRangeEndOffset = paragraph.checkingEnd();
const TextCheckingResult* result = &results[i];
- int resultLocation = result->location + paragraph.checkingStart();
+ int resultLocation = result->location;
int resultLength = result->length;
bool resultEndsAtAmbiguousBoundary = ambiguousBoundaryOffset >= 0 && resultLocation + resultLength == ambiguousBoundaryOffset;
« no previous file with comments | « LayoutTests/editing/spelling/spelling-huge-text-sync-expected.txt ('k') | Source/core/editing/SpellCheckRequester.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698