Skip to main content

browser_protocol/input/
mod.rs

1use serde::{Serialize, Deserialize};
2use serde_json::Value as JsonValue;
3use std::borrow::Cow;
4
5
6#[derive(Debug, Clone, Serialize, Deserialize, Default)]
7#[serde(rename_all = "camelCase")]
8pub struct TouchPoint {
9    /// X coordinate of the event relative to the main frame's viewport in CSS pixels.
10    x: f64,
11    /// Y coordinate of the event relative to the main frame's viewport in CSS pixels. 0 refers to
12    /// the top of the viewport and Y increases as it proceeds towards the bottom of the viewport.
13    y: f64,
14    /// X radius of the touch area (default: 1.0).
15    #[serde(skip_serializing_if = "Option::is_none")]
16    radiusX: Option<f64>,
17    /// Y radius of the touch area (default: 1.0).
18    #[serde(skip_serializing_if = "Option::is_none")]
19    radiusY: Option<f64>,
20    /// Rotation angle (default: 0.0).
21    #[serde(skip_serializing_if = "Option::is_none")]
22    rotationAngle: Option<f64>,
23    /// Force (default: 1.0).
24    #[serde(skip_serializing_if = "Option::is_none")]
25    force: Option<f64>,
26    /// The normalized tangential pressure, which has a range of [-1,1] (default: 0).
27    #[serde(skip_serializing_if = "Option::is_none")]
28    tangentialPressure: Option<f64>,
29    /// 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)
30    #[serde(skip_serializing_if = "Option::is_none")]
31    tiltX: Option<f64>,
32    /// 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).
33    #[serde(skip_serializing_if = "Option::is_none")]
34    tiltY: Option<f64>,
35    /// The clockwise rotation of a pen stylus around its own major axis, in degrees in the range [0,359] (default: 0).
36    #[serde(skip_serializing_if = "Option::is_none")]
37    twist: Option<i64>,
38    /// Identifier used to track touch sources between events, must be unique within an event.
39    #[serde(skip_serializing_if = "Option::is_none")]
40    id: Option<f64>,
41}
42
43impl TouchPoint {
44    pub fn builder(x: f64, y: f64) -> TouchPointBuilder {
45        TouchPointBuilder {
46            x: x,
47            y: y,
48            radiusX: None,
49            radiusY: None,
50            rotationAngle: None,
51            force: None,
52            tangentialPressure: None,
53            tiltX: None,
54            tiltY: None,
55            twist: None,
56            id: None,
57        }
58    }
59    pub fn x(&self) -> f64 { self.x }
60    pub fn y(&self) -> f64 { self.y }
61    pub fn radiusX(&self) -> Option<f64> { self.radiusX }
62    pub fn radiusY(&self) -> Option<f64> { self.radiusY }
63    pub fn rotationAngle(&self) -> Option<f64> { self.rotationAngle }
64    pub fn force(&self) -> Option<f64> { self.force }
65    pub fn tangentialPressure(&self) -> Option<f64> { self.tangentialPressure }
66    pub fn tiltX(&self) -> Option<f64> { self.tiltX }
67    pub fn tiltY(&self) -> Option<f64> { self.tiltY }
68    pub fn twist(&self) -> Option<i64> { self.twist }
69    pub fn id(&self) -> Option<f64> { self.id }
70}
71
72
73pub struct TouchPointBuilder {
74    x: f64,
75    y: f64,
76    radiusX: Option<f64>,
77    radiusY: Option<f64>,
78    rotationAngle: Option<f64>,
79    force: Option<f64>,
80    tangentialPressure: Option<f64>,
81    tiltX: Option<f64>,
82    tiltY: Option<f64>,
83    twist: Option<i64>,
84    id: Option<f64>,
85}
86
87impl TouchPointBuilder {
88    /// X radius of the touch area (default: 1.0).
89    pub fn radiusX(mut self, radiusX: f64) -> Self { self.radiusX = Some(radiusX); self }
90    /// Y radius of the touch area (default: 1.0).
91    pub fn radiusY(mut self, radiusY: f64) -> Self { self.radiusY = Some(radiusY); self }
92    /// Rotation angle (default: 0.0).
93    pub fn rotationAngle(mut self, rotationAngle: f64) -> Self { self.rotationAngle = Some(rotationAngle); self }
94    /// Force (default: 1.0).
95    pub fn force(mut self, force: f64) -> Self { self.force = Some(force); self }
96    /// The normalized tangential pressure, which has a range of [-1,1] (default: 0).
97    pub fn tangentialPressure(mut self, tangentialPressure: f64) -> Self { self.tangentialPressure = Some(tangentialPressure); self }
98    /// 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)
99    pub fn tiltX(mut self, tiltX: f64) -> Self { self.tiltX = Some(tiltX); self }
100    /// 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).
101    pub fn tiltY(mut self, tiltY: f64) -> Self { self.tiltY = Some(tiltY); self }
102    /// The clockwise rotation of a pen stylus around its own major axis, in degrees in the range [0,359] (default: 0).
103    pub fn twist(mut self, twist: i64) -> Self { self.twist = Some(twist); self }
104    /// Identifier used to track touch sources between events, must be unique within an event.
105    pub fn id(mut self, id: f64) -> Self { self.id = Some(id); self }
106    pub fn build(self) -> TouchPoint {
107        TouchPoint {
108            x: self.x,
109            y: self.y,
110            radiusX: self.radiusX,
111            radiusY: self.radiusY,
112            rotationAngle: self.rotationAngle,
113            force: self.force,
114            tangentialPressure: self.tangentialPressure,
115            tiltX: self.tiltX,
116            tiltY: self.tiltY,
117            twist: self.twist,
118            id: self.id,
119        }
120    }
121}
122
123
124#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Default)]
125pub enum GestureSourceType {
126    #[default]
127    #[serde(rename = "default")]
128    Default,
129    #[serde(rename = "touch")]
130    Touch,
131    #[serde(rename = "mouse")]
132    Mouse,
133}
134
135
136#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Default)]
137pub enum MouseButton {
138    #[default]
139    #[serde(rename = "none")]
140    None,
141    #[serde(rename = "left")]
142    Left,
143    #[serde(rename = "middle")]
144    Middle,
145    #[serde(rename = "right")]
146    Right,
147    #[serde(rename = "back")]
148    Back,
149    #[serde(rename = "forward")]
150    Forward,
151}
152
153/// UTC time in seconds, counted from January 1, 1970.
154
155pub type TimeSinceEpoch = f64;
156
157
158#[derive(Debug, Clone, Serialize, Deserialize, Default)]
159#[serde(rename_all = "camelCase")]
160pub struct DragDataItem<'a> {
161    /// Mime type of the dragged data.
162    mimeType: Cow<'a, str>,
163    /// Depending of the value of 'mimeType', it contains the dragged link,
164    /// text, HTML markup or any other data.
165    data: Cow<'a, str>,
166    /// Title associated with a link. Only valid when 'mimeType' == "text/uri-list".
167    #[serde(skip_serializing_if = "Option::is_none")]
168    title: Option<Cow<'a, str>>,
169    /// Stores the base URL for the contained markup. Only valid when 'mimeType'
170    /// == "text/html".
171    #[serde(skip_serializing_if = "Option::is_none")]
172    baseURL: Option<Cow<'a, str>>,
173}
174
175impl<'a> DragDataItem<'a> {
176    pub fn builder(mimeType: impl Into<Cow<'a, str>>, data: impl Into<Cow<'a, str>>) -> DragDataItemBuilder<'a> {
177        DragDataItemBuilder {
178            mimeType: mimeType.into(),
179            data: data.into(),
180            title: None,
181            baseURL: None,
182        }
183    }
184    pub fn mimeType(&self) -> &str { self.mimeType.as_ref() }
185    pub fn data(&self) -> &str { self.data.as_ref() }
186    pub fn title(&self) -> Option<&str> { self.title.as_deref() }
187    pub fn baseURL(&self) -> Option<&str> { self.baseURL.as_deref() }
188}
189
190
191pub struct DragDataItemBuilder<'a> {
192    mimeType: Cow<'a, str>,
193    data: Cow<'a, str>,
194    title: Option<Cow<'a, str>>,
195    baseURL: Option<Cow<'a, str>>,
196}
197
198impl<'a> DragDataItemBuilder<'a> {
199    /// Title associated with a link. Only valid when 'mimeType' == "text/uri-list".
200    pub fn title(mut self, title: impl Into<Cow<'a, str>>) -> Self { self.title = Some(title.into()); self }
201    /// Stores the base URL for the contained markup. Only valid when 'mimeType'
202    /// == "text/html".
203    pub fn baseURL(mut self, baseURL: impl Into<Cow<'a, str>>) -> Self { self.baseURL = Some(baseURL.into()); self }
204    pub fn build(self) -> DragDataItem<'a> {
205        DragDataItem {
206            mimeType: self.mimeType,
207            data: self.data,
208            title: self.title,
209            baseURL: self.baseURL,
210        }
211    }
212}
213
214
215#[derive(Debug, Clone, Serialize, Deserialize, Default)]
216#[serde(rename_all = "camelCase")]
217pub struct DragData<'a> {
218    items: Vec<DragDataItem<'a>>,
219    /// List of filenames that should be included when dropping
220    #[serde(skip_serializing_if = "Option::is_none")]
221    files: Option<Vec<Cow<'a, str>>>,
222    /// Bit field representing allowed drag operations. Copy = 1, Link = 2, Move = 16
223    dragOperationsMask: i64,
224}
225
226impl<'a> DragData<'a> {
227    pub fn builder(items: Vec<DragDataItem<'a>>, dragOperationsMask: i64) -> DragDataBuilder<'a> {
228        DragDataBuilder {
229            items: items,
230            files: None,
231            dragOperationsMask: dragOperationsMask,
232        }
233    }
234    pub fn items(&self) -> &[DragDataItem<'a>] { &self.items }
235    pub fn files(&self) -> Option<&[Cow<'a, str>]> { self.files.as_deref() }
236    pub fn dragOperationsMask(&self) -> i64 { self.dragOperationsMask }
237}
238
239
240pub struct DragDataBuilder<'a> {
241    items: Vec<DragDataItem<'a>>,
242    files: Option<Vec<Cow<'a, str>>>,
243    dragOperationsMask: i64,
244}
245
246impl<'a> DragDataBuilder<'a> {
247    /// List of filenames that should be included when dropping
248    pub fn files(mut self, files: Vec<Cow<'a, str>>) -> Self { self.files = Some(files); self }
249    pub fn build(self) -> DragData<'a> {
250        DragData {
251            items: self.items,
252            files: self.files,
253            dragOperationsMask: self.dragOperationsMask,
254        }
255    }
256}
257
258/// Dispatches a drag event into the page.
259
260#[derive(Debug, Clone, Serialize, Deserialize, Default)]
261#[serde(rename_all = "camelCase")]
262pub struct DispatchDragEventParams<'a> {
263    /// Type of the drag event.
264    #[serde(rename = "type")]
265    type_: Cow<'a, str>,
266    /// X coordinate of the event relative to the main frame's viewport in CSS pixels.
267    x: f64,
268    /// Y coordinate of the event relative to the main frame's viewport in CSS pixels. 0 refers to
269    /// the top of the viewport and Y increases as it proceeds towards the bottom of the viewport.
270    y: f64,
271    data: DragData<'a>,
272    /// Bit field representing pressed modifier keys. Alt=1, Ctrl=2, Meta/Command=4, Shift=8
273    /// (default: 0).
274    #[serde(skip_serializing_if = "Option::is_none")]
275    modifiers: Option<i64>,
276}
277
278impl<'a> DispatchDragEventParams<'a> {
279    pub fn builder(type_: impl Into<Cow<'a, str>>, x: f64, y: f64, data: DragData<'a>) -> DispatchDragEventParamsBuilder<'a> {
280        DispatchDragEventParamsBuilder {
281            type_: type_.into(),
282            x: x,
283            y: y,
284            data: data,
285            modifiers: None,
286        }
287    }
288    pub fn type_(&self) -> &str { self.type_.as_ref() }
289    pub fn x(&self) -> f64 { self.x }
290    pub fn y(&self) -> f64 { self.y }
291    pub fn data(&self) -> &DragData<'a> { &self.data }
292    pub fn modifiers(&self) -> Option<i64> { self.modifiers }
293}
294
295
296pub struct DispatchDragEventParamsBuilder<'a> {
297    type_: Cow<'a, str>,
298    x: f64,
299    y: f64,
300    data: DragData<'a>,
301    modifiers: Option<i64>,
302}
303
304impl<'a> DispatchDragEventParamsBuilder<'a> {
305    /// Bit field representing pressed modifier keys. Alt=1, Ctrl=2, Meta/Command=4, Shift=8
306    /// (default: 0).
307    pub fn modifiers(mut self, modifiers: i64) -> Self { self.modifiers = Some(modifiers); self }
308    pub fn build(self) -> DispatchDragEventParams<'a> {
309        DispatchDragEventParams {
310            type_: self.type_,
311            x: self.x,
312            y: self.y,
313            data: self.data,
314            modifiers: self.modifiers,
315        }
316    }
317}
318
319impl<'a> DispatchDragEventParams<'a> { pub const METHOD: &'static str = "Input.dispatchDragEvent"; }
320
321impl<'a> crate::CdpCommand<'a> for DispatchDragEventParams<'a> {
322    const METHOD: &'static str = "Input.dispatchDragEvent";
323    type Response = crate::EmptyReturns;
324}
325
326/// Dispatches a key event to the page.
327
328#[derive(Debug, Clone, Serialize, Deserialize, Default)]
329#[serde(rename_all = "camelCase")]
330pub struct DispatchKeyEventParams<'a> {
331    /// Type of the key event.
332    #[serde(rename = "type")]
333    type_: Cow<'a, str>,
334    /// Bit field representing pressed modifier keys. Alt=1, Ctrl=2, Meta/Command=4, Shift=8
335    /// (default: 0).
336    #[serde(skip_serializing_if = "Option::is_none")]
337    modifiers: Option<i64>,
338    /// Time at which the event occurred.
339    #[serde(skip_serializing_if = "Option::is_none")]
340    timestamp: Option<TimeSinceEpoch>,
341    /// Text as generated by processing a virtual key code with a keyboard layout. Not needed for
342    /// for 'keyUp' and 'rawKeyDown' events (default: "")
343    #[serde(skip_serializing_if = "Option::is_none")]
344    text: Option<Cow<'a, str>>,
345    /// Text that would have been generated by the keyboard if no modifiers were pressed (except for
346    /// shift). Useful for shortcut (accelerator) key handling (default: "").
347    #[serde(skip_serializing_if = "Option::is_none")]
348    unmodifiedText: Option<Cow<'a, str>>,
349    /// Unique key identifier (e.g., 'U+0041') (default: "").
350    #[serde(skip_serializing_if = "Option::is_none")]
351    keyIdentifier: Option<Cow<'a, str>>,
352    /// Unique DOM defined string value for each physical key (e.g., 'KeyA') (default: "").
353    #[serde(skip_serializing_if = "Option::is_none")]
354    code: Option<Cow<'a, str>>,
355    /// Unique DOM defined string value describing the meaning of the key in the context of active
356    /// modifiers, keyboard layout, etc (e.g., 'AltGr') (default: "").
357    #[serde(skip_serializing_if = "Option::is_none")]
358    key: Option<Cow<'a, str>>,
359    /// Windows virtual key code (default: 0).
360    #[serde(skip_serializing_if = "Option::is_none")]
361    windowsVirtualKeyCode: Option<i64>,
362    /// Native virtual key code (default: 0).
363    #[serde(skip_serializing_if = "Option::is_none")]
364    nativeVirtualKeyCode: Option<i64>,
365    /// Whether the event was generated from auto repeat (default: false).
366    #[serde(skip_serializing_if = "Option::is_none")]
367    autoRepeat: Option<bool>,
368    /// Whether the event was generated from the keypad (default: false).
369    #[serde(skip_serializing_if = "Option::is_none")]
370    isKeypad: Option<bool>,
371    /// Whether the event was a system key event (default: false).
372    #[serde(skip_serializing_if = "Option::is_none")]
373    isSystemKey: Option<bool>,
374    /// Whether the event was from the left or right side of the keyboard. 1=Left, 2=Right (default:
375    /// 0).
376    #[serde(skip_serializing_if = "Option::is_none")]
377    location: Option<i64>,
378    /// Editing commands to send with the key event (e.g., 'selectAll') (default: []).
379    /// These are related to but not equal the command names used in 'document.execCommand' and NSStandardKeyBindingResponding.
380    /// See https://source.chromium.org/chromium/chromium/src/+/main:third_party/blink/renderer/core/editing/commands/editor_command_names.h for valid command names.
381    #[serde(skip_serializing_if = "Option::is_none")]
382    commands: Option<Vec<Cow<'a, str>>>,
383}
384
385impl<'a> DispatchKeyEventParams<'a> {
386    pub fn builder(type_: impl Into<Cow<'a, str>>) -> DispatchKeyEventParamsBuilder<'a> {
387        DispatchKeyEventParamsBuilder {
388            type_: type_.into(),
389            modifiers: None,
390            timestamp: None,
391            text: None,
392            unmodifiedText: None,
393            keyIdentifier: None,
394            code: None,
395            key: None,
396            windowsVirtualKeyCode: None,
397            nativeVirtualKeyCode: None,
398            autoRepeat: None,
399            isKeypad: None,
400            isSystemKey: None,
401            location: None,
402            commands: None,
403        }
404    }
405    pub fn type_(&self) -> &str { self.type_.as_ref() }
406    pub fn modifiers(&self) -> Option<i64> { self.modifiers }
407    pub fn timestamp(&self) -> Option<&TimeSinceEpoch> { self.timestamp.as_ref() }
408    pub fn text(&self) -> Option<&str> { self.text.as_deref() }
409    pub fn unmodifiedText(&self) -> Option<&str> { self.unmodifiedText.as_deref() }
410    pub fn keyIdentifier(&self) -> Option<&str> { self.keyIdentifier.as_deref() }
411    pub fn code(&self) -> Option<&str> { self.code.as_deref() }
412    pub fn key(&self) -> Option<&str> { self.key.as_deref() }
413    pub fn windowsVirtualKeyCode(&self) -> Option<i64> { self.windowsVirtualKeyCode }
414    pub fn nativeVirtualKeyCode(&self) -> Option<i64> { self.nativeVirtualKeyCode }
415    pub fn autoRepeat(&self) -> Option<bool> { self.autoRepeat }
416    pub fn isKeypad(&self) -> Option<bool> { self.isKeypad }
417    pub fn isSystemKey(&self) -> Option<bool> { self.isSystemKey }
418    pub fn location(&self) -> Option<i64> { self.location }
419    pub fn commands(&self) -> Option<&[Cow<'a, str>]> { self.commands.as_deref() }
420}
421
422
423pub struct DispatchKeyEventParamsBuilder<'a> {
424    type_: Cow<'a, str>,
425    modifiers: Option<i64>,
426    timestamp: Option<TimeSinceEpoch>,
427    text: Option<Cow<'a, str>>,
428    unmodifiedText: Option<Cow<'a, str>>,
429    keyIdentifier: Option<Cow<'a, str>>,
430    code: Option<Cow<'a, str>>,
431    key: Option<Cow<'a, str>>,
432    windowsVirtualKeyCode: Option<i64>,
433    nativeVirtualKeyCode: Option<i64>,
434    autoRepeat: Option<bool>,
435    isKeypad: Option<bool>,
436    isSystemKey: Option<bool>,
437    location: Option<i64>,
438    commands: Option<Vec<Cow<'a, str>>>,
439}
440
441impl<'a> DispatchKeyEventParamsBuilder<'a> {
442    /// Bit field representing pressed modifier keys. Alt=1, Ctrl=2, Meta/Command=4, Shift=8
443    /// (default: 0).
444    pub fn modifiers(mut self, modifiers: i64) -> Self { self.modifiers = Some(modifiers); self }
445    /// Time at which the event occurred.
446    pub fn timestamp(mut self, timestamp: TimeSinceEpoch) -> Self { self.timestamp = Some(timestamp); self }
447    /// Text as generated by processing a virtual key code with a keyboard layout. Not needed for
448    /// for 'keyUp' and 'rawKeyDown' events (default: "")
449    pub fn text(mut self, text: impl Into<Cow<'a, str>>) -> Self { self.text = Some(text.into()); self }
450    /// Text that would have been generated by the keyboard if no modifiers were pressed (except for
451    /// shift). Useful for shortcut (accelerator) key handling (default: "").
452    pub fn unmodifiedText(mut self, unmodifiedText: impl Into<Cow<'a, str>>) -> Self { self.unmodifiedText = Some(unmodifiedText.into()); self }
453    /// Unique key identifier (e.g., 'U+0041') (default: "").
454    pub fn keyIdentifier(mut self, keyIdentifier: impl Into<Cow<'a, str>>) -> Self { self.keyIdentifier = Some(keyIdentifier.into()); self }
455    /// Unique DOM defined string value for each physical key (e.g., 'KeyA') (default: "").
456    pub fn code(mut self, code: impl Into<Cow<'a, str>>) -> Self { self.code = Some(code.into()); self }
457    /// Unique DOM defined string value describing the meaning of the key in the context of active
458    /// modifiers, keyboard layout, etc (e.g., 'AltGr') (default: "").
459    pub fn key(mut self, key: impl Into<Cow<'a, str>>) -> Self { self.key = Some(key.into()); self }
460    /// Windows virtual key code (default: 0).
461    pub fn windowsVirtualKeyCode(mut self, windowsVirtualKeyCode: i64) -> Self { self.windowsVirtualKeyCode = Some(windowsVirtualKeyCode); self }
462    /// Native virtual key code (default: 0).
463    pub fn nativeVirtualKeyCode(mut self, nativeVirtualKeyCode: i64) -> Self { self.nativeVirtualKeyCode = Some(nativeVirtualKeyCode); self }
464    /// Whether the event was generated from auto repeat (default: false).
465    pub fn autoRepeat(mut self, autoRepeat: bool) -> Self { self.autoRepeat = Some(autoRepeat); self }
466    /// Whether the event was generated from the keypad (default: false).
467    pub fn isKeypad(mut self, isKeypad: bool) -> Self { self.isKeypad = Some(isKeypad); self }
468    /// Whether the event was a system key event (default: false).
469    pub fn isSystemKey(mut self, isSystemKey: bool) -> Self { self.isSystemKey = Some(isSystemKey); self }
470    /// Whether the event was from the left or right side of the keyboard. 1=Left, 2=Right (default:
471    /// 0).
472    pub fn location(mut self, location: i64) -> Self { self.location = Some(location); self }
473    /// Editing commands to send with the key event (e.g., 'selectAll') (default: []).
474    /// These are related to but not equal the command names used in 'document.execCommand' and NSStandardKeyBindingResponding.
475    /// See https://source.chromium.org/chromium/chromium/src/+/main:third_party/blink/renderer/core/editing/commands/editor_command_names.h for valid command names.
476    pub fn commands(mut self, commands: Vec<Cow<'a, str>>) -> Self { self.commands = Some(commands); self }
477    pub fn build(self) -> DispatchKeyEventParams<'a> {
478        DispatchKeyEventParams {
479            type_: self.type_,
480            modifiers: self.modifiers,
481            timestamp: self.timestamp,
482            text: self.text,
483            unmodifiedText: self.unmodifiedText,
484            keyIdentifier: self.keyIdentifier,
485            code: self.code,
486            key: self.key,
487            windowsVirtualKeyCode: self.windowsVirtualKeyCode,
488            nativeVirtualKeyCode: self.nativeVirtualKeyCode,
489            autoRepeat: self.autoRepeat,
490            isKeypad: self.isKeypad,
491            isSystemKey: self.isSystemKey,
492            location: self.location,
493            commands: self.commands,
494        }
495    }
496}
497
498impl<'a> DispatchKeyEventParams<'a> { pub const METHOD: &'static str = "Input.dispatchKeyEvent"; }
499
500impl<'a> crate::CdpCommand<'a> for DispatchKeyEventParams<'a> {
501    const METHOD: &'static str = "Input.dispatchKeyEvent";
502    type Response = crate::EmptyReturns;
503}
504
505/// This method emulates inserting text that doesn't come from a key press,
506/// for example an emoji keyboard or an IME.
507
508#[derive(Debug, Clone, Serialize, Deserialize, Default)]
509#[serde(rename_all = "camelCase")]
510pub struct InsertTextParams<'a> {
511    /// The text to insert.
512    text: Cow<'a, str>,
513}
514
515impl<'a> InsertTextParams<'a> {
516    pub fn builder(text: impl Into<Cow<'a, str>>) -> InsertTextParamsBuilder<'a> {
517        InsertTextParamsBuilder {
518            text: text.into(),
519        }
520    }
521    pub fn text(&self) -> &str { self.text.as_ref() }
522}
523
524
525pub struct InsertTextParamsBuilder<'a> {
526    text: Cow<'a, str>,
527}
528
529impl<'a> InsertTextParamsBuilder<'a> {
530    pub fn build(self) -> InsertTextParams<'a> {
531        InsertTextParams {
532            text: self.text,
533        }
534    }
535}
536
537impl<'a> InsertTextParams<'a> { pub const METHOD: &'static str = "Input.insertText"; }
538
539impl<'a> crate::CdpCommand<'a> for InsertTextParams<'a> {
540    const METHOD: &'static str = "Input.insertText";
541    type Response = crate::EmptyReturns;
542}
543
544/// This method sets the current candidate text for IME.
545/// Use imeCommitComposition to commit the final text.
546/// Use imeSetComposition with empty string as text to cancel composition.
547
548#[derive(Debug, Clone, Serialize, Deserialize, Default)]
549#[serde(rename_all = "camelCase")]
550pub struct ImeSetCompositionParams<'a> {
551    /// The text to insert
552    text: Cow<'a, str>,
553    /// selection start
554    selectionStart: i64,
555    /// selection end
556    selectionEnd: i64,
557    /// replacement start
558    #[serde(skip_serializing_if = "Option::is_none")]
559    replacementStart: Option<i64>,
560    /// replacement end
561    #[serde(skip_serializing_if = "Option::is_none")]
562    replacementEnd: Option<i64>,
563}
564
565impl<'a> ImeSetCompositionParams<'a> {
566    pub fn builder(text: impl Into<Cow<'a, str>>, selectionStart: i64, selectionEnd: i64) -> ImeSetCompositionParamsBuilder<'a> {
567        ImeSetCompositionParamsBuilder {
568            text: text.into(),
569            selectionStart: selectionStart,
570            selectionEnd: selectionEnd,
571            replacementStart: None,
572            replacementEnd: None,
573        }
574    }
575    pub fn text(&self) -> &str { self.text.as_ref() }
576    pub fn selectionStart(&self) -> i64 { self.selectionStart }
577    pub fn selectionEnd(&self) -> i64 { self.selectionEnd }
578    pub fn replacementStart(&self) -> Option<i64> { self.replacementStart }
579    pub fn replacementEnd(&self) -> Option<i64> { self.replacementEnd }
580}
581
582
583pub struct ImeSetCompositionParamsBuilder<'a> {
584    text: Cow<'a, str>,
585    selectionStart: i64,
586    selectionEnd: i64,
587    replacementStart: Option<i64>,
588    replacementEnd: Option<i64>,
589}
590
591impl<'a> ImeSetCompositionParamsBuilder<'a> {
592    /// replacement start
593    pub fn replacementStart(mut self, replacementStart: i64) -> Self { self.replacementStart = Some(replacementStart); self }
594    /// replacement end
595    pub fn replacementEnd(mut self, replacementEnd: i64) -> Self { self.replacementEnd = Some(replacementEnd); self }
596    pub fn build(self) -> ImeSetCompositionParams<'a> {
597        ImeSetCompositionParams {
598            text: self.text,
599            selectionStart: self.selectionStart,
600            selectionEnd: self.selectionEnd,
601            replacementStart: self.replacementStart,
602            replacementEnd: self.replacementEnd,
603        }
604    }
605}
606
607impl<'a> ImeSetCompositionParams<'a> { pub const METHOD: &'static str = "Input.imeSetComposition"; }
608
609impl<'a> crate::CdpCommand<'a> for ImeSetCompositionParams<'a> {
610    const METHOD: &'static str = "Input.imeSetComposition";
611    type Response = crate::EmptyReturns;
612}
613
614/// Dispatches a mouse event to the page.
615
616#[derive(Debug, Clone, Serialize, Deserialize, Default)]
617#[serde(rename_all = "camelCase")]
618pub struct DispatchMouseEventParams<'a> {
619    /// Type of the mouse event.
620    #[serde(rename = "type")]
621    type_: Cow<'a, str>,
622    /// X coordinate of the event relative to the main frame's viewport in CSS pixels.
623    x: f64,
624    /// Y coordinate of the event relative to the main frame's viewport in CSS pixels. 0 refers to
625    /// the top of the viewport and Y increases as it proceeds towards the bottom of the viewport.
626    y: f64,
627    /// Bit field representing pressed modifier keys. Alt=1, Ctrl=2, Meta/Command=4, Shift=8
628    /// (default: 0).
629    #[serde(skip_serializing_if = "Option::is_none")]
630    modifiers: Option<i64>,
631    /// Time at which the event occurred.
632    #[serde(skip_serializing_if = "Option::is_none")]
633    timestamp: Option<TimeSinceEpoch>,
634    /// Mouse button (default: "none").
635    #[serde(skip_serializing_if = "Option::is_none")]
636    button: Option<MouseButton>,
637    /// A number indicating which buttons are pressed on the mouse when a mouse event is triggered.
638    /// Left=1, Right=2, Middle=4, Back=8, Forward=16, None=0.
639    #[serde(skip_serializing_if = "Option::is_none")]
640    buttons: Option<i64>,
641    /// Number of times the mouse button was clicked (default: 0).
642    #[serde(skip_serializing_if = "Option::is_none")]
643    clickCount: Option<u64>,
644    /// The normalized pressure, which has a range of [0,1] (default: 0).
645    #[serde(skip_serializing_if = "Option::is_none")]
646    force: Option<f64>,
647    /// The normalized tangential pressure, which has a range of [-1,1] (default: 0).
648    #[serde(skip_serializing_if = "Option::is_none")]
649    tangentialPressure: Option<f64>,
650    /// 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).
651    #[serde(skip_serializing_if = "Option::is_none")]
652    tiltX: Option<f64>,
653    /// 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).
654    #[serde(skip_serializing_if = "Option::is_none")]
655    tiltY: Option<f64>,
656    /// The clockwise rotation of a pen stylus around its own major axis, in degrees in the range [0,359] (default: 0).
657    #[serde(skip_serializing_if = "Option::is_none")]
658    twist: Option<i64>,
659    /// X delta in CSS pixels for mouse wheel event (default: 0).
660    #[serde(skip_serializing_if = "Option::is_none")]
661    deltaX: Option<f64>,
662    /// Y delta in CSS pixels for mouse wheel event (default: 0).
663    #[serde(skip_serializing_if = "Option::is_none")]
664    deltaY: Option<f64>,
665    /// Pointer type (default: "mouse").
666    #[serde(skip_serializing_if = "Option::is_none")]
667    pointerType: Option<Cow<'a, str>>,
668}
669
670impl<'a> DispatchMouseEventParams<'a> {
671    pub fn builder(type_: impl Into<Cow<'a, str>>, x: f64, y: f64) -> DispatchMouseEventParamsBuilder<'a> {
672        DispatchMouseEventParamsBuilder {
673            type_: type_.into(),
674            x: x,
675            y: y,
676            modifiers: None,
677            timestamp: None,
678            button: None,
679            buttons: None,
680            clickCount: None,
681            force: None,
682            tangentialPressure: None,
683            tiltX: None,
684            tiltY: None,
685            twist: None,
686            deltaX: None,
687            deltaY: None,
688            pointerType: None,
689        }
690    }
691    pub fn type_(&self) -> &str { self.type_.as_ref() }
692    pub fn x(&self) -> f64 { self.x }
693    pub fn y(&self) -> f64 { self.y }
694    pub fn modifiers(&self) -> Option<i64> { self.modifiers }
695    pub fn timestamp(&self) -> Option<&TimeSinceEpoch> { self.timestamp.as_ref() }
696    pub fn button(&self) -> Option<&MouseButton> { self.button.as_ref() }
697    pub fn buttons(&self) -> Option<i64> { self.buttons }
698    pub fn clickCount(&self) -> Option<u64> { self.clickCount }
699    pub fn force(&self) -> Option<f64> { self.force }
700    pub fn tangentialPressure(&self) -> Option<f64> { self.tangentialPressure }
701    pub fn tiltX(&self) -> Option<f64> { self.tiltX }
702    pub fn tiltY(&self) -> Option<f64> { self.tiltY }
703    pub fn twist(&self) -> Option<i64> { self.twist }
704    pub fn deltaX(&self) -> Option<f64> { self.deltaX }
705    pub fn deltaY(&self) -> Option<f64> { self.deltaY }
706    pub fn pointerType(&self) -> Option<&str> { self.pointerType.as_deref() }
707}
708
709
710pub struct DispatchMouseEventParamsBuilder<'a> {
711    type_: Cow<'a, str>,
712    x: f64,
713    y: f64,
714    modifiers: Option<i64>,
715    timestamp: Option<TimeSinceEpoch>,
716    button: Option<MouseButton>,
717    buttons: Option<i64>,
718    clickCount: Option<u64>,
719    force: Option<f64>,
720    tangentialPressure: Option<f64>,
721    tiltX: Option<f64>,
722    tiltY: Option<f64>,
723    twist: Option<i64>,
724    deltaX: Option<f64>,
725    deltaY: Option<f64>,
726    pointerType: Option<Cow<'a, str>>,
727}
728
729impl<'a> DispatchMouseEventParamsBuilder<'a> {
730    /// Bit field representing pressed modifier keys. Alt=1, Ctrl=2, Meta/Command=4, Shift=8
731    /// (default: 0).
732    pub fn modifiers(mut self, modifiers: i64) -> Self { self.modifiers = Some(modifiers); self }
733    /// Time at which the event occurred.
734    pub fn timestamp(mut self, timestamp: TimeSinceEpoch) -> Self { self.timestamp = Some(timestamp); self }
735    /// Mouse button (default: "none").
736    pub fn button(mut self, button: MouseButton) -> Self { self.button = Some(button); self }
737    /// A number indicating which buttons are pressed on the mouse when a mouse event is triggered.
738    /// Left=1, Right=2, Middle=4, Back=8, Forward=16, None=0.
739    pub fn buttons(mut self, buttons: i64) -> Self { self.buttons = Some(buttons); self }
740    /// Number of times the mouse button was clicked (default: 0).
741    pub fn clickCount(mut self, clickCount: u64) -> Self { self.clickCount = Some(clickCount); self }
742    /// The normalized pressure, which has a range of [0,1] (default: 0).
743    pub fn force(mut self, force: f64) -> Self { self.force = Some(force); self }
744    /// The normalized tangential pressure, which has a range of [-1,1] (default: 0).
745    pub fn tangentialPressure(mut self, tangentialPressure: f64) -> Self { self.tangentialPressure = Some(tangentialPressure); self }
746    /// 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).
747    pub fn tiltX(mut self, tiltX: f64) -> Self { self.tiltX = Some(tiltX); self }
748    /// 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).
749    pub fn tiltY(mut self, tiltY: f64) -> Self { self.tiltY = Some(tiltY); self }
750    /// The clockwise rotation of a pen stylus around its own major axis, in degrees in the range [0,359] (default: 0).
751    pub fn twist(mut self, twist: i64) -> Self { self.twist = Some(twist); self }
752    /// X delta in CSS pixels for mouse wheel event (default: 0).
753    pub fn deltaX(mut self, deltaX: f64) -> Self { self.deltaX = Some(deltaX); self }
754    /// Y delta in CSS pixels for mouse wheel event (default: 0).
755    pub fn deltaY(mut self, deltaY: f64) -> Self { self.deltaY = Some(deltaY); self }
756    /// Pointer type (default: "mouse").
757    pub fn pointerType(mut self, pointerType: impl Into<Cow<'a, str>>) -> Self { self.pointerType = Some(pointerType.into()); self }
758    pub fn build(self) -> DispatchMouseEventParams<'a> {
759        DispatchMouseEventParams {
760            type_: self.type_,
761            x: self.x,
762            y: self.y,
763            modifiers: self.modifiers,
764            timestamp: self.timestamp,
765            button: self.button,
766            buttons: self.buttons,
767            clickCount: self.clickCount,
768            force: self.force,
769            tangentialPressure: self.tangentialPressure,
770            tiltX: self.tiltX,
771            tiltY: self.tiltY,
772            twist: self.twist,
773            deltaX: self.deltaX,
774            deltaY: self.deltaY,
775            pointerType: self.pointerType,
776        }
777    }
778}
779
780impl<'a> DispatchMouseEventParams<'a> { pub const METHOD: &'static str = "Input.dispatchMouseEvent"; }
781
782impl<'a> crate::CdpCommand<'a> for DispatchMouseEventParams<'a> {
783    const METHOD: &'static str = "Input.dispatchMouseEvent";
784    type Response = crate::EmptyReturns;
785}
786
787/// Dispatches a touch event to the page.
788
789#[derive(Debug, Clone, Serialize, Deserialize, Default)]
790#[serde(rename_all = "camelCase")]
791pub struct DispatchTouchEventParams<'a> {
792    /// Type of the touch event. TouchEnd and TouchCancel must not contain any touch points, while
793    /// TouchStart and TouchMove must contains at least one.
794    #[serde(rename = "type")]
795    type_: Cow<'a, str>,
796    /// Active touch points on the touch device. One event per any changed point (compared to
797    /// previous touch event in a sequence) is generated, emulating pressing/moving/releasing points
798    /// one by one.
799    touchPoints: Vec<TouchPoint>,
800    /// Bit field representing pressed modifier keys. Alt=1, Ctrl=2, Meta/Command=4, Shift=8
801    /// (default: 0).
802    #[serde(skip_serializing_if = "Option::is_none")]
803    modifiers: Option<i64>,
804    /// Time at which the event occurred.
805    #[serde(skip_serializing_if = "Option::is_none")]
806    timestamp: Option<TimeSinceEpoch>,
807}
808
809impl<'a> DispatchTouchEventParams<'a> {
810    pub fn builder(type_: impl Into<Cow<'a, str>>, touchPoints: Vec<TouchPoint>) -> DispatchTouchEventParamsBuilder<'a> {
811        DispatchTouchEventParamsBuilder {
812            type_: type_.into(),
813            touchPoints: touchPoints,
814            modifiers: None,
815            timestamp: None,
816        }
817    }
818    pub fn type_(&self) -> &str { self.type_.as_ref() }
819    pub fn touchPoints(&self) -> &[TouchPoint] { &self.touchPoints }
820    pub fn modifiers(&self) -> Option<i64> { self.modifiers }
821    pub fn timestamp(&self) -> Option<&TimeSinceEpoch> { self.timestamp.as_ref() }
822}
823
824
825pub struct DispatchTouchEventParamsBuilder<'a> {
826    type_: Cow<'a, str>,
827    touchPoints: Vec<TouchPoint>,
828    modifiers: Option<i64>,
829    timestamp: Option<TimeSinceEpoch>,
830}
831
832impl<'a> DispatchTouchEventParamsBuilder<'a> {
833    /// Bit field representing pressed modifier keys. Alt=1, Ctrl=2, Meta/Command=4, Shift=8
834    /// (default: 0).
835    pub fn modifiers(mut self, modifiers: i64) -> Self { self.modifiers = Some(modifiers); self }
836    /// Time at which the event occurred.
837    pub fn timestamp(mut self, timestamp: TimeSinceEpoch) -> Self { self.timestamp = Some(timestamp); self }
838    pub fn build(self) -> DispatchTouchEventParams<'a> {
839        DispatchTouchEventParams {
840            type_: self.type_,
841            touchPoints: self.touchPoints,
842            modifiers: self.modifiers,
843            timestamp: self.timestamp,
844        }
845    }
846}
847
848impl<'a> DispatchTouchEventParams<'a> { pub const METHOD: &'static str = "Input.dispatchTouchEvent"; }
849
850impl<'a> crate::CdpCommand<'a> for DispatchTouchEventParams<'a> {
851    const METHOD: &'static str = "Input.dispatchTouchEvent";
852    type Response = crate::EmptyReturns;
853}
854
855#[derive(Debug, Clone, Serialize, Deserialize, Default)]
856pub struct CancelDraggingParams {}
857
858impl CancelDraggingParams { pub const METHOD: &'static str = "Input.cancelDragging"; }
859
860impl<'a> crate::CdpCommand<'a> for CancelDraggingParams {
861    const METHOD: &'static str = "Input.cancelDragging";
862    type Response = crate::EmptyReturns;
863}
864
865/// Emulates touch event from the mouse event parameters.
866
867#[derive(Debug, Clone, Serialize, Deserialize, Default)]
868#[serde(rename_all = "camelCase")]
869pub struct EmulateTouchFromMouseEventParams<'a> {
870    /// Type of the mouse event.
871    #[serde(rename = "type")]
872    type_: Cow<'a, str>,
873    /// X coordinate of the mouse pointer in DIP.
874    x: i32,
875    /// Y coordinate of the mouse pointer in DIP.
876    y: i32,
877    /// Mouse button. Only "none", "left", "right" are supported.
878    button: MouseButton,
879    /// Time at which the event occurred (default: current time).
880    #[serde(skip_serializing_if = "Option::is_none")]
881    timestamp: Option<TimeSinceEpoch>,
882    /// X delta in DIP for mouse wheel event (default: 0).
883    #[serde(skip_serializing_if = "Option::is_none")]
884    deltaX: Option<f64>,
885    /// Y delta in DIP for mouse wheel event (default: 0).
886    #[serde(skip_serializing_if = "Option::is_none")]
887    deltaY: Option<f64>,
888    /// Bit field representing pressed modifier keys. Alt=1, Ctrl=2, Meta/Command=4, Shift=8
889    /// (default: 0).
890    #[serde(skip_serializing_if = "Option::is_none")]
891    modifiers: Option<i64>,
892    /// Number of times the mouse button was clicked (default: 0).
893    #[serde(skip_serializing_if = "Option::is_none")]
894    clickCount: Option<u64>,
895}
896
897impl<'a> EmulateTouchFromMouseEventParams<'a> {
898    pub fn builder(type_: impl Into<Cow<'a, str>>, x: i32, y: i32, button: MouseButton) -> EmulateTouchFromMouseEventParamsBuilder<'a> {
899        EmulateTouchFromMouseEventParamsBuilder {
900            type_: type_.into(),
901            x: x,
902            y: y,
903            button: button,
904            timestamp: None,
905            deltaX: None,
906            deltaY: None,
907            modifiers: None,
908            clickCount: None,
909        }
910    }
911    pub fn type_(&self) -> &str { self.type_.as_ref() }
912    pub fn x(&self) -> i32 { self.x }
913    pub fn y(&self) -> i32 { self.y }
914    pub fn button(&self) -> &MouseButton { &self.button }
915    pub fn timestamp(&self) -> Option<&TimeSinceEpoch> { self.timestamp.as_ref() }
916    pub fn deltaX(&self) -> Option<f64> { self.deltaX }
917    pub fn deltaY(&self) -> Option<f64> { self.deltaY }
918    pub fn modifiers(&self) -> Option<i64> { self.modifiers }
919    pub fn clickCount(&self) -> Option<u64> { self.clickCount }
920}
921
922
923pub struct EmulateTouchFromMouseEventParamsBuilder<'a> {
924    type_: Cow<'a, str>,
925    x: i32,
926    y: i32,
927    button: MouseButton,
928    timestamp: Option<TimeSinceEpoch>,
929    deltaX: Option<f64>,
930    deltaY: Option<f64>,
931    modifiers: Option<i64>,
932    clickCount: Option<u64>,
933}
934
935impl<'a> EmulateTouchFromMouseEventParamsBuilder<'a> {
936    /// Time at which the event occurred (default: current time).
937    pub fn timestamp(mut self, timestamp: TimeSinceEpoch) -> Self { self.timestamp = Some(timestamp); self }
938    /// X delta in DIP for mouse wheel event (default: 0).
939    pub fn deltaX(mut self, deltaX: f64) -> Self { self.deltaX = Some(deltaX); self }
940    /// Y delta in DIP for mouse wheel event (default: 0).
941    pub fn deltaY(mut self, deltaY: f64) -> Self { self.deltaY = Some(deltaY); self }
942    /// Bit field representing pressed modifier keys. Alt=1, Ctrl=2, Meta/Command=4, Shift=8
943    /// (default: 0).
944    pub fn modifiers(mut self, modifiers: i64) -> Self { self.modifiers = Some(modifiers); self }
945    /// Number of times the mouse button was clicked (default: 0).
946    pub fn clickCount(mut self, clickCount: u64) -> Self { self.clickCount = Some(clickCount); self }
947    pub fn build(self) -> EmulateTouchFromMouseEventParams<'a> {
948        EmulateTouchFromMouseEventParams {
949            type_: self.type_,
950            x: self.x,
951            y: self.y,
952            button: self.button,
953            timestamp: self.timestamp,
954            deltaX: self.deltaX,
955            deltaY: self.deltaY,
956            modifiers: self.modifiers,
957            clickCount: self.clickCount,
958        }
959    }
960}
961
962impl<'a> EmulateTouchFromMouseEventParams<'a> { pub const METHOD: &'static str = "Input.emulateTouchFromMouseEvent"; }
963
964impl<'a> crate::CdpCommand<'a> for EmulateTouchFromMouseEventParams<'a> {
965    const METHOD: &'static str = "Input.emulateTouchFromMouseEvent";
966    type Response = crate::EmptyReturns;
967}
968
969/// Ignores input events (useful while auditing page).
970
971#[derive(Debug, Clone, Serialize, Deserialize, Default)]
972#[serde(rename_all = "camelCase")]
973pub struct SetIgnoreInputEventsParams {
974    /// Ignores input events processing when set to true.
975    ignore: bool,
976}
977
978impl SetIgnoreInputEventsParams {
979    pub fn builder(ignore: bool) -> SetIgnoreInputEventsParamsBuilder {
980        SetIgnoreInputEventsParamsBuilder {
981            ignore: ignore,
982        }
983    }
984    pub fn ignore(&self) -> bool { self.ignore }
985}
986
987
988pub struct SetIgnoreInputEventsParamsBuilder {
989    ignore: bool,
990}
991
992impl SetIgnoreInputEventsParamsBuilder {
993    pub fn build(self) -> SetIgnoreInputEventsParams {
994        SetIgnoreInputEventsParams {
995            ignore: self.ignore,
996        }
997    }
998}
999
1000impl SetIgnoreInputEventsParams { pub const METHOD: &'static str = "Input.setIgnoreInputEvents"; }
1001
1002impl<'a> crate::CdpCommand<'a> for SetIgnoreInputEventsParams {
1003    const METHOD: &'static str = "Input.setIgnoreInputEvents";
1004    type Response = crate::EmptyReturns;
1005}
1006
1007/// Prevents default drag and drop behavior and instead emits 'Input.dragIntercepted' events.
1008/// Drag and drop behavior can be directly controlled via 'Input.dispatchDragEvent'.
1009
1010#[derive(Debug, Clone, Serialize, Deserialize, Default)]
1011#[serde(rename_all = "camelCase")]
1012pub struct SetInterceptDragsParams {
1013    enabled: bool,
1014}
1015
1016impl SetInterceptDragsParams {
1017    pub fn builder(enabled: bool) -> SetInterceptDragsParamsBuilder {
1018        SetInterceptDragsParamsBuilder {
1019            enabled: enabled,
1020        }
1021    }
1022    pub fn enabled(&self) -> bool { self.enabled }
1023}
1024
1025
1026pub struct SetInterceptDragsParamsBuilder {
1027    enabled: bool,
1028}
1029
1030impl SetInterceptDragsParamsBuilder {
1031    pub fn build(self) -> SetInterceptDragsParams {
1032        SetInterceptDragsParams {
1033            enabled: self.enabled,
1034        }
1035    }
1036}
1037
1038impl SetInterceptDragsParams { pub const METHOD: &'static str = "Input.setInterceptDrags"; }
1039
1040impl<'a> crate::CdpCommand<'a> for SetInterceptDragsParams {
1041    const METHOD: &'static str = "Input.setInterceptDrags";
1042    type Response = crate::EmptyReturns;
1043}
1044
1045/// Synthesizes a pinch gesture over a time period by issuing appropriate touch events.
1046
1047#[derive(Debug, Clone, Serialize, Deserialize, Default)]
1048#[serde(rename_all = "camelCase")]
1049pub struct SynthesizePinchGestureParams {
1050    /// X coordinate of the start of the gesture in CSS pixels.
1051    x: f64,
1052    /// Y coordinate of the start of the gesture in CSS pixels.
1053    y: f64,
1054    /// Relative scale factor after zooming (>1.0 zooms in, <1.0 zooms out).
1055    scaleFactor: f64,
1056    /// Relative pointer speed in pixels per second (default: 800).
1057    #[serde(skip_serializing_if = "Option::is_none")]
1058    relativeSpeed: Option<i64>,
1059    /// Which type of input events to be generated (default: 'default', which queries the platform
1060    /// for the preferred input type).
1061    #[serde(skip_serializing_if = "Option::is_none")]
1062    gestureSourceType: Option<GestureSourceType>,
1063}
1064
1065impl SynthesizePinchGestureParams {
1066    pub fn builder(x: f64, y: f64, scaleFactor: f64) -> SynthesizePinchGestureParamsBuilder {
1067        SynthesizePinchGestureParamsBuilder {
1068            x: x,
1069            y: y,
1070            scaleFactor: scaleFactor,
1071            relativeSpeed: None,
1072            gestureSourceType: None,
1073        }
1074    }
1075    pub fn x(&self) -> f64 { self.x }
1076    pub fn y(&self) -> f64 { self.y }
1077    pub fn scaleFactor(&self) -> f64 { self.scaleFactor }
1078    pub fn relativeSpeed(&self) -> Option<i64> { self.relativeSpeed }
1079    pub fn gestureSourceType(&self) -> Option<&GestureSourceType> { self.gestureSourceType.as_ref() }
1080}
1081
1082
1083pub struct SynthesizePinchGestureParamsBuilder {
1084    x: f64,
1085    y: f64,
1086    scaleFactor: f64,
1087    relativeSpeed: Option<i64>,
1088    gestureSourceType: Option<GestureSourceType>,
1089}
1090
1091impl SynthesizePinchGestureParamsBuilder {
1092    /// Relative pointer speed in pixels per second (default: 800).
1093    pub fn relativeSpeed(mut self, relativeSpeed: i64) -> Self { self.relativeSpeed = Some(relativeSpeed); self }
1094    /// Which type of input events to be generated (default: 'default', which queries the platform
1095    /// for the preferred input type).
1096    pub fn gestureSourceType(mut self, gestureSourceType: GestureSourceType) -> Self { self.gestureSourceType = Some(gestureSourceType); self }
1097    pub fn build(self) -> SynthesizePinchGestureParams {
1098        SynthesizePinchGestureParams {
1099            x: self.x,
1100            y: self.y,
1101            scaleFactor: self.scaleFactor,
1102            relativeSpeed: self.relativeSpeed,
1103            gestureSourceType: self.gestureSourceType,
1104        }
1105    }
1106}
1107
1108impl SynthesizePinchGestureParams { pub const METHOD: &'static str = "Input.synthesizePinchGesture"; }
1109
1110impl<'a> crate::CdpCommand<'a> for SynthesizePinchGestureParams {
1111    const METHOD: &'static str = "Input.synthesizePinchGesture";
1112    type Response = crate::EmptyReturns;
1113}
1114
1115/// Synthesizes a scroll gesture over a time period by issuing appropriate touch events.
1116
1117#[derive(Debug, Clone, Serialize, Deserialize, Default)]
1118#[serde(rename_all = "camelCase")]
1119pub struct SynthesizeScrollGestureParams<'a> {
1120    /// X coordinate of the start of the gesture in CSS pixels.
1121    x: f64,
1122    /// Y coordinate of the start of the gesture in CSS pixels.
1123    y: f64,
1124    /// The distance to scroll along the X axis (positive to scroll left).
1125    #[serde(skip_serializing_if = "Option::is_none")]
1126    xDistance: Option<f64>,
1127    /// The distance to scroll along the Y axis (positive to scroll up).
1128    #[serde(skip_serializing_if = "Option::is_none")]
1129    yDistance: Option<f64>,
1130    /// The number of additional pixels to scroll back along the X axis, in addition to the given
1131    /// distance.
1132    #[serde(skip_serializing_if = "Option::is_none")]
1133    xOverscroll: Option<f64>,
1134    /// The number of additional pixels to scroll back along the Y axis, in addition to the given
1135    /// distance.
1136    #[serde(skip_serializing_if = "Option::is_none")]
1137    yOverscroll: Option<f64>,
1138    /// Prevent fling (default: true).
1139    #[serde(skip_serializing_if = "Option::is_none")]
1140    preventFling: Option<bool>,
1141    /// Swipe speed in pixels per second (default: 800).
1142    #[serde(skip_serializing_if = "Option::is_none")]
1143    speed: Option<i64>,
1144    /// Which type of input events to be generated (default: 'default', which queries the platform
1145    /// for the preferred input type).
1146    #[serde(skip_serializing_if = "Option::is_none")]
1147    gestureSourceType: Option<GestureSourceType>,
1148    /// The number of times to repeat the gesture (default: 0).
1149    #[serde(skip_serializing_if = "Option::is_none")]
1150    repeatCount: Option<u64>,
1151    /// The number of milliseconds delay between each repeat. (default: 250).
1152    #[serde(skip_serializing_if = "Option::is_none")]
1153    repeatDelayMs: Option<i64>,
1154    /// The name of the interaction markers to generate, if not empty (default: "").
1155    #[serde(skip_serializing_if = "Option::is_none")]
1156    interactionMarkerName: Option<Cow<'a, str>>,
1157}
1158
1159impl<'a> SynthesizeScrollGestureParams<'a> {
1160    pub fn builder(x: f64, y: f64) -> SynthesizeScrollGestureParamsBuilder<'a> {
1161        SynthesizeScrollGestureParamsBuilder {
1162            x: x,
1163            y: y,
1164            xDistance: None,
1165            yDistance: None,
1166            xOverscroll: None,
1167            yOverscroll: None,
1168            preventFling: None,
1169            speed: None,
1170            gestureSourceType: None,
1171            repeatCount: None,
1172            repeatDelayMs: None,
1173            interactionMarkerName: None,
1174        }
1175    }
1176    pub fn x(&self) -> f64 { self.x }
1177    pub fn y(&self) -> f64 { self.y }
1178    pub fn xDistance(&self) -> Option<f64> { self.xDistance }
1179    pub fn yDistance(&self) -> Option<f64> { self.yDistance }
1180    pub fn xOverscroll(&self) -> Option<f64> { self.xOverscroll }
1181    pub fn yOverscroll(&self) -> Option<f64> { self.yOverscroll }
1182    pub fn preventFling(&self) -> Option<bool> { self.preventFling }
1183    pub fn speed(&self) -> Option<i64> { self.speed }
1184    pub fn gestureSourceType(&self) -> Option<&GestureSourceType> { self.gestureSourceType.as_ref() }
1185    pub fn repeatCount(&self) -> Option<u64> { self.repeatCount }
1186    pub fn repeatDelayMs(&self) -> Option<i64> { self.repeatDelayMs }
1187    pub fn interactionMarkerName(&self) -> Option<&str> { self.interactionMarkerName.as_deref() }
1188}
1189
1190
1191pub struct SynthesizeScrollGestureParamsBuilder<'a> {
1192    x: f64,
1193    y: f64,
1194    xDistance: Option<f64>,
1195    yDistance: Option<f64>,
1196    xOverscroll: Option<f64>,
1197    yOverscroll: Option<f64>,
1198    preventFling: Option<bool>,
1199    speed: Option<i64>,
1200    gestureSourceType: Option<GestureSourceType>,
1201    repeatCount: Option<u64>,
1202    repeatDelayMs: Option<i64>,
1203    interactionMarkerName: Option<Cow<'a, str>>,
1204}
1205
1206impl<'a> SynthesizeScrollGestureParamsBuilder<'a> {
1207    /// The distance to scroll along the X axis (positive to scroll left).
1208    pub fn xDistance(mut self, xDistance: f64) -> Self { self.xDistance = Some(xDistance); self }
1209    /// The distance to scroll along the Y axis (positive to scroll up).
1210    pub fn yDistance(mut self, yDistance: f64) -> Self { self.yDistance = Some(yDistance); self }
1211    /// The number of additional pixels to scroll back along the X axis, in addition to the given
1212    /// distance.
1213    pub fn xOverscroll(mut self, xOverscroll: f64) -> Self { self.xOverscroll = Some(xOverscroll); self }
1214    /// The number of additional pixels to scroll back along the Y axis, in addition to the given
1215    /// distance.
1216    pub fn yOverscroll(mut self, yOverscroll: f64) -> Self { self.yOverscroll = Some(yOverscroll); self }
1217    /// Prevent fling (default: true).
1218    pub fn preventFling(mut self, preventFling: bool) -> Self { self.preventFling = Some(preventFling); self }
1219    /// Swipe speed in pixels per second (default: 800).
1220    pub fn speed(mut self, speed: i64) -> Self { self.speed = Some(speed); self }
1221    /// Which type of input events to be generated (default: 'default', which queries the platform
1222    /// for the preferred input type).
1223    pub fn gestureSourceType(mut self, gestureSourceType: GestureSourceType) -> Self { self.gestureSourceType = Some(gestureSourceType); self }
1224    /// The number of times to repeat the gesture (default: 0).
1225    pub fn repeatCount(mut self, repeatCount: u64) -> Self { self.repeatCount = Some(repeatCount); self }
1226    /// The number of milliseconds delay between each repeat. (default: 250).
1227    pub fn repeatDelayMs(mut self, repeatDelayMs: i64) -> Self { self.repeatDelayMs = Some(repeatDelayMs); self }
1228    /// The name of the interaction markers to generate, if not empty (default: "").
1229    pub fn interactionMarkerName(mut self, interactionMarkerName: impl Into<Cow<'a, str>>) -> Self { self.interactionMarkerName = Some(interactionMarkerName.into()); self }
1230    pub fn build(self) -> SynthesizeScrollGestureParams<'a> {
1231        SynthesizeScrollGestureParams {
1232            x: self.x,
1233            y: self.y,
1234            xDistance: self.xDistance,
1235            yDistance: self.yDistance,
1236            xOverscroll: self.xOverscroll,
1237            yOverscroll: self.yOverscroll,
1238            preventFling: self.preventFling,
1239            speed: self.speed,
1240            gestureSourceType: self.gestureSourceType,
1241            repeatCount: self.repeatCount,
1242            repeatDelayMs: self.repeatDelayMs,
1243            interactionMarkerName: self.interactionMarkerName,
1244        }
1245    }
1246}
1247
1248impl<'a> SynthesizeScrollGestureParams<'a> { pub const METHOD: &'static str = "Input.synthesizeScrollGesture"; }
1249
1250impl<'a> crate::CdpCommand<'a> for SynthesizeScrollGestureParams<'a> {
1251    const METHOD: &'static str = "Input.synthesizeScrollGesture";
1252    type Response = crate::EmptyReturns;
1253}
1254
1255/// Synthesizes a tap gesture over a time period by issuing appropriate touch events.
1256
1257#[derive(Debug, Clone, Serialize, Deserialize, Default)]
1258#[serde(rename_all = "camelCase")]
1259pub struct SynthesizeTapGestureParams {
1260    /// X coordinate of the start of the gesture in CSS pixels.
1261    x: f64,
1262    /// Y coordinate of the start of the gesture in CSS pixels.
1263    y: f64,
1264    /// Duration between touchdown and touchup events in ms (default: 50).
1265    #[serde(skip_serializing_if = "Option::is_none")]
1266    duration: Option<i64>,
1267    /// Number of times to perform the tap (e.g. 2 for double tap, default: 1).
1268    #[serde(skip_serializing_if = "Option::is_none")]
1269    tapCount: Option<u64>,
1270    /// Which type of input events to be generated (default: 'default', which queries the platform
1271    /// for the preferred input type).
1272    #[serde(skip_serializing_if = "Option::is_none")]
1273    gestureSourceType: Option<GestureSourceType>,
1274}
1275
1276impl SynthesizeTapGestureParams {
1277    pub fn builder(x: f64, y: f64) -> SynthesizeTapGestureParamsBuilder {
1278        SynthesizeTapGestureParamsBuilder {
1279            x: x,
1280            y: y,
1281            duration: None,
1282            tapCount: None,
1283            gestureSourceType: None,
1284        }
1285    }
1286    pub fn x(&self) -> f64 { self.x }
1287    pub fn y(&self) -> f64 { self.y }
1288    pub fn duration(&self) -> Option<i64> { self.duration }
1289    pub fn tapCount(&self) -> Option<u64> { self.tapCount }
1290    pub fn gestureSourceType(&self) -> Option<&GestureSourceType> { self.gestureSourceType.as_ref() }
1291}
1292
1293
1294pub struct SynthesizeTapGestureParamsBuilder {
1295    x: f64,
1296    y: f64,
1297    duration: Option<i64>,
1298    tapCount: Option<u64>,
1299    gestureSourceType: Option<GestureSourceType>,
1300}
1301
1302impl SynthesizeTapGestureParamsBuilder {
1303    /// Duration between touchdown and touchup events in ms (default: 50).
1304    pub fn duration(mut self, duration: i64) -> Self { self.duration = Some(duration); self }
1305    /// Number of times to perform the tap (e.g. 2 for double tap, default: 1).
1306    pub fn tapCount(mut self, tapCount: u64) -> Self { self.tapCount = Some(tapCount); self }
1307    /// Which type of input events to be generated (default: 'default', which queries the platform
1308    /// for the preferred input type).
1309    pub fn gestureSourceType(mut self, gestureSourceType: GestureSourceType) -> Self { self.gestureSourceType = Some(gestureSourceType); self }
1310    pub fn build(self) -> SynthesizeTapGestureParams {
1311        SynthesizeTapGestureParams {
1312            x: self.x,
1313            y: self.y,
1314            duration: self.duration,
1315            tapCount: self.tapCount,
1316            gestureSourceType: self.gestureSourceType,
1317        }
1318    }
1319}
1320
1321impl SynthesizeTapGestureParams { pub const METHOD: &'static str = "Input.synthesizeTapGesture"; }
1322
1323impl<'a> crate::CdpCommand<'a> for SynthesizeTapGestureParams {
1324    const METHOD: &'static str = "Input.synthesizeTapGesture";
1325    type Response = crate::EmptyReturns;
1326}