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

Side by Side Diff: content/browser/renderer_host/input/synthetic_gesture_controller.cc

Issue 2336803003: Make SyntheticPointerAction to flush the pointer action sequence (Closed)
Patch Set: controller Created 4 years, 2 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 <utility> 7 #include <utility>
8 8
9 #include "base/trace_event/trace_event.h" 9 #include "base/trace_event/trace_event.h"
10 #include "content/browser/renderer_host/input/synthetic_gesture_target.h" 10 #include "content/browser/renderer_host/input/synthetic_gesture_target.h"
11 #include "content/common/input/synthetic_smooth_scroll_gesture_params.h" 11 #include "content/common/input/synthetic_smooth_scroll_gesture_params.h"
12 #include "content/common/input_messages.h" 12 #include "content/common/input_messages.h"
13 #include "content/public/browser/render_widget_host.h" 13 #include "content/public/browser/render_widget_host.h"
14 14
15 namespace content { 15 namespace content {
16 16
17 SyntheticGestureController::SyntheticGestureController( 17 SyntheticGestureController::SyntheticGestureController(
18 std::unique_ptr<SyntheticGestureTarget> gesture_target) 18 std::unique_ptr<SyntheticGestureTarget> gesture_target)
19 : gesture_target_(std::move(gesture_target)) {} 19 : gesture_target_(std::move(gesture_target)) {
20 pointer_action_controller_.SetDefaultGestureSourceType(
21 gesture_target_->GetDefaultSyntheticGestureSourceType());
22 }
20 23
21 SyntheticGestureController::~SyntheticGestureController() {} 24 SyntheticGestureController::~SyntheticGestureController() {}
22 25
23 void SyntheticGestureController::QueueSyntheticGesture( 26 void SyntheticGestureController::QueueSyntheticGesture(
24 std::unique_ptr<SyntheticGesture> synthetic_gesture, 27 std::unique_ptr<SyntheticGesture> synthetic_gesture,
25 const OnGestureCompleteCallback& completion_callback) { 28 const OnGestureCompleteCallback& completion_callback) {
26 DCHECK(synthetic_gesture); 29 DCHECK(synthetic_gesture);
27 30
28 bool was_empty = pending_gesture_queue_.IsEmpty(); 31 bool was_empty = pending_gesture_queue_.IsEmpty();
29 32
30 pending_gesture_queue_.Push(std::move(synthetic_gesture), 33 pending_gesture_queue_.Push(std::move(synthetic_gesture),
31 completion_callback); 34 completion_callback);
32
33 if (was_empty) 35 if (was_empty)
34 StartGesture(*pending_gesture_queue_.FrontGesture()); 36 StartGesture(*pending_gesture_queue_.FrontGesture());
35 } 37 }
36 38
39 void SyntheticGestureController::QueueSyntheticPointerAction(
40 const SyntheticGestureParams& gesture_params,
41 const OnGestureCompleteCallback& completion_callback) {
42 std::unique_ptr<SyntheticGesture> synthetic_gesture;
43 if (gesture_params.GetGestureType() ==
44 SyntheticGestureParams::POINTER_ACTION_LIST) {
45 synthetic_gesture = pointer_action_controller_.CreateSyntheticPointerAction(
46 *SyntheticPointerActionListParams::Cast(&gesture_params));
47 } else
48 synthetic_gesture = SyntheticGesture::Create(gesture_params);
tdresser 2016/09/30 13:24:30 I'm not sure this logic (converting to a Synthetic
tdresser 2016/09/30 13:24:30 Use {} for all clauses.
lanwei 2016/10/21 21:53:07 Done.
lanwei 2016/10/21 21:53:07 Done.
49
50 QueueSyntheticGesture(std::move(synthetic_gesture), completion_callback);
51 }
52
37 void SyntheticGestureController::Flush(base::TimeTicks timestamp) { 53 void SyntheticGestureController::Flush(base::TimeTicks timestamp) {
38 TRACE_EVENT0("input", "SyntheticGestureController::Flush"); 54 TRACE_EVENT0("input", "SyntheticGestureController::Flush");
39 if (pending_gesture_queue_.IsEmpty()) 55 if (pending_gesture_queue_.IsEmpty())
40 return; 56 return;
41 57
42 if (pending_gesture_result_) 58 if (pending_gesture_result_)
43 return; 59 return;
44 60
45 SyntheticGesture* gesture = pending_gesture_queue_.FrontGesture(); 61 SyntheticGesture* gesture = pending_gesture_queue_.FrontGesture();
46 SyntheticGesture::Result result = 62 SyntheticGesture::Result result =
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
94 } 110 }
95 111
96 SyntheticGestureController::GestureAndCallbackQueue::GestureAndCallbackQueue() { 112 SyntheticGestureController::GestureAndCallbackQueue::GestureAndCallbackQueue() {
97 } 113 }
98 114
99 SyntheticGestureController::GestureAndCallbackQueue:: 115 SyntheticGestureController::GestureAndCallbackQueue::
100 ~GestureAndCallbackQueue() { 116 ~GestureAndCallbackQueue() {
101 } 117 }
102 118
103 } // namespace content 119 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698