1use serde::{Deserialize, Serialize};
2#[doc = "Dispatches a drag event into the page.\n[dispatchDragEvent](https://chromedevtools.github.io/devtools-protocol/tot/Input/#method-dispatchDragEvent)"]
3#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
4pub struct DispatchDragEventParams {
5 #[doc = "Type of the drag event."]
6 #[serde(rename = "type")]
7 pub r#type: DispatchDragEventType,
8 #[doc = "X coordinate of the event relative to the main frame's viewport in CSS pixels."]
9 #[serde(rename = "x")]
10 pub x: f64,
11 #[doc = "Y coordinate of the event relative to the main frame's viewport in CSS pixels. 0 refers to\nthe top of the viewport and Y increases as it proceeds towards the bottom of the viewport."]
12 #[serde(rename = "y")]
13 pub y: f64,
14 #[serde(rename = "data")]
15 pub data: super::types::DragData,
16 #[doc = "Bit field representing pressed modifier keys. Alt=1, Ctrl=2, Meta/Command=4, Shift=8\n(default: 0)."]
17 #[serde(rename = "modifiers")]
18 #[serde(skip_serializing_if = "Option::is_none")]
19 #[serde(default)]
20 pub modifiers: Option<i64>,
21}
22#[doc = "Type of the drag event."]
23#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
24pub enum DispatchDragEventType {
25 #[serde(rename = "dragEnter")]
26 DragEnter,
27 #[serde(rename = "dragOver")]
28 DragOver,
29 #[serde(rename = "drop")]
30 Drop,
31 #[serde(rename = "dragCancel")]
32 DragCancel,
33}
34impl DispatchDragEventParams {
35 pub fn new(
36 r#type: impl Into<DispatchDragEventType>,
37 x: impl Into<f64>,
38 y: impl Into<f64>,
39 data: impl Into<super::types::DragData>,
40 ) -> Self {
41 Self {
42 r#type: r#type.into(),
43 x: x.into(),
44 y: y.into(),
45 data: data.into(),
46 modifiers: None,
47 }
48 }
49}
50#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
51pub enum DispatchDragEventMethod {
52 #[serde(rename = "Input.dispatchDragEvent")]
53 DispatchDragEvent,
54}
55#[doc = "Dispatches a drag event into the page.\n[dispatchDragEvent](https://chromedevtools.github.io/devtools-protocol/tot/Input/#method-dispatchDragEvent)"]
56#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
57pub struct DispatchDragEvent {
58 pub method: DispatchDragEventMethod,
59 pub params: DispatchDragEventParams,
60}
61impl DispatchDragEvent {
62 pub const IDENTIFIER: &'static str = "Input.dispatchDragEvent";
63 pub fn identifier(&self) -> &'static str {
64 Self::IDENTIFIER
65 }
66}
67impl crate::CommandResult for DispatchDragEvent {
68 type Result = super::results::DispatchDragEventResult;
69}
70#[doc = "Dispatches a key event to the page.\n[dispatchKeyEvent](https://chromedevtools.github.io/devtools-protocol/tot/Input/#method-dispatchKeyEvent)"]
71#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
72pub struct DispatchKeyEventParams {
73 #[doc = "Type of the key event."]
74 #[serde(rename = "type")]
75 pub r#type: DispatchKeyEventType,
76 #[doc = "Bit field representing pressed modifier keys. Alt=1, Ctrl=2, Meta/Command=4, Shift=8\n(default: 0)."]
77 #[serde(rename = "modifiers")]
78 #[serde(skip_serializing_if = "Option::is_none")]
79 #[serde(default)]
80 pub modifiers: Option<i64>,
81 #[doc = "Time at which the event occurred."]
82 #[serde(rename = "timestamp")]
83 #[serde(skip_serializing_if = "Option::is_none")]
84 #[serde(default)]
85 pub timestamp: Option<super::types::TimeSinceEpoch>,
86 #[doc = "Text as generated by processing a virtual key code with a keyboard layout. Not needed for\nfor `keyUp` and `rawKeyDown` events (default: \"\")"]
87 #[serde(rename = "text")]
88 #[serde(skip_serializing_if = "Option::is_none")]
89 #[serde(default)]
90 pub text: Option<String>,
91 #[doc = "Text that would have been generated by the keyboard if no modifiers were pressed (except for\nshift). Useful for shortcut (accelerator) key handling (default: \"\")."]
92 #[serde(rename = "unmodifiedText")]
93 #[serde(skip_serializing_if = "Option::is_none")]
94 #[serde(default)]
95 pub unmodified_text: Option<String>,
96 #[doc = "Unique key identifier (e.g., 'U+0041') (default: \"\")."]
97 #[serde(rename = "keyIdentifier")]
98 #[serde(skip_serializing_if = "Option::is_none")]
99 #[serde(default)]
100 pub key_identifier: Option<String>,
101 #[doc = "Unique DOM defined string value for each physical key (e.g., 'KeyA') (default: \"\")."]
102 #[serde(rename = "code")]
103 #[serde(skip_serializing_if = "Option::is_none")]
104 #[serde(default)]
105 pub code: Option<String>,
106 #[doc = "Unique DOM defined string value describing the meaning of the key in the context of active\nmodifiers, keyboard layout, etc (e.g., 'AltGr') (default: \"\")."]
107 #[serde(rename = "key")]
108 #[serde(skip_serializing_if = "Option::is_none")]
109 #[serde(default)]
110 pub key: Option<String>,
111 #[doc = "Windows virtual key code (default: 0)."]
112 #[serde(rename = "windowsVirtualKeyCode")]
113 #[serde(skip_serializing_if = "Option::is_none")]
114 #[serde(default)]
115 pub windows_virtual_key_code: Option<i64>,
116 #[doc = "Native virtual key code (default: 0)."]
117 #[serde(rename = "nativeVirtualKeyCode")]
118 #[serde(skip_serializing_if = "Option::is_none")]
119 #[serde(default)]
120 pub native_virtual_key_code: Option<i64>,
121 #[doc = "Whether the event was generated from auto repeat (default: false)."]
122 #[serde(rename = "autoRepeat")]
123 #[serde(skip_serializing_if = "Option::is_none")]
124 #[serde(default)]
125 pub auto_repeat: Option<bool>,
126 #[doc = "Whether the event was generated from the keypad (default: false)."]
127 #[serde(rename = "isKeypad")]
128 #[serde(skip_serializing_if = "Option::is_none")]
129 #[serde(default)]
130 pub is_keypad: Option<bool>,
131 #[doc = "Whether the event was a system key event (default: false)."]
132 #[serde(rename = "isSystemKey")]
133 #[serde(skip_serializing_if = "Option::is_none")]
134 #[serde(default)]
135 pub is_system_key: Option<bool>,
136 #[doc = "Whether the event was from the left or right side of the keyboard. 1=Left, 2=Right (default:\n0)."]
137 #[serde(rename = "location")]
138 #[serde(skip_serializing_if = "Option::is_none")]
139 #[serde(default)]
140 pub location: Option<i64>,
141 #[doc = "Editing commands to send with the key event (e.g., 'selectAll') (default: []).\nThese are related to but not equal the command names used in `document.execCommand` and NSStandardKeyBindingResponding.\nSee https://source.chromium.org/chromium/chromium/src/+/main:third_party/blink/renderer/core/editing/commands/editor_command_names.h for valid command names."]
142 #[serde(rename = "commands")]
143 #[serde(skip_serializing_if = "Option::is_none")]
144 #[serde(default)]
145 pub commands: Option<Vec<String>>,
146}
147#[doc = "Type of the key event."]
148#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
149pub enum DispatchKeyEventType {
150 #[serde(rename = "keyDown")]
151 KeyDown,
152 #[serde(rename = "keyUp")]
153 KeyUp,
154 #[serde(rename = "rawKeyDown")]
155 RawKeyDown,
156 #[serde(rename = "char")]
157 Char,
158}
159impl DispatchKeyEventParams {
160 pub fn new(r#type: impl Into<DispatchKeyEventType>) -> Self {
161 Self {
162 r#type: r#type.into(),
163 modifiers: None,
164 timestamp: None,
165 text: None,
166 unmodified_text: None,
167 key_identifier: None,
168 code: None,
169 key: None,
170 windows_virtual_key_code: None,
171 native_virtual_key_code: None,
172 auto_repeat: None,
173 is_keypad: None,
174 is_system_key: None,
175 location: None,
176 commands: None,
177 }
178 }
179}
180#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
181pub enum DispatchKeyEventMethod {
182 #[serde(rename = "Input.dispatchKeyEvent")]
183 DispatchKeyEvent,
184}
185#[doc = "Dispatches a key event to the page.\n[dispatchKeyEvent](https://chromedevtools.github.io/devtools-protocol/tot/Input/#method-dispatchKeyEvent)"]
186#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
187pub struct DispatchKeyEvent {
188 pub method: DispatchKeyEventMethod,
189 pub params: DispatchKeyEventParams,
190}
191impl DispatchKeyEvent {
192 pub const IDENTIFIER: &'static str = "Input.dispatchKeyEvent";
193 pub fn identifier(&self) -> &'static str {
194 Self::IDENTIFIER
195 }
196}
197impl crate::CommandResult for DispatchKeyEvent {
198 type Result = super::results::DispatchKeyEventResult;
199}
200#[doc = "This method emulates inserting text that doesn't come from a key press,\nfor example an emoji keyboard or an IME.\n[insertText](https://chromedevtools.github.io/devtools-protocol/tot/Input/#method-insertText)"]
201#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
202pub struct InsertTextParams {
203 #[doc = "The text to insert."]
204 #[serde(rename = "text")]
205 pub text: String,
206}
207impl InsertTextParams {
208 pub fn new(text: impl Into<String>) -> Self {
209 Self { text: text.into() }
210 }
211}
212impl<T: Into<String>> From<T> for InsertTextParams {
213 fn from(url: T) -> Self {
214 InsertTextParams::new(url)
215 }
216}
217#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
218pub enum InsertTextMethod {
219 #[serde(rename = "Input.insertText")]
220 InsertText,
221}
222#[doc = "This method emulates inserting text that doesn't come from a key press,\nfor example an emoji keyboard or an IME.\n[insertText](https://chromedevtools.github.io/devtools-protocol/tot/Input/#method-insertText)"]
223#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
224pub struct InsertText {
225 pub method: InsertTextMethod,
226 pub params: InsertTextParams,
227}
228impl InsertText {
229 pub const IDENTIFIER: &'static str = "Input.insertText";
230 pub fn identifier(&self) -> &'static str {
231 Self::IDENTIFIER
232 }
233}
234impl crate::CommandResult for InsertText {
235 type Result = super::results::InsertTextResult;
236}
237#[doc = "This method sets the current candidate text for IME.\nUse imeCommitComposition to commit the final text.\nUse imeSetComposition with empty string as text to cancel composition.\n[imeSetComposition](https://chromedevtools.github.io/devtools-protocol/tot/Input/#method-imeSetComposition)"]
238#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
239pub struct ImeSetCompositionParams {
240 #[doc = "The text to insert"]
241 #[serde(rename = "text")]
242 pub text: String,
243 #[doc = "selection start"]
244 #[serde(rename = "selectionStart")]
245 pub selection_start: i64,
246 #[doc = "selection end"]
247 #[serde(rename = "selectionEnd")]
248 pub selection_end: i64,
249 #[doc = "replacement start"]
250 #[serde(rename = "replacementStart")]
251 #[serde(skip_serializing_if = "Option::is_none")]
252 #[serde(default)]
253 pub replacement_start: Option<i64>,
254 #[doc = "replacement end"]
255 #[serde(rename = "replacementEnd")]
256 #[serde(skip_serializing_if = "Option::is_none")]
257 #[serde(default)]
258 pub replacement_end: Option<i64>,
259}
260impl ImeSetCompositionParams {
261 pub fn new(
262 text: impl Into<String>,
263 selection_start: impl Into<i64>,
264 selection_end: impl Into<i64>,
265 ) -> Self {
266 Self {
267 text: text.into(),
268 selection_start: selection_start.into(),
269 selection_end: selection_end.into(),
270 replacement_start: None,
271 replacement_end: None,
272 }
273 }
274}
275#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
276pub enum ImeSetCompositionMethod {
277 #[serde(rename = "Input.imeSetComposition")]
278 ImeSetComposition,
279}
280#[doc = "This method sets the current candidate text for IME.\nUse imeCommitComposition to commit the final text.\nUse imeSetComposition with empty string as text to cancel composition.\n[imeSetComposition](https://chromedevtools.github.io/devtools-protocol/tot/Input/#method-imeSetComposition)"]
281#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
282pub struct ImeSetComposition {
283 pub method: ImeSetCompositionMethod,
284 pub params: ImeSetCompositionParams,
285}
286impl ImeSetComposition {
287 pub const IDENTIFIER: &'static str = "Input.imeSetComposition";
288 pub fn identifier(&self) -> &'static str {
289 Self::IDENTIFIER
290 }
291}
292impl crate::CommandResult for ImeSetComposition {
293 type Result = super::results::ImeSetCompositionResult;
294}
295#[doc = "Dispatches a mouse event to the page.\n[dispatchMouseEvent](https://chromedevtools.github.io/devtools-protocol/tot/Input/#method-dispatchMouseEvent)"]
296#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
297pub struct DispatchMouseEventParams {
298 #[doc = "Type of the mouse event."]
299 #[serde(rename = "type")]
300 pub r#type: DispatchMouseEventType,
301 #[doc = "X coordinate of the event relative to the main frame's viewport in CSS pixels."]
302 #[serde(rename = "x")]
303 pub x: f64,
304 #[doc = "Y coordinate of the event relative to the main frame's viewport in CSS pixels. 0 refers to\nthe top of the viewport and Y increases as it proceeds towards the bottom of the viewport."]
305 #[serde(rename = "y")]
306 pub y: f64,
307 #[doc = "Bit field representing pressed modifier keys. Alt=1, Ctrl=2, Meta/Command=4, Shift=8\n(default: 0)."]
308 #[serde(rename = "modifiers")]
309 #[serde(skip_serializing_if = "Option::is_none")]
310 #[serde(default)]
311 pub modifiers: Option<i64>,
312 #[doc = "Time at which the event occurred."]
313 #[serde(rename = "timestamp")]
314 #[serde(skip_serializing_if = "Option::is_none")]
315 #[serde(default)]
316 pub timestamp: Option<super::types::TimeSinceEpoch>,
317 #[doc = "Mouse button (default: \"none\")."]
318 #[serde(rename = "button")]
319 #[serde(skip_serializing_if = "Option::is_none")]
320 #[serde(default)]
321 pub button: Option<super::types::MouseButton>,
322 #[doc = "A number indicating which buttons are pressed on the mouse when a mouse event is triggered.\nLeft=1, Right=2, Middle=4, Back=8, Forward=16, None=0."]
323 #[serde(rename = "buttons")]
324 #[serde(skip_serializing_if = "Option::is_none")]
325 #[serde(default)]
326 pub buttons: Option<i64>,
327 #[doc = "Number of times the mouse button was clicked (default: 0)."]
328 #[serde(rename = "clickCount")]
329 #[serde(skip_serializing_if = "Option::is_none")]
330 #[serde(default)]
331 pub click_count: Option<i64>,
332 #[doc = "The normalized pressure, which has a range of [0,1] (default: 0)."]
333 #[serde(rename = "force")]
334 #[serde(skip_serializing_if = "Option::is_none")]
335 #[serde(default)]
336 pub force: Option<f64>,
337 #[doc = "The normalized tangential pressure, which has a range of [-1,1] (default: 0)."]
338 #[serde(rename = "tangentialPressure")]
339 #[serde(skip_serializing_if = "Option::is_none")]
340 #[serde(default)]
341 pub tangential_pressure: Option<f64>,
342 #[doc = "The plane angle between the Y-Z plane and the plane containing both the stylus axis and the Y axis, in degrees of the range [-90,90], a positive tiltX is to the right (default: 0)."]
343 #[serde(rename = "tiltX")]
344 #[serde(skip_serializing_if = "Option::is_none")]
345 #[serde(default)]
346 pub tilt_x: Option<f64>,
347 #[doc = "The plane angle between the X-Z plane and the plane containing both the stylus axis and the X axis, in degrees of the range [-90,90], a positive tiltY is towards the user (default: 0)."]
348 #[serde(rename = "tiltY")]
349 #[serde(skip_serializing_if = "Option::is_none")]
350 #[serde(default)]
351 pub tilt_y: Option<f64>,
352 #[doc = "The clockwise rotation of a pen stylus around its own major axis, in degrees in the range [0,359] (default: 0)."]
353 #[serde(rename = "twist")]
354 #[serde(skip_serializing_if = "Option::is_none")]
355 #[serde(default)]
356 pub twist: Option<i64>,
357 #[doc = "X delta in CSS pixels for mouse wheel event (default: 0)."]
358 #[serde(rename = "deltaX")]
359 #[serde(skip_serializing_if = "Option::is_none")]
360 #[serde(default)]
361 pub delta_x: Option<f64>,
362 #[doc = "Y delta in CSS pixels for mouse wheel event (default: 0)."]
363 #[serde(rename = "deltaY")]
364 #[serde(skip_serializing_if = "Option::is_none")]
365 #[serde(default)]
366 pub delta_y: Option<f64>,
367 #[doc = "Pointer type (default: \"mouse\")."]
368 #[serde(rename = "pointerType")]
369 #[serde(skip_serializing_if = "Option::is_none")]
370 #[serde(default)]
371 pub pointer_type: Option<DispatchMouseEventPointerType>,
372}
373#[doc = "Type of the mouse event."]
374#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
375pub enum DispatchMouseEventType {
376 #[serde(rename = "mousePressed")]
377 MousePressed,
378 #[serde(rename = "mouseReleased")]
379 MouseReleased,
380 #[serde(rename = "mouseMoved")]
381 MouseMoved,
382 #[serde(rename = "mouseWheel")]
383 MouseWheel,
384}
385#[doc = "Pointer type (default: \"mouse\")."]
386#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
387pub enum DispatchMouseEventPointerType {
388 #[serde(rename = "mouse")]
389 Mouse,
390 #[serde(rename = "pen")]
391 Pen,
392}
393impl DispatchMouseEventParams {
394 pub fn new(
395 r#type: impl Into<DispatchMouseEventType>,
396 x: impl Into<f64>,
397 y: impl Into<f64>,
398 ) -> Self {
399 Self {
400 r#type: r#type.into(),
401 x: x.into(),
402 y: y.into(),
403 modifiers: None,
404 timestamp: None,
405 button: None,
406 buttons: None,
407 click_count: None,
408 force: None,
409 tangential_pressure: None,
410 tilt_x: None,
411 tilt_y: None,
412 twist: None,
413 delta_x: None,
414 delta_y: None,
415 pointer_type: None,
416 }
417 }
418}
419#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
420pub enum DispatchMouseEventMethod {
421 #[serde(rename = "Input.dispatchMouseEvent")]
422 DispatchMouseEvent,
423}
424#[doc = "Dispatches a mouse event to the page.\n[dispatchMouseEvent](https://chromedevtools.github.io/devtools-protocol/tot/Input/#method-dispatchMouseEvent)"]
425#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
426pub struct DispatchMouseEvent {
427 pub method: DispatchMouseEventMethod,
428 pub params: DispatchMouseEventParams,
429}
430impl DispatchMouseEvent {
431 pub const IDENTIFIER: &'static str = "Input.dispatchMouseEvent";
432 pub fn identifier(&self) -> &'static str {
433 Self::IDENTIFIER
434 }
435}
436impl crate::CommandResult for DispatchMouseEvent {
437 type Result = super::results::DispatchMouseEventResult;
438}
439#[doc = "Dispatches a touch event to the page.\n[dispatchTouchEvent](https://chromedevtools.github.io/devtools-protocol/tot/Input/#method-dispatchTouchEvent)"]
440#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
441pub struct DispatchTouchEventParams {
442 #[doc = "Type of the touch event. TouchEnd and TouchCancel must not contain any touch points, while\nTouchStart and TouchMove must contains at least one."]
443 #[serde(rename = "type")]
444 pub r#type: DispatchTouchEventType,
445 #[doc = "Active touch points on the touch device. One event per any changed point (compared to\nprevious touch event in a sequence) is generated, emulating pressing/moving/releasing points\none by one."]
446 #[serde(rename = "touchPoints")]
447 #[serde(skip_serializing_if = "Vec::is_empty")]
448 pub touch_points: Vec<super::types::TouchPoint>,
449 #[doc = "Bit field representing pressed modifier keys. Alt=1, Ctrl=2, Meta/Command=4, Shift=8\n(default: 0)."]
450 #[serde(rename = "modifiers")]
451 #[serde(skip_serializing_if = "Option::is_none")]
452 #[serde(default)]
453 pub modifiers: Option<i64>,
454 #[doc = "Time at which the event occurred."]
455 #[serde(rename = "timestamp")]
456 #[serde(skip_serializing_if = "Option::is_none")]
457 #[serde(default)]
458 pub timestamp: Option<super::types::TimeSinceEpoch>,
459}
460#[doc = "Type of the touch event. TouchEnd and TouchCancel must not contain any touch points, while\nTouchStart and TouchMove must contains at least one."]
461#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
462pub enum DispatchTouchEventType {
463 #[serde(rename = "touchStart")]
464 TouchStart,
465 #[serde(rename = "touchEnd")]
466 TouchEnd,
467 #[serde(rename = "touchMove")]
468 TouchMove,
469 #[serde(rename = "touchCancel")]
470 TouchCancel,
471}
472impl DispatchTouchEventParams {
473 pub fn new(
474 r#type: impl Into<DispatchTouchEventType>,
475 touch_points: Vec<super::types::TouchPoint>,
476 ) -> Self {
477 Self {
478 r#type: r#type.into(),
479 touch_points,
480 modifiers: None,
481 timestamp: None,
482 }
483 }
484}
485#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
486pub enum DispatchTouchEventMethod {
487 #[serde(rename = "Input.dispatchTouchEvent")]
488 DispatchTouchEvent,
489}
490#[doc = "Dispatches a touch event to the page.\n[dispatchTouchEvent](https://chromedevtools.github.io/devtools-protocol/tot/Input/#method-dispatchTouchEvent)"]
491#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
492pub struct DispatchTouchEvent {
493 pub method: DispatchTouchEventMethod,
494 pub params: DispatchTouchEventParams,
495}
496impl DispatchTouchEvent {
497 pub const IDENTIFIER: &'static str = "Input.dispatchTouchEvent";
498 pub fn identifier(&self) -> &'static str {
499 Self::IDENTIFIER
500 }
501}
502impl crate::CommandResult for DispatchTouchEvent {
503 type Result = super::results::DispatchTouchEventResult;
504}
505#[doc = "Cancels any active dragging in the page.\n[cancelDragging](https://chromedevtools.github.io/devtools-protocol/tot/Input/#method-cancelDragging)"]
506#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
507pub struct CancelDraggingParams {}
508#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
509pub enum CancelDraggingMethod {
510 #[serde(rename = "Input.cancelDragging")]
511 CancelDragging,
512}
513#[doc = "Cancels any active dragging in the page.\n[cancelDragging](https://chromedevtools.github.io/devtools-protocol/tot/Input/#method-cancelDragging)"]
514#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
515pub struct CancelDragging {
516 pub method: CancelDraggingMethod,
517 pub params: CancelDraggingParams,
518}
519impl CancelDragging {
520 pub const IDENTIFIER: &'static str = "Input.cancelDragging";
521 pub fn identifier(&self) -> &'static str {
522 Self::IDENTIFIER
523 }
524}
525impl crate::CommandResult for CancelDragging {
526 type Result = super::results::CancelDraggingResult;
527}
528#[doc = "Emulates touch event from the mouse event parameters.\n[emulateTouchFromMouseEvent](https://chromedevtools.github.io/devtools-protocol/tot/Input/#method-emulateTouchFromMouseEvent)"]
529#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
530pub struct EmulateTouchFromMouseEventParams {
531 #[doc = "Type of the mouse event."]
532 #[serde(rename = "type")]
533 pub r#type: EmulateTouchFromMouseEventType,
534 #[doc = "X coordinate of the mouse pointer in DIP."]
535 #[serde(rename = "x")]
536 pub x: i64,
537 #[doc = "Y coordinate of the mouse pointer in DIP."]
538 #[serde(rename = "y")]
539 pub y: i64,
540 #[doc = "Mouse button. Only \"none\", \"left\", \"right\" are supported."]
541 #[serde(rename = "button")]
542 pub button: super::types::MouseButton,
543 #[doc = "Time at which the event occurred (default: current time)."]
544 #[serde(rename = "timestamp")]
545 #[serde(skip_serializing_if = "Option::is_none")]
546 #[serde(default)]
547 pub timestamp: Option<super::types::TimeSinceEpoch>,
548 #[doc = "X delta in DIP for mouse wheel event (default: 0)."]
549 #[serde(rename = "deltaX")]
550 #[serde(skip_serializing_if = "Option::is_none")]
551 #[serde(default)]
552 pub delta_x: Option<f64>,
553 #[doc = "Y delta in DIP for mouse wheel event (default: 0)."]
554 #[serde(rename = "deltaY")]
555 #[serde(skip_serializing_if = "Option::is_none")]
556 #[serde(default)]
557 pub delta_y: Option<f64>,
558 #[doc = "Bit field representing pressed modifier keys. Alt=1, Ctrl=2, Meta/Command=4, Shift=8\n(default: 0)."]
559 #[serde(rename = "modifiers")]
560 #[serde(skip_serializing_if = "Option::is_none")]
561 #[serde(default)]
562 pub modifiers: Option<i64>,
563 #[doc = "Number of times the mouse button was clicked (default: 0)."]
564 #[serde(rename = "clickCount")]
565 #[serde(skip_serializing_if = "Option::is_none")]
566 #[serde(default)]
567 pub click_count: Option<i64>,
568}
569#[doc = "Type of the mouse event."]
570#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
571pub enum EmulateTouchFromMouseEventType {
572 #[serde(rename = "mousePressed")]
573 MousePressed,
574 #[serde(rename = "mouseReleased")]
575 MouseReleased,
576 #[serde(rename = "mouseMoved")]
577 MouseMoved,
578 #[serde(rename = "mouseWheel")]
579 MouseWheel,
580}
581impl EmulateTouchFromMouseEventParams {
582 pub fn new(
583 r#type: impl Into<EmulateTouchFromMouseEventType>,
584 x: impl Into<i64>,
585 y: impl Into<i64>,
586 button: impl Into<super::types::MouseButton>,
587 ) -> Self {
588 Self {
589 r#type: r#type.into(),
590 x: x.into(),
591 y: y.into(),
592 button: button.into(),
593 timestamp: None,
594 delta_x: None,
595 delta_y: None,
596 modifiers: None,
597 click_count: None,
598 }
599 }
600}
601#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
602pub enum EmulateTouchFromMouseEventMethod {
603 #[serde(rename = "Input.emulateTouchFromMouseEvent")]
604 EmulateTouchFromMouseEvent,
605}
606#[doc = "Emulates touch event from the mouse event parameters.\n[emulateTouchFromMouseEvent](https://chromedevtools.github.io/devtools-protocol/tot/Input/#method-emulateTouchFromMouseEvent)"]
607#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
608pub struct EmulateTouchFromMouseEvent {
609 pub method: EmulateTouchFromMouseEventMethod,
610 pub params: EmulateTouchFromMouseEventParams,
611}
612impl EmulateTouchFromMouseEvent {
613 pub const IDENTIFIER: &'static str = "Input.emulateTouchFromMouseEvent";
614 pub fn identifier(&self) -> &'static str {
615 Self::IDENTIFIER
616 }
617}
618impl crate::CommandResult for EmulateTouchFromMouseEvent {
619 type Result = super::results::EmulateTouchFromMouseEventResult;
620}
621#[doc = "Ignores input events (useful while auditing page).\n[setIgnoreInputEvents](https://chromedevtools.github.io/devtools-protocol/tot/Input/#method-setIgnoreInputEvents)"]
622#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
623pub struct SetIgnoreInputEventsParams {
624 #[doc = "Ignores input events processing when set to true."]
625 #[serde(rename = "ignore")]
626 pub ignore: bool,
627}
628impl SetIgnoreInputEventsParams {
629 pub fn new(ignore: impl Into<bool>) -> Self {
630 Self {
631 ignore: ignore.into(),
632 }
633 }
634}
635#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
636pub enum SetIgnoreInputEventsMethod {
637 #[serde(rename = "Input.setIgnoreInputEvents")]
638 SetIgnoreInputEvents,
639}
640#[doc = "Ignores input events (useful while auditing page).\n[setIgnoreInputEvents](https://chromedevtools.github.io/devtools-protocol/tot/Input/#method-setIgnoreInputEvents)"]
641#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
642pub struct SetIgnoreInputEvents {
643 pub method: SetIgnoreInputEventsMethod,
644 pub params: SetIgnoreInputEventsParams,
645}
646impl SetIgnoreInputEvents {
647 pub const IDENTIFIER: &'static str = "Input.setIgnoreInputEvents";
648 pub fn identifier(&self) -> &'static str {
649 Self::IDENTIFIER
650 }
651}
652impl crate::CommandResult for SetIgnoreInputEvents {
653 type Result = super::results::SetIgnoreInputEventsResult;
654}
655#[doc = "Prevents default drag and drop behavior and instead emits `Input.dragIntercepted` events.\nDrag and drop behavior can be directly controlled via `Input.dispatchDragEvent`.\n[setInterceptDrags](https://chromedevtools.github.io/devtools-protocol/tot/Input/#method-setInterceptDrags)"]
656#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
657pub struct SetInterceptDragsParams {
658 #[serde(rename = "enabled")]
659 pub enabled: bool,
660}
661impl SetInterceptDragsParams {
662 pub fn new(enabled: impl Into<bool>) -> Self {
663 Self {
664 enabled: enabled.into(),
665 }
666 }
667}
668#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
669pub enum SetInterceptDragsMethod {
670 #[serde(rename = "Input.setInterceptDrags")]
671 SetInterceptDrags,
672}
673#[doc = "Prevents default drag and drop behavior and instead emits `Input.dragIntercepted` events.\nDrag and drop behavior can be directly controlled via `Input.dispatchDragEvent`.\n[setInterceptDrags](https://chromedevtools.github.io/devtools-protocol/tot/Input/#method-setInterceptDrags)"]
674#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
675pub struct SetInterceptDrags {
676 pub method: SetInterceptDragsMethod,
677 pub params: SetInterceptDragsParams,
678}
679impl SetInterceptDrags {
680 pub const IDENTIFIER: &'static str = "Input.setInterceptDrags";
681 pub fn identifier(&self) -> &'static str {
682 Self::IDENTIFIER
683 }
684}
685impl crate::CommandResult for SetInterceptDrags {
686 type Result = super::results::SetInterceptDragsResult;
687}
688#[doc = "Synthesizes a pinch gesture over a time period by issuing appropriate touch events.\n[synthesizePinchGesture](https://chromedevtools.github.io/devtools-protocol/tot/Input/#method-synthesizePinchGesture)"]
689#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
690pub struct SynthesizePinchGestureParams {
691 #[doc = "X coordinate of the start of the gesture in CSS pixels."]
692 #[serde(rename = "x")]
693 pub x: f64,
694 #[doc = "Y coordinate of the start of the gesture in CSS pixels."]
695 #[serde(rename = "y")]
696 pub y: f64,
697 #[doc = "Relative scale factor after zooming (>1.0 zooms in, <1.0 zooms out)."]
698 #[serde(rename = "scaleFactor")]
699 pub scale_factor: f64,
700 #[doc = "Relative pointer speed in pixels per second (default: 800)."]
701 #[serde(rename = "relativeSpeed")]
702 #[serde(skip_serializing_if = "Option::is_none")]
703 #[serde(default)]
704 pub relative_speed: Option<i64>,
705 #[doc = "Which type of input events to be generated (default: 'default', which queries the platform\nfor the preferred input type)."]
706 #[serde(rename = "gestureSourceType")]
707 #[serde(skip_serializing_if = "Option::is_none")]
708 #[serde(default)]
709 pub gesture_source_type: Option<super::types::GestureSourceType>,
710}
711impl SynthesizePinchGestureParams {
712 pub fn new(x: impl Into<f64>, y: impl Into<f64>, scale_factor: impl Into<f64>) -> Self {
713 Self {
714 x: x.into(),
715 y: y.into(),
716 scale_factor: scale_factor.into(),
717 relative_speed: None,
718 gesture_source_type: None,
719 }
720 }
721}
722#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
723pub enum SynthesizePinchGestureMethod {
724 #[serde(rename = "Input.synthesizePinchGesture")]
725 SynthesizePinchGesture,
726}
727#[doc = "Synthesizes a pinch gesture over a time period by issuing appropriate touch events.\n[synthesizePinchGesture](https://chromedevtools.github.io/devtools-protocol/tot/Input/#method-synthesizePinchGesture)"]
728#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
729pub struct SynthesizePinchGesture {
730 pub method: SynthesizePinchGestureMethod,
731 pub params: SynthesizePinchGestureParams,
732}
733impl SynthesizePinchGesture {
734 pub const IDENTIFIER: &'static str = "Input.synthesizePinchGesture";
735 pub fn identifier(&self) -> &'static str {
736 Self::IDENTIFIER
737 }
738}
739impl crate::CommandResult for SynthesizePinchGesture {
740 type Result = super::results::SynthesizePinchGestureResult;
741}
742#[doc = "Synthesizes a scroll gesture over a time period by issuing appropriate touch events.\n[synthesizeScrollGesture](https://chromedevtools.github.io/devtools-protocol/tot/Input/#method-synthesizeScrollGesture)"]
743#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
744pub struct SynthesizeScrollGestureParams {
745 #[doc = "X coordinate of the start of the gesture in CSS pixels."]
746 #[serde(rename = "x")]
747 pub x: f64,
748 #[doc = "Y coordinate of the start of the gesture in CSS pixels."]
749 #[serde(rename = "y")]
750 pub y: f64,
751 #[doc = "The distance to scroll along the X axis (positive to scroll left)."]
752 #[serde(rename = "xDistance")]
753 #[serde(skip_serializing_if = "Option::is_none")]
754 #[serde(default)]
755 pub x_distance: Option<f64>,
756 #[doc = "The distance to scroll along the Y axis (positive to scroll up)."]
757 #[serde(rename = "yDistance")]
758 #[serde(skip_serializing_if = "Option::is_none")]
759 #[serde(default)]
760 pub y_distance: Option<f64>,
761 #[doc = "The number of additional pixels to scroll back along the X axis, in addition to the given\ndistance."]
762 #[serde(rename = "xOverscroll")]
763 #[serde(skip_serializing_if = "Option::is_none")]
764 #[serde(default)]
765 pub x_overscroll: Option<f64>,
766 #[doc = "The number of additional pixels to scroll back along the Y axis, in addition to the given\ndistance."]
767 #[serde(rename = "yOverscroll")]
768 #[serde(skip_serializing_if = "Option::is_none")]
769 #[serde(default)]
770 pub y_overscroll: Option<f64>,
771 #[doc = "Prevent fling (default: true)."]
772 #[serde(rename = "preventFling")]
773 #[serde(skip_serializing_if = "Option::is_none")]
774 #[serde(default)]
775 pub prevent_fling: Option<bool>,
776 #[doc = "Swipe speed in pixels per second (default: 800)."]
777 #[serde(rename = "speed")]
778 #[serde(skip_serializing_if = "Option::is_none")]
779 #[serde(default)]
780 pub speed: Option<i64>,
781 #[doc = "Which type of input events to be generated (default: 'default', which queries the platform\nfor the preferred input type)."]
782 #[serde(rename = "gestureSourceType")]
783 #[serde(skip_serializing_if = "Option::is_none")]
784 #[serde(default)]
785 pub gesture_source_type: Option<super::types::GestureSourceType>,
786 #[doc = "The number of times to repeat the gesture (default: 0)."]
787 #[serde(rename = "repeatCount")]
788 #[serde(skip_serializing_if = "Option::is_none")]
789 #[serde(default)]
790 pub repeat_count: Option<i64>,
791 #[doc = "The number of milliseconds delay between each repeat. (default: 250)."]
792 #[serde(rename = "repeatDelayMs")]
793 #[serde(skip_serializing_if = "Option::is_none")]
794 #[serde(default)]
795 pub repeat_delay_ms: Option<i64>,
796 #[doc = "The name of the interaction markers to generate, if not empty (default: \"\")."]
797 #[serde(rename = "interactionMarkerName")]
798 #[serde(skip_serializing_if = "Option::is_none")]
799 #[serde(default)]
800 pub interaction_marker_name: Option<String>,
801}
802impl SynthesizeScrollGestureParams {
803 pub fn new(x: impl Into<f64>, y: impl Into<f64>) -> Self {
804 Self {
805 x: x.into(),
806 y: y.into(),
807 x_distance: None,
808 y_distance: None,
809 x_overscroll: None,
810 y_overscroll: None,
811 prevent_fling: None,
812 speed: None,
813 gesture_source_type: None,
814 repeat_count: None,
815 repeat_delay_ms: None,
816 interaction_marker_name: None,
817 }
818 }
819}
820#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
821pub enum SynthesizeScrollGestureMethod {
822 #[serde(rename = "Input.synthesizeScrollGesture")]
823 SynthesizeScrollGesture,
824}
825#[doc = "Synthesizes a scroll gesture over a time period by issuing appropriate touch events.\n[synthesizeScrollGesture](https://chromedevtools.github.io/devtools-protocol/tot/Input/#method-synthesizeScrollGesture)"]
826#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
827pub struct SynthesizeScrollGesture {
828 pub method: SynthesizeScrollGestureMethod,
829 pub params: SynthesizeScrollGestureParams,
830}
831impl SynthesizeScrollGesture {
832 pub const IDENTIFIER: &'static str = "Input.synthesizeScrollGesture";
833 pub fn identifier(&self) -> &'static str {
834 Self::IDENTIFIER
835 }
836}
837impl crate::CommandResult for SynthesizeScrollGesture {
838 type Result = super::results::SynthesizeScrollGestureResult;
839}
840#[doc = "Synthesizes a tap gesture over a time period by issuing appropriate touch events.\n[synthesizeTapGesture](https://chromedevtools.github.io/devtools-protocol/tot/Input/#method-synthesizeTapGesture)"]
841#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
842pub struct SynthesizeTapGestureParams {
843 #[doc = "X coordinate of the start of the gesture in CSS pixels."]
844 #[serde(rename = "x")]
845 pub x: f64,
846 #[doc = "Y coordinate of the start of the gesture in CSS pixels."]
847 #[serde(rename = "y")]
848 pub y: f64,
849 #[doc = "Duration between touchdown and touchup events in ms (default: 50)."]
850 #[serde(rename = "duration")]
851 #[serde(skip_serializing_if = "Option::is_none")]
852 #[serde(default)]
853 pub duration: Option<i64>,
854 #[doc = "Number of times to perform the tap (e.g. 2 for double tap, default: 1)."]
855 #[serde(rename = "tapCount")]
856 #[serde(skip_serializing_if = "Option::is_none")]
857 #[serde(default)]
858 pub tap_count: Option<i64>,
859 #[doc = "Which type of input events to be generated (default: 'default', which queries the platform\nfor the preferred input type)."]
860 #[serde(rename = "gestureSourceType")]
861 #[serde(skip_serializing_if = "Option::is_none")]
862 #[serde(default)]
863 pub gesture_source_type: Option<super::types::GestureSourceType>,
864}
865impl SynthesizeTapGestureParams {
866 pub fn new(x: impl Into<f64>, y: impl Into<f64>) -> Self {
867 Self {
868 x: x.into(),
869 y: y.into(),
870 duration: None,
871 tap_count: None,
872 gesture_source_type: None,
873 }
874 }
875}
876#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
877pub enum SynthesizeTapGestureMethod {
878 #[serde(rename = "Input.synthesizeTapGesture")]
879 SynthesizeTapGesture,
880}
881#[doc = "Synthesizes a tap gesture over a time period by issuing appropriate touch events.\n[synthesizeTapGesture](https://chromedevtools.github.io/devtools-protocol/tot/Input/#method-synthesizeTapGesture)"]
882#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
883pub struct SynthesizeTapGesture {
884 pub method: SynthesizeTapGestureMethod,
885 pub params: SynthesizeTapGestureParams,
886}
887impl SynthesizeTapGesture {
888 pub const IDENTIFIER: &'static str = "Input.synthesizeTapGesture";
889 pub fn identifier(&self) -> &'static str {
890 Self::IDENTIFIER
891 }
892}
893impl crate::CommandResult for SynthesizeTapGesture {
894 type Result = super::results::SynthesizeTapGestureResult;
895}
896group_enum ! (InputCommands { DispatchDragEvent (DispatchDragEvent) , DispatchKeyEvent (DispatchKeyEvent) , InsertText (InsertText) , ImeSetComposition (ImeSetComposition) , DispatchMouseEvent (DispatchMouseEvent) , DispatchTouchEvent (DispatchTouchEvent) , CancelDragging (CancelDragging) , EmulateTouchFromMouseEvent (EmulateTouchFromMouseEvent) , SetIgnoreInputEvents (SetIgnoreInputEvents) , SetInterceptDrags (SetInterceptDrags) , SynthesizePinchGesture (SynthesizePinchGesture) , SynthesizeScrollGesture (SynthesizeScrollGesture) , SynthesizeTapGesture (SynthesizeTapGesture) } + identifiable);