| OLD | NEW |
| 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); |
| 49 |
| 50 if (synthetic_gesture) { |
| 51 QueueSyntheticGesture(std::move(synthetic_gesture), completion_callback); |
| 52 } |
| 53 } |
| 54 |
| 55 void SyntheticGestureController::ResetSyntheticPointer() { |
| 56 pointer_action_controller_.ResetSyntheticPointer(); |
| 57 } |
| 58 |
| 37 void SyntheticGestureController::Flush(base::TimeTicks timestamp) { | 59 void SyntheticGestureController::Flush(base::TimeTicks timestamp) { |
| 38 TRACE_EVENT0("input", "SyntheticGestureController::Flush"); | 60 TRACE_EVENT0("input", "SyntheticGestureController::Flush"); |
| 39 if (pending_gesture_queue_.IsEmpty()) | 61 if (pending_gesture_queue_.IsEmpty()) |
| 40 return; | 62 return; |
| 41 | 63 |
| 42 if (pending_gesture_result_) | 64 if (pending_gesture_result_) |
| 43 return; | 65 return; |
| 44 | 66 |
| 45 SyntheticGesture* gesture = pending_gesture_queue_.FrontGesture(); | 67 SyntheticGesture* gesture = pending_gesture_queue_.FrontGesture(); |
| 46 SyntheticGesture::Result result = | 68 SyntheticGesture::Result result = |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 94 } | 116 } |
| 95 | 117 |
| 96 SyntheticGestureController::GestureAndCallbackQueue::GestureAndCallbackQueue() { | 118 SyntheticGestureController::GestureAndCallbackQueue::GestureAndCallbackQueue() { |
| 97 } | 119 } |
| 98 | 120 |
| 99 SyntheticGestureController::GestureAndCallbackQueue:: | 121 SyntheticGestureController::GestureAndCallbackQueue:: |
| 100 ~GestureAndCallbackQueue() { | 122 ~GestureAndCallbackQueue() { |
| 101 } | 123 } |
| 102 | 124 |
| 103 } // namespace content | 125 } // namespace content |
| OLD | NEW |