| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "content/browser/renderer_host/input/synthetic_touch_driver.h" | 5 #include "content/browser/renderer_host/input/synthetic_touch_driver.h" |
| 6 | 6 |
| 7 #include "content/browser/renderer_host/input/synthetic_gesture_target.h" | 7 #include "content/browser/renderer_host/input/synthetic_gesture_target.h" |
| 8 | 8 |
| 9 namespace content { | 9 namespace content { |
| 10 | 10 |
| 11 SyntheticTouchDriver::SyntheticTouchDriver() { | 11 SyntheticTouchDriver::SyntheticTouchDriver() { |
| 12 std::fill(index_map_.begin(), index_map_.end(), -1); | 12 std::fill(index_map_.begin(), index_map_.end(), -1); |
| 13 } | 13 } |
| 14 | 14 |
| 15 SyntheticTouchDriver::SyntheticTouchDriver(SyntheticWebTouchEvent touch_event) | 15 SyntheticTouchDriver::SyntheticTouchDriver(SyntheticWebTouchEvent touch_event) |
| 16 : touch_event_(touch_event) { | 16 : touch_event_(touch_event) { |
| 17 std::fill(index_map_.begin(), index_map_.end(), -1); | 17 std::fill(index_map_.begin(), index_map_.end(), -1); |
| 18 } | 18 } |
| 19 | 19 |
| 20 SyntheticTouchDriver::~SyntheticTouchDriver() {} | 20 SyntheticTouchDriver::~SyntheticTouchDriver() {} |
| 21 | 21 |
| 22 void SyntheticTouchDriver::DispatchEvent(SyntheticGestureTarget* target, | 22 void SyntheticTouchDriver::DispatchEvent(SyntheticGestureTarget* target, |
| 23 const base::TimeTicks& timestamp) { | 23 const base::TimeTicks& timestamp) { |
| 24 touch_event_.setTimeStampSeconds(ConvertTimestampToSeconds(timestamp)); | 24 touch_event_.setTimeStampSeconds(ConvertTimestampToSeconds(timestamp)); |
| 25 if (touch_event_.type() != blink::WebInputEvent::Undefined) | 25 if (touch_event_.type() != blink::WebInputEvent::Undefined) |
| 26 target->DispatchInputEventToPlatform(touch_event_); | 26 target->DispatchInputEventToPlatform(touch_event_); |
| 27 touch_event_.ResetPoints(); | 27 touch_event_.ResetPoints(); |
| 28 } | 28 } |
| 29 | 29 |
| 30 void SyntheticTouchDriver::Press(float x, float y, int index) { | 30 void SyntheticTouchDriver::Press(float x, |
| 31 float y, |
| 32 int index, |
| 33 SyntheticPointerActionParams::Button button) { |
| 31 DCHECK_GE(index, 0); | 34 DCHECK_GE(index, 0); |
| 32 DCHECK_LT(index, blink::WebTouchEvent::kTouchesLengthCap); | 35 DCHECK_LT(index, blink::WebTouchEvent::kTouchesLengthCap); |
| 33 int touch_index = touch_event_.PressPoint(x, y); | 36 int touch_index = touch_event_.PressPoint(x, y); |
| 34 index_map_[index] = touch_index; | 37 index_map_[index] = touch_index; |
| 35 } | 38 } |
| 36 | 39 |
| 37 void SyntheticTouchDriver::Move(float x, float y, int index) { | 40 void SyntheticTouchDriver::Move(float x, float y, int index) { |
| 38 DCHECK_GE(index, 0); | 41 DCHECK_GE(index, 0); |
| 39 DCHECK_LT(index, blink::WebTouchEvent::kTouchesLengthCap); | 42 DCHECK_LT(index, blink::WebTouchEvent::kTouchesLengthCap); |
| 40 touch_event_.MovePoint(index_map_[index], x, y); | 43 touch_event_.MovePoint(index_map_[index], x, y); |
| 41 } | 44 } |
| 42 | 45 |
| 43 void SyntheticTouchDriver::Release(int index) { | 46 void SyntheticTouchDriver::Release( |
| 47 int index, |
| 48 SyntheticPointerActionParams::Button button) { |
| 44 DCHECK_GE(index, 0); | 49 DCHECK_GE(index, 0); |
| 45 DCHECK_LT(index, blink::WebTouchEvent::kTouchesLengthCap); | 50 DCHECK_LT(index, blink::WebTouchEvent::kTouchesLengthCap); |
| 46 touch_event_.ReleasePoint(index_map_[index]); | 51 touch_event_.ReleasePoint(index_map_[index]); |
| 47 index_map_[index] = -1; | 52 index_map_[index] = -1; |
| 48 } | 53 } |
| 49 | 54 |
| 50 bool SyntheticTouchDriver::UserInputCheck( | 55 bool SyntheticTouchDriver::UserInputCheck( |
| 51 const SyntheticPointerActionParams& params) const { | 56 const SyntheticPointerActionParams& params) const { |
| 52 if (params.index() < 0 || | 57 if (params.index() < 0 || |
| 53 params.index() >= blink::WebTouchEvent::kTouchesLengthCap) | 58 params.index() >= blink::WebTouchEvent::kTouchesLengthCap) |
| (...skipping 19 matching lines...) Expand all Loading... |
| 73 if (params.pointer_action_type() == | 78 if (params.pointer_action_type() == |
| 74 SyntheticPointerActionParams::PointerActionType::RELEASE && | 79 SyntheticPointerActionParams::PointerActionType::RELEASE && |
| 75 index_map_[params.index()] == -1) { | 80 index_map_[params.index()] == -1) { |
| 76 return false; | 81 return false; |
| 77 } | 82 } |
| 78 | 83 |
| 79 return true; | 84 return true; |
| 80 } | 85 } |
| 81 | 86 |
| 82 } // namespace content | 87 } // namespace content |
| OLD | NEW |