Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(541)

Side by Side Diff: content/browser/renderer_host/input/synthetic_touch_driver.cc

Issue 2336803003: Make SyntheticPointerAction to flush the pointer action sequence (Closed)
Patch Set: controller Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 using blink::WebTouchEvent; 9 using blink::WebTouchEvent;
10 10
11 namespace content { 11 namespace content {
12 12
13 SyntheticTouchDriver::SyntheticTouchDriver() {} 13 SyntheticTouchDriver::SyntheticTouchDriver() {
14 std::fill(index_map_.begin(), index_map_.end(), -1);
15 }
14 16
15 SyntheticTouchDriver::SyntheticTouchDriver(SyntheticWebTouchEvent touch_event) 17 SyntheticTouchDriver::SyntheticTouchDriver(SyntheticWebTouchEvent touch_event)
16 : touch_event_(touch_event) {} 18 : touch_event_(touch_event) {
19 std::fill(index_map_.begin(), index_map_.end(), -1);
20 }
17 21
18 SyntheticTouchDriver::~SyntheticTouchDriver() {} 22 SyntheticTouchDriver::~SyntheticTouchDriver() {}
19 23
20 void SyntheticTouchDriver::DispatchEvent(SyntheticGestureTarget* target, 24 void SyntheticTouchDriver::DispatchEvent(SyntheticGestureTarget* target,
21 const base::TimeTicks& timestamp) { 25 const base::TimeTicks& timestamp) {
22 touch_event_.timeStampSeconds = ConvertTimestampToSeconds(timestamp); 26 touch_event_.timeStampSeconds = ConvertTimestampToSeconds(timestamp);
23 target->DispatchInputEventToPlatform(touch_event_); 27 target->DispatchInputEventToPlatform(touch_event_);
24 } 28 }
25 29
26 int SyntheticTouchDriver::Press(float x, float y) { 30 void SyntheticTouchDriver::Press(float x, float y, int index) {
27 int index = touch_event_.PressPoint(x, y); 31 int touch_index = touch_event_.PressPoint(x, y);
28 return index; 32 index_map_[index] = touch_index;
Navid Zolghadr 2016/12/06 17:05:38 We are using an array and passing the index direct
lanwei 2016/12/07 19:04:27 Done.
29 } 33 }
30 34
31 void SyntheticTouchDriver::Move(float x, float y, int index) { 35 void SyntheticTouchDriver::Move(float x, float y, int index) {
32 touch_event_.MovePoint(index, x, y); 36 touch_event_.MovePoint(index_map_[index], x, y);
33 } 37 }
34 38
35 void SyntheticTouchDriver::Release(int index) { 39 void SyntheticTouchDriver::Release(int index) {
36 touch_event_.ReleasePoint(index); 40 touch_event_.ReleasePoint(index_map_[index]);
41 index_map_[index] = -1;
37 } 42 }
38 43
39 bool SyntheticTouchDriver::UserInputCheck( 44 bool SyntheticTouchDriver::UserInputCheck(
40 const SyntheticPointerActionParams& params) const { 45 const SyntheticPointerActionParams& params) const {
41 DCHECK_GE(params.index(), -1); 46 DCHECK_GE(params.index(), 0);
42 DCHECK_LT(params.index(), WebTouchEvent::kTouchesLengthCap); 47 DCHECK_LT(params.index(), WebTouchEvent::kTouchesLengthCap);
43 if (params.gesture_source_type != SyntheticGestureParams::TOUCH_INPUT) 48
49 if (params.gesture_source_type() != SyntheticGestureParams::TOUCH_INPUT)
44 return false; 50 return false;
45 51
46 if (params.pointer_action_type() == 52 if (params.pointer_action_type() ==
47 SyntheticPointerActionParams::PointerActionType::NOT_INITIALIZED) { 53 SyntheticPointerActionParams::PointerActionType::NOT_INITIALIZED) {
48 return false; 54 return false;
49 } 55 }
50 56
51 if (params.pointer_action_type() == 57 if (params.pointer_action_type() ==
52 SyntheticPointerActionParams::PointerActionType::PRESS && 58 SyntheticPointerActionParams::PointerActionType::PRESS &&
53 params.index() >= 0) { 59 index_map_[params.index()] >= 0) {
54 return false; 60 return false;
55 } 61 }
56 62
57 if (params.pointer_action_type() == 63 if (params.pointer_action_type() ==
58 SyntheticPointerActionParams::PointerActionType::MOVE && 64 SyntheticPointerActionParams::PointerActionType::MOVE &&
59 params.index() == -1) { 65 index_map_[params.index()] == -1) {
60 return false; 66 return false;
61 } 67 }
62 68
63 if (params.pointer_action_type() == 69 if (params.pointer_action_type() ==
64 SyntheticPointerActionParams::PointerActionType::RELEASE && 70 SyntheticPointerActionParams::PointerActionType::RELEASE &&
65 params.index() == -1) { 71 index_map_[params.index()] == -1) {
66 return false; 72 return false;
67 } 73 }
68 74
69 return true; 75 return true;
70 } 76 }
71 77
72 } // namespace content 78 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698