| 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..f19e8f6aa56595cb0e5917ed0d5e098552b65a25 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) {}
|
|
|
| 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 (!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_->SourceType() != 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
|
|
|