| OLD | NEW |
| 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 #ifndef IdleSpellCheckCallback_h | 5 #ifndef IdleSpellCheckCallback_h |
| 6 #define IdleSpellCheckCallback_h | 6 #define IdleSpellCheckCallback_h |
| 7 | 7 |
| 8 #include "core/dom/IdleRequestCallback.h" | 8 #include "core/dom/IdleRequestCallback.h" |
| 9 #include "core/dom/SynchronousMutationObserver.h" | 9 #include "core/dom/SynchronousMutationObserver.h" |
| 10 #include "platform/Timer.h" | 10 #include "platform/Timer.h" |
| 11 | 11 |
| 12 namespace blink { | 12 namespace blink { |
| 13 | 13 |
| 14 class LocalFrame; | 14 class LocalFrame; |
| 15 class SpellCheckRequester; | 15 class SpellCheckRequester; |
| 16 | 16 |
| 17 #define FOR_EACH_IDLE_SPELL_CHECK_CALLBACK_STATE(V) \ |
| 18 V(Inactive) \ |
| 19 V(HotModeRequested) \ |
| 20 V(InHotModeInvocation) \ |
| 21 V(ColdModeTimerStarted) \ |
| 22 V(ColdModeRequested) \ |
| 23 V(InColdModeInvocation) |
| 24 |
| 17 // Main class for the implementation of idle time spell checker. | 25 // Main class for the implementation of idle time spell checker. |
| 18 class CORE_EXPORT IdleSpellCheckCallback final | 26 class CORE_EXPORT IdleSpellCheckCallback final |
| 19 : public IdleRequestCallback, | 27 : public IdleRequestCallback, |
| 20 public SynchronousMutationObserver { | 28 public SynchronousMutationObserver { |
| 21 DISALLOW_COPY_AND_ASSIGN(IdleSpellCheckCallback); | 29 DISALLOW_COPY_AND_ASSIGN(IdleSpellCheckCallback); |
| 22 USING_GARBAGE_COLLECTED_MIXIN(IdleSpellCheckCallback); | 30 USING_GARBAGE_COLLECTED_MIXIN(IdleSpellCheckCallback); |
| 23 | 31 |
| 24 public: | 32 public: |
| 25 static IdleSpellCheckCallback* create(LocalFrame&); | 33 static IdleSpellCheckCallback* create(LocalFrame&); |
| 26 ~IdleSpellCheckCallback() override; | 34 ~IdleSpellCheckCallback() override; |
| 27 | 35 |
| 28 enum class State { | 36 enum class State { |
| 29 kInactive, | 37 #define V(state) k##state, |
| 30 kHotModeRequested, | 38 FOR_EACH_IDLE_SPELL_CHECK_CALLBACK_STATE(V) |
| 31 kInHotModeInvocation, | 39 #undef V |
| 32 kColdModeTimerStarted, | |
| 33 kColdModeRequested, | |
| 34 kInColdModeInvocation | |
| 35 }; | 40 }; |
| 36 | 41 |
| 37 State state() const { return m_state; } | 42 State state() const { return m_state; } |
| 38 | 43 |
| 39 // Transit to HotModeRequested, if possible. Called by operations that need | 44 // Transit to HotModeRequested, if possible. Called by operations that need |
| 40 // spell checker to follow up. | 45 // spell checker to follow up. |
| 41 void setNeedsInvocation(); | 46 void setNeedsInvocation(); |
| 42 | 47 |
| 43 // Cleans everything up and makes the callback inactive. Should be called when | 48 // Cleans everything up and makes the callback inactive. Should be called when |
| 44 // document is detached or spellchecking is globally disabled. | 49 // document is detached or spellchecking is globally disabled. |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 88 int m_idleCallbackHandle; | 93 int m_idleCallbackHandle; |
| 89 mutable bool m_needsMoreColdModeInvocationForTesting; | 94 mutable bool m_needsMoreColdModeInvocationForTesting; |
| 90 const Member<LocalFrame> m_frame; | 95 const Member<LocalFrame> m_frame; |
| 91 | 96 |
| 92 TaskRunnerTimer<IdleSpellCheckCallback> m_coldModeTimer; | 97 TaskRunnerTimer<IdleSpellCheckCallback> m_coldModeTimer; |
| 93 }; | 98 }; |
| 94 | 99 |
| 95 } // namespace blink | 100 } // namespace blink |
| 96 | 101 |
| 97 #endif // IdleSpellCheckCallback_h | 102 #endif // IdleSpellCheckCallback_h |
| OLD | NEW |