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 392 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
403 break; | 403 break; |
404 VisiblePosition newParagraphStart = startOfNextParagraph(paragraphRange-
>endPosition()); | 404 VisiblePosition newParagraphStart = startOfNextParagraph(paragraphRange-
>endPosition()); |
405 setStart(paragraphRange.get(), newParagraphStart); | 405 setStart(paragraphRange.get(), newParagraphStart); |
406 setEnd(paragraphRange.get(), endOfParagraph(newParagraphStart)); | 406 setEnd(paragraphRange.get(), endOfParagraph(newParagraphStart)); |
407 firstIteration = false; | 407 firstIteration = false; |
408 totalLengthProcessed += currentLength; | 408 totalLengthProcessed += currentLength; |
409 } | 409 } |
410 return firstFoundItem; | 410 return firstFoundItem; |
411 } | 411 } |
412 | 412 |
413 int TextCheckingHelper::findFirstGrammarDetail(const Vector<GrammarDetail>& gram
marDetails, int badGrammarPhraseLocation, int /*badGrammarPhraseLength*/, int st
artOffset, int endOffset, bool markAll) | 413 int TextCheckingHelper::findFirstGrammarDetail(const Vector<GrammarDetail>& gram
marDetails, int badGrammarPhraseLocation, int startOffset, int endOffset, bool m
arkAll) const |
414 { | 414 { |
415 // Found some bad grammar. Find the earliest detail range that starts in our
search range (if any). | 415 // 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. | 416 // Optionally add a DocumentMarker for each detail in the range. |
417 int earliestDetailLocationSoFar = -1; | 417 int earliestDetailLocationSoFar = -1; |
418 int earliestDetailIndex = -1; | 418 int earliestDetailIndex = -1; |
419 for (unsigned i = 0; i < grammarDetails.size(); i++) { | 419 for (unsigned i = 0; i < grammarDetails.size(); i++) { |
420 const GrammarDetail* detail = &grammarDetails[i]; | 420 const GrammarDetail* detail = &grammarDetails[i]; |
421 ASSERT(detail->length > 0 && detail->location >= 0); | 421 ASSERT(detail->length > 0 && detail->location >= 0); |
422 | 422 |
423 int detailStartOffsetInParagraph = badGrammarPhraseLocation + detail->lo
cation; | 423 int detailStartOffsetInParagraph = badGrammarPhraseLocation + detail->lo
cation; |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
472 if (!badGrammarPhraseLength) { | 472 if (!badGrammarPhraseLength) { |
473 ASSERT(badGrammarPhraseLocation == -1); | 473 ASSERT(badGrammarPhraseLocation == -1); |
474 return String(); | 474 return String(); |
475 } | 475 } |
476 | 476 |
477 ASSERT(badGrammarPhraseLocation >= 0); | 477 ASSERT(badGrammarPhraseLocation >= 0); |
478 badGrammarPhraseLocation += startOffset; | 478 badGrammarPhraseLocation += startOffset; |
479 | 479 |
480 | 480 |
481 // Found some bad grammar. Find the earliest detail range that starts in
our search range (if any). | 481 // Found some bad grammar. Find the earliest detail range that starts in
our search range (if any). |
482 int badGrammarIndex = findFirstGrammarDetail(grammarDetails, badGrammarP
hraseLocation, badGrammarPhraseLength, paragraph.checkingStart(), paragraph.chec
kingEnd(), markAll); | 482 int badGrammarIndex = findFirstGrammarDetail(grammarDetails, badGrammarP
hraseLocation, paragraph.checkingStart(), paragraph.checkingEnd(), markAll); |
483 if (badGrammarIndex >= 0) { | 483 if (badGrammarIndex >= 0) { |
484 ASSERT(static_cast<unsigned>(badGrammarIndex) < grammarDetails.size(
)); | 484 ASSERT(static_cast<unsigned>(badGrammarIndex) < grammarDetails.size(
)); |
485 outGrammarDetail = grammarDetails[badGrammarIndex]; | 485 outGrammarDetail = grammarDetails[badGrammarIndex]; |
486 } | 486 } |
487 | 487 |
488 // If we found a detail in range, then we have found the first bad phras
e (unless we found one earlier but | 488 // If we found a detail in range, then we have found the first bad phras
e (unless we found one earlier but |
489 // kept going so we could mark all instances). | 489 // kept going so we could mark all instances). |
490 if (badGrammarIndex >= 0 && firstBadGrammarPhrase.isEmpty()) { | 490 if (badGrammarIndex >= 0 && firstBadGrammarPhrase.isEmpty()) { |
491 outGrammarPhraseOffset = badGrammarPhraseLocation - paragraph.checki
ngStart(); | 491 outGrammarPhraseOffset = badGrammarPhraseLocation - paragraph.checki
ngStart(); |
492 firstBadGrammarPhrase = paragraph.textSubstring(badGrammarPhraseLoca
tion, badGrammarPhraseLength); | 492 firstBadGrammarPhrase = paragraph.textSubstring(badGrammarPhraseLoca
tion, badGrammarPhraseLength); |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
572 return false; | 572 return false; |
573 | 573 |
574 const Settings* settings = frame->settings(); | 574 const Settings* settings = frame->settings(); |
575 if (!settings) | 575 if (!settings) |
576 return false; | 576 return false; |
577 | 577 |
578 return settings->unifiedTextCheckerEnabled(); | 578 return settings->unifiedTextCheckerEnabled(); |
579 } | 579 } |
580 | 580 |
581 } | 581 } |
OLD | NEW |