Chromium Code Reviews| Index: content/browser/renderer_host/input/synthetic_pointer_action.cc |
| diff --git a/content/browser/renderer_host/input/synthetic_pointer_action.cc b/content/browser/renderer_host/input/synthetic_pointer_action.cc |
| index 6353f342631d0cf7cb7ca49235e5e5311823921b..5fc671eded230e9d9c2c09faa2394c4ac5770780 100644 |
| --- a/content/browser/renderer_host/input/synthetic_pointer_action.cc |
| +++ b/content/browser/renderer_host/input/synthetic_pointer_action.cc |
| @@ -15,45 +15,67 @@ SyntheticPointerAction::SyntheticPointerAction( |
| : params_(params) {} |
| SyntheticPointerAction::SyntheticPointerAction( |
| - const SyntheticPointerActionParams& params, |
| - SyntheticPointer* synthetic_pointer) |
| - : params_(params), synthetic_pointer_(synthetic_pointer) {} |
| + std::unique_ptr<std::vector<SyntheticPointerActionParams>> param_list, |
| + SyntheticPointer* synthetic_pointer, |
| + IndexMap* index_map) |
| + : param_list_(std::move(param_list)), |
| + synthetic_pointer_(synthetic_pointer), |
| + index_map_(index_map) {} |
| SyntheticPointerAction::~SyntheticPointerAction() {} |
| SyntheticGesture::Result SyntheticPointerAction::ForwardInputEvents( |
| const base::TimeTicks& timestamp, |
| SyntheticGestureTarget* target) { |
| - if (params_.gesture_source_type == SyntheticGestureParams::DEFAULT_INPUT) |
| - params_.gesture_source_type = |
| - target->GetDefaultSyntheticGestureSourceType(); |
| - |
| - DCHECK_NE(params_.gesture_source_type, SyntheticGestureParams::DEFAULT_INPUT); |
| - |
| - ForwardTouchOrMouseInputEvents(timestamp, target); |
| - return SyntheticGesture::GESTURE_FINISHED; |
| + DCHECK(synthetic_pointer_); |
| + return ForwardTouchOrMouseInputEvents(timestamp, target); |
| } |
| -void SyntheticPointerAction::ForwardTouchOrMouseInputEvents( |
| +SyntheticGesture::Result SyntheticPointerAction::ForwardTouchOrMouseInputEvents( |
| const base::TimeTicks& timestamp, |
| SyntheticGestureTarget* target) { |
| - switch (params_.pointer_action_type()) { |
| - case SyntheticPointerActionParams::PointerActionType::PRESS: |
| - synthetic_pointer_->Press(params_.position().x(), params_.position().y(), |
| - target, timestamp); |
| - break; |
| - case SyntheticPointerActionParams::PointerActionType::MOVE: |
| - synthetic_pointer_->Move(params_.index(), params_.position().x(), |
| - params_.position().y(), target, timestamp); |
| - break; |
| - case SyntheticPointerActionParams::PointerActionType::RELEASE: |
| - synthetic_pointer_->Release(params_.index(), target, timestamp); |
| - break; |
| - default: |
| - NOTREACHED(); |
| - break; |
| + int point_index; |
| + for (const SyntheticPointerActionParams& params : *param_list_) { |
| + if (params.pointer_action_type() == |
| + SyntheticPointerActionParams::PointerActionType::FINISH) |
| + return SyntheticGesture::POINTER_ACTION_FINISHED; |
| + |
| + switch (params.pointer_action_type()) { |
| + case SyntheticPointerActionParams::PointerActionType::PRESS: { |
|
tdresser
2016/05/31 13:44:26
Let's use {} in these case statements consistently
lanwei
2016/06/02 13:26:26
Done.
|
| + point_index = synthetic_pointer_->Press( |
| + params.position().x(), params.position().y(), target, timestamp); |
| + SetPointIndex(params.index(), point_index); |
| + break; |
| + } |
| + case SyntheticPointerActionParams::PointerActionType::MOVE: |
| + point_index = GetPointIndex(params.index()); |
| + synthetic_pointer_->Move(point_index, params.position().x(), |
| + params.position().y(), target, timestamp); |
| + break; |
| + case SyntheticPointerActionParams::PointerActionType::RELEASE: |
| + point_index = GetPointIndex(params.index()); |
| + synthetic_pointer_->Release(point_index, target, timestamp); |
| + break; |
| + default: |
| + NOTREACHED(); |
| + break; |
| + } |
| } |
| synthetic_pointer_->DispatchEvent(target, timestamp); |
| + return SyntheticGesture::POINTER_ACTION_PROCESSED; |
| +} |
| + |
| +int SyntheticPointerAction::GetPointIndex(int index) const { |
| + DCHECK_NE(synthetic_pointer_->PointerSourceType(), |
| + SyntheticGestureParams::DEFAULT_INPUT); |
| + |
| + if (synthetic_pointer_->PointerSourceType() == |
| + SyntheticGestureParams::TOUCH_INPUT) { |
| + CHECK_GE(index, 0); |
| + CHECK_LT(index, WebTouchEvent::touchesLengthCap); |
| + return (*index_map_)[index]; |
|
tdresser
2016/05/31 13:44:26
GetPointIndex(index).
|
| + } |
| + return 0; |
| } |
| } // namespace content |