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

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

Issue 2740603003: Hide SpellCheckRequest from other classes in editing/spellcheck (Closed)
Patch Set: Created 3 years, 9 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, 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 482 matching lines...) Expand 10 before | Expand all | Expand 10 after
493 return; 493 return;
494 const EphemeralRange& paragraphRange = fullParagraphToCheck.paragraphRange(); 494 const EphemeralRange& paragraphRange = fullParagraphToCheck.paragraphRange();
495 495
496 // Since the text may be quite big chunk it up and adjust to the sentence 496 // Since the text may be quite big chunk it up and adjust to the sentence
497 // boundary. 497 // boundary.
498 const int kChunkSize = 16 * 1024; 498 const int kChunkSize = 16 * 1024;
499 499
500 // Check the full paragraph instead if the paragraph is short, which saves 500 // Check the full paragraph instead if the paragraph is short, which saves
501 // the cost on sentence boundary finding. 501 // the cost on sentence boundary finding.
502 if (fullParagraphToCheck.rangeLength() <= kChunkSize) { 502 if (fullParagraphToCheck.rangeLength() <= kChunkSize) {
503 SpellCheckRequest* request = SpellCheckRequest::create(paragraphRange, 0); 503 m_spellCheckRequester->requestCheckingFor(paragraphRange);
504 if (request)
505 m_spellCheckRequester->requestCheckingFor(request);
506 return; 504 return;
507 } 505 }
508 506
509 CharacterIterator checkRangeIterator( 507 CharacterIterator checkRangeIterator(
510 fullParagraphToCheck.checkingRange(), 508 fullParagraphToCheck.checkingRange(),
511 TextIteratorBehavior::Builder() 509 TextIteratorBehavior::Builder()
512 .setEmitsObjectReplacementCharacter(true) 510 .setEmitsObjectReplacementCharacter(true)
513 .build()); 511 .build());
514 for (int requestNum = 0; !checkRangeIterator.atEnd(); requestNum++) { 512 for (int requestNum = 0; !checkRangeIterator.atEnd(); requestNum++) {
515 EphemeralRange chunkRange = 513 EphemeralRange chunkRange =
516 checkRangeIterator.calculateCharacterSubrange(0, kChunkSize); 514 checkRangeIterator.calculateCharacterSubrange(0, kChunkSize);
517 EphemeralRange checkRange = requestNum 515 EphemeralRange checkRange = requestNum
518 ? expandEndToSentenceBoundary(chunkRange) 516 ? expandEndToSentenceBoundary(chunkRange)
519 : expandRangeToSentenceBoundary(chunkRange); 517 : expandRangeToSentenceBoundary(chunkRange);
520 518
521 SpellCheckRequest* request = 519 m_spellCheckRequester->requestCheckingFor(checkRange, requestNum);
522 SpellCheckRequest::create(checkRange, requestNum);
523 if (request)
524 m_spellCheckRequester->requestCheckingFor(request);
525 520
526 if (!checkRangeIterator.atEnd()) { 521 if (!checkRangeIterator.atEnd()) {
527 checkRangeIterator.advance(1); 522 checkRangeIterator.advance(1);
528 // The layout should be already update due to the initialization of 523 // The layout should be already update due to the initialization of
529 // checkRangeIterator, so comparePositions can be directly called. 524 // checkRangeIterator, so comparePositions can be directly called.
530 if (comparePositions(chunkRange.endPosition(), checkRange.endPosition()) < 525 if (comparePositions(chunkRange.endPosition(), checkRange.endPosition()) <
531 0) 526 0)
532 checkRangeIterator.advance(TextIterator::rangeLength( 527 checkRangeIterator.advance(TextIterator::rangeLength(
533 chunkRange.endPosition(), checkRange.endPosition())); 528 chunkRange.endPosition(), checkRange.endPosition()));
534 } 529 }
(...skipping 666 matching lines...) Expand 10 before | Expand all | Expand 10 after
1201 if (!input.isFocusedElementInDocument()) 1196 if (!input.isFocusedElementInDocument())
1202 return false; 1197 return false;
1203 } 1198 }
1204 } 1199 }
1205 HTMLElement* element = 1200 HTMLElement* element =
1206 Traversal<HTMLElement>::firstAncestorOrSelf(*position.anchorNode()); 1201 Traversal<HTMLElement>::firstAncestorOrSelf(*position.anchorNode());
1207 return element && element->isSpellCheckingEnabled(); 1202 return element && element->isSpellCheckingEnabled();
1208 } 1203 }
1209 1204
1210 } // namespace blink 1205 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698