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