| Index: content/browser/renderer_host/input/synthetic_touch_driver.cc
|
| diff --git a/content/browser/renderer_host/input/synthetic_touch_driver.cc b/content/browser/renderer_host/input/synthetic_touch_driver.cc
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..e014ba18f5214546c84beb6c51330cf74d7377ca
|
| --- /dev/null
|
| +++ b/content/browser/renderer_host/input/synthetic_touch_driver.cc
|
| @@ -0,0 +1,77 @@
|
| +// Copyright 2015 The Chromium Authors. All rights reserved.
|
| +// Use of this source code is governed by a BSD-style license that can be
|
| +// found in the LICENSE file.
|
| +
|
| +#include "content/browser/renderer_host/input/synthetic_touch_driver.h"
|
| +
|
| +#include "content/browser/renderer_host/input/synthetic_gesture_target.h"
|
| +
|
| +namespace content {
|
| +
|
| +SyntheticTouchDriver::SyntheticTouchDriver() {
|
| + std::fill(index_map_.begin(), index_map_.end(), -1);
|
| +}
|
| +
|
| +SyntheticTouchDriver::SyntheticTouchDriver(SyntheticWebTouchEvent touch_event)
|
| + : touch_event_(touch_event) {
|
| + std::fill(index_map_.begin(), index_map_.end(), -1);
|
| +}
|
| +
|
| +SyntheticTouchDriver::~SyntheticTouchDriver() {}
|
| +
|
| +void SyntheticTouchDriver::DispatchEvent(SyntheticGestureTarget* target,
|
| + const base::TimeTicks& timestamp) {
|
| + touch_event_.timeStampSeconds = ConvertTimestampToSeconds(timestamp);
|
| + target->DispatchInputEventToPlatform(touch_event_);
|
| +}
|
| +
|
| +void SyntheticTouchDriver::Press(float x, float y, int index) {
|
| + int point_index = touch_event_.PressPoint(x, y);
|
| + index_map_[index] = point_index;
|
| +}
|
| +
|
| +void SyntheticTouchDriver::Move(float x, float y, int index) {
|
| + touch_event_.MovePoint(index_map_[index], x, y);
|
| +}
|
| +
|
| +void SyntheticTouchDriver::Release(int index) {
|
| + touch_event_.ReleasePoint(index_map_[index]);
|
| + index_map_[index] = -1;
|
| +}
|
| +
|
| +bool SyntheticTouchDriver::UserInputCheck(
|
| + const SyntheticPointerActionParams& params) const {
|
| + if (params.index() < 0 ||
|
| + params.index() >= blink::WebTouchEvent::kTouchesLengthCap) {
|
| + return false;
|
| + }
|
| +
|
| + if (params.gesture_source_type != SyntheticGestureParams::TOUCH_INPUT)
|
| + return false;
|
| +
|
| + if (params.pointer_action_type() ==
|
| + SyntheticPointerActionParams::PointerActionType::PRESS &&
|
| + GetPointIndex(params.index()) >= 0) {
|
| + return false;
|
| + }
|
| +
|
| + if (params.pointer_action_type() ==
|
| + SyntheticPointerActionParams::PointerActionType::MOVE &&
|
| + GetPointIndex(params.index()) < 0) {
|
| + return false;
|
| + }
|
| +
|
| + if (params.pointer_action_type() ==
|
| + SyntheticPointerActionParams::PointerActionType::RELEASE &&
|
| + GetPointIndex(params.index()) < 0) {
|
| + return false;
|
| + }
|
| +
|
| + return true;
|
| +}
|
| +
|
| +int SyntheticTouchDriver::GetPointIndex(int index) const {
|
| + return index_map_[index];
|
| +}
|
| +
|
| +} // namespace content
|
|
|