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" |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 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. A FINISH action will be received when | 25 // we'll dispatch all queued events. A FINISH action will be received when |
| 26 // we reach the end of the action sequence. | 26 // we reach the end of the 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, |
|
tdresser
2016/11/10 14:58:32
Can we add a comment here? Why did this name chang
lanwei
2016/11/10 19:45:23
Done.
| |
| 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 explicit SyntheticPointerActionParams(PointerActionType type); |
| 39 SyntheticPointerActionParams(const SyntheticPointerActionParams& other); | 39 SyntheticPointerActionParams(const SyntheticPointerActionParams& other); |
| 40 ~SyntheticPointerActionParams() override; | 40 ~SyntheticPointerActionParams() override; |
| 41 | 41 |
| 42 GestureType GetGestureType() const override; | 42 GestureType GetGestureType() const override; |
| 43 | 43 |
| 44 static const SyntheticPointerActionParams* Cast( | 44 static const SyntheticPointerActionParams* Cast( |
| 45 const SyntheticGestureParams* gesture_params); | 45 const SyntheticGestureParams* gesture_params); |
| 46 | 46 |
| 47 void set_pointer_action_type(PointerActionType pointer_action_type) { | 47 void set_pointer_action_type(PointerActionType pointer_action_type) { |
| 48 pointer_action_type_ = pointer_action_type; | 48 pointer_action_type_ = pointer_action_type; |
| 49 } | 49 } |
| 50 | 50 |
| 51 void set_index(int index) { | 51 void set_index(int index) { |
| 52 DCHECK(pointer_action_type_ != PointerActionType::PROCESS && | 52 DCHECK(pointer_action_type_ != PointerActionType::FINISH); |
| 53 pointer_action_type_ != PointerActionType::FINISH); | 53 // We only set index for source types which are not mouse. |
|
tdresser
2016/11/10 14:58:32
We shouldn't silently not do anything here.
if (g
lanwei
2016/11/10 19:45:23
Done.
| |
| 54 // For all mouse pointer actions, the index should always be 0. | 54 if (gesture_source_type != MOUSE_INPUT) |
| 55 DCHECK(gesture_source_type != MOUSE_INPUT || index == 0); | 55 index_ = index; |
| 56 index_ = index; | |
| 57 } | 56 } |
| 58 | 57 |
| 59 void set_position(const gfx::PointF& position) { | 58 void set_position(const gfx::PointF& position) { |
| 60 DCHECK(pointer_action_type_ == PointerActionType::PRESS || | 59 DCHECK(pointer_action_type_ == PointerActionType::PRESS || |
| 61 pointer_action_type_ == PointerActionType::MOVE); | 60 pointer_action_type_ == PointerActionType::MOVE); |
| 62 position_ = position; | 61 position_ = position; |
| 63 } | 62 } |
| 64 | 63 |
| 65 PointerActionType pointer_action_type() const { return pointer_action_type_; } | 64 PointerActionType pointer_action_type() const { return pointer_action_type_; } |
| 66 | 65 |
| 67 int index() const { | 66 int index() const { |
| 68 DCHECK(pointer_action_type_ != PointerActionType::PROCESS && | 67 DCHECK(pointer_action_type_ != PointerActionType::FINISH); |
| 69 pointer_action_type_ != PointerActionType::FINISH); | 68 // For source type of mouse, the index should always be -1 and never change. |
| 70 DCHECK(gesture_source_type != MOUSE_INPUT || index_ == 0); | 69 DCHECK(gesture_source_type != MOUSE_INPUT || index_ == -1); |
| 71 return index_; | 70 return index_; |
| 72 } | 71 } |
| 73 | 72 |
| 74 gfx::PointF position() const { | 73 gfx::PointF position() const { |
| 75 DCHECK(pointer_action_type_ == PointerActionType::PRESS || | 74 DCHECK(pointer_action_type_ == PointerActionType::PRESS || |
| 76 pointer_action_type_ == PointerActionType::MOVE); | 75 pointer_action_type_ == PointerActionType::MOVE); |
| 77 return position_; | 76 return position_; |
| 78 } | 77 } |
| 79 | 78 |
| 80 private: | 79 private: |
| 81 friend struct IPC::ParamTraits<content::SyntheticPointerActionParams>; | 80 friend struct IPC::ParamTraits<content::SyntheticPointerActionParams>; |
| 82 friend struct ipc_fuzzer::FuzzTraits<content::SyntheticPointerActionParams>; | 81 friend struct ipc_fuzzer::FuzzTraits<content::SyntheticPointerActionParams>; |
| 83 | 82 |
| 84 PointerActionType pointer_action_type_; | 83 PointerActionType pointer_action_type_; |
| 85 // Pass a position value when sending a press or move action. | 84 // Pass a position value when sending a press or move action. |
| 86 gfx::PointF position_; | 85 gfx::PointF position_; |
| 87 // Pass an index value except if the pointer_action_type_ is PROCESS. | 86 // Pass an index value except if the pointer_action_type_ is PROCESS. |
| 88 int index_; | 87 int index_; |
| 89 }; | 88 }; |
| 90 | 89 |
| 91 } // namespace content | 90 } // namespace content |
| 92 | 91 |
| 93 #endif // CONTENT_COMMON_INPUT_SYNTHETIC_POINTER_ACTION_PARAMS_H_ | 92 #endif // CONTENT_COMMON_INPUT_SYNTHETIC_POINTER_ACTION_PARAMS_H_ |
| OLD | NEW |