| 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 std::fill(index_map_.begin(), index_map_.end(), -1); |
| 13 } |
| 14 |
| 15 SyntheticTouchDriver::SyntheticTouchDriver(SyntheticWebTouchEvent touch_event) |
| 16 : touch_event_(touch_event) { |
| 17 std::fill(index_map_.begin(), index_map_.end(), -1); |
| 18 } |
| 19 |
| 20 SyntheticTouchDriver::~SyntheticTouchDriver() {} |
| 21 |
| 22 void SyntheticTouchDriver::DispatchEvent(SyntheticGestureTarget* target, |
| 23 const base::TimeTicks& timestamp) { |
| 24 touch_event_.timeStampSeconds = ConvertTimestampToSeconds(timestamp); |
| 25 target->DispatchInputEventToPlatform(touch_event_); |
| 26 } |
| 27 |
| 28 int SyntheticTouchDriver::Press(int index, |
| 29 float x, |
| 30 float y, |
| 31 SyntheticGestureTarget* target, |
| 32 const base::TimeTicks& timestamp) { |
| 33 int point_index = touch_event_.PressPoint(x, y); |
| 34 index_map_[index] = point_index; |
| 35 return index; |
| 36 } |
| 37 |
| 38 void SyntheticTouchDriver::Move(int index, |
| 39 float x, |
| 40 float y, |
| 41 SyntheticGestureTarget* target, |
| 42 const base::TimeTicks& timestamp) { |
| 43 touch_event_.MovePoint(index_map_[index], x, y); |
| 44 } |
| 45 |
| 46 void SyntheticTouchDriver::Release(int index, |
| 47 SyntheticGestureTarget* target, |
| 48 const base::TimeTicks& timestamp) { |
| 49 touch_event_.ReleasePoint(index_map_[index]); |
| 50 index_map_[index] = -1; |
| 51 } |
| 52 |
| 53 SyntheticGestureParams::GestureSourceType SyntheticTouchDriver::SourceType() |
| 54 const { |
| 55 return SyntheticGestureParams::TOUCH_INPUT; |
| 56 } |
| 57 |
| 58 int SyntheticTouchDriver::GetPointIndex(int index) const { |
| 59 return index_map_[index]; |
| 60 } |
| 61 |
| 62 } // namespace content |
| OLD | NEW |