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

Side by Side 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, 8 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 #include "content/browser/renderer_host/input/synthetic_gesture_controller.h" 5 #include "content/browser/renderer_host/input/synthetic_gesture_controller.h"
6 6
7 #include "base/debug/trace_event.h" 7 #include "base/debug/trace_event.h"
8 #include "content/browser/renderer_host/input/synthetic_gesture_target.h" 8 #include "content/browser/renderer_host/input/synthetic_gesture_target.h"
9 #include "content/common/input/synthetic_smooth_scroll_gesture_params.h" 9 #include "content/common/input/synthetic_smooth_scroll_gesture_params.h"
10 #include "content/common/input_messages.h" 10 #include "content/common/input_messages.h"
(...skipping 18 matching lines...) Expand all
29 29
30 if (was_empty) 30 if (was_empty)
31 StartGesture(*pending_gesture_queue_.FrontGesture()); 31 StartGesture(*pending_gesture_queue_.FrontGesture());
32 } 32 }
33 33
34 void SyntheticGestureController::Flush(base::TimeTicks timestamp) { 34 void SyntheticGestureController::Flush(base::TimeTicks timestamp) {
35 TRACE_EVENT0("input", "SyntheticGestureController::Flush"); 35 TRACE_EVENT0("input", "SyntheticGestureController::Flush");
36 if (pending_gesture_queue_.IsEmpty()) 36 if (pending_gesture_queue_.IsEmpty())
37 return; 37 return;
38 38
39 if (pending_gesture_result_)
40 return;
41
39 SyntheticGesture* gesture = pending_gesture_queue_.FrontGesture(); 42 SyntheticGesture* gesture = pending_gesture_queue_.FrontGesture();
40 SyntheticGesture::Result result = gesture->ForwardInputEvents(timestamp, 43 SyntheticGesture::Result result =
41 gesture_target_.get()); 44 gesture->ForwardInputEvents(timestamp, gesture_target_.get());
42 45
43 if (result == SyntheticGesture::GESTURE_RUNNING) { 46 if (result == SyntheticGesture::GESTURE_RUNNING) {
44 gesture_target_->SetNeedsFlush(); 47 gesture_target_->SetNeedsFlush();
45 return; 48 return;
46 } 49 }
47 50
48 StopGesture(*gesture, pending_gesture_queue_.FrontCallback(), result); 51 // It's possible that all events generated by the gesture have been fully
52 // dispatched at this point, in which case |OnDidFlushInput()| was called
53 // before |pending_gesture_result_| was initialized. Requesting another flush
54 // will trigger the necessary gesture-ending call to |OnDidFlushInput()|.
55 pending_gesture_result_.reset(new SyntheticGesture::Result(result));
56 gesture_target_->SetNeedsFlush();
57 }
58
59 void SyntheticGestureController::OnDidFlushInput() {
60 if (!pending_gesture_result_)
61 return;
62
63 DCHECK(!pending_gesture_queue_.IsEmpty());
64 StopGesture(*pending_gesture_queue_.FrontGesture(),
65 pending_gesture_queue_.FrontCallback(),
66 *pending_gesture_result_.Pass());
49 pending_gesture_queue_.Pop(); 67 pending_gesture_queue_.Pop();
50 68
51 if (!pending_gesture_queue_.IsEmpty()) 69 if (!pending_gesture_queue_.IsEmpty())
52 StartGesture(*pending_gesture_queue_.FrontGesture()); 70 StartGesture(*pending_gesture_queue_.FrontGesture());
53 } 71 }
54 72
55 void SyntheticGestureController::StartGesture(const SyntheticGesture& gesture) { 73 void SyntheticGestureController::StartGesture(const SyntheticGesture& gesture) {
56 TRACE_EVENT_ASYNC_BEGIN0("input,benchmark", 74 TRACE_EVENT_ASYNC_BEGIN0("input,benchmark",
57 "SyntheticGestureController::running", 75 "SyntheticGestureController::running",
58 &gesture); 76 &gesture);
(...skipping 13 matching lines...) Expand all
72 } 90 }
73 91
74 SyntheticGestureController::GestureAndCallbackQueue::GestureAndCallbackQueue() { 92 SyntheticGestureController::GestureAndCallbackQueue::GestureAndCallbackQueue() {
75 } 93 }
76 94
77 SyntheticGestureController::GestureAndCallbackQueue:: 95 SyntheticGestureController::GestureAndCallbackQueue::
78 ~GestureAndCallbackQueue() { 96 ~GestureAndCallbackQueue() {
79 } 97 }
80 98
81 } // namespace content 99 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698