Index: Source/core/editing/spellcheck/SpellChecker.cpp |
diff --git a/Source/core/editing/spellcheck/SpellChecker.cpp b/Source/core/editing/spellcheck/SpellChecker.cpp |
index 10aa296a26fe40d35e43bc933a038269fe0c9895..79d26920f28ad87a6b62d89e2cfe64930a635eb7 100644 |
--- a/Source/core/editing/spellcheck/SpellChecker.cpp |
+++ b/Source/core/editing/spellcheck/SpellChecker.cpp |
@@ -487,8 +487,7 @@ void SpellChecker::markAllMisspellingsAndBadGrammarInRanges(TextCheckingTypeMask |
if (!isSpellCheckingEnabledFor(editableNode)) |
return; |
- RefPtrWillBeRawPtr<Range> rangeToCheck = createRange(shouldMarkGrammar ? grammarRange : spellingRange); |
- TextCheckingParagraph fullParagraphToCheck(rangeToCheck); |
+ TextCheckingParagraph fullParagraphToCheck(shouldMarkGrammar ? grammarRange : spellingRange); |
bool asynchronous = frame().settings() && frame().settings()->asynchronousSpellCheckingEnabled(); |
chunkAndMarkAllMisspellingsAndBadGrammar(textCheckingOptions, fullParagraphToCheck, asynchronous); |
@@ -518,29 +517,29 @@ void SpellChecker::chunkAndMarkAllMisspellingsAndBadGrammar(TextCheckingTypeMask |
end = std::max(start, end); |
const int kNumChunksToCheck = asynchronous ? (end - start + kChunkSize - 1) / (kChunkSize) : 1; |
int currentChunkStart = start; |
- RefPtrWillBeRawPtr<Range> checkRange = fullParagraphToCheck.checkingRange(); |
+ EphemeralRange checkRange = fullParagraphToCheck.checkingRange(); |
yosin_UTC9
2015/09/10 01:58:39
nit: |const EphemeralRange|.
|
if (kNumChunksToCheck == 1 && asynchronous) { |
- markAllMisspellingsAndBadGrammarInRanges(textCheckingOptions, checkRange.get(), checkRange.get(), asynchronous, 0); |
+ markAllMisspellingsAndBadGrammarInRanges(textCheckingOptions, checkRange, checkRange, asynchronous, 0); |
return; |
} |
for (int iter = 0; iter < kNumChunksToCheck; ++iter) { |
checkRange = fullParagraphToCheck.subrange(currentChunkStart, kChunkSize); |
yosin_UTC9
2015/09/10 01:58:39
nit: Let's use new variable name. We don't want to
|
- expandRangeToSentenceBoundary(*checkRange); |
+ checkRange = expandRangeToSentenceBoundary(checkRange); |
int checkingLength = 0; |
- markAllMisspellingsAndBadGrammarInRanges(textCheckingOptions, checkRange.get(), checkRange.get(), asynchronous, iter, &checkingLength); |
+ markAllMisspellingsAndBadGrammarInRanges(textCheckingOptions, checkRange, checkRange, asynchronous, iter, &checkingLength); |
currentChunkStart += checkingLength; |
} |
} |
-void SpellChecker::markAllMisspellingsAndBadGrammarInRanges(TextCheckingTypeMask textCheckingOptions, Range* checkRange, Range* paragraphRange, bool asynchronous, int requestNumber, int* checkingLength) |
+void SpellChecker::markAllMisspellingsAndBadGrammarInRanges(TextCheckingTypeMask textCheckingOptions, const EphemeralRange& checkRange, const EphemeralRange& paragraphRange, bool asynchronous, int requestNumber, int* checkingLength) |
{ |
TextCheckingParagraph sentenceToCheck(checkRange, paragraphRange); |
if (checkingLength) |
*checkingLength = sentenceToCheck.checkingLength(); |
- RefPtrWillBeRawPtr<SpellCheckRequest> request = SpellCheckRequest::create(resolveTextCheckingTypeMask(textCheckingOptions), TextCheckingProcessBatch, checkRange, paragraphRange, requestNumber); |
+ RefPtrWillBeRawPtr<SpellCheckRequest> request = SpellCheckRequest::create(resolveTextCheckingTypeMask(textCheckingOptions), TextCheckingProcessBatch, createRange(checkRange), createRange(paragraphRange), requestNumber); |
if (!request) |
return; |
@@ -598,7 +597,7 @@ void SpellChecker::markAndReplaceFor(PassRefPtrWillBeRawPtr<SpellCheckRequest> r |
// "wouldn'" as misspelled right after apostrophe is typed. |
if (shouldMarkSpelling && result->decoration == TextDecorationTypeSpelling && resultLocation >= paragraph.checkingStart() && resultLocation + resultLength <= spellingRangeEndOffset && !resultEndsAtAmbiguousBoundary) { |
ASSERT(resultLength > 0 && resultLocation >= 0); |
- const EphemeralRange misspellingRange = calculateCharacterSubrange(EphemeralRange(paragraph.paragraphRange().get()), resultLocation, resultLength); |
+ const EphemeralRange misspellingRange = calculateCharacterSubrange(paragraph.paragraphRange(), resultLocation, resultLength); |
frame().document()->markers().addMarker(misspellingRange.startPosition(), misspellingRange.endPosition(), DocumentMarker::Spelling, result->replacement, result->hash); |
} else if (shouldMarkGrammar && result->decoration == TextDecorationTypeGrammar && paragraph.checkingRangeCovers(resultLocation, resultLength)) { |
ASSERT(resultLength > 0 && resultLocation >= 0); |
@@ -606,13 +605,13 @@ void SpellChecker::markAndReplaceFor(PassRefPtrWillBeRawPtr<SpellCheckRequest> r |
const GrammarDetail* detail = &result->details[j]; |
ASSERT(detail->length > 0 && detail->location >= 0); |
if (paragraph.checkingRangeCovers(resultLocation + detail->location, detail->length)) { |
- const EphemeralRange badGrammarRange = calculateCharacterSubrange(EphemeralRange(paragraph.paragraphRange().get()), resultLocation + detail->location, detail->length); |
+ const EphemeralRange badGrammarRange = calculateCharacterSubrange(paragraph.paragraphRange(), resultLocation + detail->location, detail->length); |
frame().document()->markers().addMarker(badGrammarRange.startPosition(), badGrammarRange.endPosition(), DocumentMarker::Grammar, detail->userDescription, result->hash); |
} |
} |
} else if (result->decoration == TextDecorationTypeInvisibleSpellcheck && resultLocation >= paragraph.checkingStart() && resultLocation + resultLength <= spellingRangeEndOffset) { |
ASSERT(resultLength > 0 && resultLocation >= 0); |
- const EphemeralRange invisibleSpellcheckRange = calculateCharacterSubrange(EphemeralRange(paragraph.paragraphRange().get()), resultLocation, resultLength); |
+ const EphemeralRange invisibleSpellcheckRange = calculateCharacterSubrange(paragraph.paragraphRange(), resultLocation, resultLength); |
frame().document()->markers().addMarker(invisibleSpellcheckRange.startPosition(), invisibleSpellcheckRange.endPosition(), DocumentMarker::InvisibleSpellcheck, result->replacement, result->hash); |
} |
} |
@@ -622,8 +621,8 @@ void SpellChecker::markAndReplaceFor(PassRefPtrWillBeRawPtr<SpellCheckRequest> r |
// Restore the caret position if we have made any replacements |
extendedParagraph.expandRangeToNextEnd(); |
if (restoreSelectionAfterChange && selectionOffset >= 0 && selectionOffset <= extendedParagraph.rangeLength()) { |
- RefPtrWillBeRawPtr<Range> selectionRange = extendedParagraph.subrange(0, selectionOffset); |
- frame().selection().moveTo(selectionRange->endPosition(), TextAffinity::Downstream); |
+ EphemeralRange selectionRange = extendedParagraph.subrange(0, selectionOffset); |
yosin_UTC9
2015/09/10 01:58:39
nit: |const EphemeralRange|
|
+ frame().selection().moveTo(selectionRange.endPosition(), TextAffinity::Downstream); |
if (adjustSelectionForParagraphBoundaries) |
frame().selection().modify(FrameSelection::AlterationMove, DirectionForward, CharacterGranularity); |
} else { |