forked from chromedp/chromedp
/
types.go
414 lines (344 loc) · 10.1 KB
/
types.go
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
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
package input
import (
"errors"
"fmt"
"strconv"
"time"
"github.com/mailru/easyjson"
"github.com/mailru/easyjson/jlexer"
"github.com/mailru/easyjson/jwriter"
)
// Code generated by chromedp-gen. DO NOT EDIT.
// TouchPoint [no description].
type TouchPoint struct {
State TouchState `json:"state"` // State of the touch point.
X int64 `json:"x"` // X coordinate of the event relative to the main frame's viewport.
Y int64 `json:"y"` // Y coordinate of the event relative to the main frame's viewport. 0 refers to the top of the viewport and Y increases as it proceeds towards the bottom of the viewport.
RadiusX int64 `json:"radiusX,omitempty"` // X radius of the touch area (default: 1).
RadiusY int64 `json:"radiusY,omitempty"` // Y radius of the touch area (default: 1).
RotationAngle float64 `json:"rotationAngle,omitempty"` // Rotation angle (default: 0.0).
Force float64 `json:"force,omitempty"` // Force (default: 1.0).
ID float64 `json:"id,omitempty"` // Identifier used to track touch sources between events, must be unique within an event.
}
// GestureType [no description].
type GestureType string
// String returns the GestureType as string value.
func (t GestureType) String() string {
return string(t)
}
// GestureType values.
const (
GestureDefault GestureType = "default"
GestureTouch GestureType = "touch"
GestureMouse GestureType = "mouse"
)
// MarshalEasyJSON satisfies easyjson.Marshaler.
func (t GestureType) MarshalEasyJSON(out *jwriter.Writer) {
out.String(string(t))
}
// MarshalJSON satisfies json.Marshaler.
func (t GestureType) MarshalJSON() ([]byte, error) {
return easyjson.Marshal(t)
}
// UnmarshalEasyJSON satisfies easyjson.Unmarshaler.
func (t *GestureType) UnmarshalEasyJSON(in *jlexer.Lexer) {
switch GestureType(in.String()) {
case GestureDefault:
*t = GestureDefault
case GestureTouch:
*t = GestureTouch
case GestureMouse:
*t = GestureMouse
default:
in.AddError(errors.New("unknown GestureType value"))
}
}
// UnmarshalJSON satisfies json.Unmarshaler.
func (t *GestureType) UnmarshalJSON(buf []byte) error {
return easyjson.Unmarshal(buf, t)
}
// TimeSinceEpoch uTC time in seconds, counted from January 1, 1970.
type TimeSinceEpoch time.Time
// Time returns the TimeSinceEpoch as time.Time value.
func (t TimeSinceEpoch) Time() time.Time {
return time.Time(t)
}
// MarshalEasyJSON satisfies easyjson.Marshaler.
func (t TimeSinceEpoch) MarshalEasyJSON(out *jwriter.Writer) {
v := float64(time.Time(t).UnixNano() / int64(time.Second))
out.Buffer.EnsureSpace(20)
out.Buffer.Buf = strconv.AppendFloat(out.Buffer.Buf, v, 'f', -1, 64)
}
// MarshalJSON satisfies json.Marshaler.
func (t TimeSinceEpoch) MarshalJSON() ([]byte, error) {
return easyjson.Marshal(t)
}
// UnmarshalEasyJSON satisfies easyjson.Unmarshaler.
func (t *TimeSinceEpoch) UnmarshalEasyJSON(in *jlexer.Lexer) {
*t = TimeSinceEpoch(time.Unix(0, int64(in.Float64()*float64(time.Second))))
}
// UnmarshalJSON satisfies json.Unmarshaler.
func (t *TimeSinceEpoch) UnmarshalJSON(buf []byte) error {
return easyjson.Unmarshal(buf, t)
}
// Modifier input key modifier type.
type Modifier int64
// Int64 returns the Modifier as int64 value.
func (t Modifier) Int64() int64 {
return int64(t)
}
// Modifier values.
const (
ModifierNone Modifier = 0
ModifierAlt Modifier = 1
ModifierCtrl Modifier = 2
ModifierMeta Modifier = 4
ModifierShift Modifier = 8
)
// String returns the Modifier as string value.
func (t Modifier) String() string {
switch t {
case ModifierNone:
return "None"
case ModifierAlt:
return "Alt"
case ModifierCtrl:
return "Ctrl"
case ModifierMeta:
return "Meta"
case ModifierShift:
return "Shift"
}
return fmt.Sprintf("Modifier(%d)", t)
}
// MarshalEasyJSON satisfies easyjson.Marshaler.
func (t Modifier) MarshalEasyJSON(out *jwriter.Writer) {
out.Int64(int64(t))
}
// MarshalJSON satisfies json.Marshaler.
func (t Modifier) MarshalJSON() ([]byte, error) {
return easyjson.Marshal(t)
}
// UnmarshalEasyJSON satisfies easyjson.Unmarshaler.
func (t *Modifier) UnmarshalEasyJSON(in *jlexer.Lexer) {
switch Modifier(in.Int64()) {
case ModifierNone:
*t = ModifierNone
case ModifierAlt:
*t = ModifierAlt
case ModifierCtrl:
*t = ModifierCtrl
case ModifierMeta:
*t = ModifierMeta
case ModifierShift:
*t = ModifierShift
default:
in.AddError(errors.New("unknown Modifier value"))
}
}
// UnmarshalJSON satisfies json.Unmarshaler.
func (t *Modifier) UnmarshalJSON(buf []byte) error {
return easyjson.Unmarshal(buf, t)
}
// ModifierCommand is an alias for ModifierMeta.
const ModifierCommand Modifier = ModifierMeta
// TouchState state of the touch point.
type TouchState string
// String returns the TouchState as string value.
func (t TouchState) String() string {
return string(t)
}
// TouchState values.
const (
TouchPressed TouchState = "touchPressed"
TouchReleased TouchState = "touchReleased"
TouchMoved TouchState = "touchMoved"
TouchStationary TouchState = "touchStationary"
TouchCanceled TouchState = "touchCancelled"
)
// MarshalEasyJSON satisfies easyjson.Marshaler.
func (t TouchState) MarshalEasyJSON(out *jwriter.Writer) {
out.String(string(t))
}
// MarshalJSON satisfies json.Marshaler.
func (t TouchState) MarshalJSON() ([]byte, error) {
return easyjson.Marshal(t)
}
// UnmarshalEasyJSON satisfies easyjson.Unmarshaler.
func (t *TouchState) UnmarshalEasyJSON(in *jlexer.Lexer) {
switch TouchState(in.String()) {
case TouchPressed:
*t = TouchPressed
case TouchReleased:
*t = TouchReleased
case TouchMoved:
*t = TouchMoved
case TouchStationary:
*t = TouchStationary
case TouchCanceled:
*t = TouchCanceled
default:
in.AddError(errors.New("unknown TouchState value"))
}
}
// UnmarshalJSON satisfies json.Unmarshaler.
func (t *TouchState) UnmarshalJSON(buf []byte) error {
return easyjson.Unmarshal(buf, t)
}
// KeyType type of the key event.
type KeyType string
// String returns the KeyType as string value.
func (t KeyType) String() string {
return string(t)
}
// KeyType values.
const (
KeyDown KeyType = "keyDown"
KeyUp KeyType = "keyUp"
KeyRawDown KeyType = "rawKeyDown"
KeyChar KeyType = "char"
)
// MarshalEasyJSON satisfies easyjson.Marshaler.
func (t KeyType) MarshalEasyJSON(out *jwriter.Writer) {
out.String(string(t))
}
// MarshalJSON satisfies json.Marshaler.
func (t KeyType) MarshalJSON() ([]byte, error) {
return easyjson.Marshal(t)
}
// UnmarshalEasyJSON satisfies easyjson.Unmarshaler.
func (t *KeyType) UnmarshalEasyJSON(in *jlexer.Lexer) {
switch KeyType(in.String()) {
case KeyDown:
*t = KeyDown
case KeyUp:
*t = KeyUp
case KeyRawDown:
*t = KeyRawDown
case KeyChar:
*t = KeyChar
default:
in.AddError(errors.New("unknown KeyType value"))
}
}
// UnmarshalJSON satisfies json.Unmarshaler.
func (t *KeyType) UnmarshalJSON(buf []byte) error {
return easyjson.Unmarshal(buf, t)
}
// MouseType type of the mouse event.
type MouseType string
// String returns the MouseType as string value.
func (t MouseType) String() string {
return string(t)
}
// MouseType values.
const (
MousePressed MouseType = "mousePressed"
MouseReleased MouseType = "mouseReleased"
MouseMoved MouseType = "mouseMoved"
MouseWheel MouseType = "mouseWheel"
)
// MarshalEasyJSON satisfies easyjson.Marshaler.
func (t MouseType) MarshalEasyJSON(out *jwriter.Writer) {
out.String(string(t))
}
// MarshalJSON satisfies json.Marshaler.
func (t MouseType) MarshalJSON() ([]byte, error) {
return easyjson.Marshal(t)
}
// UnmarshalEasyJSON satisfies easyjson.Unmarshaler.
func (t *MouseType) UnmarshalEasyJSON(in *jlexer.Lexer) {
switch MouseType(in.String()) {
case MousePressed:
*t = MousePressed
case MouseReleased:
*t = MouseReleased
case MouseMoved:
*t = MouseMoved
case MouseWheel:
*t = MouseWheel
default:
in.AddError(errors.New("unknown MouseType value"))
}
}
// UnmarshalJSON satisfies json.Unmarshaler.
func (t *MouseType) UnmarshalJSON(buf []byte) error {
return easyjson.Unmarshal(buf, t)
}
// ButtonType mouse button (default: "none").
type ButtonType string
// String returns the ButtonType as string value.
func (t ButtonType) String() string {
return string(t)
}
// ButtonType values.
const (
ButtonNone ButtonType = "none"
ButtonLeft ButtonType = "left"
ButtonMiddle ButtonType = "middle"
ButtonRight ButtonType = "right"
)
// MarshalEasyJSON satisfies easyjson.Marshaler.
func (t ButtonType) MarshalEasyJSON(out *jwriter.Writer) {
out.String(string(t))
}
// MarshalJSON satisfies json.Marshaler.
func (t ButtonType) MarshalJSON() ([]byte, error) {
return easyjson.Marshal(t)
}
// UnmarshalEasyJSON satisfies easyjson.Unmarshaler.
func (t *ButtonType) UnmarshalEasyJSON(in *jlexer.Lexer) {
switch ButtonType(in.String()) {
case ButtonNone:
*t = ButtonNone
case ButtonLeft:
*t = ButtonLeft
case ButtonMiddle:
*t = ButtonMiddle
case ButtonRight:
*t = ButtonRight
default:
in.AddError(errors.New("unknown ButtonType value"))
}
}
// UnmarshalJSON satisfies json.Unmarshaler.
func (t *ButtonType) UnmarshalJSON(buf []byte) error {
return easyjson.Unmarshal(buf, t)
}
// TouchType type of the touch event.
type TouchType string
// String returns the TouchType as string value.
func (t TouchType) String() string {
return string(t)
}
// TouchType values.
const (
TouchStart TouchType = "touchStart"
TouchEnd TouchType = "touchEnd"
TouchMove TouchType = "touchMove"
)
// MarshalEasyJSON satisfies easyjson.Marshaler.
func (t TouchType) MarshalEasyJSON(out *jwriter.Writer) {
out.String(string(t))
}
// MarshalJSON satisfies json.Marshaler.
func (t TouchType) MarshalJSON() ([]byte, error) {
return easyjson.Marshal(t)
}
// UnmarshalEasyJSON satisfies easyjson.Unmarshaler.
func (t *TouchType) UnmarshalEasyJSON(in *jlexer.Lexer) {
switch TouchType(in.String()) {
case TouchStart:
*t = TouchStart
case TouchEnd:
*t = TouchEnd
case TouchMove:
*t = TouchMove
default:
in.AddError(errors.New("unknown TouchType value"))
}
}
// UnmarshalJSON satisfies json.Unmarshaler.
func (t *TouchType) UnmarshalJSON(buf []byte) error {
return easyjson.Unmarshal(buf, t)
}