Index: Source/core/editing/TextCheckingHelper.cpp |
diff --git a/Source/core/editing/TextCheckingHelper.cpp b/Source/core/editing/TextCheckingHelper.cpp |
index e96620aeb4cb03ab084ef5e2dae0b53e3e016aa7..335e48ed83d5d40a204c8d277aa1d39cedb68539 100644 |
--- a/Source/core/editing/TextCheckingHelper.cpp |
+++ b/Source/core/editing/TextCheckingHelper.cpp |
@@ -98,15 +98,15 @@ static void findMisspellings(TextCheckerClient& client, const UChar* text, int s |
} |
} |
-static PassRefPtr<Range> expandToParagraphBoundary(PassRefPtr<Range> range) |
+static PassRefPtrWillBeRawPtr<Range> expandToParagraphBoundary(PassRefPtrWillBeRawPtr<Range> range) |
{ |
- RefPtr<Range> paragraphRange = range->cloneRange(IGNORE_EXCEPTION); |
+ RefPtrWillBeRawPtr<Range> paragraphRange = range->cloneRange(IGNORE_EXCEPTION); |
setStart(paragraphRange.get(), startOfParagraph(VisiblePosition(range->startPosition()))); |
setEnd(paragraphRange.get(), endOfParagraph(VisiblePosition(range->endPosition()))); |
return paragraphRange; |
} |
-TextCheckingParagraph::TextCheckingParagraph(PassRefPtr<Range> checkingRange) |
+TextCheckingParagraph::TextCheckingParagraph(PassRefPtrWillBeRawPtr<Range> checkingRange) |
: m_checkingRange(checkingRange) |
, m_checkingStart(-1) |
, m_checkingEnd(-1) |
@@ -114,7 +114,7 @@ TextCheckingParagraph::TextCheckingParagraph(PassRefPtr<Range> checkingRange) |
{ |
} |
-TextCheckingParagraph::TextCheckingParagraph(PassRefPtr<Range> checkingRange, PassRefPtr<Range> paragraphRange) |
+TextCheckingParagraph::TextCheckingParagraph(PassRefPtrWillBeRawPtr<Range> checkingRange, PassRefPtrWillBeRawPtr<Range> paragraphRange) |
: m_checkingRange(checkingRange) |
, m_paragraphRange(paragraphRange) |
, m_checkingStart(-1) |
@@ -147,7 +147,7 @@ int TextCheckingParagraph::rangeLength() const |
return TextIterator::rangeLength(paragraphRange().get()); |
} |
-PassRefPtr<Range> TextCheckingParagraph::paragraphRange() const |
+PassRefPtrWillBeRawPtr<Range> TextCheckingParagraph::paragraphRange() const |
{ |
ASSERT(m_checkingRange); |
if (!m_paragraphRange) |
@@ -155,7 +155,7 @@ PassRefPtr<Range> TextCheckingParagraph::paragraphRange() const |
return m_paragraphRange; |
} |
-PassRefPtr<Range> TextCheckingParagraph::subrange(int characterOffset, int characterCount) const |
+PassRefPtrWillBeRawPtr<Range> TextCheckingParagraph::subrange(int characterOffset, int characterCount) const |
{ |
ASSERT(m_checkingRange); |
return TextIterator::subrange(paragraphRange().get(), characterOffset, characterCount); |
@@ -164,7 +164,7 @@ PassRefPtr<Range> TextCheckingParagraph::subrange(int characterOffset, int chara |
int TextCheckingParagraph::offsetTo(const Position& position, ExceptionState& exceptionState) const |
{ |
ASSERT(m_checkingRange); |
- RefPtr<Range> range = offsetAsRange()->cloneRange(ASSERT_NO_EXCEPTION); |
+ RefPtrWillBeRawPtr<Range> range = offsetAsRange()->cloneRange(ASSERT_NO_EXCEPTION); |
range->setEnd(position.containerNode(), position.computeOffsetInContainerNode(), exceptionState); |
if (exceptionState.hadException()) |
return 0; |
@@ -178,7 +178,7 @@ bool TextCheckingParagraph::isEmpty() const |
return isRangeEmpty() || isTextEmpty(); |
} |
-PassRefPtr<Range> TextCheckingParagraph::offsetAsRange() const |
+PassRefPtrWillBeRawPtr<Range> TextCheckingParagraph::offsetAsRange() const |
{ |
ASSERT(m_checkingRange); |
if (!m_offsetAsRange) |
@@ -219,7 +219,14 @@ int TextCheckingParagraph::checkingLength() const |
return m_checkingLength; |
} |
-TextCheckingHelper::TextCheckingHelper(SpellCheckerClient& client, PassRefPtr<Range> range) |
+void TextCheckingParagraph::trace(Visitor* visitor) |
+{ |
+ visitor->trace(m_checkingRange); |
+ visitor->trace(m_paragraphRange); |
+ visitor->trace(m_offsetAsRange); |
+} |
+ |
+TextCheckingHelper::TextCheckingHelper(SpellCheckerClient& client, PassRefPtrWillBeRawPtr<Range> range) |
: m_client(&client) |
, m_range(range) |
{ |
@@ -230,7 +237,7 @@ TextCheckingHelper::~TextCheckingHelper() |
{ |
} |
-String TextCheckingHelper::findFirstMisspelling(int& firstMisspellingOffset, bool markAll, RefPtr<Range>& firstMisspellingRange) |
+String TextCheckingHelper::findFirstMisspelling(int& firstMisspellingOffset, bool markAll, RefPtrWillBeRawPtr<Range>& firstMisspellingRange) |
{ |
WordAwareIterator it(m_range.get()); |
firstMisspellingOffset = 0; |
@@ -261,7 +268,7 @@ String TextCheckingHelper::findFirstMisspelling(int& firstMisspellingOffset, boo |
if (misspellingLocation >= 0 && misspellingLength > 0 && misspellingLocation < length && misspellingLength <= length && misspellingLocation + misspellingLength <= length) { |
// Compute range of misspelled word |
- RefPtr<Range> misspellingRange = TextIterator::subrange(m_range.get(), currentChunkOffset + misspellingLocation, misspellingLength); |
+ RefPtrWillBeRawPtr<Range> misspellingRange = TextIterator::subrange(m_range.get(), currentChunkOffset + misspellingLocation, misspellingLength); |
// Remember first-encountered misspelling and its offset. |
if (!firstMisspelling) { |
@@ -306,12 +313,12 @@ String TextCheckingHelper::findFirstMisspellingOrBadGrammar(bool checkGrammar, b |
// Expand the search range to encompass entire paragraphs, since text checking needs that much context. |
// Determine the character offset from the start of the paragraph to the start of the original search range, |
// since we will want to ignore results in this area. |
- RefPtr<Range> paragraphRange = m_range->cloneRange(IGNORE_EXCEPTION); |
+ RefPtrWillBeRawPtr<Range> paragraphRange = m_range->cloneRange(IGNORE_EXCEPTION); |
setStart(paragraphRange.get(), startOfParagraph(VisiblePosition(m_range->startPosition()))); |
int totalRangeLength = TextIterator::rangeLength(paragraphRange.get()); |
setEnd(paragraphRange.get(), endOfParagraph(VisiblePosition(m_range->startPosition()))); |
- RefPtr<Range> offsetAsRange = Range::create(paragraphRange->startContainer()->document(), paragraphRange->startPosition(), m_range->startPosition()); |
+ RefPtrWillBeRawPtr<Range> offsetAsRange = Range::create(paragraphRange->startContainer()->document(), paragraphRange->startPosition(), m_range->startPosition()); |
int rangeStartOffset = TextIterator::rangeLength(offsetAsRange.get()); |
int totalLengthProcessed = 0; |
@@ -325,7 +332,7 @@ String TextCheckingHelper::findFirstMisspellingOrBadGrammar(bool checkGrammar, b |
if (inSameParagraph(VisiblePosition(paragraphRange->startPosition()), VisiblePosition(m_range->endPosition()))) { |
// Determine the character offset from the end of the original search range to the end of the paragraph, |
// since we will want to ignore results in this area. |
- RefPtr<Range> endOffsetAsRange = Range::create(paragraphRange->startContainer()->document(), paragraphRange->startPosition(), m_range->endPosition()); |
+ RefPtrWillBeRawPtr<Range> endOffsetAsRange = Range::create(paragraphRange->startContainer()->document(), paragraphRange->startPosition(), m_range->endPosition()); |
currentEndOffset = TextIterator::rangeLength(endOffsetAsRange.get()); |
lastIteration = true; |
} |
@@ -378,7 +385,7 @@ String TextCheckingHelper::findFirstMisspellingOrBadGrammar(bool checkGrammar, b |
if (!misspelledWord.isEmpty() && (!checkGrammar || badGrammarPhrase.isEmpty() || spellingLocation <= grammarDetailLocation)) { |
int spellingOffset = spellingLocation - currentStartOffset; |
if (!firstIteration) { |
- RefPtr<Range> paragraphOffsetAsRange = Range::create(paragraphRange->startContainer()->document(), m_range->startPosition(), paragraphRange->startPosition()); |
+ RefPtrWillBeRawPtr<Range> paragraphOffsetAsRange = Range::create(paragraphRange->startContainer()->document(), m_range->startPosition(), paragraphRange->startPosition()); |
spellingOffset += TextIterator::rangeLength(paragraphOffsetAsRange.get()); |
} |
outIsSpelling = true; |
@@ -389,7 +396,7 @@ String TextCheckingHelper::findFirstMisspellingOrBadGrammar(bool checkGrammar, b |
if (checkGrammar && !badGrammarPhrase.isEmpty()) { |
int grammarPhraseOffset = grammarPhraseLocation - currentStartOffset; |
if (!firstIteration) { |
- RefPtr<Range> paragraphOffsetAsRange = Range::create(paragraphRange->startContainer()->document(), m_range->startPosition(), paragraphRange->startPosition()); |
+ RefPtrWillBeRawPtr<Range> paragraphOffsetAsRange = Range::create(paragraphRange->startContainer()->document(), m_range->startPosition(), paragraphRange->startPosition()); |
grammarPhraseOffset += TextIterator::rangeLength(paragraphOffsetAsRange.get()); |
} |
outIsSpelling = false; |
@@ -431,7 +438,7 @@ int TextCheckingHelper::findFirstGrammarDetail(const Vector<GrammarDetail>& gram |
continue; |
if (markAll) { |
- RefPtr<Range> badGrammarRange = TextIterator::subrange(m_range.get(), badGrammarPhraseLocation - startOffset + detail->location, detail->length); |
+ RefPtrWillBeRawPtr<Range> badGrammarRange = TextIterator::subrange(m_range.get(), badGrammarPhraseLocation - startOffset + detail->location, detail->length); |
badGrammarRange->startContainer()->document().markers().addMarker(badGrammarRange.get(), DocumentMarker::Grammar, detail->userDescription); |
} |
@@ -504,7 +511,7 @@ String TextCheckingHelper::findFirstBadGrammar(GrammarDetail& outGrammarDetail, |
return firstBadGrammarPhrase; |
} |
-void TextCheckingHelper::markAllMisspellings(RefPtr<Range>& firstMisspellingRange) |
+void TextCheckingHelper::markAllMisspellings(RefPtrWillBeRawPtr<Range>& firstMisspellingRange) |
{ |
// Use the "markAll" feature of findFirstMisspelling. Ignore the return value and the "out parameter"; |
// all we need to do is mark every instance. |
@@ -530,6 +537,11 @@ bool TextCheckingHelper::unifiedTextCheckerEnabled() const |
return WebCore::unifiedTextCheckerEnabled(doc.frame()); |
} |
+void TextCheckingHelper::trace(Visitor* visitor) |
+{ |
+ visitor->trace(m_range); |
+} |
+ |
void checkTextOfParagraph(TextCheckerClient& client, const String& text, TextCheckingTypeMask checkingTypes, Vector<TextCheckingResult>& results) |
{ |
Vector<UChar> characters; |