Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "content/browser/renderer_host/input/synthetic_touch_driver.h" | |
| 6 | |
| 7 #include "content/browser/renderer_host/input/synthetic_gesture_target.h" | |
| 8 | |
| 9 namespace content { | |
| 10 | |
| 11 SyntheticTouchDriver::SyntheticTouchDriver() {} | |
| 12 | |
| 13 SyntheticTouchDriver::SyntheticTouchDriver(SyntheticWebTouchEvent touch_event) | |
| 14 : touch_event_(touch_event) {} | |
| 15 | |
| 16 SyntheticTouchDriver::~SyntheticTouchDriver() {} | |
| 17 | |
| 18 void SyntheticTouchDriver::DispatchEvent(SyntheticGestureTarget* target, | |
| 19 const base::TimeTicks& timestamp) { | |
| 20 touch_event_.timeStampSeconds = ConvertTimestampToSeconds(timestamp); | |
| 21 target->DispatchInputEventToPlatform(touch_event_); | |
| 22 } | |
| 23 | |
| 24 int SyntheticTouchDriver::Press(float x, float y) { | |
| 25 int index = touch_event_.PressPoint(x, y); | |
| 26 return index; | |
| 27 } | |
| 28 | |
| 29 void SyntheticTouchDriver::Move(float x, float y, int index) { | |
| 30 touch_event_.MovePoint(index, x, y); | |
| 31 } | |
| 32 | |
| 33 void SyntheticTouchDriver::Release(int index) { | |
| 34 touch_event_.ReleasePoint(index); | |
| 35 } | |
| 36 | |
| 37 bool SyntheticTouchDriver::UserInputCheck( | |
| 38 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
| |
| 39 if (params.gesture_source_type != SyntheticGestureParams::TOUCH_INPUT) | |
| 40 return false; | |
| 41 | |
| 42 if (params.pointer_action_type() == | |
| 43 SyntheticPointerActionParams::PointerActionType::NOT_INITIALIZED) { | |
| 44 return false; | |
| 45 } | |
| 46 | |
| 47 if (params.pointer_action_type() == | |
| 48 SyntheticPointerActionParams::PointerActionType::PRESS && | |
| 49 params.index() >= 0) { | |
| 50 return false; | |
| 51 } | |
| 52 | |
| 53 if (params.pointer_action_type() == | |
| 54 SyntheticPointerActionParams::PointerActionType::MOVE && | |
| 55 params.index() == -1) { | |
| 56 return false; | |
| 57 } | |
| 58 | |
| 59 if (params.pointer_action_type() == | |
| 60 SyntheticPointerActionParams::PointerActionType::RELEASE && | |
| 61 params.index() == -1) { | |
| 62 return false; | |
| 63 } | |
| 64 | |
| 65 return true; | |
| 66 } | |
| 67 | |
| 68 } // namespace content | |
| OLD | NEW |