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

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

Issue 2286573002: Revert "Stop SpellChecker::chunkAndMarkAllMisspellingsAndBadGrammar from using TextCheckingParagrah" (Closed)
Patch Set: Created 4 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
« no previous file with comments | « third_party/WebKit/Source/core/editing/spellcheck/SpellChecker.h ('k') | 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/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);
« no previous file with comments | « third_party/WebKit/Source/core/editing/spellcheck/SpellChecker.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698