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

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

Issue 2580773002: Let IdleSpellCheckCallback take full control over SpellCheckRequester (Closed)
Patch Set: Add CORE_EXPORT to IdleRequestCallback Created 4 years 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 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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/IdleSpellCheckCallback.h" 5 #include "core/editing/spellcheck/IdleSpellCheckCallback.h"
6 6
7 #include "core/dom/IdleRequestOptions.h" 7 #include "core/dom/IdleRequestOptions.h"
8 #include "core/editing/EditingUtilities.h" 8 #include "core/editing/EditingUtilities.h"
9 #include "core/editing/FrameSelection.h" 9 #include "core/editing/FrameSelection.h"
10 #include "core/editing/VisibleSelection.h" 10 #include "core/editing/VisibleSelection.h"
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 42
43 IdleSpellCheckCallback* IdleSpellCheckCallback::create(LocalFrame& frame) { 43 IdleSpellCheckCallback* IdleSpellCheckCallback::create(LocalFrame& frame) {
44 return new IdleSpellCheckCallback(frame); 44 return new IdleSpellCheckCallback(frame);
45 } 45 }
46 46
47 IdleSpellCheckCallback::IdleSpellCheckCallback(LocalFrame& frame) 47 IdleSpellCheckCallback::IdleSpellCheckCallback(LocalFrame& frame)
48 : m_state(State::kInactive), 48 : m_state(State::kInactive),
49 m_frame(frame), 49 m_frame(frame),
50 m_coldModeTimer(this, &IdleSpellCheckCallback::coldModeTimerFired) {} 50 m_coldModeTimer(this, &IdleSpellCheckCallback::coldModeTimerFired) {}
51 51
52 SpellCheckRequester& IdleSpellCheckCallback::spellCheckRequester() const {
53 // TODO(xiaochengh): decouple with SpellChecker after SpellCheckRequester is
54 // moved to IdleSpellCheckCallback.
55 return frame().spellChecker().spellCheckRequester();
56 }
57
52 bool IdleSpellCheckCallback::isSpellCheckingEnabled() const { 58 bool IdleSpellCheckCallback::isSpellCheckingEnabled() const {
53 // TODO(xiaochengh): decouple with SpellChecker. 59 // TODO(xiaochengh): decouple with SpellChecker.
54 return frame().spellChecker().isSpellCheckingEnabled(); 60 return frame().spellChecker().isSpellCheckingEnabled();
55 } 61 }
56 62
63 void IdleSpellCheckCallback::prepareForLeakDetection() {
64 if (RuntimeEnabledFeatures::idleTimeSpellCheckingEnabled())
65 spellCheckRequester().prepareForLeakDetection();
66 }
67
57 void IdleSpellCheckCallback::requestInvocation() { 68 void IdleSpellCheckCallback::requestInvocation() {
58 IdleRequestOptions options; 69 IdleRequestOptions options;
59 options.setTimeout(kRequestTimeoutMS); 70 options.setTimeout(kRequestTimeoutMS);
60 frame().document()->requestIdleCallback(this, options); 71 frame().document()->requestIdleCallback(this, options);
61 } 72 }
62 73
63 void IdleSpellCheckCallback::deactivate() { 74 void IdleSpellCheckCallback::deactivate() {
64 m_state = State::kInactive; 75 m_state = State::kInactive;
65 if (m_coldModeTimer.isActive()) 76 if (m_coldModeTimer.isActive())
66 m_coldModeTimer.stop(); 77 m_coldModeTimer.stop();
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
150 if (coldModeFinishesFullDocument()) 161 if (coldModeFinishesFullDocument())
151 m_state = State::kInactive; 162 m_state = State::kInactive;
152 else 163 else
153 setNeedsColdModeInvocation(); 164 setNeedsColdModeInvocation();
154 } else { 165 } else {
155 NOTREACHED(); 166 NOTREACHED();
156 } 167 }
157 } 168 }
158 169
159 } // namespace blink 170 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698