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

Side by Side Diff: Source/core/editing/TextCheckingHelper.cpp

Issue 224113002: Oilpan: move Range object to the oilpan heap. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: heap/Handle.h => platform/heap/Handle.h Created 6 years, 8 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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2006, 2007 Apple Inc. All rights reserved. 2 * Copyright (C) 2006, 2007 Apple Inc. All rights reserved.
3 * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies) 3 * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies)
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions 6 * modification, are permitted provided that the following conditions
7 * are met: 7 * are met:
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
91 misspelling.location = start + wordStart + misspellingLocation; 91 misspelling.location = start + wordStart + misspellingLocation;
92 misspelling.length = misspellingLength; 92 misspelling.length = misspellingLength;
93 misspelling.replacement = client.getAutoCorrectSuggestionForMisspell edWord(String(text + misspelling.location, misspelling.length)); 93 misspelling.replacement = client.getAutoCorrectSuggestionForMisspell edWord(String(text + misspelling.location, misspelling.length));
94 results.append(misspelling); 94 results.append(misspelling);
95 } 95 }
96 96
97 wordStart = wordEnd; 97 wordStart = wordEnd;
98 } 98 }
99 } 99 }
100 100
101 static PassRefPtr<Range> expandToParagraphBoundary(PassRefPtr<Range> range) 101 static PassRefPtrWillBeRawPtr<Range> expandToParagraphBoundary(PassRefPtrWillBeR awPtr<Range> range)
102 { 102 {
103 RefPtr<Range> paragraphRange = range->cloneRange(IGNORE_EXCEPTION); 103 RefPtrWillBeRawPtr<Range> paragraphRange = range->cloneRange(IGNORE_EXCEPTIO N);
104 setStart(paragraphRange.get(), startOfParagraph(VisiblePosition(range->start Position()))); 104 setStart(paragraphRange.get(), startOfParagraph(VisiblePosition(range->start Position())));
105 setEnd(paragraphRange.get(), endOfParagraph(VisiblePosition(range->endPositi on()))); 105 setEnd(paragraphRange.get(), endOfParagraph(VisiblePosition(range->endPositi on())));
106 return paragraphRange; 106 return paragraphRange;
107 } 107 }
108 108
109 TextCheckingParagraph::TextCheckingParagraph(PassRefPtr<Range> checkingRange) 109 TextCheckingParagraph::TextCheckingParagraph(PassRefPtrWillBeRawPtr<Range> check ingRange)
110 : m_checkingRange(checkingRange) 110 : m_checkingRange(checkingRange)
111 , m_checkingStart(-1) 111 , m_checkingStart(-1)
112 , m_checkingEnd(-1) 112 , m_checkingEnd(-1)
113 , m_checkingLength(-1) 113 , m_checkingLength(-1)
114 { 114 {
115 } 115 }
116 116
117 TextCheckingParagraph::TextCheckingParagraph(PassRefPtr<Range> checkingRange, Pa ssRefPtr<Range> paragraphRange) 117 TextCheckingParagraph::TextCheckingParagraph(PassRefPtrWillBeRawPtr<Range> check ingRange, PassRefPtrWillBeRawPtr<Range> paragraphRange)
118 : m_checkingRange(checkingRange) 118 : m_checkingRange(checkingRange)
119 , m_paragraphRange(paragraphRange) 119 , m_paragraphRange(paragraphRange)
120 , m_checkingStart(-1) 120 , m_checkingStart(-1)
121 , m_checkingEnd(-1) 121 , m_checkingEnd(-1)
122 , m_checkingLength(-1) 122 , m_checkingLength(-1)
123 { 123 {
124 } 124 }
125 125
126 TextCheckingParagraph::~TextCheckingParagraph() 126 TextCheckingParagraph::~TextCheckingParagraph()
127 { 127 {
(...skipping 12 matching lines...) Expand all
140 m_offsetAsRange = nullptr; 140 m_offsetAsRange = nullptr;
141 m_text = String(); 141 m_text = String();
142 } 142 }
143 143
144 int TextCheckingParagraph::rangeLength() const 144 int TextCheckingParagraph::rangeLength() const
145 { 145 {
146 ASSERT(m_checkingRange); 146 ASSERT(m_checkingRange);
147 return TextIterator::rangeLength(paragraphRange().get()); 147 return TextIterator::rangeLength(paragraphRange().get());
148 } 148 }
149 149
150 PassRefPtr<Range> TextCheckingParagraph::paragraphRange() const 150 PassRefPtrWillBeRawPtr<Range> TextCheckingParagraph::paragraphRange() const
151 { 151 {
152 ASSERT(m_checkingRange); 152 ASSERT(m_checkingRange);
153 if (!m_paragraphRange) 153 if (!m_paragraphRange)
154 m_paragraphRange = expandToParagraphBoundary(checkingRange()); 154 m_paragraphRange = expandToParagraphBoundary(checkingRange());
155 return m_paragraphRange; 155 return m_paragraphRange;
156 } 156 }
157 157
158 PassRefPtr<Range> TextCheckingParagraph::subrange(int characterOffset, int chara cterCount) const 158 PassRefPtrWillBeRawPtr<Range> TextCheckingParagraph::subrange(int characterOffse t, int characterCount) const
159 { 159 {
160 ASSERT(m_checkingRange); 160 ASSERT(m_checkingRange);
161 return TextIterator::subrange(paragraphRange().get(), characterOffset, chara cterCount); 161 return TextIterator::subrange(paragraphRange().get(), characterOffset, chara cterCount);
162 } 162 }
163 163
164 int TextCheckingParagraph::offsetTo(const Position& position, ExceptionState& ex ceptionState) const 164 int TextCheckingParagraph::offsetTo(const Position& position, ExceptionState& ex ceptionState) const
165 { 165 {
166 ASSERT(m_checkingRange); 166 ASSERT(m_checkingRange);
167 RefPtr<Range> range = offsetAsRange()->cloneRange(ASSERT_NO_EXCEPTION); 167 RefPtrWillBeRawPtr<Range> range = offsetAsRange()->cloneRange(ASSERT_NO_EXCE PTION);
168 range->setEnd(position.containerNode(), position.computeOffsetInContainerNod e(), exceptionState); 168 range->setEnd(position.containerNode(), position.computeOffsetInContainerNod e(), exceptionState);
169 if (exceptionState.hadException()) 169 if (exceptionState.hadException())
170 return 0; 170 return 0;
171 return TextIterator::rangeLength(range.get()); 171 return TextIterator::rangeLength(range.get());
172 } 172 }
173 173
174 bool TextCheckingParagraph::isEmpty() const 174 bool TextCheckingParagraph::isEmpty() const
175 { 175 {
176 // Both predicates should have same result, but we check both just for sure. 176 // Both predicates should have same result, but we check both just for sure.
177 // We need to investigate to remove this redundancy. 177 // We need to investigate to remove this redundancy.
178 return isRangeEmpty() || isTextEmpty(); 178 return isRangeEmpty() || isTextEmpty();
179 } 179 }
180 180
181 PassRefPtr<Range> TextCheckingParagraph::offsetAsRange() const 181 PassRefPtrWillBeRawPtr<Range> TextCheckingParagraph::offsetAsRange() const
182 { 182 {
183 ASSERT(m_checkingRange); 183 ASSERT(m_checkingRange);
184 if (!m_offsetAsRange) 184 if (!m_offsetAsRange)
185 m_offsetAsRange = Range::create(paragraphRange()->startContainer()->docu ment(), paragraphRange()->startPosition(), checkingRange()->startPosition()); 185 m_offsetAsRange = Range::create(paragraphRange()->startContainer()->docu ment(), paragraphRange()->startPosition(), checkingRange()->startPosition());
186 186
187 return m_offsetAsRange; 187 return m_offsetAsRange;
188 } 188 }
189 189
190 const String& TextCheckingParagraph::text() const 190 const String& TextCheckingParagraph::text() const
191 { 191 {
(...skipping 20 matching lines...) Expand all
212 } 212 }
213 213
214 int TextCheckingParagraph::checkingLength() const 214 int TextCheckingParagraph::checkingLength() const
215 { 215 {
216 ASSERT(m_checkingRange); 216 ASSERT(m_checkingRange);
217 if (-1 == m_checkingLength) 217 if (-1 == m_checkingLength)
218 m_checkingLength = TextIterator::rangeLength(checkingRange().get()); 218 m_checkingLength = TextIterator::rangeLength(checkingRange().get());
219 return m_checkingLength; 219 return m_checkingLength;
220 } 220 }
221 221
222 TextCheckingHelper::TextCheckingHelper(SpellCheckerClient& client, PassRefPtr<Ra nge> range) 222 void TextCheckingParagraph::trace(Visitor* visitor)
223 {
224 visitor->trace(m_checkingRange);
225 visitor->trace(m_paragraphRange);
226 visitor->trace(m_offsetAsRange);
227 }
228
229 TextCheckingHelper::TextCheckingHelper(SpellCheckerClient& client, PassRefPtrWil lBeRawPtr<Range> range)
223 : m_client(&client) 230 : m_client(&client)
224 , m_range(range) 231 , m_range(range)
225 { 232 {
226 ASSERT_ARG(m_range, m_range); 233 ASSERT_ARG(m_range, m_range);
227 } 234 }
228 235
229 TextCheckingHelper::~TextCheckingHelper() 236 TextCheckingHelper::~TextCheckingHelper()
230 { 237 {
231 } 238 }
232 239
233 String TextCheckingHelper::findFirstMisspelling(int& firstMisspellingOffset, boo l markAll, RefPtr<Range>& firstMisspellingRange) 240 String TextCheckingHelper::findFirstMisspelling(int& firstMisspellingOffset, boo l markAll, RefPtrWillBeRawPtr<Range>& firstMisspellingRange)
234 { 241 {
235 WordAwareIterator it(m_range.get()); 242 WordAwareIterator it(m_range.get());
236 firstMisspellingOffset = 0; 243 firstMisspellingOffset = 0;
237 244
238 String firstMisspelling; 245 String firstMisspelling;
239 int currentChunkOffset = 0; 246 int currentChunkOffset = 0;
240 247
241 while (!it.atEnd()) { 248 while (!it.atEnd()) {
242 int length = it.length(); 249 int length = it.length();
243 250
(...skipping 10 matching lines...) Expand all
254 ASSERT(misspellingLength >= 0); 261 ASSERT(misspellingLength >= 0);
255 ASSERT(misspellingLocation >= -1); 262 ASSERT(misspellingLocation >= -1);
256 ASSERT(!misspellingLength || misspellingLocation >= 0); 263 ASSERT(!misspellingLength || misspellingLocation >= 0);
257 ASSERT(misspellingLocation < length); 264 ASSERT(misspellingLocation < length);
258 ASSERT(misspellingLength <= length); 265 ASSERT(misspellingLength <= length);
259 ASSERT(misspellingLocation + misspellingLength <= length); 266 ASSERT(misspellingLocation + misspellingLength <= length);
260 267
261 if (misspellingLocation >= 0 && misspellingLength > 0 && misspelling Location < length && misspellingLength <= length && misspellingLocation + misspe llingLength <= length) { 268 if (misspellingLocation >= 0 && misspellingLength > 0 && misspelling Location < length && misspellingLength <= length && misspellingLocation + misspe llingLength <= length) {
262 269
263 // Compute range of misspelled word 270 // Compute range of misspelled word
264 RefPtr<Range> misspellingRange = TextIterator::subrange(m_range. get(), currentChunkOffset + misspellingLocation, misspellingLength); 271 RefPtrWillBeRawPtr<Range> misspellingRange = TextIterator::subra nge(m_range.get(), currentChunkOffset + misspellingLocation, misspellingLength);
265 272
266 // Remember first-encountered misspelling and its offset. 273 // Remember first-encountered misspelling and its offset.
267 if (!firstMisspelling) { 274 if (!firstMisspelling) {
268 firstMisspellingOffset = currentChunkOffset + misspellingLoc ation; 275 firstMisspellingOffset = currentChunkOffset + misspellingLoc ation;
269 firstMisspelling = it.substring(misspellingLocation, misspel lingLength); 276 firstMisspelling = it.substring(misspellingLocation, misspel lingLength);
270 firstMisspellingRange = misspellingRange; 277 firstMisspellingRange = misspellingRange;
271 } 278 }
272 279
273 // Store marker for misspelled word. 280 // Store marker for misspelled word.
274 misspellingRange->startContainer()->document().markers().addMark er(misspellingRange.get(), DocumentMarker::Spelling); 281 misspellingRange->startContainer()->document().markers().addMark er(misspellingRange.get(), DocumentMarker::Spelling);
(...skipping 24 matching lines...) Expand all
299 outIsSpelling = true; 306 outIsSpelling = true;
300 outFirstFoundOffset = 0; 307 outFirstFoundOffset = 0;
301 outGrammarDetail.location = -1; 308 outGrammarDetail.location = -1;
302 outGrammarDetail.length = 0; 309 outGrammarDetail.length = 0;
303 outGrammarDetail.guesses.clear(); 310 outGrammarDetail.guesses.clear();
304 outGrammarDetail.userDescription = ""; 311 outGrammarDetail.userDescription = "";
305 312
306 // Expand the search range to encompass entire paragraphs, since text checki ng needs that much context. 313 // Expand the search range to encompass entire paragraphs, since text checki ng needs that much context.
307 // Determine the character offset from the start of the paragraph to the sta rt of the original search range, 314 // Determine the character offset from the start of the paragraph to the sta rt of the original search range,
308 // since we will want to ignore results in this area. 315 // since we will want to ignore results in this area.
309 RefPtr<Range> paragraphRange = m_range->cloneRange(IGNORE_EXCEPTION); 316 RefPtrWillBeRawPtr<Range> paragraphRange = m_range->cloneRange(IGNORE_EXCEPT ION);
310 setStart(paragraphRange.get(), startOfParagraph(VisiblePosition(m_range->sta rtPosition()))); 317 setStart(paragraphRange.get(), startOfParagraph(VisiblePosition(m_range->sta rtPosition())));
311 int totalRangeLength = TextIterator::rangeLength(paragraphRange.get()); 318 int totalRangeLength = TextIterator::rangeLength(paragraphRange.get());
312 setEnd(paragraphRange.get(), endOfParagraph(VisiblePosition(m_range->startPo sition()))); 319 setEnd(paragraphRange.get(), endOfParagraph(VisiblePosition(m_range->startPo sition())));
313 320
314 RefPtr<Range> offsetAsRange = Range::create(paragraphRange->startContainer() ->document(), paragraphRange->startPosition(), m_range->startPosition()); 321 RefPtrWillBeRawPtr<Range> offsetAsRange = Range::create(paragraphRange->star tContainer()->document(), paragraphRange->startPosition(), m_range->startPositio n());
315 int rangeStartOffset = TextIterator::rangeLength(offsetAsRange.get()); 322 int rangeStartOffset = TextIterator::rangeLength(offsetAsRange.get());
316 int totalLengthProcessed = 0; 323 int totalLengthProcessed = 0;
317 324
318 bool firstIteration = true; 325 bool firstIteration = true;
319 bool lastIteration = false; 326 bool lastIteration = false;
320 while (totalLengthProcessed < totalRangeLength) { 327 while (totalLengthProcessed < totalRangeLength) {
321 // Iterate through the search range by paragraphs, checking each one for spelling and grammar. 328 // Iterate through the search range by paragraphs, checking each one for spelling and grammar.
322 int currentLength = TextIterator::rangeLength(paragraphRange.get()); 329 int currentLength = TextIterator::rangeLength(paragraphRange.get());
323 int currentStartOffset = firstIteration ? rangeStartOffset : 0; 330 int currentStartOffset = firstIteration ? rangeStartOffset : 0;
324 int currentEndOffset = currentLength; 331 int currentEndOffset = currentLength;
325 if (inSameParagraph(VisiblePosition(paragraphRange->startPosition()), Vi siblePosition(m_range->endPosition()))) { 332 if (inSameParagraph(VisiblePosition(paragraphRange->startPosition()), Vi siblePosition(m_range->endPosition()))) {
326 // Determine the character offset from the end of the original searc h range to the end of the paragraph, 333 // Determine the character offset from the end of the original searc h range to the end of the paragraph,
327 // since we will want to ignore results in this area. 334 // since we will want to ignore results in this area.
328 RefPtr<Range> endOffsetAsRange = Range::create(paragraphRange->start Container()->document(), paragraphRange->startPosition(), m_range->endPosition() ); 335 RefPtrWillBeRawPtr<Range> endOffsetAsRange = Range::create(paragraph Range->startContainer()->document(), paragraphRange->startPosition(), m_range->e ndPosition());
329 currentEndOffset = TextIterator::rangeLength(endOffsetAsRange.get()) ; 336 currentEndOffset = TextIterator::rangeLength(endOffsetAsRange.get()) ;
330 lastIteration = true; 337 lastIteration = true;
331 } 338 }
332 if (currentStartOffset < currentEndOffset) { 339 if (currentStartOffset < currentEndOffset) {
333 String paragraphString = plainText(paragraphRange.get()); 340 String paragraphString = plainText(paragraphRange.get());
334 if (paragraphString.length() > 0) { 341 if (paragraphString.length() > 0) {
335 bool foundGrammar = false; 342 bool foundGrammar = false;
336 int spellingLocation = 0; 343 int spellingLocation = 0;
337 int grammarPhraseLocation = 0; 344 int grammarPhraseLocation = 0;
338 int grammarDetailLocation = 0; 345 int grammarDetailLocation = 0;
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
371 outGrammarDetail = result->details[grammarDetailInde x]; 378 outGrammarDetail = result->details[grammarDetailInde x];
372 badGrammarPhrase = paragraphString.substring(result- >location, result->length); 379 badGrammarPhrase = paragraphString.substring(result- >location, result->length);
373 ASSERT(badGrammarPhrase.length()); 380 ASSERT(badGrammarPhrase.length());
374 } 381 }
375 } 382 }
376 } 383 }
377 384
378 if (!misspelledWord.isEmpty() && (!checkGrammar || badGrammarPhr ase.isEmpty() || spellingLocation <= grammarDetailLocation)) { 385 if (!misspelledWord.isEmpty() && (!checkGrammar || badGrammarPhr ase.isEmpty() || spellingLocation <= grammarDetailLocation)) {
379 int spellingOffset = spellingLocation - currentStartOffset; 386 int spellingOffset = spellingLocation - currentStartOffset;
380 if (!firstIteration) { 387 if (!firstIteration) {
381 RefPtr<Range> paragraphOffsetAsRange = Range::create(par agraphRange->startContainer()->document(), m_range->startPosition(), paragraphRa nge->startPosition()); 388 RefPtrWillBeRawPtr<Range> paragraphOffsetAsRange = Range ::create(paragraphRange->startContainer()->document(), m_range->startPosition(), paragraphRange->startPosition());
382 spellingOffset += TextIterator::rangeLength(paragraphOff setAsRange.get()); 389 spellingOffset += TextIterator::rangeLength(paragraphOff setAsRange.get());
383 } 390 }
384 outIsSpelling = true; 391 outIsSpelling = true;
385 outFirstFoundOffset = spellingOffset; 392 outFirstFoundOffset = spellingOffset;
386 firstFoundItem = misspelledWord; 393 firstFoundItem = misspelledWord;
387 break; 394 break;
388 } 395 }
389 if (checkGrammar && !badGrammarPhrase.isEmpty()) { 396 if (checkGrammar && !badGrammarPhrase.isEmpty()) {
390 int grammarPhraseOffset = grammarPhraseLocation - currentSta rtOffset; 397 int grammarPhraseOffset = grammarPhraseLocation - currentSta rtOffset;
391 if (!firstIteration) { 398 if (!firstIteration) {
392 RefPtr<Range> paragraphOffsetAsRange = Range::create(par agraphRange->startContainer()->document(), m_range->startPosition(), paragraphRa nge->startPosition()); 399 RefPtrWillBeRawPtr<Range> paragraphOffsetAsRange = Range ::create(paragraphRange->startContainer()->document(), m_range->startPosition(), paragraphRange->startPosition());
393 grammarPhraseOffset += TextIterator::rangeLength(paragra phOffsetAsRange.get()); 400 grammarPhraseOffset += TextIterator::rangeLength(paragra phOffsetAsRange.get());
394 } 401 }
395 outIsSpelling = false; 402 outIsSpelling = false;
396 outFirstFoundOffset = grammarPhraseOffset; 403 outFirstFoundOffset = grammarPhraseOffset;
397 firstFoundItem = badGrammarPhrase; 404 firstFoundItem = badGrammarPhrase;
398 break; 405 break;
399 } 406 }
400 } 407 }
401 } 408 }
402 if (lastIteration || totalLengthProcessed + currentLength >= totalRangeL ength) 409 if (lastIteration || totalLengthProcessed + currentLength >= totalRangeL ength)
(...skipping 21 matching lines...) Expand all
424 431
425 // Skip this detail if it starts before the original search range 432 // Skip this detail if it starts before the original search range
426 if (detailStartOffsetInParagraph < startOffset) 433 if (detailStartOffsetInParagraph < startOffset)
427 continue; 434 continue;
428 435
429 // Skip this detail if it starts after the original search range 436 // Skip this detail if it starts after the original search range
430 if (detailStartOffsetInParagraph >= endOffset) 437 if (detailStartOffsetInParagraph >= endOffset)
431 continue; 438 continue;
432 439
433 if (markAll) { 440 if (markAll) {
434 RefPtr<Range> badGrammarRange = TextIterator::subrange(m_range.get() , badGrammarPhraseLocation - startOffset + detail->location, detail->length); 441 RefPtrWillBeRawPtr<Range> badGrammarRange = TextIterator::subrange(m _range.get(), badGrammarPhraseLocation - startOffset + detail->location, detail- >length);
435 badGrammarRange->startContainer()->document().markers().addMarker(ba dGrammarRange.get(), DocumentMarker::Grammar, detail->userDescription); 442 badGrammarRange->startContainer()->document().markers().addMarker(ba dGrammarRange.get(), DocumentMarker::Grammar, detail->userDescription);
436 } 443 }
437 444
438 // Remember this detail only if it's earlier than our current candidate (the details aren't in a guaranteed order) 445 // Remember this detail only if it's earlier than our current candidate (the details aren't in a guaranteed order)
439 if (earliestDetailIndex < 0 || earliestDetailLocationSoFar > detail->loc ation) { 446 if (earliestDetailIndex < 0 || earliestDetailLocationSoFar > detail->loc ation) {
440 earliestDetailIndex = i; 447 earliestDetailIndex = i;
441 earliestDetailLocationSoFar = detail->location; 448 earliestDetailLocationSoFar = detail->location;
442 } 449 }
443 } 450 }
444 451
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
497 } 504 }
498 505
499 // These results were all between the start of the paragraph and the sta rt of the search range; look 506 // These results were all between the start of the paragraph and the sta rt of the search range; look
500 // beyond this phrase. 507 // beyond this phrase.
501 startOffset = badGrammarPhraseLocation + badGrammarPhraseLength; 508 startOffset = badGrammarPhraseLocation + badGrammarPhraseLength;
502 } 509 }
503 510
504 return firstBadGrammarPhrase; 511 return firstBadGrammarPhrase;
505 } 512 }
506 513
507 void TextCheckingHelper::markAllMisspellings(RefPtr<Range>& firstMisspellingRang e) 514 void TextCheckingHelper::markAllMisspellings(RefPtrWillBeRawPtr<Range>& firstMis spellingRange)
508 { 515 {
509 // Use the "markAll" feature of findFirstMisspelling. Ignore the return valu e and the "out parameter"; 516 // Use the "markAll" feature of findFirstMisspelling. Ignore the return valu e and the "out parameter";
510 // all we need to do is mark every instance. 517 // all we need to do is mark every instance.
511 int ignoredOffset; 518 int ignoredOffset;
512 findFirstMisspelling(ignoredOffset, true, firstMisspellingRange); 519 findFirstMisspelling(ignoredOffset, true, firstMisspellingRange);
513 } 520 }
514 521
515 void TextCheckingHelper::markAllBadGrammar() 522 void TextCheckingHelper::markAllBadGrammar()
516 { 523 {
517 // Use the "markAll" feature of ofindFirstBadGrammar. Ignore the return valu e and "out parameters"; all we need to 524 // Use the "markAll" feature of ofindFirstBadGrammar. Ignore the return valu e and "out parameters"; all we need to
518 // do is mark every instance. 525 // do is mark every instance.
519 GrammarDetail ignoredGrammarDetail; 526 GrammarDetail ignoredGrammarDetail;
520 int ignoredOffset; 527 int ignoredOffset;
521 findFirstBadGrammar(ignoredGrammarDetail, ignoredOffset, true); 528 findFirstBadGrammar(ignoredGrammarDetail, ignoredOffset, true);
522 } 529 }
523 530
524 bool TextCheckingHelper::unifiedTextCheckerEnabled() const 531 bool TextCheckingHelper::unifiedTextCheckerEnabled() const
525 { 532 {
526 if (!m_range) 533 if (!m_range)
527 return false; 534 return false;
528 535
529 Document& doc = m_range->ownerDocument(); 536 Document& doc = m_range->ownerDocument();
530 return WebCore::unifiedTextCheckerEnabled(doc.frame()); 537 return WebCore::unifiedTextCheckerEnabled(doc.frame());
531 } 538 }
532 539
540 void TextCheckingHelper::trace(Visitor* visitor)
541 {
542 visitor->trace(m_range);
543 }
544
533 void checkTextOfParagraph(TextCheckerClient& client, const String& text, TextChe ckingTypeMask checkingTypes, Vector<TextCheckingResult>& results) 545 void checkTextOfParagraph(TextCheckerClient& client, const String& text, TextChe ckingTypeMask checkingTypes, Vector<TextCheckingResult>& results)
534 { 546 {
535 Vector<UChar> characters; 547 Vector<UChar> characters;
536 text.appendTo(characters); 548 text.appendTo(characters);
537 unsigned length = text.length(); 549 unsigned length = text.length();
538 550
539 Vector<TextCheckingResult> spellingResult; 551 Vector<TextCheckingResult> spellingResult;
540 if (checkingTypes & TextCheckingTypeSpelling) 552 if (checkingTypes & TextCheckingTypeSpelling)
541 findMisspellings(client, characters.data(), 0, length, spellingResult); 553 findMisspellings(client, characters.data(), 0, length, spellingResult);
542 554
(...skipping 26 matching lines...) Expand all
569 return false; 581 return false;
570 582
571 const Settings* settings = frame->settings(); 583 const Settings* settings = frame->settings();
572 if (!settings) 584 if (!settings)
573 return false; 585 return false;
574 586
575 return settings->unifiedTextCheckerEnabled(); 587 return settings->unifiedTextCheckerEnabled();
576 } 588 }
577 589
578 } 590 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698