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
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
content / common / input / input_injector_mojom_traits.h [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.
#ifndef CONTENT_COMMON_INPUT_INPUT_INJECTOR_MOJOM_TRAITS_H_
#define CONTENT_COMMON_INPUT_INPUT_INJECTOR_MOJOM_TRAITS_H_
#include "content/common/input/input_injector.mojom.h"
#include "content/common/input/synthetic_pinch_gesture_params.h"
#include "content/common/input/synthetic_pointer_action_list_params.h"
#include "content/common/input/synthetic_pointer_action_params.h"
#include "content/common/input/synthetic_smooth_drag_gesture_params.h"
#include "content/common/input/synthetic_smooth_scroll_gesture_params.h"
#include "content/common/input/synthetic_tap_gesture_params.h"
#include "ui/events/types/scroll_types.h"
#include "ui/gfx/geometry/point_f.h"
namespace mojo {
template <>
struct EnumTraits<content::mojom::PointerActionType,
content::SyntheticPointerActionParams::PointerActionType> {
static content::mojom::PointerActionType ToMojom(
content::SyntheticPointerActionParams::PointerActionType input);
static bool FromMojom(
content::mojom::PointerActionType input,
content::SyntheticPointerActionParams::PointerActionType* output);
};
template <>
struct EnumTraits<content::mojom::SyntheticButton,
content::SyntheticPointerActionParams::Button> {
static content::mojom::SyntheticButton ToMojom(
content::SyntheticPointerActionParams::Button input);
static bool FromMojom(content::mojom::SyntheticButton input,
content::SyntheticPointerActionParams::Button* output);
};
template <>
struct StructTraits<content::mojom::SyntheticSmoothDragDataView,
content::SyntheticSmoothDragGestureParams> {
static content::mojom::GestureSourceType gesture_source_type(
const content::SyntheticSmoothDragGestureParams& r) {
return r.gesture_source_type;
}
static const gfx::PointF& start_point(
const content::SyntheticSmoothDragGestureParams& r) {
return r.start_point;
}
static const std::vector<gfx::Vector2dF>& distances(
const content::SyntheticSmoothDragGestureParams& r) {
return r.distances;
}
static float speed_in_pixels_s(
const content::SyntheticSmoothDragGestureParams& r) {
return r.speed_in_pixels_s;
}
static float vsync_offset_ms(
const content::SyntheticSmoothDragGestureParams& r) {
return r.vsync_offset_ms;
}
static content::mojom::InputEventPattern input_event_pattern(
const content::SyntheticSmoothDragGestureParams& r) {
return r.input_event_pattern;
}
static bool Read(content::mojom::SyntheticSmoothDragDataView r,
content::SyntheticSmoothDragGestureParams* out);
};
template <>
struct StructTraits<content::mojom::SyntheticPinchDataView,
content::SyntheticPinchGestureParams> {
static float scale_factor(const content::SyntheticPinchGestureParams& r) {
return r.scale_factor;
}
static const gfx::PointF& anchor(
const content::SyntheticPinchGestureParams& r) {
return r.anchor;
}
static float relative_pointer_speed_in_pixels_s(
const content::SyntheticPinchGestureParams& r) {
return r.relative_pointer_speed_in_pixels_s;
}
static float vsync_offset_ms(const content::SyntheticPinchGestureParams& r) {
return r.vsync_offset_ms;
}
static content::mojom::InputEventPattern input_event_pattern(
const content::SyntheticPinchGestureParams& r) {
return r.input_event_pattern;
}
static bool Read(content::mojom::SyntheticPinchDataView r,
content::SyntheticPinchGestureParams* out);
};
template <>
struct StructTraits<content::mojom::SyntheticSmoothScrollDataView,
content::SyntheticSmoothScrollGestureParams> {
static content::mojom::GestureSourceType gesture_source_type(
const content::SyntheticSmoothScrollGestureParams& r) {
return r.gesture_source_type;
}
static const gfx::PointF& anchor(
const content::SyntheticSmoothScrollGestureParams& r) {
return r.anchor;
}
static const std::vector<gfx::Vector2dF>& distances(
const content::SyntheticSmoothScrollGestureParams& r) {
return r.distances;
}
static bool prevent_fling(
const content::SyntheticSmoothScrollGestureParams& r) {
return r.prevent_fling;
}
static float speed_in_pixels_s(
const content::SyntheticSmoothScrollGestureParams& r) {
return r.speed_in_pixels_s;
}
static float fling_velocity_x(
const content::SyntheticSmoothScrollGestureParams& r) {
return r.fling_velocity_x;
}
static float fling_velocity_y(
const content::SyntheticSmoothScrollGestureParams& r) {
return r.fling_velocity_y;
}
static ui::ScrollGranularity granularity(
const content::SyntheticSmoothScrollGestureParams& r) {
return r.granularity;
}
static int32_t modifiers(
const content::SyntheticSmoothScrollGestureParams& r) {
return r.modifiers;
}
static float vsync_offset_ms(
const content::SyntheticSmoothScrollGestureParams& r) {
return r.vsync_offset_ms;
}
static content::mojom::InputEventPattern input_event_pattern(
const content::SyntheticSmoothScrollGestureParams& r) {
return r.input_event_pattern;
}
static bool Read(content::mojom::SyntheticSmoothScrollDataView r,
content::SyntheticSmoothScrollGestureParams* out);
};
template <>
struct StructTraits<content::mojom::SyntheticTapDataView,
content::SyntheticTapGestureParams> {
static content::mojom::GestureSourceType gesture_source_type(
const content::SyntheticTapGestureParams& r) {
return r.gesture_source_type;
}
static const gfx::PointF& position(
const content::SyntheticTapGestureParams& r) {
return r.position;
}
static float duration_ms(const content::SyntheticTapGestureParams& r) {
return r.duration_ms;
}
static bool Read(content::mojom::SyntheticTapDataView r,
content::SyntheticTapGestureParams* out);
};
template <>
struct StructTraits<content::mojom::SyntheticPointerActionParamsDataView,
content::SyntheticPointerActionParams> {
static content::SyntheticPointerActionParams::PointerActionType
pointer_action_type(const content::SyntheticPointerActionParams& r) {
return r.pointer_action_type_;
}
static gfx::PointF position(const content::SyntheticPointerActionParams& r) {
return r.position_;
}
static uint32_t pointer_id(const content::SyntheticPointerActionParams& r) {
return r.pointer_id_;
}
static content::SyntheticPointerActionParams::Button button(
const content::SyntheticPointerActionParams& r) {
return r.button_;
}
static uint32_t key_modifiers(
const content::SyntheticPointerActionParams& r) {
return r.key_modifiers_;
}
static float width(const content::SyntheticPointerActionParams& r) {
return r.width_;
}
static float height(const content::SyntheticPointerActionParams& r) {
return r.height_;
}
static float rotation_angle(const content::SyntheticPointerActionParams& r) {
return r.rotation_angle_;
}
static float force(const content::SyntheticPointerActionParams& r) {
return r.force_;
}
static float tangential_pressure(
const content::SyntheticPointerActionParams& r) {
return r.tangential_pressure_;
}
static uint32_t tilt_x(const content::SyntheticPointerActionParams& r) {
return r.tilt_x_;
}
static uint32_t tilt_y(const content::SyntheticPointerActionParams& r) {
return r.tilt_y_;
}
static base::TimeTicks timestamp(
const content::SyntheticPointerActionParams& r) {
return r.timestamp_;
}
static base::TimeDelta duration(
const content::SyntheticPointerActionParams& r) {
return r.duration_;
}
static bool Read(content::mojom::SyntheticPointerActionParamsDataView r,
content::SyntheticPointerActionParams* out);
};
template <>
struct StructTraits<content::mojom::SyntheticPointerActionDataView,
content::SyntheticPointerActionListParams> {
static content::mojom::GestureSourceType gesture_source_type(
const content::SyntheticPointerActionListParams& r) {
return r.gesture_source_type;
}
static const std::vector<std::vector<content::SyntheticPointerActionParams>>&
params(const content::SyntheticPointerActionListParams& r) {
return r.params;
}
static bool Read(content::mojom::SyntheticPointerActionDataView r,
content::SyntheticPointerActionListParams* out);
};
} // namespace mojo
#endif // CONTENT_COMMON_INPUT_INPUT_INJECTOR_MOJOM_TRAITS_H_