OLD | NEW |
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/ColdModeSpellCheckRequester.h" | 5 #include "core/editing/spellcheck/ColdModeSpellCheckRequester.h" |
6 | 6 |
7 #include "core/dom/Element.h" | 7 #include "core/dom/Element.h" |
8 #include "core/dom/IdleDeadline.h" | 8 #include "core/dom/IdleDeadline.h" |
9 #include "core/editing/EditingUtilities.h" | 9 #include "core/editing/EditingUtilities.h" |
10 #include "core/editing/VisibleUnits.h" | 10 #include "core/editing/VisibleUnits.h" |
11 #include "core/editing/iterators/CharacterIterator.h" | 11 #include "core/editing/iterators/CharacterIterator.h" |
12 #include "core/editing/spellcheck/SpellCheckRequester.h" | 12 #include "core/editing/spellcheck/SpellCheckRequester.h" |
13 #include "core/editing/spellcheck/SpellChecker.h" | 13 #include "core/editing/spellcheck/SpellChecker.h" |
14 #include "core/frame/LocalFrame.h" | 14 #include "core/frame/LocalFrame.h" |
15 #include "platform/instrumentation/tracing/TraceEvent.h" | 15 #include "platform/instrumentation/tracing/TraceEvent.h" |
16 | 16 |
17 namespace blink { | 17 namespace blink { |
18 | 18 |
19 namespace { | 19 namespace { |
20 | 20 |
21 const int kColdModeChunkSize = 16384; // in UTF16 code units | 21 const int kColdModeChunkSize = 16384; // in UTF16 code units |
22 const int kInvalidLength = -1; | 22 const int kInvalidLength = -1; |
23 const int kInvalidChunkIndex = -1; | 23 const int kInvalidChunkIndex = -1; |
24 | 24 |
25 bool ShouldCheckNode(const Node& node) { | 25 bool ShouldCheckNode(const Node& node) { |
26 if (!node.IsElementNode()) | 26 if (!node.IsElementNode()) |
27 return false; | 27 return false; |
28 // TODO(editing-dev): Make |Position| constructors take const parameters. | 28 // TODO(editing-dev): Make |Position| constructors take const parameters. |
29 const Position& position = | 29 const Position& position = Position::FirstPositionInNode(node); |
30 Position::FirstPositionInNode(const_cast<Node*>(&node)); | |
31 if (!IsEditablePosition(position)) | 30 if (!IsEditablePosition(position)) |
32 return false; | 31 return false; |
33 return SpellChecker::IsSpellCheckingEnabledAt(position); | 32 return SpellChecker::IsSpellCheckingEnabledAt(position); |
34 } | 33 } |
35 | 34 |
36 } // namespace | 35 } // namespace |
37 | 36 |
38 // static | 37 // static |
39 ColdModeSpellCheckRequester* ColdModeSpellCheckRequester::Create( | 38 ColdModeSpellCheckRequester* ColdModeSpellCheckRequester::Create( |
40 LocalFrame& frame) { | 39 LocalFrame& frame) { |
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
174 next_node_ = FlatTreeTraversal::NextSkippingChildren( | 173 next_node_ = FlatTreeTraversal::NextSkippingChildren( |
175 *next_node_, GetFrame().GetDocument()->body()); | 174 *next_node_, GetFrame().GetDocument()->body()); |
176 | 175 |
177 current_root_editable_ = nullptr; | 176 current_root_editable_ = nullptr; |
178 current_full_length_ = kInvalidLength; | 177 current_full_length_ = kInvalidLength; |
179 current_chunk_index_ = kInvalidChunkIndex; | 178 current_chunk_index_ = kInvalidChunkIndex; |
180 current_chunk_start_ = Position(); | 179 current_chunk_start_ = Position(); |
181 } | 180 } |
182 | 181 |
183 } // namespace blink | 182 } // namespace blink |
OLD | NEW |