| 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> |
| 8 |
| 7 #include "base/trace_event/trace_event.h" | 9 #include "base/trace_event/trace_event.h" |
| 8 #include "content/browser/renderer_host/input/synthetic_gesture_target.h" | 10 #include "content/browser/renderer_host/input/synthetic_gesture_target.h" |
| 9 #include "content/common/input/synthetic_smooth_scroll_gesture_params.h" | 11 #include "content/common/input/synthetic_smooth_scroll_gesture_params.h" |
| 10 #include "content/common/input_messages.h" | 12 #include "content/common/input_messages.h" |
| 11 #include "content/public/browser/render_widget_host.h" | 13 #include "content/public/browser/render_widget_host.h" |
| 12 | 14 |
| 13 namespace content { | 15 namespace content { |
| 14 | 16 |
| 15 SyntheticGestureController::SyntheticGestureController( | 17 SyntheticGestureController::SyntheticGestureController( |
| 16 scoped_ptr<SyntheticGestureTarget> gesture_target) | 18 scoped_ptr<SyntheticGestureTarget> gesture_target) |
| 17 : gesture_target_(gesture_target.Pass()) {} | 19 : gesture_target_(std::move(gesture_target)) {} |
| 18 | 20 |
| 19 SyntheticGestureController::~SyntheticGestureController() {} | 21 SyntheticGestureController::~SyntheticGestureController() {} |
| 20 | 22 |
| 21 void SyntheticGestureController::QueueSyntheticGesture( | 23 void SyntheticGestureController::QueueSyntheticGesture( |
| 22 scoped_ptr<SyntheticGesture> synthetic_gesture, | 24 scoped_ptr<SyntheticGesture> synthetic_gesture, |
| 23 const OnGestureCompleteCallback& completion_callback) { | 25 const OnGestureCompleteCallback& completion_callback) { |
| 24 DCHECK(synthetic_gesture); | 26 DCHECK(synthetic_gesture); |
| 25 | 27 |
| 26 bool was_empty = pending_gesture_queue_.IsEmpty(); | 28 bool was_empty = pending_gesture_queue_.IsEmpty(); |
| 27 | 29 |
| 28 pending_gesture_queue_.Push(synthetic_gesture.Pass(), completion_callback); | 30 pending_gesture_queue_.Push(std::move(synthetic_gesture), |
| 31 completion_callback); |
| 29 | 32 |
| 30 if (was_empty) | 33 if (was_empty) |
| 31 StartGesture(*pending_gesture_queue_.FrontGesture()); | 34 StartGesture(*pending_gesture_queue_.FrontGesture()); |
| 32 } | 35 } |
| 33 | 36 |
| 34 void SyntheticGestureController::Flush(base::TimeTicks timestamp) { | 37 void SyntheticGestureController::Flush(base::TimeTicks timestamp) { |
| 35 TRACE_EVENT0("input", "SyntheticGestureController::Flush"); | 38 TRACE_EVENT0("input", "SyntheticGestureController::Flush"); |
| 36 if (pending_gesture_queue_.IsEmpty()) | 39 if (pending_gesture_queue_.IsEmpty()) |
| 37 return; | 40 return; |
| 38 | 41 |
| (...skipping 15 matching lines...) Expand all Loading... |
| 54 // will trigger the necessary gesture-ending call to |OnDidFlushInput()|. | 57 // will trigger the necessary gesture-ending call to |OnDidFlushInput()|. |
| 55 pending_gesture_result_.reset(new SyntheticGesture::Result(result)); | 58 pending_gesture_result_.reset(new SyntheticGesture::Result(result)); |
| 56 gesture_target_->SetNeedsFlush(); | 59 gesture_target_->SetNeedsFlush(); |
| 57 } | 60 } |
| 58 | 61 |
| 59 void SyntheticGestureController::OnDidFlushInput() { | 62 void SyntheticGestureController::OnDidFlushInput() { |
| 60 if (!pending_gesture_result_) | 63 if (!pending_gesture_result_) |
| 61 return; | 64 return; |
| 62 | 65 |
| 63 DCHECK(!pending_gesture_queue_.IsEmpty()); | 66 DCHECK(!pending_gesture_queue_.IsEmpty()); |
| 64 auto pending_gesture_result = pending_gesture_result_.Pass(); | 67 auto pending_gesture_result = std::move(pending_gesture_result_); |
| 65 StopGesture(*pending_gesture_queue_.FrontGesture(), | 68 StopGesture(*pending_gesture_queue_.FrontGesture(), |
| 66 pending_gesture_queue_.FrontCallback(), | 69 pending_gesture_queue_.FrontCallback(), |
| 67 *pending_gesture_result); | 70 *pending_gesture_result); |
| 68 pending_gesture_queue_.Pop(); | 71 pending_gesture_queue_.Pop(); |
| 69 | 72 |
| 70 if (!pending_gesture_queue_.IsEmpty()) | 73 if (!pending_gesture_queue_.IsEmpty()) |
| 71 StartGesture(*pending_gesture_queue_.FrontGesture()); | 74 StartGesture(*pending_gesture_queue_.FrontGesture()); |
| 72 } | 75 } |
| 73 | 76 |
| 74 void SyntheticGestureController::StartGesture(const SyntheticGesture& gesture) { | 77 void SyntheticGestureController::StartGesture(const SyntheticGesture& gesture) { |
| (...skipping 16 matching lines...) Expand all Loading... |
| 91 } | 94 } |
| 92 | 95 |
| 93 SyntheticGestureController::GestureAndCallbackQueue::GestureAndCallbackQueue() { | 96 SyntheticGestureController::GestureAndCallbackQueue::GestureAndCallbackQueue() { |
| 94 } | 97 } |
| 95 | 98 |
| 96 SyntheticGestureController::GestureAndCallbackQueue:: | 99 SyntheticGestureController::GestureAndCallbackQueue:: |
| 97 ~GestureAndCallbackQueue() { | 100 ~GestureAndCallbackQueue() { |
| 98 } | 101 } |
| 99 | 102 |
| 100 } // namespace content | 103 } // namespace content |
| OLD | NEW |