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

Unified Diff: content/browser/renderer_host/input/synthetic_gesture_controller.cc

Issue 217163006: Defer synthetic gesture completions until events have been flushed (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Restore browser test Created 6 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 side-by-side diff with in-line comments
Download patch
Index: content/browser/renderer_host/input/synthetic_gesture_controller.cc
diff --git a/content/browser/renderer_host/input/synthetic_gesture_controller.cc b/content/browser/renderer_host/input/synthetic_gesture_controller.cc
index 57b3af0e1af0cbcf40d8dd7122fb16e3b5067f4b..8314d948ba751c5776816c29fc3c86dd567c2700 100644
--- a/content/browser/renderer_host/input/synthetic_gesture_controller.cc
+++ b/content/browser/renderer_host/input/synthetic_gesture_controller.cc
@@ -36,16 +36,34 @@ void SyntheticGestureController::Flush(base::TimeTicks timestamp) {
if (pending_gesture_queue_.IsEmpty())
return;
+ if (pending_gesture_result_)
+ return;
+
SyntheticGesture* gesture = pending_gesture_queue_.FrontGesture();
- SyntheticGesture::Result result = gesture->ForwardInputEvents(timestamp,
- gesture_target_.get());
+ SyntheticGesture::Result result =
+ gesture->ForwardInputEvents(timestamp, gesture_target_.get());
if (result == SyntheticGesture::GESTURE_RUNNING) {
gesture_target_->SetNeedsFlush();
return;
}
- StopGesture(*gesture, pending_gesture_queue_.FrontCallback(), result);
+ // It's possible that all events generated by the gesture have been fully
+ // dispatched at this point, in which case |OnDidFlushInput()| was called
+ // before |pending_gesture_result_| was initialized. Requesting another flush
+ // will trigger the necessary gesture-ending call to |OnDidFlushInput()|.
+ pending_gesture_result_.reset(new SyntheticGesture::Result(result));
+ gesture_target_->SetNeedsFlush();
+}
+
+void SyntheticGestureController::OnDidFlushInput() {
+ if (!pending_gesture_result_)
+ return;
+
+ DCHECK(!pending_gesture_queue_.IsEmpty());
+ StopGesture(*pending_gesture_queue_.FrontGesture(),
+ pending_gesture_queue_.FrontCallback(),
+ *pending_gesture_result_.Pass());
pending_gesture_queue_.Pop();
if (!pending_gesture_queue_.IsEmpty())

Powered by Google App Engine
This is Rietveld 408576698