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