Index: third_party/WebKit/Source/core/editing/spellcheck/SpellChecker.cpp |
diff --git a/third_party/WebKit/Source/core/editing/spellcheck/SpellChecker.cpp b/third_party/WebKit/Source/core/editing/spellcheck/SpellChecker.cpp |
index 05d972bdb04912e73c99c2ba3d4bf4f502aa48c6..463148e86665692c28a9bdb38b9e1c93a737d646 100644 |
--- a/third_party/WebKit/Source/core/editing/spellcheck/SpellChecker.cpp |
+++ b/third_party/WebKit/Source/core/editing/spellcheck/SpellChecker.cpp |
@@ -327,7 +327,8 @@ void SpellChecker::markMisspellingsAndBadGrammar(const VisibleSelection& selecti |
if (!editableNode || !hasEditableStyle(*editableNode)) |
return; |
- chunkAndMarkAllMisspellingsAndBadGrammar(range); |
+ TextCheckingParagraph fullParagraphToCheck(expandRangeToSentenceBoundary(range)); |
+ chunkAndMarkAllMisspellingsAndBadGrammar(fullParagraphToCheck); |
} |
void SpellChecker::markMisspellingsAfterApplyingCommand(const CompositeEditCommand& cmd) |
@@ -415,36 +416,38 @@ void SpellChecker::markMisspellingsAfterReplaceSelectionCommand(const ReplaceSel |
{ |
TRACE_EVENT0("blink", "SpellChecker::markMisspellingsAfterReplaceSelectionCommand"); |
- chunkAndMarkAllMisspellingsAndBadGrammar(cmd.insertedRange()); |
-} |
- |
-void SpellChecker::chunkAndMarkAllMisspellingsAndBadGrammar(const EphemeralRange& range) |
-{ |
- if (range.isNull()) |
+ const EphemeralRange& insertedRange = cmd.insertedRange(); |
+ if (insertedRange.isNull()) |
return; |
- Node* rootEditableElement = rootEditableElementOf(range.startPosition()); |
- if (!rootEditableElement) |
+ Node* node = cmd.endingSelection().rootEditableElement(); |
+ if (!node) |
return; |
- const EphemeralRange& fullTextRange = EphemeralRange::rangeOfContents(*rootEditableElement); |
- int fullTextLength = TextIterator::rangeLength(fullTextRange.startPosition(), fullTextRange.endPosition()); |
- if (fullTextLength <= 0) |
+ EphemeralRange paragraphRange(Position::firstPositionInNode(node), Position::lastPositionInNode(node)); |
+ TextCheckingParagraph textToCheck(insertedRange, paragraphRange); |
+ chunkAndMarkAllMisspellingsAndBadGrammar(textToCheck); |
+} |
+ |
+void SpellChecker::chunkAndMarkAllMisspellingsAndBadGrammar(const TextCheckingParagraph& fullParagraphToCheck) |
+{ |
+ if (fullParagraphToCheck.isEmpty()) |
return; |
+ const EphemeralRange& paragraphRange = fullParagraphToCheck.paragraphRange(); |
// Since the text may be quite big chunk it up and adjust to the sentence boundary. |
const int kChunkSize = 16 * 1024; |
// Check the full paragraph instead if the paragraph is short, which saves |
// the cost on sentence boundary finding. |
- if (fullTextLength <= kChunkSize) { |
- SpellCheckRequest* request = SpellCheckRequest::create(TextCheckingProcessBatch, fullTextRange, 0); |
+ if (fullParagraphToCheck.rangeLength() <= kChunkSize) { |
+ SpellCheckRequest* request = SpellCheckRequest::create(TextCheckingProcessBatch, paragraphRange, 0); |
if (request) |
m_spellCheckRequester->requestCheckingFor(request); |
return; |
} |
- CharacterIterator checkRangeIterator(range, TextIteratorEmitsObjectReplacementCharacter); |
+ CharacterIterator checkRangeIterator(fullParagraphToCheck.checkingRange(), TextIteratorEmitsObjectReplacementCharacter); |
for (int requestNum = 0; !checkRangeIterator.atEnd(); requestNum++) { |
EphemeralRange chunkRange = checkRangeIterator.calculateCharacterSubrange(0, kChunkSize); |
EphemeralRange checkRange = requestNum ? expandEndToSentenceBoundary(chunkRange) : expandRangeToSentenceBoundary(chunkRange); |