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 |
| index 519390d212c289bd0522587ca547c2ef6d137b24..7ce4ddfa7d49f5ec1e80ec05c9509a70363f09c5 100644 |
| --- a/content/browser/renderer_host/input/synthetic_touch_driver.cc |
| +++ b/content/browser/renderer_host/input/synthetic_touch_driver.cc |
| @@ -10,10 +10,14 @@ using blink::WebTouchEvent; |
| namespace content { |
| -SyntheticTouchDriver::SyntheticTouchDriver() {} |
| +SyntheticTouchDriver::SyntheticTouchDriver() { |
| + std::fill(index_map_.begin(), index_map_.end(), -1); |
| +} |
| SyntheticTouchDriver::SyntheticTouchDriver(SyntheticWebTouchEvent touch_event) |
| - : touch_event_(touch_event) {} |
| + : touch_event_(touch_event) { |
| + std::fill(index_map_.begin(), index_map_.end(), -1); |
| +} |
| SyntheticTouchDriver::~SyntheticTouchDriver() {} |
| @@ -23,24 +27,32 @@ void SyntheticTouchDriver::DispatchEvent(SyntheticGestureTarget* target, |
| target->DispatchInputEventToPlatform(touch_event_); |
| } |
| -int SyntheticTouchDriver::Press(float x, float y) { |
| - int index = touch_event_.PressPoint(x, y); |
| - return index; |
| +void SyntheticTouchDriver::Press(float x, float y, int index) { |
| + DCHECK_GE(index, 0); |
| + DCHECK_LT(index, WebTouchEvent::kTouchesLengthCap); |
| + int touch_index = touch_event_.PressPoint(x, y); |
| + index_map_[index] = touch_index; |
|
Navid Zolghadr
2016/12/09 16:04:47
I wonder if the debug check is enough. When users
|
| } |
| void SyntheticTouchDriver::Move(float x, float y, int index) { |
| - touch_event_.MovePoint(index, x, y); |
| + DCHECK_GE(index, 0); |
| + DCHECK_LT(index, WebTouchEvent::kTouchesLengthCap); |
| + touch_event_.MovePoint(index_map_[index], x, y); |
| } |
| void SyntheticTouchDriver::Release(int index) { |
| - touch_event_.ReleasePoint(index); |
| + DCHECK_GE(index, 0); |
| + DCHECK_LT(index, WebTouchEvent::kTouchesLengthCap); |
| + touch_event_.ReleasePoint(index_map_[index]); |
| + index_map_[index] = -1; |
| } |
| bool SyntheticTouchDriver::UserInputCheck( |
| const SyntheticPointerActionParams& params) const { |
| - DCHECK_GE(params.index(), -1); |
| + DCHECK_GE(params.index(), 0); |
| DCHECK_LT(params.index(), WebTouchEvent::kTouchesLengthCap); |
| - if (params.gesture_source_type != SyntheticGestureParams::TOUCH_INPUT) |
| + |
| + if (params.gesture_source_type() != SyntheticGestureParams::TOUCH_INPUT) |
| return false; |
| if (params.pointer_action_type() == |
| @@ -50,19 +62,19 @@ bool SyntheticTouchDriver::UserInputCheck( |
| if (params.pointer_action_type() == |
| SyntheticPointerActionParams::PointerActionType::PRESS && |
| - params.index() >= 0) { |
| + index_map_[params.index()] >= 0) { |
| return false; |
| } |
| if (params.pointer_action_type() == |
| SyntheticPointerActionParams::PointerActionType::MOVE && |
| - params.index() == -1) { |
| + index_map_[params.index()] == -1) { |
| return false; |
| } |
| if (params.pointer_action_type() == |
| SyntheticPointerActionParams::PointerActionType::RELEASE && |
| - params.index() == -1) { |
| + index_map_[params.index()] == -1) { |
| return false; |
| } |