Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 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, PassRefPtrWil lBeRawPtr<Range> range) | 222 TextCheckingHelper::TextCheckingHelper(SpellCheckerClient& client, const Positio n& start, const Position& end) |
| 223 : m_client(&client) | 223 : m_client(&client) |
| 224 , m_range(range) | 224 , m_start(start) |
| 225 , m_end(end) | |
| 225 { | 226 { |
| 226 ASSERT_ARG(m_range, m_range); | |
| 227 } | 227 } |
| 228 | 228 |
| 229 TextCheckingHelper::~TextCheckingHelper() | 229 TextCheckingHelper::~TextCheckingHelper() |
| 230 { | 230 { |
| 231 } | 231 } |
| 232 | 232 |
| 233 String TextCheckingHelper::findFirstMisspelling(int& firstMisspellingOffset, boo l markAll, RefPtrWillBeRawPtr<Range>& firstMisspellingRange) | 233 String TextCheckingHelper::findFirstMisspelling(int& firstMisspellingOffset, boo l markAll, RefPtrWillBeRawPtr<Range>& firstMisspellingRange) |
| 234 { | 234 { |
| 235 WordAwareIterator it(m_range.get()); | 235 WordAwareIterator it(m_start, m_end); |
| 236 firstMisspellingOffset = 0; | 236 firstMisspellingOffset = 0; |
| 237 | 237 |
| 238 String firstMisspelling; | 238 String firstMisspelling; |
| 239 int currentChunkOffset = 0; | 239 int currentChunkOffset = 0; |
| 240 | 240 |
| 241 while (!it.atEnd()) { | 241 while (!it.atEnd()) { |
| 242 int length = it.length(); | 242 int length = it.length(); |
| 243 | 243 |
| 244 // Skip some work for one-space-char hunks | 244 // Skip some work for one-space-char hunks |
| 245 if (!(length == 1 && it.characterAt(0) == ' ')) { | 245 if (!(length == 1 && it.characterAt(0) == ' ')) { |
| 246 | 246 |
| 247 int misspellingLocation = -1; | 247 int misspellingLocation = -1; |
| 248 int misspellingLength = 0; | 248 int misspellingLength = 0; |
| 249 m_client->textChecker().checkSpellingOfString(it.substring(0, length ), &misspellingLocation, &misspellingLength); | 249 m_client->textChecker().checkSpellingOfString(it.substring(0, length ), &misspellingLocation, &misspellingLength); |
| 250 | 250 |
| 251 // 5490627 shows that there was some code path here where the String constructor below crashes. | 251 // 5490627 shows that there was some code path here where the String constructor below crashes. |
| 252 // We don't know exactly what combination of bad input caused this, so we're making this much | 252 // We don't know exactly what combination of bad input caused this, so we're making this much |
| 253 // more robust against bad input on release builds. | 253 // more robust against bad input on release builds. |
| 254 ASSERT(misspellingLength >= 0); | 254 ASSERT(misspellingLength >= 0); |
| 255 ASSERT(misspellingLocation >= -1); | 255 ASSERT(misspellingLocation >= -1); |
| 256 ASSERT(!misspellingLength || misspellingLocation >= 0); | 256 ASSERT(!misspellingLength || misspellingLocation >= 0); |
| 257 ASSERT(misspellingLocation < length); | 257 ASSERT(misspellingLocation < length); |
| 258 ASSERT(misspellingLength <= length); | 258 ASSERT(misspellingLength <= length); |
| 259 ASSERT(misspellingLocation + misspellingLength <= length); | 259 ASSERT(misspellingLocation + misspellingLength <= length); |
| 260 | 260 |
| 261 if (misspellingLocation >= 0 && misspellingLength > 0 && misspelling Location < length && misspellingLength <= length && misspellingLocation + misspe llingLength <= length) { | 261 if (misspellingLocation >= 0 && misspellingLength > 0 && misspelling Location < length && misspellingLength <= length && misspellingLocation + misspe llingLength <= length) { |
| 262 | 262 |
| 263 // Compute range of misspelled word | 263 // Compute range of misspelled word |
| 264 RefPtrWillBeRawPtr<Range> misspellingRange = TextIterator::subra nge(m_range.get(), currentChunkOffset + misspellingLocation, misspellingLength); | 264 Position misspellingStart = m_start; |
| 265 Position misspellingEnd = m_end; | |
| 266 TextIterator::subrange(misspellingStart, misspellingEnd, current ChunkOffset + misspellingLocation, misspellingLength); | |
| 265 | 267 |
| 266 // Remember first-encountered misspelling and its offset. | 268 // Remember first-encountered misspelling and its offset. |
| 267 if (!firstMisspelling) { | 269 if (!firstMisspelling) { |
| 268 firstMisspellingOffset = currentChunkOffset + misspellingLoc ation; | 270 firstMisspellingOffset = currentChunkOffset + misspellingLoc ation; |
| 269 firstMisspelling = it.substring(misspellingLocation, misspel lingLength); | 271 firstMisspelling = it.substring(misspellingLocation, misspel lingLength); |
| 270 firstMisspellingRange = misspellingRange; | 272 firstMisspellingRange = Range::create(misspellingStart.conta inerNode()->document(), m_start, m_end); |
| 271 } | 273 } |
| 272 | 274 |
| 273 // Store marker for misspelled word. | 275 // Store marker for misspelled word. |
| 274 misspellingRange->startContainer()->document().markers().addMark er(misspellingRange.get(), DocumentMarker::Spelling); | 276 misspellingStart.containerNode()->document().markers().addMarker (misspellingStart, misspellingEnd, DocumentMarker::Spelling); |
| 275 | 277 |
| 276 // Bail out if we're marking only the first misspelling, and not all instances. | 278 // Bail out if we're marking only the first misspelling, and not all instances. |
| 277 if (!markAll) | 279 if (!markAll) |
| 278 break; | 280 break; |
| 279 } | 281 } |
| 280 } | 282 } |
| 281 | 283 |
| 282 currentChunkOffset += length; | 284 currentChunkOffset += length; |
| 283 it.advance(); | 285 it.advance(); |
| 284 } | 286 } |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 299 outIsSpelling = true; | 301 outIsSpelling = true; |
| 300 outFirstFoundOffset = 0; | 302 outFirstFoundOffset = 0; |
| 301 outGrammarDetail.location = -1; | 303 outGrammarDetail.location = -1; |
| 302 outGrammarDetail.length = 0; | 304 outGrammarDetail.length = 0; |
| 303 outGrammarDetail.guesses.clear(); | 305 outGrammarDetail.guesses.clear(); |
| 304 outGrammarDetail.userDescription = ""; | 306 outGrammarDetail.userDescription = ""; |
| 305 | 307 |
| 306 // Expand the search range to encompass entire paragraphs, since text checki ng needs that much context. | 308 // 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, | 309 // 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. | 310 // since we will want to ignore results in this area. |
| 309 RefPtrWillBeRawPtr<Range> paragraphRange = m_range->cloneRange(); | 311 Position paragraphStart = startOfParagraph(VisiblePosition(m_start)).toParen tAnchoredPosition(); |
| 310 setStart(paragraphRange.get(), startOfParagraph(VisiblePosition(m_range->sta rtPosition()))); | 312 Position paragraphEnd = m_end; |
| 311 int totalRangeLength = TextIterator::rangeLength(paragraphRange.get()); | 313 int totalRangeLength = TextIterator::rangeLength(paragraphStart, paragraphEn d); |
| 312 setEnd(paragraphRange.get(), endOfParagraph(VisiblePosition(m_range->startPo sition()))); | 314 paragraphEnd = endOfParagraph(VisiblePosition(m_start)).toParentAnchoredPosi tion(); |
| 313 | 315 |
| 314 RefPtrWillBeRawPtr<Range> offsetAsRange = Range::create(paragraphRange->star tContainer()->document(), paragraphRange->startPosition(), m_range->startPositio n()); | 316 int rangeStartOffset = TextIterator::rangeLength(paragraphStart, m_start); |
| 315 int rangeStartOffset = TextIterator::rangeLength(offsetAsRange.get()); | |
| 316 int totalLengthProcessed = 0; | 317 int totalLengthProcessed = 0; |
| 317 | 318 |
| 318 bool firstIteration = true; | 319 bool firstIteration = true; |
| 319 bool lastIteration = false; | 320 bool lastIteration = false; |
| 320 while (totalLengthProcessed < totalRangeLength) { | 321 while (totalLengthProcessed < totalRangeLength) { |
| 321 // Iterate through the search range by paragraphs, checking each one for spelling and grammar. | 322 // Iterate through the search range by paragraphs, checking each one for spelling and grammar. |
| 322 int currentLength = TextIterator::rangeLength(paragraphRange.get()); | 323 int currentLength = TextIterator::rangeLength(paragraphStart, paragraphE nd); |
| 323 int currentStartOffset = firstIteration ? rangeStartOffset : 0; | 324 int currentStartOffset = firstIteration ? rangeStartOffset : 0; |
| 324 int currentEndOffset = currentLength; | 325 int currentEndOffset = currentLength; |
| 325 if (inSameParagraph(VisiblePosition(paragraphRange->startPosition()), Vi siblePosition(m_range->endPosition()))) { | 326 if (inSameParagraph(VisiblePosition(paragraphStart), VisiblePosition(m_e nd))) { |
| 326 // Determine the character offset from the end of the original searc h range to the end of the paragraph, | 327 // 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. | 328 // since we will want to ignore results in this area. |
| 328 RefPtrWillBeRawPtr<Range> endOffsetAsRange = Range::create(paragraph Range->startContainer()->document(), paragraphRange->startPosition(), m_range->e ndPosition()); | 329 currentEndOffset = TextIterator::rangeLength(paragraphStart, m_end); |
| 329 currentEndOffset = TextIterator::rangeLength(endOffsetAsRange.get()) ; | |
| 330 lastIteration = true; | 330 lastIteration = true; |
| 331 } | 331 } |
| 332 if (currentStartOffset < currentEndOffset) { | 332 if (currentStartOffset < currentEndOffset) { |
| 333 String paragraphString = plainText(paragraphRange.get()); | 333 String paragraphString = plainText(paragraphStart, paragraphEnd); |
| 334 if (paragraphString.length() > 0) { | 334 if (paragraphString.length() > 0) { |
| 335 bool foundGrammar = false; | 335 bool foundGrammar = false; |
| 336 int spellingLocation = 0; | 336 int spellingLocation = 0; |
| 337 int grammarPhraseLocation = 0; | 337 int grammarPhraseLocation = 0; |
| 338 int grammarDetailLocation = 0; | 338 int grammarDetailLocation = 0; |
| 339 unsigned grammarDetailIndex = 0; | 339 unsigned grammarDetailIndex = 0; |
| 340 | 340 |
| 341 Vector<TextCheckingResult> results; | 341 Vector<TextCheckingResult> results; |
| 342 TextCheckingTypeMask checkingTypes = checkGrammar ? (TextCheckin gTypeSpelling | TextCheckingTypeGrammar) : TextCheckingTypeSpelling; | 342 TextCheckingTypeMask checkingTypes = checkGrammar ? (TextCheckin gTypeSpelling | TextCheckingTypeGrammar) : TextCheckingTypeSpelling; |
| 343 checkTextOfParagraph(m_client->textChecker(), paragraphString, c heckingTypes, results); | 343 checkTextOfParagraph(m_client->textChecker(), paragraphString, c heckingTypes, results); |
| (...skipping 26 matching lines...) Expand all Loading... | |
| 370 grammarPhraseLocation = result->location; | 370 grammarPhraseLocation = result->location; |
| 371 outGrammarDetail = result->details[grammarDetailInde x]; | 371 outGrammarDetail = result->details[grammarDetailInde x]; |
| 372 badGrammarPhrase = paragraphString.substring(result- >location, result->length); | 372 badGrammarPhrase = paragraphString.substring(result- >location, result->length); |
| 373 ASSERT(badGrammarPhrase.length()); | 373 ASSERT(badGrammarPhrase.length()); |
| 374 } | 374 } |
| 375 } | 375 } |
| 376 } | 376 } |
| 377 | 377 |
| 378 if (!misspelledWord.isEmpty() && (!checkGrammar || badGrammarPhr ase.isEmpty() || spellingLocation <= grammarDetailLocation)) { | 378 if (!misspelledWord.isEmpty() && (!checkGrammar || badGrammarPhr ase.isEmpty() || spellingLocation <= grammarDetailLocation)) { |
| 379 int spellingOffset = spellingLocation - currentStartOffset; | 379 int spellingOffset = spellingLocation - currentStartOffset; |
| 380 if (!firstIteration) { | 380 if (!firstIteration) |
| 381 RefPtrWillBeRawPtr<Range> paragraphOffsetAsRange = Range ::create(paragraphRange->startContainer()->document(), m_range->startPosition(), paragraphRange->startPosition()); | 381 spellingOffset += TextIterator::rangeLength(m_start, par agraphStart); |
| 382 spellingOffset += TextIterator::rangeLength(paragraphOff setAsRange.get()); | |
| 383 } | |
| 384 outIsSpelling = true; | 382 outIsSpelling = true; |
| 385 outFirstFoundOffset = spellingOffset; | 383 outFirstFoundOffset = spellingOffset; |
| 386 firstFoundItem = misspelledWord; | 384 firstFoundItem = misspelledWord; |
| 387 break; | 385 break; |
| 388 } | 386 } |
| 389 if (checkGrammar && !badGrammarPhrase.isEmpty()) { | 387 if (checkGrammar && !badGrammarPhrase.isEmpty()) { |
| 390 int grammarPhraseOffset = grammarPhraseLocation - currentSta rtOffset; | 388 int grammarPhraseOffset = grammarPhraseLocation - currentSta rtOffset; |
| 391 if (!firstIteration) { | 389 if (!firstIteration) |
| 392 RefPtrWillBeRawPtr<Range> paragraphOffsetAsRange = Range ::create(paragraphRange->startContainer()->document(), m_range->startPosition(), paragraphRange->startPosition()); | 390 grammarPhraseOffset += TextIterator::rangeLength(m_start , paragraphStart); |
| 393 grammarPhraseOffset += TextIterator::rangeLength(paragra phOffsetAsRange.get()); | |
| 394 } | |
| 395 outIsSpelling = false; | 391 outIsSpelling = false; |
| 396 outFirstFoundOffset = grammarPhraseOffset; | 392 outFirstFoundOffset = grammarPhraseOffset; |
| 397 firstFoundItem = badGrammarPhrase; | 393 firstFoundItem = badGrammarPhrase; |
| 398 break; | 394 break; |
| 399 } | 395 } |
| 400 } | 396 } |
| 401 } | 397 } |
| 402 if (lastIteration || totalLengthProcessed + currentLength >= totalRangeL ength) | 398 if (lastIteration || totalLengthProcessed + currentLength >= totalRangeL ength) |
| 403 break; | 399 break; |
| 404 VisiblePosition newParagraphStart = startOfNextParagraph(VisiblePosition (paragraphRange->endPosition())); | 400 VisiblePosition newParagraphStart = startOfNextParagraph(VisiblePosition (paragraphEnd)); |
| 405 setStart(paragraphRange.get(), newParagraphStart); | 401 paragraphStart = newParagraphStart.toParentAnchoredPosition(); |
| 406 setEnd(paragraphRange.get(), endOfParagraph(newParagraphStart)); | 402 paragraphEnd = endOfParagraph(newParagraphStart).toParentAnchoredPositio n(); |
| 407 firstIteration = false; | 403 firstIteration = false; |
| 408 totalLengthProcessed += currentLength; | 404 totalLengthProcessed += currentLength; |
| 409 } | 405 } |
| 410 return firstFoundItem; | 406 return firstFoundItem; |
| 411 } | 407 } |
| 412 | 408 |
| 413 int TextCheckingHelper::findFirstGrammarDetail(const Vector<GrammarDetail>& gram marDetails, int badGrammarPhraseLocation, int startOffset, int endOffset, bool m arkAll) const | 409 int TextCheckingHelper::findFirstGrammarDetail(const Vector<GrammarDetail>& gram marDetails, int badGrammarPhraseLocation, int startOffset, int endOffset, bool m arkAll) const |
| 414 { | 410 { |
| 415 // Found some bad grammar. Find the earliest detail range that starts in our search range (if any). | 411 // Found some bad grammar. Find the earliest detail range that starts in our search range (if any). |
| 416 // Optionally add a DocumentMarker for each detail in the range. | 412 // Optionally add a DocumentMarker for each detail in the range. |
| 417 int earliestDetailLocationSoFar = -1; | 413 int earliestDetailLocationSoFar = -1; |
| 418 int earliestDetailIndex = -1; | 414 int earliestDetailIndex = -1; |
| 419 for (unsigned i = 0; i < grammarDetails.size(); i++) { | 415 for (unsigned i = 0; i < grammarDetails.size(); i++) { |
| 420 const GrammarDetail* detail = &grammarDetails[i]; | 416 const GrammarDetail* detail = &grammarDetails[i]; |
| 421 ASSERT(detail->length > 0 && detail->location >= 0); | 417 ASSERT(detail->length > 0 && detail->location >= 0); |
| 422 | 418 |
| 423 int detailStartOffsetInParagraph = badGrammarPhraseLocation + detail->lo cation; | 419 int detailStartOffsetInParagraph = badGrammarPhraseLocation + detail->lo cation; |
| 424 | 420 |
| 425 // Skip this detail if it starts before the original search range | 421 // Skip this detail if it starts before the original search range |
| 426 if (detailStartOffsetInParagraph < startOffset) | 422 if (detailStartOffsetInParagraph < startOffset) |
| 427 continue; | 423 continue; |
| 428 | 424 |
| 429 // Skip this detail if it starts after the original search range | 425 // Skip this detail if it starts after the original search range |
| 430 if (detailStartOffsetInParagraph >= endOffset) | 426 if (detailStartOffsetInParagraph >= endOffset) |
| 431 continue; | 427 continue; |
| 432 | 428 |
| 433 if (markAll) { | 429 if (markAll) { |
| 434 RefPtrWillBeRawPtr<Range> badGrammarRange = TextIterator::subrange(m _range.get(), badGrammarPhraseLocation - startOffset + detail->location, detail- >length); | 430 Position badGrammarStart = m_start; |
| 435 badGrammarRange->startContainer()->document().markers().addMarker(ba dGrammarRange.get(), DocumentMarker::Grammar, detail->userDescription); | 431 Position badGrammarEnd = m_end; |
| 432 TextIterator::subrange(badGrammarStart, badGrammarEnd, badGrammarPhr aseLocation - startOffset + detail->location, detail->length); | |
| 433 badGrammarStart.containerNode()->document().markers().addMarker(badG rammarStart, badGrammarEnd, DocumentMarker::Grammar, detail->userDescription); | |
| 436 } | 434 } |
| 437 | 435 |
| 438 // Remember this detail only if it's earlier than our current candidate (the details aren't in a guaranteed order) | 436 // 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) { | 437 if (earliestDetailIndex < 0 || earliestDetailLocationSoFar > detail->loc ation) { |
| 440 earliestDetailIndex = i; | 438 earliestDetailIndex = i; |
| 441 earliestDetailLocationSoFar = detail->location; | 439 earliestDetailLocationSoFar = detail->location; |
| 442 } | 440 } |
| 443 } | 441 } |
| 444 | 442 |
| 445 return earliestDetailIndex; | 443 return earliestDetailIndex; |
| 446 } | 444 } |
| 447 | 445 |
| 448 String TextCheckingHelper::findFirstBadGrammar(GrammarDetail& outGrammarDetail, int& outGrammarPhraseOffset, bool markAll) | 446 String TextCheckingHelper::findFirstBadGrammar(GrammarDetail& outGrammarDetail, int& outGrammarPhraseOffset, bool markAll) |
| 449 { | 447 { |
| 450 // Initialize out parameters; these will be updated if we find something to return. | 448 // Initialize out parameters; these will be updated if we find something to return. |
| 451 outGrammarDetail.location = -1; | 449 outGrammarDetail.location = -1; |
| 452 outGrammarDetail.length = 0; | 450 outGrammarDetail.length = 0; |
| 453 outGrammarDetail.guesses.clear(); | 451 outGrammarDetail.guesses.clear(); |
| 454 outGrammarDetail.userDescription = ""; | 452 outGrammarDetail.userDescription = ""; |
| 455 outGrammarPhraseOffset = 0; | 453 outGrammarPhraseOffset = 0; |
| 456 | 454 |
| 457 String firstBadGrammarPhrase; | 455 String firstBadGrammarPhrase; |
| 458 | 456 |
| 459 // Expand the search range to encompass entire paragraphs, since grammar che cking needs that much context. | 457 // Expand the search range to encompass entire paragraphs, since grammar che cking needs that much context. |
| 460 // Determine the character offset from the start of the paragraph to the sta rt of the original search range, | 458 // Determine the character offset from the start of the paragraph to the sta rt of the original search range, |
| 461 // since we will want to ignore results in this area. | 459 // since we will want to ignore results in this area. |
| 462 TextCheckingParagraph paragraph(m_range); | 460 TextCheckingParagraph paragraph(Range::create(m_start.containerNode()->docum ent(), m_start, m_end)); |
| 463 | 461 |
| 464 // Start checking from beginning of paragraph, but skip past results that oc cur before the start of the original search range. | 462 // Start checking from beginning of paragraph, but skip past results that oc cur before the start of the original search range. |
| 465 int startOffset = 0; | 463 int startOffset = 0; |
| 466 while (startOffset < paragraph.checkingEnd()) { | 464 while (startOffset < paragraph.checkingEnd()) { |
| 467 Vector<GrammarDetail> grammarDetails; | 465 Vector<GrammarDetail> grammarDetails; |
| 468 int badGrammarPhraseLocation = -1; | 466 int badGrammarPhraseLocation = -1; |
| 469 int badGrammarPhraseLength = 0; | 467 int badGrammarPhraseLength = 0; |
| 470 m_client->textChecker().checkGrammarOfString(paragraph.textSubstring(sta rtOffset), grammarDetails, &badGrammarPhraseLocation, &badGrammarPhraseLength); | 468 m_client->textChecker().checkGrammarOfString(paragraph.textSubstring(sta rtOffset), grammarDetails, &badGrammarPhraseLocation, &badGrammarPhraseLength); |
| 471 | 469 |
| 472 if (!badGrammarPhraseLength) { | 470 if (!badGrammarPhraseLength) { |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 516 { | 514 { |
| 517 // Use the "markAll" feature of ofindFirstBadGrammar. Ignore the return valu e and "out parameters"; all we need to | 515 // Use the "markAll" feature of ofindFirstBadGrammar. Ignore the return valu e and "out parameters"; all we need to |
| 518 // do is mark every instance. | 516 // do is mark every instance. |
| 519 GrammarDetail ignoredGrammarDetail; | 517 GrammarDetail ignoredGrammarDetail; |
| 520 int ignoredOffset; | 518 int ignoredOffset; |
| 521 findFirstBadGrammar(ignoredGrammarDetail, ignoredOffset, true); | 519 findFirstBadGrammar(ignoredGrammarDetail, ignoredOffset, true); |
| 522 } | 520 } |
| 523 | 521 |
| 524 bool TextCheckingHelper::unifiedTextCheckerEnabled() const | 522 bool TextCheckingHelper::unifiedTextCheckerEnabled() const |
| 525 { | 523 { |
| 526 if (!m_range) | 524 Document& doc = m_start.containerNode()->document(); |
|
yosin_UTC9
2014/09/18 01:08:52
Since, |m_start.m_anchorNode| can be null. Could y
Mads Ager (chromium)
2014/09/18 06:58:49
Done.
| |
| 527 return false; | |
| 528 | |
| 529 Document& doc = m_range->ownerDocument(); | |
| 530 return blink::unifiedTextCheckerEnabled(doc.frame()); | 525 return blink::unifiedTextCheckerEnabled(doc.frame()); |
| 531 } | 526 } |
| 532 | 527 |
| 533 void checkTextOfParagraph(TextCheckerClient& client, const String& text, TextChe ckingTypeMask checkingTypes, Vector<TextCheckingResult>& results) | 528 void checkTextOfParagraph(TextCheckerClient& client, const String& text, TextChe ckingTypeMask checkingTypes, Vector<TextCheckingResult>& results) |
| 534 { | 529 { |
| 535 Vector<UChar> characters; | 530 Vector<UChar> characters; |
| 536 text.appendTo(characters); | 531 text.appendTo(characters); |
| 537 unsigned length = text.length(); | 532 unsigned length = text.length(); |
| 538 | 533 |
| 539 Vector<TextCheckingResult> spellingResult; | 534 Vector<TextCheckingResult> spellingResult; |
| (...skipping 29 matching lines...) Expand all Loading... | |
| 569 return false; | 564 return false; |
| 570 | 565 |
| 571 const Settings* settings = frame->settings(); | 566 const Settings* settings = frame->settings(); |
| 572 if (!settings) | 567 if (!settings) |
| 573 return false; | 568 return false; |
| 574 | 569 |
| 575 return settings->unifiedTextCheckerEnabled(); | 570 return settings->unifiedTextCheckerEnabled(); |
| 576 } | 571 } |
| 577 | 572 |
| 578 } | 573 } |
| OLD | NEW |