Index: third_party/WebKit/Source/core/editing/spellcheck/IdleSpellCheckCallback.cpp |
diff --git a/third_party/WebKit/Source/core/editing/spellcheck/IdleSpellCheckCallback.cpp b/third_party/WebKit/Source/core/editing/spellcheck/IdleSpellCheckCallback.cpp |
index 2c400a479fa4ad213609139d7e6f4af24c4694fb..999d5a8d587b2a9b6f908e8b206d8a4cce0a1912 100644 |
--- a/third_party/WebKit/Source/core/editing/spellcheck/IdleSpellCheckCallback.cpp |
+++ b/third_party/WebKit/Source/core/editing/spellcheck/IdleSpellCheckCallback.cpp |
@@ -27,7 +27,7 @@ namespace { |
const int kColdModeTimerIntervalMS = 1000; |
const int kConsecutiveColdModeTimerIntervalMS = 200; |
-const int kRequestTimeoutMS = 200; |
+const int kHotModeRequestTimeoutMS = 200; |
const int kInvalidHandle = -1; |
const int kDummyHandleForForcedInvocation = -2; |
const double kForcedInvocationDeadlineSeconds = 10; |
@@ -64,11 +64,12 @@ bool IdleSpellCheckCallback::isSpellCheckingEnabled() const { |
return frame().spellChecker().isSpellCheckingEnabled(); |
} |
-void IdleSpellCheckCallback::requestInvocation() { |
+void IdleSpellCheckCallback::requestInvocation(int timeoutMS) { |
yosin_UTC9
2017/03/07 08:15:30
Should we use base::TimeDeltta, available in WTF/T
Xiaocheng
2017/03/07 21:27:44
I still prefer just an |int|, as IdleRequestOption
|
DCHECK_EQ(m_idleCallbackHandle, kInvalidHandle); |
IdleRequestOptions options; |
- options.setTimeout(kRequestTimeoutMS); |
+ if (timeoutMS > 0) |
+ options.setTimeout(timeoutMS); |
m_idleCallbackHandle = frame().document()->requestIdleCallback(this, options); |
} |
@@ -95,8 +96,12 @@ void IdleSpellCheckCallback::setNeedsInvocation() { |
m_coldModeTimer.stop(); |
} |
- if (m_state != State::kColdModeRequested) |
- requestInvocation(); |
+ if (m_state == State::kColdModeRequested) { |
+ frame().document()->cancelIdleCallback(m_idleCallbackHandle); |
+ m_idleCallbackHandle = kInvalidHandle; |
+ } |
+ |
+ requestInvocation(kHotModeRequestTimeoutMS); |
m_state = State::kHotModeRequested; |
} |
@@ -126,7 +131,7 @@ void IdleSpellCheckCallback::coldModeTimerFired(TimerBase*) { |
return; |
} |
- requestInvocation(); |
+ requestInvocation(0); |
m_state = State::kColdModeRequested; |
} |