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

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

Issue 2734393003: Correct usage of text iterator in idle time spellchecker (Closed)
Patch Set: Remove TODO 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
« no previous file with comments | « no previous file | 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 // Copyright 2017 The Chromium Authors. All rights reserved. 1 // Copyright 2017 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "core/editing/spellcheck/HotModeSpellCheckRequester.h" 5 #include "core/editing/spellcheck/HotModeSpellCheckRequester.h"
6 6
7 #include "core/editing/EditingUtilities.h" 7 #include "core/editing/EditingUtilities.h"
8 #include "core/editing/Editor.h" 8 #include "core/editing/Editor.h"
9 #include "core/editing/VisiblePosition.h" 9 #include "core/editing/VisiblePosition.h"
10 #include "core/editing/commands/CompositeEditCommand.h" 10 #include "core/editing/commands/CompositeEditCommand.h"
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
66 const int fullLength = TextIterator::rangeLength(fullRange.startPosition(), 66 const int fullLength = TextIterator::rangeLength(fullRange.startPosition(),
67 fullRange.endPosition()); 67 fullRange.endPosition());
68 if (fullLength <= kHotModeChunkSize) 68 if (fullLength <= kHotModeChunkSize)
69 return fullRange; 69 return fullRange;
70 70
71 TextIteratorBehavior behavior = TextIteratorBehavior::Builder() 71 TextIteratorBehavior behavior = TextIteratorBehavior::Builder()
72 .setEmitsObjectReplacementCharacter(true) 72 .setEmitsObjectReplacementCharacter(true)
73 .build(); 73 .build();
74 BackwardsCharacterIterator backwardIterator(fullRange.startPosition(), 74 BackwardsCharacterIterator backwardIterator(fullRange.startPosition(),
75 position, behavior); 75 position, behavior);
76 backwardIterator.advance(kHotModeChunkSize / 2); 76 if (!backwardIterator.atEnd())
77 backwardIterator.advance(kHotModeChunkSize / 2);
77 const Position& chunkStart = backwardIterator.endPosition(); 78 const Position& chunkStart = backwardIterator.endPosition();
78 CharacterIterator forwardIterator(position, fullRange.endPosition(), 79 CharacterIterator forwardIterator(position, fullRange.endPosition(),
79 behavior); 80 behavior);
80 forwardIterator.advance(kHotModeChunkSize / 2); 81 if (!forwardIterator.atEnd())
82 forwardIterator.advance(kHotModeChunkSize / 2);
81 const Position& chunkEnd = forwardIterator.endPosition(); 83 const Position& chunkEnd = forwardIterator.endPosition();
82 return expandRangeToSentenceBoundary(EphemeralRange(chunkStart, chunkEnd)); 84 return expandRangeToSentenceBoundary(EphemeralRange(chunkStart, chunkEnd));
83 } 85 }
84 86
85 } // namespace 87 } // namespace
86 88
87 HotModeSpellCheckRequester::HotModeSpellCheckRequester( 89 HotModeSpellCheckRequester::HotModeSpellCheckRequester(
88 SpellCheckRequester& requester) 90 SpellCheckRequester& requester)
89 : m_requester(requester) {} 91 : m_requester(requester) {}
90 92
91 void HotModeSpellCheckRequester::checkSpellingAt(const Position& position) { 93 void HotModeSpellCheckRequester::checkSpellingAt(const Position& position) {
92 const Element* rootEditable = rootEditableElementOf(position); 94 const Element* rootEditable = rootEditableElementOf(position);
93 if (!rootEditable || !rootEditable->isConnected()) 95 if (!rootEditable || !rootEditable->isConnected())
94 return; 96 return;
95 97
96 if (m_processedRootEditables.contains(rootEditable)) 98 if (m_processedRootEditables.contains(rootEditable))
97 return; 99 return;
98 m_processedRootEditables.push_back(rootEditable); 100 m_processedRootEditables.push_back(rootEditable);
99 101
100 if (!shouldCheckRootEditableInHotMode(*rootEditable, position)) 102 if (!shouldCheckRootEditableInHotMode(*rootEditable, position))
101 return; 103 return;
102 104
103 SpellCheckRequest* request = SpellCheckRequest::create( 105 SpellCheckRequest* request = SpellCheckRequest::create(
104 calculateHotModeCheckingRange(*rootEditable, position)); 106 calculateHotModeCheckingRange(*rootEditable, position));
105 m_requester->requestCheckingFor(request); 107 m_requester->requestCheckingFor(request);
106 } 108 }
107 109
108 } // namespace blink 110 } // namespace blink
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698