Chromium Code Reviews| 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..b5f808cf0591d73ca7f66e3da26cad589c48fb0a |
| --- /dev/null |
| +++ b/content/browser/renderer_host/input/synthetic_touch_driver.cc |
| @@ -0,0 +1,68 @@ |
| +// 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() {} |
| + |
| +SyntheticTouchDriver::SyntheticTouchDriver(SyntheticWebTouchEvent touch_event) |
| + : touch_event_(touch_event) {} |
| + |
| +SyntheticTouchDriver::~SyntheticTouchDriver() {} |
| + |
| +void SyntheticTouchDriver::DispatchEvent(SyntheticGestureTarget* target, |
| + const base::TimeTicks& timestamp) { |
| + touch_event_.timeStampSeconds = ConvertTimestampToSeconds(timestamp); |
| + target->DispatchInputEventToPlatform(touch_event_); |
| +} |
| + |
| +int SyntheticTouchDriver::Press(float x, float y) { |
| + int index = touch_event_.PressPoint(x, y); |
| + return index; |
| +} |
| + |
| +void SyntheticTouchDriver::Move(float x, float y, int index) { |
| + touch_event_.MovePoint(index, x, y); |
| +} |
| + |
| +void SyntheticTouchDriver::Release(int index) { |
| + touch_event_.ReleasePoint(index); |
| +} |
| + |
| +bool SyntheticTouchDriver::UserInputCheck( |
| + const SyntheticPointerActionParams& params) const { |
|
tdresser
2016/11/10 14:58:32
Should we check that the index is valid (we have a
lanwei
2016/11/10 19:45:22
I added a DCHECK, because the params.index() is se
|
| + if (params.gesture_source_type != SyntheticGestureParams::TOUCH_INPUT) |
| + return false; |
| + |
| + if (params.pointer_action_type() == |
| + SyntheticPointerActionParams::PointerActionType::NOT_INITIALIZED) { |
| + return false; |
| + } |
| + |
| + if (params.pointer_action_type() == |
| + SyntheticPointerActionParams::PointerActionType::PRESS && |
| + params.index() >= 0) { |
| + return false; |
| + } |
| + |
| + if (params.pointer_action_type() == |
| + SyntheticPointerActionParams::PointerActionType::MOVE && |
| + params.index() == -1) { |
| + return false; |
| + } |
| + |
| + if (params.pointer_action_type() == |
| + SyntheticPointerActionParams::PointerActionType::RELEASE && |
| + params.index() == -1) { |
| + return false; |
| + } |
| + |
| + return true; |
| +} |
| + |
| +} // namespace content |