| 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 "content/common/input/synthetic_web_input_event_builders.h" |
| 12 #include "ui/gfx/geometry/point_f.h" | 13 #include "ui/gfx/geometry/point_f.h" |
| 13 | 14 |
| 14 namespace ipc_fuzzer { | 15 namespace ipc_fuzzer { |
| 15 template <class T> | 16 template <class T> |
| 16 struct FuzzTraits; | 17 struct FuzzTraits; |
| 17 } // namespace ipc_fuzzer | 18 } // namespace ipc_fuzzer |
| 18 | 19 |
| 19 namespace content { | 20 namespace content { |
| 20 | 21 |
| 21 struct CONTENT_EXPORT SyntheticPointerActionParams { | 22 struct CONTENT_EXPORT SyntheticPointerActionParams { |
| 22 public: | 23 public: |
| 23 // All the pointer actions that will be dispatched together will be grouped | 24 // All the pointer actions that will be dispatched together will be grouped |
| 24 // in an array. | 25 // in an array. |
| 25 enum class PointerActionType { | 26 enum class PointerActionType { |
| 26 NOT_INITIALIZED, | 27 NOT_INITIALIZED, |
| 27 PRESS, | 28 PRESS, |
| 28 MOVE, | 29 MOVE, |
| 29 RELEASE, | 30 RELEASE, |
| 30 IDLE, | 31 IDLE, |
| 31 POINTER_ACTION_TYPE_MAX = IDLE | 32 POINTER_ACTION_TYPE_MAX = IDLE |
| 32 }; | 33 }; |
| 33 | 34 |
| 35 enum class Button { LEFT, MIDDLE, RIGHT, BUTTON_MAX = RIGHT }; |
| 36 |
| 34 SyntheticPointerActionParams(); | 37 SyntheticPointerActionParams(); |
| 35 SyntheticPointerActionParams(PointerActionType action_type); | 38 SyntheticPointerActionParams(PointerActionType action_type); |
| 36 ~SyntheticPointerActionParams(); | 39 ~SyntheticPointerActionParams(); |
| 37 | 40 |
| 38 void set_pointer_action_type(PointerActionType pointer_action_type) { | 41 void set_pointer_action_type(PointerActionType pointer_action_type) { |
| 39 pointer_action_type_ = pointer_action_type; | 42 pointer_action_type_ = pointer_action_type; |
| 40 } | 43 } |
| 41 | 44 |
| 42 void set_index(int index) { | 45 void set_index(int index) { |
| 43 DCHECK_GE(index, 0); | 46 DCHECK_GE(index, 0); |
| 44 DCHECK_LT(index, blink::WebTouchEvent::kTouchesLengthCap); | 47 DCHECK_LT(index, blink::WebTouchEvent::kTouchesLengthCap); |
| 45 index_ = index; | 48 index_ = index; |
| 46 } | 49 } |
| 47 | 50 |
| 48 void set_position(const gfx::PointF& position) { | 51 void set_position(const gfx::PointF& position) { |
| 49 DCHECK(pointer_action_type_ == PointerActionType::PRESS || | 52 DCHECK(pointer_action_type_ == PointerActionType::PRESS || |
| 50 pointer_action_type_ == PointerActionType::MOVE); | 53 pointer_action_type_ == PointerActionType::MOVE); |
| 51 position_ = position; | 54 position_ = position; |
| 52 } | 55 } |
| 53 | 56 |
| 57 void set_button(Button button) { |
| 58 DCHECK(pointer_action_type_ == PointerActionType::PRESS || |
| 59 pointer_action_type_ == PointerActionType::RELEASE); |
| 60 button_ = button; |
| 61 } |
| 62 |
| 54 PointerActionType pointer_action_type() const { return pointer_action_type_; } | 63 PointerActionType pointer_action_type() const { return pointer_action_type_; } |
| 55 | 64 |
| 56 int index() const { | 65 int index() const { |
| 57 DCHECK_GE(index_, 0); | 66 DCHECK_GE(index_, 0); |
| 58 DCHECK_LT(index_, blink::WebTouchEvent::kTouchesLengthCap); | 67 DCHECK_LT(index_, blink::WebTouchEvent::kTouchesLengthCap); |
| 59 return index_; | 68 return index_; |
| 60 } | 69 } |
| 61 | 70 |
| 62 gfx::PointF position() const { | 71 gfx::PointF position() const { |
| 63 DCHECK(pointer_action_type_ == PointerActionType::PRESS || | 72 DCHECK(pointer_action_type_ == PointerActionType::PRESS || |
| 64 pointer_action_type_ == PointerActionType::MOVE); | 73 pointer_action_type_ == PointerActionType::MOVE); |
| 65 return position_; | 74 return position_; |
| 66 } | 75 } |
| 67 | 76 |
| 77 Button button() const { |
| 78 DCHECK(pointer_action_type_ == PointerActionType::PRESS || |
| 79 pointer_action_type_ == PointerActionType::RELEASE); |
| 80 return button_; |
| 81 } |
| 82 |
| 83 static unsigned GetWebMouseEventModifier( |
| 84 SyntheticPointerActionParams::Button button); |
| 85 static blink::WebMouseEvent::Button GetWebMouseEventButton( |
| 86 SyntheticPointerActionParams::Button button); |
| 87 |
| 68 private: | 88 private: |
| 69 friend struct IPC::ParamTraits<content::SyntheticPointerActionParams>; | 89 friend struct IPC::ParamTraits<content::SyntheticPointerActionParams>; |
| 70 friend struct ipc_fuzzer::FuzzTraits<content::SyntheticPointerActionParams>; | 90 friend struct ipc_fuzzer::FuzzTraits<content::SyntheticPointerActionParams>; |
| 71 | 91 |
| 72 PointerActionType pointer_action_type_; | 92 PointerActionType pointer_action_type_; |
| 73 // The position of the pointer, where it presses or moves to. | 93 // The position of the pointer, where it presses or moves to. |
| 74 gfx::PointF position_; | 94 gfx::PointF position_; |
| 75 // The index of the pointer in the pointer action sequence passed from the | 95 // The index of the pointer in the pointer action sequence passed from the |
| 76 // user API. | 96 // user API. |
| 77 int index_; | 97 int index_; |
| 98 Button button_; |
| 78 }; | 99 }; |
| 79 | 100 |
| 80 } // namespace content | 101 } // namespace content |
| 81 | 102 |
| 82 #endif // CONTENT_COMMON_INPUT_SYNTHETIC_POINTER_ACTION_PARAMS_H_ | 103 #endif // CONTENT_COMMON_INPUT_SYNTHETIC_POINTER_ACTION_PARAMS_H_ |
| OLD | NEW |