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..9f16c03c6f836b1895580d39c6ceba70297a7242 100644 |
| --- a/content/browser/renderer_host/input/synthetic_pointer_action.cc |
| +++ b/content/browser/renderer_host/input/synthetic_pointer_action.cc |
| @@ -15,45 +15,76 @@ 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) {} |
|
samuong
2016/07/08 18:38:34
In a previous discussion, we decided that the Synt
lanwei
2016/07/12 19:54:55
Yes, it is commented in its head file.
|
| 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); |
|
samuong
2016/07/08 18:38:35
Does this still need to be a separate function, or
lanwei
2016/07/12 19:54:55
This will be changed in the next patch, so I think
|
| } |
| -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 (!UserInputCheck(params)) |
| + return POINTER_ACTION_INPUT_INVALID; |
| + |
| + switch (params.pointer_action_type()) { |
| + case SyntheticPointerActionParams::PointerActionType::PRESS: |
| + 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); |
| + SetPointIndex(params.index(), -1); |
| + break; |
| + default: |
| + return POINTER_ACTION_INPUT_INVALID; |
| + } |
| } |
| synthetic_pointer_->DispatchEvent(target, timestamp); |
| + return GESTURE_FINISHED; |
| +} |
| + |
| +bool SyntheticPointerAction::UserInputCheck( |
| + const SyntheticPointerActionParams& params) { |
| + if (params.index() < 0 || params.index() >= WebTouchEvent::touchesLengthCap) |
| + return false; |
| + |
| + if (synthetic_pointer_->PointerSourceType() != params.gesture_source_type) |
| + return false; |
| + |
| + if (params.pointer_action_type() == |
| + SyntheticPointerActionParams::PointerActionType::PRESS && |
| + GetPointIndex(params.index()) >= 0) { |
| + return false; |
| + } |
| + |
| + if ((params.pointer_action_type() == |
| + SyntheticPointerActionParams::PointerActionType::MOVE || |
| + params.pointer_action_type() == |
| + SyntheticPointerActionParams::PointerActionType::RELEASE) && |
| + GetPointIndex(params.index()) < 0) { |
| + return false; |
| + } |
| + return true; |
| } |
| } // namespace content |