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

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

Issue 2578493002: Add a skeleton of idle time spell checker (Closed)
Patch Set: Fix usage of Timer::startOneShot 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
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef IdleSpellCheckCallback_h
6 #define IdleSpellCheckCallback_h
7
8 #include "core/dom/IdleRequestCallback.h"
9 #include "core/frame/LocalFrame.h"
10 #include "platform/Timer.h"
11
12 namespace blink {
13
14 // Main class for the implementation of idle time spell checker.
15 class IdleSpellCheckCallback final : public IdleRequestCallback {
16 public:
17 // TODO(xiaochengh): Make each LocalFrame own an IdleSpellCheckCallback.
18 static IdleSpellCheckCallback* create(LocalFrame&);
19 ~IdleSpellCheckCallback() override;
20
21 // Transit to HotModeRequested, if possible. Called by operations that need
22 // spell checker to follow up.
23 // TODO(xiaochengh): Add proper call sites.
24 void setNeedsHotModeInvocation();
25
26 // Transit to ColdModeTimerStarted, if possible. Sets up a timer, and requests
27 // cold mode invocation if no critical operation occurs before timer firing.
28 // TODO(xiaochengh): Add proper call sites.
29 void setNeedsColdModeInvocation();
30
31 // Cleans everything up and makes the callback inactive. Should be called when
32 // document is detached or spellchecking is globally disabled.
33 // TODO(xiaochengh): Add proper call sites.
34 void deactivate();
35
36 DECLARE_VIRTUAL_TRACE();
37
38 private:
39 explicit IdleSpellCheckCallback(LocalFrame&);
40 void handleEvent(IdleDeadline*) override;
41
42 LocalFrame& frame() const { return *m_frame; }
43
44 enum class State {
45 Inactive,
tkent 2016/12/14 08:45:50 Please prepend 'k' to each items. Reference: [nam
Xiaocheng 2016/12/14 09:08:12 Done.
46 HotModeRequested,
47 InHotModeInvocation,
48 ColdModeTimerStarted,
49 ColdModeRequested,
50 InColdModeInvocation
51 };
52
53 // Returns whether spell checking is globally enabled.
54 bool isSpellCheckingEnabled() const;
55
56 // Calls requestIdleCallback with this IdleSpellCheckCallback.
57 void requestInvocation();
58
59 // Functions for hot mode.
60 void hotModeInvocation(IdleDeadline*);
61
62 // Functions for cold mode.
63 void coldModeTimerFired(TimerBase*);
64 void coldModeInvocation(IdleDeadline*);
65 bool coldModeFinishesFullDocument() const;
66
67 State m_state;
68 const Member<LocalFrame> m_frame;
69
70 // TODO(xiaochengh): assign the timer to some proper task runner.
71 Timer<IdleSpellCheckCallback> m_coldModeTimer;
72 };
73
74 } // namespace blink
75
76 #endif // IdleSpellCheckCallback_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698