OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (C) 2006, 2007, 2008, 2011 Apple Inc. All rights reserved. | 2 * Copyright (C) 2006, 2007, 2008, 2011 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 499 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
510 | 510 |
511 // Since the text may be quite big chunk it up and adjust to the sentence bo undary. | 511 // Since the text may be quite big chunk it up and adjust to the sentence bo undary. |
512 const int kChunkSize = 16 * 1024; | 512 const int kChunkSize = 16 * 1024; |
513 int start = fullParagraphToCheck.checkingStart(); | 513 int start = fullParagraphToCheck.checkingStart(); |
514 int end = fullParagraphToCheck.checkingEnd(); | 514 int end = fullParagraphToCheck.checkingEnd(); |
515 start = std::min(start, end); | 515 start = std::min(start, end); |
516 end = std::max(start, end); | 516 end = std::max(start, end); |
517 const int kNumChunksToCheck = asynchronous ? (end - start + kChunkSize - 1) / (kChunkSize) : 1; | 517 const int kNumChunksToCheck = asynchronous ? (end - start + kChunkSize - 1) / (kChunkSize) : 1; |
518 int currentChunkStart = start; | 518 int currentChunkStart = start; |
519 if (kNumChunksToCheck == 1 && asynchronous) { | 519 if (kNumChunksToCheck == 1 && asynchronous) { |
520 EphemeralRange checkRange = fullParagraphToCheck.checkingRange(); | 520 const EphemeralRange checkRange = fullParagraphToCheck.checkingRange(); |
yosin_UTC9
2015/09/26 04:56:00
nit: better in another patch.
Sorry, I forgot to a
sof
2015/09/26 06:59:44
A minor tidyup in any case, but reverted it from t
| |
521 markAllMisspellingsAndBadGrammarInRanges(textCheckingOptions, checkRange , checkRange, asynchronous, 0); | 521 markAllMisspellingsAndBadGrammarInRanges(textCheckingOptions, checkRange , checkRange, asynchronous, 0); |
522 return; | 522 return; |
523 } | 523 } |
524 | 524 |
525 for (int iter = 0; iter < kNumChunksToCheck; ++iter) { | 525 for (int iter = 0; iter < kNumChunksToCheck; ++iter) { |
526 EphemeralRange checkRange = expandRangeToSentenceBoundary(fullParagraphT oCheck.subrange(currentChunkStart, kChunkSize)); | 526 const EphemeralRange checkRange = expandRangeToSentenceBoundary(fullPara graphToCheck.subrange(currentChunkStart, kChunkSize)); |
yosin_UTC9
2015/09/26 04:55:59
nit: better in another patch.
Sorry, I forgot to a
sof
2015/09/26 06:59:43
Same.
| |
527 | 527 |
528 int checkingLength = 0; | 528 int checkingLength = 0; |
529 markAllMisspellingsAndBadGrammarInRanges(textCheckingOptions, checkRange , checkRange, asynchronous, iter, &checkingLength); | 529 markAllMisspellingsAndBadGrammarInRanges(textCheckingOptions, checkRange , checkRange, asynchronous, iter, &checkingLength); |
530 currentChunkStart += checkingLength; | 530 currentChunkStart += checkingLength; |
531 } | 531 } |
532 } | 532 } |
533 | 533 |
534 void SpellChecker::markAllMisspellingsAndBadGrammarInRanges(TextCheckingTypeMask textCheckingOptions, const EphemeralRange& checkRange, const EphemeralRange& pa ragraphRange, bool asynchronous, int requestNumber, int* checkingLength) | 534 void SpellChecker::markAllMisspellingsAndBadGrammarInRanges(TextCheckingTypeMask textCheckingOptions, const EphemeralRange& checkRange, const EphemeralRange& pa ragraphRange, bool asynchronous, int requestNumber, int* checkingLength) |
535 { | 535 { |
536 TextCheckingParagraph sentenceToCheck(checkRange, paragraphRange); | 536 TextCheckingParagraph sentenceToCheck(checkRange, paragraphRange); |
537 if (checkingLength) | 537 if (checkingLength) |
538 *checkingLength = sentenceToCheck.checkingLength(); | 538 *checkingLength = sentenceToCheck.checkingLength(); |
539 | 539 |
540 RefPtrWillBeRawPtr<SpellCheckRequest> request = SpellCheckRequest::create(re solveTextCheckingTypeMask(textCheckingOptions), TextCheckingProcessBatch, create Range(checkRange), createRange(paragraphRange), requestNumber); | 540 RefPtrWillBeRawPtr<Range> checkRangeObject = createRange(checkRange); |
541 RefPtrWillBeRawPtr<Range> paragraphRangeObject = (checkRange == paragraphRan ge) ? checkRangeObject.get() : createRange(paragraphRange).get(); | |
542 RefPtrWillBeRawPtr<SpellCheckRequest> request = SpellCheckRequest::create(re solveTextCheckingTypeMask(textCheckingOptions), TextCheckingProcessBatch, checkR angeObject, paragraphRangeObject, requestNumber); | |
yosin_UTC9
2015/09/26 04:55:59
Could you do this in |SpellCheckRequest::create()|
sof
2015/09/26 06:59:44
That's well worthwhile, pushed the Range conversio
| |
541 if (!request) | 543 if (!request) |
542 return; | 544 return; |
543 | 545 |
544 if (asynchronous) { | 546 if (asynchronous) { |
545 m_spellCheckRequester->requestCheckingFor(request); | 547 m_spellCheckRequester->requestCheckingFor(request); |
546 return; | 548 return; |
547 } | 549 } |
548 | 550 |
549 Vector<TextCheckingResult> results; | 551 Vector<TextCheckingResult> results; |
550 checkTextOfParagraph(textChecker(), sentenceToCheck.text(), resolveTextCheck ingTypeMask(textCheckingOptions), results); | 552 checkTextOfParagraph(textChecker(), sentenceToCheck.text(), resolveTextCheck ingTypeMask(textCheckingOptions), results); |
(...skipping 384 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
935 m_spellCheckRequester->requestCheckingFor(SpellCheckRequest::create(TextChec kingTypeSpelling | TextCheckingTypeGrammar, TextCheckingProcessBatch, rangeToChe ck, rangeToCheck)); | 937 m_spellCheckRequester->requestCheckingFor(SpellCheckRequest::create(TextChec kingTypeSpelling | TextCheckingTypeGrammar, TextCheckingProcessBatch, rangeToChe ck, rangeToCheck)); |
936 } | 938 } |
937 | 939 |
938 DEFINE_TRACE(SpellChecker) | 940 DEFINE_TRACE(SpellChecker) |
939 { | 941 { |
940 visitor->trace(m_frame); | 942 visitor->trace(m_frame); |
941 visitor->trace(m_spellCheckRequester); | 943 visitor->trace(m_spellCheckRequester); |
942 } | 944 } |
943 | 945 |
944 } // namespace blink | 946 } // namespace blink |
OLD | NEW |