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

Side by Side Diff: third_party/WebKit/Source/core/editing/spellcheck/SpellChecker.cpp

Issue 2252973002: Remove m_paragraphRange from SpellCheckRequest (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@SpellCheckerDebugInfo
Patch Set: Rebased Created 4 years, 4 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
« no previous file with comments | « third_party/WebKit/Source/core/editing/spellcheck/SpellCheckRequester.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 371 matching lines...) Expand 10 before | Expand all | Expand 10 after
382 if (fullParagraphToCheck.isEmpty()) 382 if (fullParagraphToCheck.isEmpty())
383 return; 383 return;
384 const EphemeralRange& paragraphRange = fullParagraphToCheck.paragraphRange() ; 384 const EphemeralRange& paragraphRange = fullParagraphToCheck.paragraphRange() ;
385 385
386 // Since the text may be quite big chunk it up and adjust to the sentence bo undary. 386 // Since the text may be quite big chunk it up and adjust to the sentence bo undary.
387 const int kChunkSize = 16 * 1024; 387 const int kChunkSize = 16 * 1024;
388 388
389 // Check the full paragraph instead if the paragraph is short, which saves 389 // Check the full paragraph instead if the paragraph is short, which saves
390 // the cost on sentence boundary finding. 390 // the cost on sentence boundary finding.
391 if (fullParagraphToCheck.rangeLength() <= kChunkSize) { 391 if (fullParagraphToCheck.rangeLength() <= kChunkSize) {
392 SpellCheckRequest* request = SpellCheckRequest::create(TextCheckingProce ssBatch, paragraphRange, paragraphRange, 0); 392 SpellCheckRequest* request = SpellCheckRequest::create(TextCheckingProce ssBatch, paragraphRange, 0);
393 if (request) 393 if (request)
394 m_spellCheckRequester->requestCheckingFor(request); 394 m_spellCheckRequester->requestCheckingFor(request);
395 return; 395 return;
396 } 396 }
397 397
398 CharacterIterator checkRangeIterator(fullParagraphToCheck.checkingRange(), T extIteratorEmitsObjectReplacementCharacter); 398 CharacterIterator checkRangeIterator(fullParagraphToCheck.checkingRange(), T extIteratorEmitsObjectReplacementCharacter);
399 for (int requestNum = 0; !checkRangeIterator.atEnd(); requestNum++) { 399 for (int requestNum = 0; !checkRangeIterator.atEnd(); requestNum++) {
400 EphemeralRange chunkRange = checkRangeIterator.calculateCharacterSubrang e(0, kChunkSize); 400 EphemeralRange chunkRange = checkRangeIterator.calculateCharacterSubrang e(0, kChunkSize);
401 EphemeralRange checkRange = requestNum ? expandEndToSentenceBoundary(chu nkRange) : expandRangeToSentenceBoundary(chunkRange); 401 EphemeralRange checkRange = requestNum ? expandEndToSentenceBoundary(chu nkRange) : expandRangeToSentenceBoundary(chunkRange);
402 402
403 SpellCheckRequest* request = SpellCheckRequest::create(TextCheckingProce ssBatch, checkRange, paragraphRange, requestNum); 403 SpellCheckRequest* request = SpellCheckRequest::create(TextCheckingProce ssBatch, checkRange, requestNum);
404 if (request) 404 if (request)
405 m_spellCheckRequester->requestCheckingFor(request); 405 m_spellCheckRequester->requestCheckingFor(request);
406 406
407 if (!checkRangeIterator.atEnd()) { 407 if (!checkRangeIterator.atEnd()) {
408 checkRangeIterator.advance(1); 408 checkRangeIterator.advance(1);
409 // The layout should be already update due to the initialization of checkRangeIterator, 409 // The layout should be already update due to the initialization of checkRangeIterator,
410 // so comparePositions can be directly called. 410 // so comparePositions can be directly called.
411 if (comparePositions(chunkRange.endPosition(), checkRange.endPositio n()) < 0) 411 if (comparePositions(chunkRange.endPosition(), checkRange.endPositio n()) < 0)
412 checkRangeIterator.advance(TextIterator::rangeLength(chunkRange. endPosition(), checkRange.endPosition())); 412 checkRangeIterator.advance(TextIterator::rangeLength(chunkRange. endPosition(), checkRange.endPosition()));
413 } 413 }
414 } 414 }
415 } 415 }
416 416
417 void SpellChecker::markAndReplaceFor(SpellCheckRequest* request, const Vector<Te xtCheckingResult>& results) 417 void SpellChecker::markAndReplaceFor(SpellCheckRequest* request, const Vector<Te xtCheckingResult>& results)
418 { 418 {
419 TRACE_EVENT0("blink", "SpellChecker::markAndReplaceFor"); 419 TRACE_EVENT0("blink", "SpellChecker::markAndReplaceFor");
420 DCHECK(request); 420 DCHECK(request);
421 if (!frame().selection().isAvailable()) { 421 if (!frame().selection().isAvailable()) {
422 // "editing/spelling/spellcheck-async-remove-frame.html" reaches here. 422 // "editing/spelling/spellcheck-async-remove-frame.html" reaches here.
423 return; 423 return;
424 } 424 }
425 if (!request->isValid()) 425 if (!request->isValid())
426 return; 426 return;
427 if (request->rootEditableElement()->document() != frame().selection().docume nt()) { 427 if (request->rootEditableElement()->document() != frame().selection().docume nt()) {
428 // we ignore |request| made for another document. 428 // we ignore |request| made for another document.
429 // "editing/spelling/spellcheck-sequencenum.html" and others reach here. 429 // "editing/spelling/spellcheck-sequencenum.html" and others reach here.
430 return; 430 return;
431 } 431 }
432 432
433 TextCheckingParagraph paragraph(request->checkingRange(), request->paragraph Range()); 433 TextCheckingParagraph paragraph(request->checkingRange(), request->checkingR ange());
434 434
435 // Expand the range to encompass entire paragraphs, since text checking need s that much context. 435 // Expand the range to encompass entire paragraphs, since text checking need s that much context.
436 int selectionOffset = 0; 436 int selectionOffset = 0;
437 int ambiguousBoundaryOffset = -1; 437 int ambiguousBoundaryOffset = -1;
438 bool selectionChanged = false; 438 bool selectionChanged = false;
439 bool restoreSelectionAfterChange = false; 439 bool restoreSelectionAfterChange = false;
440 bool adjustSelectionForParagraphBoundaries = false; 440 bool adjustSelectionForParagraphBoundaries = false;
441 441
442 if (frame().selection().isCaret()) { 442 if (frame().selection().isCaret()) {
443 // Attempt to save the caret position so we can restore it later if need ed 443 // Attempt to save the caret position so we can restore it later if need ed
(...skipping 324 matching lines...) Expand 10 before | Expand all | Expand 10 after
768 } 768 }
769 769
770 void SpellChecker::cancelCheck() 770 void SpellChecker::cancelCheck()
771 { 771 {
772 m_spellCheckRequester->cancelCheck(); 772 m_spellCheckRequester->cancelCheck();
773 } 773 }
774 774
775 void SpellChecker::requestTextChecking(const Element& element) 775 void SpellChecker::requestTextChecking(const Element& element)
776 { 776 {
777 const EphemeralRange rangeToCheck = EphemeralRange::rangeOfContents(element) ; 777 const EphemeralRange rangeToCheck = EphemeralRange::rangeOfContents(element) ;
778 m_spellCheckRequester->requestCheckingFor(SpellCheckRequest::create(TextChec kingProcessBatch, rangeToCheck, rangeToCheck)); 778 m_spellCheckRequester->requestCheckingFor(SpellCheckRequest::create(TextChec kingProcessBatch, rangeToCheck));
779 } 779 }
780 780
781 DEFINE_TRACE(SpellChecker) 781 DEFINE_TRACE(SpellChecker)
782 { 782 {
783 visitor->trace(m_frame); 783 visitor->trace(m_frame);
784 visitor->trace(m_spellCheckRequester); 784 visitor->trace(m_spellCheckRequester);
785 } 785 }
786 786
787 void SpellChecker::prepareForLeakDetection() 787 void SpellChecker::prepareForLeakDetection()
788 { 788 {
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
889 VisiblePosition newParagraphStart = startOfNextParagraph(createVisiblePo sition(paragraphEnd)); 889 VisiblePosition newParagraphStart = startOfNextParagraph(createVisiblePo sition(paragraphEnd));
890 paragraphStart = newParagraphStart.toParentAnchoredPosition(); 890 paragraphStart = newParagraphStart.toParentAnchoredPosition();
891 paragraphEnd = endOfParagraph(newParagraphStart).toParentAnchoredPositio n(); 891 paragraphEnd = endOfParagraph(newParagraphStart).toParentAnchoredPositio n();
892 firstIteration = false; 892 firstIteration = false;
893 totalLengthProcessed += currentLength; 893 totalLengthProcessed += currentLength;
894 } 894 }
895 return std::make_pair(firstFoundItem, firstFoundOffset); 895 return std::make_pair(firstFoundItem, firstFoundOffset);
896 } 896 }
897 897
898 } // namespace blink 898 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/editing/spellcheck/SpellCheckRequester.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698