1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
content / common / input / input_injector_mojom_traits.cc [blame]
// Copyright 2021 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "content/common/input/input_injector_mojom_traits.h"
namespace mojo {
// static
content::mojom::PointerActionType
EnumTraits<content::mojom::PointerActionType,
content::SyntheticPointerActionParams::PointerActionType>::
ToMojom(content::SyntheticPointerActionParams::PointerActionType input) {
switch (input) {
case content::SyntheticPointerActionParams::PointerActionType::
NOT_INITIALIZED:
return content::mojom::PointerActionType::kNotInitialized;
case content::SyntheticPointerActionParams::PointerActionType::PRESS:
return content::mojom::PointerActionType::kPress;
case content::SyntheticPointerActionParams::PointerActionType::MOVE:
return content::mojom::PointerActionType::kMove;
case content::SyntheticPointerActionParams::PointerActionType::RELEASE:
return content::mojom::PointerActionType::kRelease;
case content::SyntheticPointerActionParams::PointerActionType::CANCEL:
return content::mojom::PointerActionType::kCancel;
case content::SyntheticPointerActionParams::PointerActionType::LEAVE:
return content::mojom::PointerActionType::kLeave;
case content::SyntheticPointerActionParams::PointerActionType::IDLE:
return content::mojom::PointerActionType::kIdle;
}
NOTREACHED_IN_MIGRATION();
return content::mojom::PointerActionType::kMaxValue;
}
// static
bool EnumTraits<content::mojom::PointerActionType,
content::SyntheticPointerActionParams::PointerActionType>::
FromMojom(
content::mojom::PointerActionType input,
content::SyntheticPointerActionParams::PointerActionType* output) {
switch (input) {
case content::mojom::PointerActionType::kNotInitialized:
*output = content::SyntheticPointerActionParams::PointerActionType::
NOT_INITIALIZED;
return true;
case content::mojom::PointerActionType::kPress:
*output = content::SyntheticPointerActionParams::PointerActionType::PRESS;
return true;
case content::mojom::PointerActionType::kMove:
*output = content::SyntheticPointerActionParams::PointerActionType::MOVE;
return true;
case content::mojom::PointerActionType::kRelease:
*output =
content::SyntheticPointerActionParams::PointerActionType::RELEASE;
return true;
case content::mojom::PointerActionType::kCancel:
*output =
content::SyntheticPointerActionParams::PointerActionType::CANCEL;
return true;
case content::mojom::PointerActionType::kLeave:
*output = content::SyntheticPointerActionParams::PointerActionType::LEAVE;
return true;
case content::mojom::PointerActionType::kIdle:
*output = content::SyntheticPointerActionParams::PointerActionType::IDLE;
return true;
}
NOTREACHED_IN_MIGRATION();
return false;
}
// static
content::mojom::SyntheticButton
EnumTraits<content::mojom::SyntheticButton,
content::SyntheticPointerActionParams::Button>::
ToMojom(content::SyntheticPointerActionParams::Button input) {
switch (input) {
case content::SyntheticPointerActionParams::Button::NO_BUTTON:
return content::mojom::SyntheticButton::kNoButton;
case content::SyntheticPointerActionParams::Button::LEFT:
return content::mojom::SyntheticButton::kLeft;
case content::SyntheticPointerActionParams::Button::MIDDLE:
return content::mojom::SyntheticButton::kMiddle;
case content::SyntheticPointerActionParams::Button::RIGHT:
return content::mojom::SyntheticButton::kRight;
case content::SyntheticPointerActionParams::Button::BACK:
return content::mojom::SyntheticButton::kBack;
case content::SyntheticPointerActionParams::Button::FORWARD:
return content::mojom::SyntheticButton::kForward;
}
NOTREACHED_IN_MIGRATION();
return content::mojom::SyntheticButton::kMaxValue;
}
// static
bool EnumTraits<content::mojom::SyntheticButton,
content::SyntheticPointerActionParams::Button>::
FromMojom(content::mojom::SyntheticButton input,
content::SyntheticPointerActionParams::Button* output) {
switch (input) {
case content::mojom::SyntheticButton::kNoButton:
*output = content::SyntheticPointerActionParams::Button::NO_BUTTON;
return true;
case content::mojom::SyntheticButton::kLeft:
*output = content::SyntheticPointerActionParams::Button::LEFT;
return true;
case content::mojom::SyntheticButton::kMiddle:
*output = content::SyntheticPointerActionParams::Button::MIDDLE;
return true;
case content::mojom::SyntheticButton::kRight:
*output = content::SyntheticPointerActionParams::Button::RIGHT;
return true;
case content::mojom::SyntheticButton::kBack:
*output = content::SyntheticPointerActionParams::Button::BACK;
return true;
case content::mojom::SyntheticButton::kForward:
*output = content::SyntheticPointerActionParams::Button::FORWARD;
return true;
}
NOTREACHED_IN_MIGRATION();
return false;
}
// static
bool StructTraits<content::mojom::SyntheticSmoothDragDataView,
content::SyntheticSmoothDragGestureParams>::
Read(content::mojom::SyntheticSmoothDragDataView data,
content::SyntheticSmoothDragGestureParams* out) {
if (!data.ReadStartPoint(&out->start_point) ||
!data.ReadDistances(&out->distances))
return false;
out->gesture_source_type = data.gesture_source_type();
out->speed_in_pixels_s = data.speed_in_pixels_s();
out->vsync_offset_ms = data.vsync_offset_ms();
out->input_event_pattern = data.input_event_pattern();
return true;
}
// static
bool StructTraits<content::mojom::SyntheticSmoothScrollDataView,
content::SyntheticSmoothScrollGestureParams>::
Read(content::mojom::SyntheticSmoothScrollDataView data,
content::SyntheticSmoothScrollGestureParams* out) {
if (!data.ReadAnchor(&out->anchor) || !data.ReadDistances(&out->distances) ||
!data.ReadGranularity(&out->granularity))
return false;
out->gesture_source_type = data.gesture_source_type();
out->prevent_fling = data.prevent_fling();
out->speed_in_pixels_s = data.speed_in_pixels_s();
out->fling_velocity_x = data.fling_velocity_x();
out->fling_velocity_y = data.fling_velocity_y();
out->modifiers = data.modifiers();
out->vsync_offset_ms = data.vsync_offset_ms();
out->input_event_pattern = data.input_event_pattern();
return true;
}
// static
bool StructTraits<content::mojom::SyntheticPinchDataView,
content::SyntheticPinchGestureParams>::
Read(content::mojom::SyntheticPinchDataView data,
content::SyntheticPinchGestureParams* out) {
if (!data.ReadAnchor(&out->anchor))
return false;
out->scale_factor = data.scale_factor();
out->relative_pointer_speed_in_pixels_s =
data.relative_pointer_speed_in_pixels_s();
out->vsync_offset_ms = data.vsync_offset_ms();
out->input_event_pattern = data.input_event_pattern();
return true;
}
// static
bool StructTraits<content::mojom::SyntheticTapDataView,
content::SyntheticTapGestureParams>::
Read(content::mojom::SyntheticTapDataView data,
content::SyntheticTapGestureParams* out) {
if (!data.ReadPosition(&out->position))
return false;
out->gesture_source_type = data.gesture_source_type();
out->duration_ms = data.duration_ms();
return true;
}
// static
bool StructTraits<content::mojom::SyntheticPointerActionParamsDataView,
content::SyntheticPointerActionParams>::
Read(content::mojom::SyntheticPointerActionParamsDataView data,
content::SyntheticPointerActionParams* out) {
if (!data.ReadPointerActionType(&out->pointer_action_type_) ||
!data.ReadPosition(&out->position_) || !data.ReadButton(&out->button_) ||
!data.ReadTimestamp(&out->timestamp_) ||
!data.ReadDuration(&out->duration_))
return false;
out->pointer_id_ = data.pointer_id();
out->key_modifiers_ = data.key_modifiers();
out->width_ = data.width();
out->height_ = data.height();
out->rotation_angle_ = data.rotation_angle();
out->force_ = data.force();
out->tangential_pressure_ = data.tangential_pressure();
out->tilt_x_ = data.tilt_x();
out->tilt_y_ = data.tilt_y();
return true;
}
// static
bool StructTraits<content::mojom::SyntheticPointerActionDataView,
content::SyntheticPointerActionListParams>::
Read(content::mojom::SyntheticPointerActionDataView data,
content::SyntheticPointerActionListParams* out) {
if (!data.ReadParams(&out->params))
return false;
out->gesture_source_type = data.gesture_source_type();
return true;
}
} // namespace mojo