OLD | NEW |
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 // Actions are queued up until we receive a PROCESS action, at which point | 23 // Actions are queued up until we receive a PROCESS action, at which point |
25 // we'll dispatch all queued events. A FINISH action will be received when | 24 // we'll dispatch all queued events. A FINISH action will be received when |
26 // we reach the end of the action sequence. | 25 // we reach the end of the action sequence. |
27 enum class PointerActionType { | 26 enum class PointerActionType { |
28 NOT_INITIALIZED, | 27 NOT_INITIALIZED, |
29 PRESS, | 28 PRESS, |
30 MOVE, | 29 MOVE, |
31 RELEASE, | 30 RELEASE, |
32 PROCESS, | 31 PROCESS, |
33 FINISH, | 32 FINISH, |
34 POINTER_ACTION_TYPE_MAX = FINISH | 33 POINTER_ACTION_TYPE_MAX = FINISH |
35 }; | 34 }; |
36 | 35 |
37 SyntheticPointerActionParams(); | 36 SyntheticPointerActionParams(); |
38 explicit SyntheticPointerActionParams(PointerActionType type); | 37 SyntheticPointerActionParams( |
39 SyntheticPointerActionParams(const SyntheticPointerActionParams& other); | 38 SyntheticGestureParams::GestureSourceType source_type, |
40 ~SyntheticPointerActionParams() override; | 39 PointerActionType action_type); |
41 | 40 ~SyntheticPointerActionParams(); |
42 GestureType GetGestureType() const override; | |
43 | |
44 static const SyntheticPointerActionParams* Cast( | |
45 const SyntheticGestureParams* gesture_params); | |
46 | 41 |
47 void set_pointer_action_type(PointerActionType pointer_action_type) { | 42 void set_pointer_action_type(PointerActionType pointer_action_type) { |
48 pointer_action_type_ = pointer_action_type; | 43 pointer_action_type_ = pointer_action_type; |
49 } | 44 } |
50 | 45 |
51 void set_index(int index) { | 46 void set_index(int index) { |
52 DCHECK(pointer_action_type_ != PointerActionType::PROCESS && | 47 DCHECK(pointer_action_type_ != PointerActionType::PROCESS && |
53 pointer_action_type_ != PointerActionType::FINISH); | 48 pointer_action_type_ != PointerActionType::FINISH); |
54 // For all mouse pointer actions, the index should always be 0. | 49 // For all mouse pointer actions, the index should always be 0. |
55 DCHECK(gesture_source_type != MOUSE_INPUT || index == 0); | 50 DCHECK(gesture_source_type_ != SyntheticGestureParams::MOUSE_INPUT || |
| 51 index == 0); |
56 index_ = index; | 52 index_ = index; |
57 } | 53 } |
58 | 54 |
59 void set_position(const gfx::PointF& position) { | 55 void set_position(const gfx::PointF& position) { |
60 DCHECK(pointer_action_type_ == PointerActionType::PRESS || | 56 DCHECK(pointer_action_type_ == PointerActionType::PRESS || |
61 pointer_action_type_ == PointerActionType::MOVE); | 57 pointer_action_type_ == PointerActionType::MOVE); |
62 position_ = position; | 58 position_ = position; |
63 } | 59 } |
64 | 60 |
65 PointerActionType pointer_action_type() const { return pointer_action_type_; } | 61 PointerActionType pointer_action_type() const { return pointer_action_type_; } |
66 | 62 |
67 int index() const { | 63 int index() const { |
68 DCHECK(pointer_action_type_ != PointerActionType::PROCESS && | 64 DCHECK(pointer_action_type_ != PointerActionType::PROCESS && |
69 pointer_action_type_ != PointerActionType::FINISH); | 65 pointer_action_type_ != PointerActionType::FINISH); |
70 DCHECK(gesture_source_type != MOUSE_INPUT || index_ == 0); | 66 DCHECK(gesture_source_type_ != SyntheticGestureParams::MOUSE_INPUT || |
| 67 index_ == 0); |
71 return index_; | 68 return index_; |
72 } | 69 } |
73 | 70 |
74 gfx::PointF position() const { | 71 gfx::PointF position() const { |
75 DCHECK(pointer_action_type_ == PointerActionType::PRESS || | 72 DCHECK(pointer_action_type_ == PointerActionType::PRESS || |
76 pointer_action_type_ == PointerActionType::MOVE); | 73 pointer_action_type_ == PointerActionType::MOVE); |
77 return position_; | 74 return position_; |
78 } | 75 } |
79 | 76 |
80 private: | 77 private: |
81 friend struct IPC::ParamTraits<content::SyntheticPointerActionParams>; | 78 friend struct IPC::ParamTraits<content::SyntheticPointerActionParams>; |
82 friend struct ipc_fuzzer::FuzzTraits<content::SyntheticPointerActionParams>; | 79 friend struct ipc_fuzzer::FuzzTraits<content::SyntheticPointerActionParams>; |
83 | 80 |
| 81 SyntheticGestureParams::GestureSourceType gesture_source_type_; |
84 PointerActionType pointer_action_type_; | 82 PointerActionType pointer_action_type_; |
85 // Pass a position value when sending a press or move action. | 83 // Pass a position value when sending a press or move action. |
86 gfx::PointF position_; | 84 gfx::PointF position_; |
87 // Pass an index value except if the pointer_action_type_ is PROCESS. | 85 // Pass an index value except if the pointer_action_type_ is PROCESS. |
88 int index_; | 86 int index_; |
89 }; | 87 }; |
90 | 88 |
91 } // namespace content | 89 } // namespace content |
92 | 90 |
93 #endif // CONTENT_COMMON_INPUT_SYNTHETIC_POINTER_ACTION_PARAMS_H_ | 91 #endif // CONTENT_COMMON_INPUT_SYNTHETIC_POINTER_ACTION_PARAMS_H_ |
OLD | NEW |