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

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

Issue 2273453003: Stop SpellChecker::chunkAndMarkAllMisspellingsAndBadGrammar from using TextCheckingParagrah (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@RemoveSCRDoubleCheck
Patch Set: Rebased 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 17fa86ca749289960124956ac3076caf3eb2891b..135f97f4f7ab0c056a7b45e42005641a81b4f4f5 100644
--- a/third_party/WebKit/Source/core/editing/spellcheck/SpellChecker.cpp
+++ b/third_party/WebKit/Source/core/editing/spellcheck/SpellChecker.cpp
@@ -313,8 +313,7 @@ void SpellChecker::markMisspellingsAndBadGrammar(const VisibleSelection& selecti
if (!isSpellCheckingEnabledFor(editableNode))
return;
- TextCheckingParagraph fullParagraphToCheck(expandRangeToSentenceBoundary(range));
- chunkAndMarkAllMisspellingsAndBadGrammar(fullParagraphToCheck);
+ chunkAndMarkAllMisspellingsAndBadGrammar(range);
}
void SpellChecker::markMisspellingsAfterApplyingCommand(const CompositeEditCommand& cmd)
@@ -423,38 +422,36 @@ void SpellChecker::markMisspellingsAfterReplaceSelectionCommand(const ReplaceSel
{
TRACE_EVENT0("blink", "SpellChecker::markMisspellingsAfterReplaceSelectionCommand");
- const EphemeralRange& insertedRange = cmd.insertedRange();
- if (insertedRange.isNull())
- return;
+ chunkAndMarkAllMisspellingsAndBadGrammar(cmd.insertedRange());
+}
- Node* node = cmd.endingSelection().rootEditableElement();
- if (!node)
+void SpellChecker::chunkAndMarkAllMisspellingsAndBadGrammar(const EphemeralRange& range)
+{
+ if (range.isNull())
return;
- EphemeralRange paragraphRange(Position::firstPositionInNode(node), Position::lastPositionInNode(node));
- TextCheckingParagraph textToCheck(insertedRange, paragraphRange);
- chunkAndMarkAllMisspellingsAndBadGrammar(textToCheck);
-}
+ Node* rootEditableElement = rootEditableElementOf(range.startPosition());
+ if (!rootEditableElement)
+ return;
-void SpellChecker::chunkAndMarkAllMisspellingsAndBadGrammar(const TextCheckingParagraph& fullParagraphToCheck)
-{
- if (fullParagraphToCheck.isEmpty())
+ const EphemeralRange& fullTextRange = EphemeralRange::rangeOfContents(*rootEditableElement);
+ int fullTextLength = TextIterator::rangeLength(fullTextRange.startPosition(), fullTextRange.endPosition());
+ if (fullTextLength <= 0)
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 (fullParagraphToCheck.rangeLength() <= kChunkSize) {
- SpellCheckRequest* request = SpellCheckRequest::create(TextCheckingProcessBatch, paragraphRange, 0);
+ if (fullTextLength <= kChunkSize) {
+ SpellCheckRequest* request = SpellCheckRequest::create(TextCheckingProcessBatch, fullTextRange, 0);
if (request)
m_spellCheckRequester->requestCheckingFor(request);
return;
}
- CharacterIterator checkRangeIterator(fullParagraphToCheck.checkingRange(), TextIteratorEmitsObjectReplacementCharacter);
+ CharacterIterator checkRangeIterator(range, 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