| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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_pointer_action.h" | 5 #include "content/browser/renderer_host/input/synthetic_pointer_action.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "third_party/WebKit/public/web/WebInputEvent.h" | 8 #include "third_party/WebKit/public/web/WebInputEvent.h" |
| 9 #include "ui/events/latency_info.h" | 9 #include "ui/events/latency_info.h" |
| 10 | 10 |
| 11 namespace content { | 11 namespace content { |
| 12 | 12 |
| 13 SyntheticPointerAction::SyntheticPointerAction( | 13 SyntheticPointerAction::SyntheticPointerAction( |
| 14 const SyntheticPointerActionParams& params) |
| 15 : params_(params) {} |
| 16 |
| 17 SyntheticPointerAction::SyntheticPointerAction( |
| 14 SyntheticGestureParams::GestureSourceType gesture_source_type, | 18 SyntheticGestureParams::GestureSourceType gesture_source_type, |
| 15 PointerActionType pointer_action_type, | 19 SyntheticGestureParams::PointerActionType pointer_action_type, |
| 16 SyntheticPointer* synthetic_pointer, | 20 SyntheticPointer* synthetic_pointer, |
| 17 gfx::PointF position, | 21 gfx::PointF position, |
| 18 int index) | 22 int index) |
| 19 : gesture_source_type_(gesture_source_type), | 23 : gesture_source_type_(gesture_source_type), |
| 20 pointer_action_type_(pointer_action_type), | 24 pointer_action_type_(pointer_action_type), |
| 21 position_(position), | 25 position_(position), |
| 22 index_(index), | 26 index_(index), |
| 23 synthetic_pointer_(synthetic_pointer) {} | 27 synthetic_pointer_(synthetic_pointer) {} |
| 24 | 28 |
| 25 SyntheticPointerAction::~SyntheticPointerAction() {} | 29 SyntheticPointerAction::~SyntheticPointerAction() {} |
| 26 | 30 |
| 27 SyntheticGesture::Result SyntheticPointerAction::ForwardInputEvents( | 31 SyntheticGesture::Result SyntheticPointerAction::ForwardInputEvents( |
| 28 const base::TimeTicks& timestamp, | 32 const base::TimeTicks& timestamp, |
| 29 SyntheticGestureTarget* target) { | 33 SyntheticGestureTarget* target) { |
| 30 if (gesture_source_type_ == SyntheticGestureParams::DEFAULT_INPUT) | 34 if (gesture_source_type_ == SyntheticGestureParams::DEFAULT_INPUT) |
| 31 gesture_source_type_ = target->GetDefaultSyntheticGestureSourceType(); | 35 gesture_source_type_ = target->GetDefaultSyntheticGestureSourceType(); |
| 32 | 36 |
| 33 DCHECK_NE(gesture_source_type_, SyntheticGestureParams::DEFAULT_INPUT); | 37 DCHECK_NE(gesture_source_type_, SyntheticGestureParams::DEFAULT_INPUT); |
| 34 | 38 |
| 35 ForwardTouchOrMouseInputEvents(timestamp, target); | 39 ForwardTouchOrMouseInputEvents(timestamp, target); |
| 36 return SyntheticGesture::GESTURE_FINISHED; | 40 return SyntheticGesture::GESTURE_FINISHED; |
| 37 } | 41 } |
| 38 | 42 |
| 39 void SyntheticPointerAction::ForwardTouchOrMouseInputEvents( | 43 void SyntheticPointerAction::ForwardTouchOrMouseInputEvents( |
| 40 const base::TimeTicks& timestamp, | 44 const base::TimeTicks& timestamp, |
| 41 SyntheticGestureTarget* target) { | 45 SyntheticGestureTarget* target) { |
| 42 switch (pointer_action_type_) { | 46 switch (pointer_action_type_) { |
| 43 case SyntheticGesture::PRESS: | 47 case SyntheticGestureParams::PointerActionType::PRESS: |
| 44 synthetic_pointer_->Press(position_.x(), position_.y(), target, | 48 synthetic_pointer_->Press(position_.x(), position_.y(), target, |
| 45 timestamp); | 49 timestamp); |
| 46 break; | 50 break; |
| 47 case SyntheticGesture::MOVE: | 51 case SyntheticGestureParams::PointerActionType::MOVE: |
| 48 synthetic_pointer_->Move(index_, position_.x(), position_.y(), target, | 52 synthetic_pointer_->Move(index_, position_.x(), position_.y(), target, |
| 49 timestamp); | 53 timestamp); |
| 50 break; | 54 break; |
| 51 case SyntheticGesture::RELEASE: | 55 case SyntheticGestureParams::PointerActionType::RELEASE: |
| 52 synthetic_pointer_->Release(index_, target, timestamp); | 56 synthetic_pointer_->Release(index_, target, timestamp); |
| 53 break; | 57 break; |
| 58 default: |
| 59 break; |
| 54 } | 60 } |
| 55 synthetic_pointer_->DispatchEvent(target, timestamp); | 61 synthetic_pointer_->DispatchEvent(target, timestamp); |
| 56 } | 62 } |
| 57 | 63 |
| 58 } // namespace content | 64 } // namespace content |
| OLD | NEW |