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

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

Issue 2720193002: Implement hot mode invocation for idle time spell checker (Closed)
Patch Set: Wed Mar 1 16:02:57 PST 2017 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
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 #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 "core/editing/EphemeralRange.h"
11 #include "core/editing/Position.h"
10 #include "platform/Timer.h" 12 #include "platform/Timer.h"
11 13
12 namespace blink { 14 namespace blink {
13 15
14 class LocalFrame; 16 class LocalFrame;
15 class SpellCheckRequester; 17 class SpellCheckRequester;
18 class UndoStack;
16 19
17 // Main class for the implementation of idle time spell checker. 20 // Main class for the implementation of idle time spell checker.
18 class CORE_EXPORT IdleSpellCheckCallback final 21 class CORE_EXPORT IdleSpellCheckCallback final
19 : public IdleRequestCallback, 22 : public IdleRequestCallback,
20 public SynchronousMutationObserver { 23 public SynchronousMutationObserver {
21 DISALLOW_COPY_AND_ASSIGN(IdleSpellCheckCallback); 24 DISALLOW_COPY_AND_ASSIGN(IdleSpellCheckCallback);
22 USING_GARBAGE_COLLECTED_MIXIN(IdleSpellCheckCallback); 25 USING_GARBAGE_COLLECTED_MIXIN(IdleSpellCheckCallback);
23 26
24 public: 27 public:
25 static IdleSpellCheckCallback* create(LocalFrame&); 28 static IdleSpellCheckCallback* create(LocalFrame&);
(...skipping 29 matching lines...) Expand all
55 void skipColdModeTimerForTesting(); 58 void skipColdModeTimerForTesting();
56 int idleCallbackHandle() const { return m_idleCallbackHandle; } 59 int idleCallbackHandle() const { return m_idleCallbackHandle; }
57 60
58 DECLARE_VIRTUAL_TRACE(); 61 DECLARE_VIRTUAL_TRACE();
59 62
60 private: 63 private:
61 explicit IdleSpellCheckCallback(LocalFrame&); 64 explicit IdleSpellCheckCallback(LocalFrame&);
62 void handleEvent(IdleDeadline*) override; 65 void handleEvent(IdleDeadline*) override;
63 66
64 LocalFrame& frame() const { return *m_frame; } 67 LocalFrame& frame() const { return *m_frame; }
68 UndoStack& undoStack() const;
yosin_UTC9 2017/03/02 03:38:41 This should be private.
Xiaocheng 2017/03/02 04:34:59 This is private.
65 69
66 // Returns whether spell checking is globally enabled. 70 // Returns whether spell checking is globally enabled.
67 bool isSpellCheckingEnabled() const; 71 bool isSpellCheckingEnabled() const;
68 72
69 // Calls requestIdleCallback with this IdleSpellCheckCallback. 73 // Calls requestIdleCallback with this IdleSpellCheckCallback.
70 void requestInvocation(); 74 void requestInvocation();
71 75
72 // Functions for hot mode. 76 // Functions for hot mode.
77 bool isTypingInPartialWord(const Element&) const;
78 bool shouldCheckRootEditableInHotMode(const Element&, const Position&) const;
79 EphemeralRange calcHotModeCheckingRange(const Element&,
80 const Position&) const;
81 void hotModeCheckRootEditable(Element*,
82 const Position&,
83 HeapVector<Member<Element>>*);
73 void hotModeInvocation(IdleDeadline*); 84 void hotModeInvocation(IdleDeadline*);
74 85
75 // Transit to ColdModeTimerStarted, if possible. Sets up a timer, and requests 86 // Transit to ColdModeTimerStarted, if possible. Sets up a timer, and requests
76 // cold mode invocation if no critical operation occurs before timer firing. 87 // cold mode invocation if no critical operation occurs before timer firing.
77 void setNeedsColdModeInvocation(); 88 void setNeedsColdModeInvocation();
78 89
79 // Functions for cold mode. 90 // Functions for cold mode.
80 void coldModeTimerFired(TimerBase*); 91 void coldModeTimerFired(TimerBase*);
81 void coldModeInvocation(IdleDeadline*); 92 void coldModeInvocation(IdleDeadline*);
82 bool coldModeFinishesFullDocument() const; 93 bool coldModeFinishesFullDocument() const;
83 94
84 // Implements |SynchronousMutationObserver|. 95 // Implements |SynchronousMutationObserver|.
85 void contextDestroyed(Document*) final; 96 void contextDestroyed(Document*) final;
86 97
87 State m_state; 98 State m_state;
88 int m_idleCallbackHandle; 99 int m_idleCallbackHandle;
89 mutable bool m_needsMoreColdModeInvocationForTesting; 100 mutable bool m_needsMoreColdModeInvocationForTesting;
90 const Member<LocalFrame> m_frame; 101 const Member<LocalFrame> m_frame;
91 102 uint64_t m_lastProcessedUndoStepSequence;
92 TaskRunnerTimer<IdleSpellCheckCallback> m_coldModeTimer; 103 TaskRunnerTimer<IdleSpellCheckCallback> m_coldModeTimer;
93 }; 104 };
94 105
95 } // namespace blink 106 } // namespace blink
96 107
97 #endif // IdleSpellCheckCallback_h 108 #endif // IdleSpellCheckCallback_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698