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

Side by Side Diff: content/common/input/synthetic_pointer_action_params.h

Issue 2336803003: Make SyntheticPointerAction to flush the pointer action sequence (Closed)
Patch Set: return invaid when index is out bound 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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 #ifndef CONTENT_COMMON_INPUT_SYNTHETIC_POINTER_ACTION_PARAMS_H_ 5 #ifndef CONTENT_COMMON_INPUT_SYNTHETIC_POINTER_ACTION_PARAMS_H_
6 #define CONTENT_COMMON_INPUT_SYNTHETIC_POINTER_ACTION_PARAMS_H_ 6 #define CONTENT_COMMON_INPUT_SYNTHETIC_POINTER_ACTION_PARAMS_H_
7 7
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "content/common/content_export.h" 9 #include "content/common/content_export.h"
10 #include "content/common/input/input_param_traits.h" 10 #include "content/common/input/input_param_traits.h"
11 #include "content/common/input/synthetic_gesture_params.h" 11 #include "content/common/input/synthetic_gesture_params.h"
12 #include "ui/gfx/geometry/point_f.h" 12 #include "ui/gfx/geometry/point_f.h"
13 13
14 namespace ipc_fuzzer { 14 namespace ipc_fuzzer {
15 template <class T> 15 template <class T>
16 struct FuzzTraits; 16 struct FuzzTraits;
17 } // namespace ipc_fuzzer 17 } // namespace ipc_fuzzer
18 18
19 namespace content { 19 namespace content {
20 20
21 struct CONTENT_EXPORT SyntheticPointerActionParams 21 struct CONTENT_EXPORT SyntheticPointerActionParams {
22 : public SyntheticGestureParams {
23 public: 22 public:
24 // All the pointer actions that will be dispatched together will be grouped 23 // All the pointer actions that will be dispatched together will be grouped
25 // in an array. A FINISH action will be received when we reach the end of the 24 // in an array.
26 // action sequence.
27 enum class PointerActionType { 25 enum class PointerActionType {
28 NOT_INITIALIZED, 26 NOT_INITIALIZED,
29 PRESS, 27 PRESS,
30 MOVE, 28 MOVE,
31 RELEASE, 29 RELEASE,
32 IDLE, 30 POINTER_ACTION_TYPE_MAX = RELEASE
33 FINISH,
34 POINTER_ACTION_TYPE_MAX = FINISH
35 }; 31 };
36 32
37 SyntheticPointerActionParams(); 33 SyntheticPointerActionParams();
38 SyntheticPointerActionParams(PointerActionType action_type, 34 SyntheticPointerActionParams(
39 GestureSourceType source_type); 35 PointerActionType action_type,
40 SyntheticPointerActionParams(const SyntheticPointerActionParams& other); 36 SyntheticGestureParams::GestureSourceType source_type);
41 ~SyntheticPointerActionParams() override; 37 ~SyntheticPointerActionParams();
42
43 GestureType GetGestureType() const override;
44
45 static const SyntheticPointerActionParams* Cast(
46 const SyntheticGestureParams* gesture_params);
47 38
48 void set_pointer_action_type(PointerActionType pointer_action_type) { 39 void set_pointer_action_type(PointerActionType pointer_action_type) {
49 pointer_action_type_ = pointer_action_type; 40 pointer_action_type_ = pointer_action_type;
50 } 41 }
51 42
43 void set_gesture_source_type(
44 SyntheticGestureParams::GestureSourceType gesture_source_type) {
45 gesture_source_type_ = gesture_source_type;
46 }
47
52 void set_index(int index) { 48 void set_index(int index) {
53 DCHECK(pointer_action_type_ != PointerActionType::FINISH);
54 // For mouse pointers, the index should always be 0. 49 // For mouse pointers, the index should always be 0.
tdresser 2016/12/13 14:37:44 Given the comment, let's switch the condition here
lanwei 2016/12/18 17:35:55 Done.
55 DCHECK(gesture_source_type != MOUSE_INPUT || index == 0); 50 if (gesture_source_type_ != SyntheticGestureParams::MOUSE_INPUT) {
51 DCHECK_GE(index, 0);
52 DCHECK_LT(index, blink::WebTouchEvent::kTouchesLengthCap);
53 } else {
54 DCHECK_EQ(index, 0);
55 }
56 index_ = index; 56 index_ = index;
57 } 57 }
58 58
59 void set_position(const gfx::PointF& position) { 59 void set_position(const gfx::PointF& position) {
60 DCHECK(pointer_action_type_ == PointerActionType::PRESS || 60 DCHECK(pointer_action_type_ == PointerActionType::PRESS ||
61 pointer_action_type_ == PointerActionType::MOVE); 61 pointer_action_type_ == PointerActionType::MOVE);
62 position_ = position; 62 position_ = position;
63 } 63 }
64 64
65 PointerActionType pointer_action_type() const { return pointer_action_type_; } 65 PointerActionType pointer_action_type() const { return pointer_action_type_; }
66 66
67 SyntheticGestureParams::GestureSourceType gesture_source_type() const {
68 return gesture_source_type_;
69 }
70
67 int index() const { 71 int index() const {
68 DCHECK(pointer_action_type_ != PointerActionType::FINISH);
69 // For mouse pointers, the index should always be 0. 72 // For mouse pointers, the index should always be 0.
70 DCHECK(gesture_source_type != MOUSE_INPUT || index_ == 0); 73 if (gesture_source_type_ != SyntheticGestureParams::MOUSE_INPUT) {
tdresser 2016/12/13 14:37:43 Same as above, switch the clause order.
lanwei 2016/12/18 17:35:55 Done.
74 DCHECK_GE(index_, 0);
75 DCHECK_LT(index_, blink::WebTouchEvent::kTouchesLengthCap);
76 } else {
77 DCHECK_EQ(index_, 0);
78 }
71 return index_; 79 return index_;
72 } 80 }
73 81
74 gfx::PointF position() const { 82 gfx::PointF position() const {
75 DCHECK(pointer_action_type_ == PointerActionType::PRESS || 83 DCHECK(pointer_action_type_ == PointerActionType::PRESS ||
76 pointer_action_type_ == PointerActionType::MOVE); 84 pointer_action_type_ == PointerActionType::MOVE);
77 return position_; 85 return position_;
78 } 86 }
79 87
80 private: 88 private:
81 friend struct IPC::ParamTraits<content::SyntheticPointerActionParams>; 89 friend struct IPC::ParamTraits<content::SyntheticPointerActionParams>;
82 friend struct ipc_fuzzer::FuzzTraits<content::SyntheticPointerActionParams>; 90 friend struct ipc_fuzzer::FuzzTraits<content::SyntheticPointerActionParams>;
83 91
84 PointerActionType pointer_action_type_; 92 PointerActionType pointer_action_type_;
93 SyntheticGestureParams::GestureSourceType gesture_source_type_;
85 // Pass a position value when sending a press or move action. 94 // Pass a position value when sending a press or move action.
86 gfx::PointF position_; 95 gfx::PointF position_;
87 // Pass an index value except if the pointer_action_type_ is PROCESS. 96 // Pass an index value which is the index of the pointer in the list.
tdresser 2016/12/13 14:37:44 This is a bit confusing. Maybe something like: //
lanwei 2016/12/18 17:35:55 Done.
88 int index_; 97 int index_;
89 }; 98 };
90 99
91 } // namespace content 100 } // namespace content
92 101
93 #endif // CONTENT_COMMON_INPUT_SYNTHETIC_POINTER_ACTION_PARAMS_H_ 102 #endif // CONTENT_COMMON_INPUT_SYNTHETIC_POINTER_ACTION_PARAMS_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698