Skip to main content

browser_protocol/accessibility/
mod.rs

1use serde::{Serialize, Deserialize};
2use serde_json::Value as JsonValue;
3use std::borrow::Cow;
4
5/// Unique accessibility node identifier.
6
7pub type AXNodeId<'a> = Cow<'a, str>;
8
9/// Enum of possible property types.
10
11#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Default)]
12pub enum AXValueType {
13    #[default]
14    #[serde(rename = "boolean")]
15    Boolean,
16    #[serde(rename = "tristate")]
17    Tristate,
18    #[serde(rename = "booleanOrUndefined")]
19    BooleanOrUndefined,
20    #[serde(rename = "idref")]
21    Idref,
22    #[serde(rename = "idrefList")]
23    IdrefList,
24    #[serde(rename = "integer")]
25    Integer,
26    #[serde(rename = "node")]
27    Node,
28    #[serde(rename = "nodeList")]
29    NodeList,
30    #[serde(rename = "number")]
31    Number,
32    #[serde(rename = "string")]
33    String,
34    #[serde(rename = "computedString")]
35    ComputedString,
36    #[serde(rename = "token")]
37    Token,
38    #[serde(rename = "tokenList")]
39    TokenList,
40    #[serde(rename = "domRelation")]
41    DomRelation,
42    #[serde(rename = "role")]
43    Role,
44    #[serde(rename = "internalRole")]
45    InternalRole,
46    #[serde(rename = "valueUndefined")]
47    ValueUndefined,
48}
49
50/// Enum of possible property sources.
51
52#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Default)]
53pub enum AXValueSourceType {
54    #[default]
55    #[serde(rename = "attribute")]
56    Attribute,
57    #[serde(rename = "implicit")]
58    Implicit,
59    #[serde(rename = "style")]
60    Style,
61    #[serde(rename = "contents")]
62    Contents,
63    #[serde(rename = "placeholder")]
64    Placeholder,
65    #[serde(rename = "relatedElement")]
66    RelatedElement,
67}
68
69/// Enum of possible native property sources (as a subtype of a particular AXValueSourceType).
70
71#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Default)]
72pub enum AXValueNativeSourceType {
73    #[default]
74    #[serde(rename = "description")]
75    Description,
76    #[serde(rename = "figcaption")]
77    Figcaption,
78    #[serde(rename = "label")]
79    Label,
80    #[serde(rename = "labelfor")]
81    Labelfor,
82    #[serde(rename = "labelwrapped")]
83    Labelwrapped,
84    #[serde(rename = "legend")]
85    Legend,
86    #[serde(rename = "rubyannotation")]
87    Rubyannotation,
88    #[serde(rename = "tablecaption")]
89    Tablecaption,
90    #[serde(rename = "title")]
91    Title,
92    #[serde(rename = "other")]
93    Other,
94}
95
96/// A single source for a computed AX property.
97
98#[derive(Debug, Clone, Serialize, Deserialize, Default)]
99#[serde(rename_all = "camelCase")]
100pub struct AXValueSource<'a> {
101    /// What type of source this is.
102    #[serde(rename = "type")]
103    type_: AXValueSourceType,
104    /// The value of this property source.
105    #[serde(skip_serializing_if = "Option::is_none")]
106    value: Option<AXValue<'a>>,
107    /// The name of the relevant attribute, if any.
108    #[serde(skip_serializing_if = "Option::is_none")]
109    attribute: Option<Cow<'a, str>>,
110    /// The value of the relevant attribute, if any.
111    #[serde(skip_serializing_if = "Option::is_none", rename = "attributeValue")]
112    attribute_value: Option<AXValue<'a>>,
113    /// Whether this source is superseded by a higher priority source.
114    #[serde(skip_serializing_if = "Option::is_none")]
115    superseded: Option<bool>,
116    /// The native markup source for this value, e.g. a '\<label\>' element.
117    #[serde(skip_serializing_if = "Option::is_none", rename = "nativeSource")]
118    native_source: Option<AXValueNativeSourceType>,
119    /// The value, such as a node or node list, of the native source.
120    #[serde(skip_serializing_if = "Option::is_none", rename = "nativeSourceValue")]
121    native_source_value: Option<AXValue<'a>>,
122    /// Whether the value for this property is invalid.
123    #[serde(skip_serializing_if = "Option::is_none")]
124    invalid: Option<bool>,
125    /// Reason for the value being invalid, if it is.
126    #[serde(skip_serializing_if = "Option::is_none", rename = "invalidReason")]
127    invalid_reason: Option<Cow<'a, str>>,
128}
129
130impl<'a> AXValueSource<'a> {
131    /// Creates a builder for this type with the required parameters:
132    /// * `type_`: What type of source this is.
133    pub fn builder(type_: impl Into<AXValueSourceType>) -> AXValueSourceBuilder<'a> {
134        AXValueSourceBuilder {
135            type_: type_.into(),
136            value: None,
137            attribute: None,
138            attribute_value: None,
139            superseded: None,
140            native_source: None,
141            native_source_value: None,
142            invalid: None,
143            invalid_reason: None,
144        }
145    }
146    /// What type of source this is.
147    pub fn type_(&self) -> &AXValueSourceType { &self.type_ }
148    /// The value of this property source.
149    pub fn value(&self) -> Option<&AXValue<'a>> { self.value.as_ref() }
150    /// The name of the relevant attribute, if any.
151    pub fn attribute(&self) -> Option<&str> { self.attribute.as_deref() }
152    /// The value of the relevant attribute, if any.
153    pub fn attribute_value(&self) -> Option<&AXValue<'a>> { self.attribute_value.as_ref() }
154    /// Whether this source is superseded by a higher priority source.
155    pub fn superseded(&self) -> Option<bool> { self.superseded }
156    /// The native markup source for this value, e.g. a '\<label\>' element.
157    pub fn native_source(&self) -> Option<&AXValueNativeSourceType> { self.native_source.as_ref() }
158    /// The value, such as a node or node list, of the native source.
159    pub fn native_source_value(&self) -> Option<&AXValue<'a>> { self.native_source_value.as_ref() }
160    /// Whether the value for this property is invalid.
161    pub fn invalid(&self) -> Option<bool> { self.invalid }
162    /// Reason for the value being invalid, if it is.
163    pub fn invalid_reason(&self) -> Option<&str> { self.invalid_reason.as_deref() }
164}
165
166
167pub struct AXValueSourceBuilder<'a> {
168    type_: AXValueSourceType,
169    value: Option<AXValue<'a>>,
170    attribute: Option<Cow<'a, str>>,
171    attribute_value: Option<AXValue<'a>>,
172    superseded: Option<bool>,
173    native_source: Option<AXValueNativeSourceType>,
174    native_source_value: Option<AXValue<'a>>,
175    invalid: Option<bool>,
176    invalid_reason: Option<Cow<'a, str>>,
177}
178
179impl<'a> AXValueSourceBuilder<'a> {
180    /// The value of this property source.
181    pub fn value(mut self, value: AXValue<'a>) -> Self { self.value = Some(value); self }
182    /// The name of the relevant attribute, if any.
183    pub fn attribute(mut self, attribute: impl Into<Cow<'a, str>>) -> Self { self.attribute = Some(attribute.into()); self }
184    /// The value of the relevant attribute, if any.
185    pub fn attribute_value(mut self, attribute_value: AXValue<'a>) -> Self { self.attribute_value = Some(attribute_value); self }
186    /// Whether this source is superseded by a higher priority source.
187    pub fn superseded(mut self, superseded: bool) -> Self { self.superseded = Some(superseded); self }
188    /// The native markup source for this value, e.g. a '\<label\>' element.
189    pub fn native_source(mut self, native_source: impl Into<AXValueNativeSourceType>) -> Self { self.native_source = Some(native_source.into()); self }
190    /// The value, such as a node or node list, of the native source.
191    pub fn native_source_value(mut self, native_source_value: AXValue<'a>) -> Self { self.native_source_value = Some(native_source_value); self }
192    /// Whether the value for this property is invalid.
193    pub fn invalid(mut self, invalid: bool) -> Self { self.invalid = Some(invalid); self }
194    /// Reason for the value being invalid, if it is.
195    pub fn invalid_reason(mut self, invalid_reason: impl Into<Cow<'a, str>>) -> Self { self.invalid_reason = Some(invalid_reason.into()); self }
196    pub fn build(self) -> AXValueSource<'a> {
197        AXValueSource {
198            type_: self.type_,
199            value: self.value,
200            attribute: self.attribute,
201            attribute_value: self.attribute_value,
202            superseded: self.superseded,
203            native_source: self.native_source,
204            native_source_value: self.native_source_value,
205            invalid: self.invalid,
206            invalid_reason: self.invalid_reason,
207        }
208    }
209}
210
211
212#[derive(Debug, Clone, Serialize, Deserialize, Default)]
213#[serde(rename_all = "camelCase")]
214pub struct AXRelatedNode<'a> {
215    /// The BackendNodeId of the related DOM node.
216    #[serde(rename = "backendDOMNodeId")]
217    backend_dom_node_id: crate::dom::BackendNodeId,
218    /// The IDRef value provided, if any.
219    #[serde(skip_serializing_if = "Option::is_none")]
220    idref: Option<Cow<'a, str>>,
221    /// The text alternative of this node in the current context.
222    #[serde(skip_serializing_if = "Option::is_none")]
223    text: Option<Cow<'a, str>>,
224}
225
226impl<'a> AXRelatedNode<'a> {
227    /// Creates a builder for this type with the required parameters:
228    /// * `backend_dom_node_id`: The BackendNodeId of the related DOM node.
229    pub fn builder(backend_dom_node_id: crate::dom::BackendNodeId) -> AXRelatedNodeBuilder<'a> {
230        AXRelatedNodeBuilder {
231            backend_dom_node_id: backend_dom_node_id,
232            idref: None,
233            text: None,
234        }
235    }
236    /// The BackendNodeId of the related DOM node.
237    pub fn backend_dom_node_id(&self) -> &crate::dom::BackendNodeId { &self.backend_dom_node_id }
238    /// The IDRef value provided, if any.
239    pub fn idref(&self) -> Option<&str> { self.idref.as_deref() }
240    /// The text alternative of this node in the current context.
241    pub fn text(&self) -> Option<&str> { self.text.as_deref() }
242}
243
244
245pub struct AXRelatedNodeBuilder<'a> {
246    backend_dom_node_id: crate::dom::BackendNodeId,
247    idref: Option<Cow<'a, str>>,
248    text: Option<Cow<'a, str>>,
249}
250
251impl<'a> AXRelatedNodeBuilder<'a> {
252    /// The IDRef value provided, if any.
253    pub fn idref(mut self, idref: impl Into<Cow<'a, str>>) -> Self { self.idref = Some(idref.into()); self }
254    /// The text alternative of this node in the current context.
255    pub fn text(mut self, text: impl Into<Cow<'a, str>>) -> Self { self.text = Some(text.into()); self }
256    pub fn build(self) -> AXRelatedNode<'a> {
257        AXRelatedNode {
258            backend_dom_node_id: self.backend_dom_node_id,
259            idref: self.idref,
260            text: self.text,
261        }
262    }
263}
264
265
266#[derive(Debug, Clone, Serialize, Deserialize, Default)]
267#[serde(rename_all = "camelCase")]
268pub struct AXProperty<'a> {
269    /// The name of this property.
270    name: AXPropertyName,
271    /// The value of this property.
272    value: AXValue<'a>,
273}
274
275impl<'a> AXProperty<'a> {
276    /// Creates a builder for this type with the required parameters:
277    /// * `name`: The name of this property.
278    /// * `value`: The value of this property.
279    pub fn builder(name: impl Into<AXPropertyName>, value: AXValue<'a>) -> AXPropertyBuilder<'a> {
280        AXPropertyBuilder {
281            name: name.into(),
282            value: value,
283        }
284    }
285    /// The name of this property.
286    pub fn name(&self) -> &AXPropertyName { &self.name }
287    /// The value of this property.
288    pub fn value(&self) -> &AXValue<'a> { &self.value }
289}
290
291
292pub struct AXPropertyBuilder<'a> {
293    name: AXPropertyName,
294    value: AXValue<'a>,
295}
296
297impl<'a> AXPropertyBuilder<'a> {
298    pub fn build(self) -> AXProperty<'a> {
299        AXProperty {
300            name: self.name,
301            value: self.value,
302        }
303    }
304}
305
306/// A single computed AX property.
307
308#[derive(Debug, Clone, Serialize, Deserialize, Default)]
309#[serde(rename_all = "camelCase")]
310pub struct AXValue<'a> {
311    /// The type of this value.
312    #[serde(rename = "type")]
313    type_: AXValueType,
314    /// The computed value of this property.
315    #[serde(skip_serializing_if = "Option::is_none")]
316    value: Option<JsonValue>,
317    /// One or more related nodes, if applicable.
318    #[serde(skip_serializing_if = "Option::is_none", rename = "relatedNodes")]
319    related_nodes: Option<Vec<AXRelatedNode<'a>>>,
320    /// The sources which contributed to the computation of this property.
321    #[serde(skip_serializing_if = "Option::is_none")]
322    sources: Option<Vec<AXValueSource<'a>>>,
323}
324
325impl<'a> AXValue<'a> {
326    /// Creates a builder for this type with the required parameters:
327    /// * `type_`: The type of this value.
328    pub fn builder(type_: impl Into<AXValueType>) -> AXValueBuilder<'a> {
329        AXValueBuilder {
330            type_: type_.into(),
331            value: None,
332            related_nodes: None,
333            sources: None,
334        }
335    }
336    /// The type of this value.
337    pub fn type_(&self) -> &AXValueType { &self.type_ }
338    /// The computed value of this property.
339    pub fn value(&self) -> Option<&JsonValue> { self.value.as_ref() }
340    /// One or more related nodes, if applicable.
341    pub fn related_nodes(&self) -> Option<&[AXRelatedNode<'a>]> { self.related_nodes.as_deref() }
342    /// The sources which contributed to the computation of this property.
343    pub fn sources(&self) -> Option<&[AXValueSource<'a>]> { self.sources.as_deref() }
344}
345
346
347pub struct AXValueBuilder<'a> {
348    type_: AXValueType,
349    value: Option<JsonValue>,
350    related_nodes: Option<Vec<AXRelatedNode<'a>>>,
351    sources: Option<Vec<AXValueSource<'a>>>,
352}
353
354impl<'a> AXValueBuilder<'a> {
355    /// The computed value of this property.
356    pub fn value(mut self, value: JsonValue) -> Self { self.value = Some(value); self }
357    /// One or more related nodes, if applicable.
358    pub fn related_nodes(mut self, related_nodes: Vec<AXRelatedNode<'a>>) -> Self { self.related_nodes = Some(related_nodes); self }
359    /// The sources which contributed to the computation of this property.
360    pub fn sources(mut self, sources: Vec<AXValueSource<'a>>) -> Self { self.sources = Some(sources); self }
361    pub fn build(self) -> AXValue<'a> {
362        AXValue {
363            type_: self.type_,
364            value: self.value,
365            related_nodes: self.related_nodes,
366            sources: self.sources,
367        }
368    }
369}
370
371/// Values of AXProperty name:
372/// - from 'busy' to 'roledescription': states which apply to every AX node
373/// - from 'live' to 'root': attributes which apply to nodes in live regions
374/// - from 'autocomplete' to 'valuetext': attributes which apply to widgets
375/// - from 'checked' to 'selected': states which apply to widgets
376/// - from 'activedescendant' to 'owns': relationships between elements other than parent/child/sibling
377/// - from 'activeFullscreenElement' to 'uninteresting': reasons why this noode is hidden
378
379#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Default)]
380pub enum AXPropertyName {
381    #[default]
382    #[serde(rename = "actions")]
383    Actions,
384    #[serde(rename = "busy")]
385    Busy,
386    #[serde(rename = "disabled")]
387    Disabled,
388    #[serde(rename = "editable")]
389    Editable,
390    #[serde(rename = "focusable")]
391    Focusable,
392    #[serde(rename = "focused")]
393    Focused,
394    #[serde(rename = "hidden")]
395    Hidden,
396    #[serde(rename = "hiddenRoot")]
397    HiddenRoot,
398    #[serde(rename = "invalid")]
399    Invalid,
400    #[serde(rename = "keyshortcuts")]
401    Keyshortcuts,
402    #[serde(rename = "settable")]
403    Settable,
404    #[serde(rename = "roledescription")]
405    Roledescription,
406    #[serde(rename = "live")]
407    Live,
408    #[serde(rename = "atomic")]
409    Atomic,
410    #[serde(rename = "relevant")]
411    Relevant,
412    #[serde(rename = "root")]
413    Root,
414    #[serde(rename = "autocomplete")]
415    Autocomplete,
416    #[serde(rename = "hasPopup")]
417    HasPopup,
418    #[serde(rename = "level")]
419    Level,
420    #[serde(rename = "multiselectable")]
421    Multiselectable,
422    #[serde(rename = "orientation")]
423    Orientation,
424    #[serde(rename = "multiline")]
425    Multiline,
426    #[serde(rename = "readonly")]
427    Readonly,
428    #[serde(rename = "required")]
429    Required,
430    #[serde(rename = "valuemin")]
431    Valuemin,
432    #[serde(rename = "valuemax")]
433    Valuemax,
434    #[serde(rename = "valuetext")]
435    Valuetext,
436    #[serde(rename = "checked")]
437    Checked,
438    #[serde(rename = "expanded")]
439    Expanded,
440    #[serde(rename = "modal")]
441    Modal,
442    #[serde(rename = "pressed")]
443    Pressed,
444    #[serde(rename = "selected")]
445    Selected,
446    #[serde(rename = "activedescendant")]
447    Activedescendant,
448    #[serde(rename = "controls")]
449    Controls,
450    #[serde(rename = "describedby")]
451    Describedby,
452    #[serde(rename = "details")]
453    Details,
454    #[serde(rename = "errormessage")]
455    Errormessage,
456    #[serde(rename = "flowto")]
457    Flowto,
458    #[serde(rename = "labelledby")]
459    Labelledby,
460    #[serde(rename = "owns")]
461    Owns,
462    #[serde(rename = "url")]
463    Url,
464    #[serde(rename = "activeFullscreenElement")]
465    ActiveFullscreenElement,
466    #[serde(rename = "activeModalDialog")]
467    ActiveModalDialog,
468    #[serde(rename = "activeAriaModalDialog")]
469    ActiveAriaModalDialog,
470    #[serde(rename = "ariaHiddenElement")]
471    AriaHiddenElement,
472    #[serde(rename = "ariaHiddenSubtree")]
473    AriaHiddenSubtree,
474    #[serde(rename = "emptyAlt")]
475    EmptyAlt,
476    #[serde(rename = "emptyText")]
477    EmptyText,
478    #[serde(rename = "inertElement")]
479    InertElement,
480    #[serde(rename = "inertSubtree")]
481    InertSubtree,
482    #[serde(rename = "labelContainer")]
483    LabelContainer,
484    #[serde(rename = "labelFor")]
485    LabelFor,
486    #[serde(rename = "notRendered")]
487    NotRendered,
488    #[serde(rename = "notVisible")]
489    NotVisible,
490    #[serde(rename = "presentationalRole")]
491    PresentationalRole,
492    #[serde(rename = "probablyPresentational")]
493    ProbablyPresentational,
494    #[serde(rename = "inactiveCarouselTabContent")]
495    InactiveCarouselTabContent,
496    #[serde(rename = "uninteresting")]
497    Uninteresting,
498}
499
500/// A node in the accessibility tree.
501
502#[derive(Debug, Clone, Serialize, Deserialize, Default)]
503#[serde(rename_all = "camelCase")]
504pub struct AXNode<'a> {
505    /// Unique identifier for this node.
506    #[serde(rename = "nodeId")]
507    node_id: AXNodeId<'a>,
508    /// Whether this node is ignored for accessibility
509    ignored: bool,
510    /// Collection of reasons why this node is hidden.
511    #[serde(skip_serializing_if = "Option::is_none", rename = "ignoredReasons")]
512    ignored_reasons: Option<Vec<AXProperty<'a>>>,
513    /// This 'Node''s role, whether explicit or implicit.
514    #[serde(skip_serializing_if = "Option::is_none")]
515    role: Option<AXValue<'a>>,
516    /// This 'Node''s Chrome raw role.
517    #[serde(skip_serializing_if = "Option::is_none", rename = "chromeRole")]
518    chrome_role: Option<AXValue<'a>>,
519    /// The accessible name for this 'Node'.
520    #[serde(skip_serializing_if = "Option::is_none")]
521    name: Option<AXValue<'a>>,
522    /// The accessible description for this 'Node'.
523    #[serde(skip_serializing_if = "Option::is_none")]
524    description: Option<AXValue<'a>>,
525    /// The value for this 'Node'.
526    #[serde(skip_serializing_if = "Option::is_none")]
527    value: Option<AXValue<'a>>,
528    /// All other properties
529    #[serde(skip_serializing_if = "Option::is_none")]
530    properties: Option<Vec<AXProperty<'a>>>,
531    /// ID for this node's parent.
532    #[serde(skip_serializing_if = "Option::is_none", rename = "parentId")]
533    parent_id: Option<AXNodeId<'a>>,
534    /// IDs for each of this node's child nodes.
535    #[serde(skip_serializing_if = "Option::is_none", rename = "childIds")]
536    child_ids: Option<Vec<AXNodeId<'a>>>,
537    /// The backend ID for the associated DOM node, if any.
538    #[serde(skip_serializing_if = "Option::is_none", rename = "backendDOMNodeId")]
539    backend_dom_node_id: Option<crate::dom::BackendNodeId>,
540    /// The frame ID for the frame associated with this nodes document.
541    #[serde(skip_serializing_if = "Option::is_none", rename = "frameId")]
542    frame_id: Option<crate::page::FrameId<'a>>,
543}
544
545impl<'a> AXNode<'a> {
546    /// Creates a builder for this type with the required parameters:
547    /// * `node_id`: Unique identifier for this node.
548    /// * `ignored`: Whether this node is ignored for accessibility
549    pub fn builder(node_id: impl Into<AXNodeId<'a>>, ignored: bool) -> AXNodeBuilder<'a> {
550        AXNodeBuilder {
551            node_id: node_id.into(),
552            ignored: ignored,
553            ignored_reasons: None,
554            role: None,
555            chrome_role: None,
556            name: None,
557            description: None,
558            value: None,
559            properties: None,
560            parent_id: None,
561            child_ids: None,
562            backend_dom_node_id: None,
563            frame_id: None,
564        }
565    }
566    /// Unique identifier for this node.
567    pub fn node_id(&self) -> &AXNodeId<'a> { &self.node_id }
568    /// Whether this node is ignored for accessibility
569    pub fn ignored(&self) -> bool { self.ignored }
570    /// Collection of reasons why this node is hidden.
571    pub fn ignored_reasons(&self) -> Option<&[AXProperty<'a>]> { self.ignored_reasons.as_deref() }
572    /// This 'Node''s role, whether explicit or implicit.
573    pub fn role(&self) -> Option<&AXValue<'a>> { self.role.as_ref() }
574    /// This 'Node''s Chrome raw role.
575    pub fn chrome_role(&self) -> Option<&AXValue<'a>> { self.chrome_role.as_ref() }
576    /// The accessible name for this 'Node'.
577    pub fn name(&self) -> Option<&AXValue<'a>> { self.name.as_ref() }
578    /// The accessible description for this 'Node'.
579    pub fn description(&self) -> Option<&AXValue<'a>> { self.description.as_ref() }
580    /// The value for this 'Node'.
581    pub fn value(&self) -> Option<&AXValue<'a>> { self.value.as_ref() }
582    /// All other properties
583    pub fn properties(&self) -> Option<&[AXProperty<'a>]> { self.properties.as_deref() }
584    /// ID for this node's parent.
585    pub fn parent_id(&self) -> Option<&AXNodeId<'a>> { self.parent_id.as_ref() }
586    /// IDs for each of this node's child nodes.
587    pub fn child_ids(&self) -> Option<&[AXNodeId<'a>]> { self.child_ids.as_deref() }
588    /// The backend ID for the associated DOM node, if any.
589    pub fn backend_dom_node_id(&self) -> Option<&crate::dom::BackendNodeId> { self.backend_dom_node_id.as_ref() }
590    /// The frame ID for the frame associated with this nodes document.
591    pub fn frame_id(&self) -> Option<&crate::page::FrameId<'a>> { self.frame_id.as_ref() }
592}
593
594
595pub struct AXNodeBuilder<'a> {
596    node_id: AXNodeId<'a>,
597    ignored: bool,
598    ignored_reasons: Option<Vec<AXProperty<'a>>>,
599    role: Option<AXValue<'a>>,
600    chrome_role: Option<AXValue<'a>>,
601    name: Option<AXValue<'a>>,
602    description: Option<AXValue<'a>>,
603    value: Option<AXValue<'a>>,
604    properties: Option<Vec<AXProperty<'a>>>,
605    parent_id: Option<AXNodeId<'a>>,
606    child_ids: Option<Vec<AXNodeId<'a>>>,
607    backend_dom_node_id: Option<crate::dom::BackendNodeId>,
608    frame_id: Option<crate::page::FrameId<'a>>,
609}
610
611impl<'a> AXNodeBuilder<'a> {
612    /// Collection of reasons why this node is hidden.
613    pub fn ignored_reasons(mut self, ignored_reasons: Vec<AXProperty<'a>>) -> Self { self.ignored_reasons = Some(ignored_reasons); self }
614    /// This 'Node''s role, whether explicit or implicit.
615    pub fn role(mut self, role: AXValue<'a>) -> Self { self.role = Some(role); self }
616    /// This 'Node''s Chrome raw role.
617    pub fn chrome_role(mut self, chrome_role: AXValue<'a>) -> Self { self.chrome_role = Some(chrome_role); self }
618    /// The accessible name for this 'Node'.
619    pub fn name(mut self, name: AXValue<'a>) -> Self { self.name = Some(name); self }
620    /// The accessible description for this 'Node'.
621    pub fn description(mut self, description: AXValue<'a>) -> Self { self.description = Some(description); self }
622    /// The value for this 'Node'.
623    pub fn value(mut self, value: AXValue<'a>) -> Self { self.value = Some(value); self }
624    /// All other properties
625    pub fn properties(mut self, properties: Vec<AXProperty<'a>>) -> Self { self.properties = Some(properties); self }
626    /// ID for this node's parent.
627    pub fn parent_id(mut self, parent_id: impl Into<AXNodeId<'a>>) -> Self { self.parent_id = Some(parent_id.into()); self }
628    /// IDs for each of this node's child nodes.
629    pub fn child_ids(mut self, child_ids: Vec<AXNodeId<'a>>) -> Self { self.child_ids = Some(child_ids); self }
630    /// The backend ID for the associated DOM node, if any.
631    pub fn backend_dom_node_id(mut self, backend_dom_node_id: crate::dom::BackendNodeId) -> Self { self.backend_dom_node_id = Some(backend_dom_node_id); self }
632    /// The frame ID for the frame associated with this nodes document.
633    pub fn frame_id(mut self, frame_id: crate::page::FrameId<'a>) -> Self { self.frame_id = Some(frame_id); self }
634    pub fn build(self) -> AXNode<'a> {
635        AXNode {
636            node_id: self.node_id,
637            ignored: self.ignored,
638            ignored_reasons: self.ignored_reasons,
639            role: self.role,
640            chrome_role: self.chrome_role,
641            name: self.name,
642            description: self.description,
643            value: self.value,
644            properties: self.properties,
645            parent_id: self.parent_id,
646            child_ids: self.child_ids,
647            backend_dom_node_id: self.backend_dom_node_id,
648            frame_id: self.frame_id,
649        }
650    }
651}
652
653#[derive(Debug, Clone, Serialize, Deserialize, Default)]
654pub struct DisableParams {}
655
656impl DisableParams { pub const METHOD: &'static str = "Accessibility.disable"; }
657
658impl<'a> crate::CdpCommand<'a> for DisableParams {
659    const METHOD: &'static str = "Accessibility.disable";
660    type Response = crate::EmptyReturns;
661}
662
663#[derive(Debug, Clone, Serialize, Deserialize, Default)]
664pub struct EnableParams {}
665
666impl EnableParams { pub const METHOD: &'static str = "Accessibility.enable"; }
667
668impl<'a> crate::CdpCommand<'a> for EnableParams {
669    const METHOD: &'static str = "Accessibility.enable";
670    type Response = crate::EmptyReturns;
671}
672
673/// Fetches the accessibility node and partial accessibility tree for this DOM node, if it exists.
674
675#[derive(Debug, Clone, Serialize, Deserialize, Default)]
676#[serde(rename_all = "camelCase")]
677pub struct GetPartialAXTreeParams<'a> {
678    /// Identifier of the node to get the partial accessibility tree for.
679    #[serde(skip_serializing_if = "Option::is_none", rename = "nodeId")]
680    node_id: Option<crate::dom::NodeId>,
681    /// Identifier of the backend node to get the partial accessibility tree for.
682    #[serde(skip_serializing_if = "Option::is_none", rename = "backendNodeId")]
683    backend_node_id: Option<crate::dom::BackendNodeId>,
684    /// JavaScript object id of the node wrapper to get the partial accessibility tree for.
685    #[serde(skip_serializing_if = "Option::is_none", rename = "objectId")]
686    object_id: Option<crate::runtime::RemoteObjectId<'a>>,
687    /// Whether to fetch this node's ancestors, siblings and children. Defaults to true.
688    #[serde(skip_serializing_if = "Option::is_none", rename = "fetchRelatives")]
689    fetch_relatives: Option<bool>,
690}
691
692impl<'a> GetPartialAXTreeParams<'a> {
693    /// Creates a builder for this type.
694    pub fn builder() -> GetPartialAXTreeParamsBuilder<'a> {
695        GetPartialAXTreeParamsBuilder {
696            node_id: None,
697            backend_node_id: None,
698            object_id: None,
699            fetch_relatives: None,
700        }
701    }
702    /// Identifier of the node to get the partial accessibility tree for.
703    pub fn node_id(&self) -> Option<&crate::dom::NodeId> { self.node_id.as_ref() }
704    /// Identifier of the backend node to get the partial accessibility tree for.
705    pub fn backend_node_id(&self) -> Option<&crate::dom::BackendNodeId> { self.backend_node_id.as_ref() }
706    /// JavaScript object id of the node wrapper to get the partial accessibility tree for.
707    pub fn object_id(&self) -> Option<&crate::runtime::RemoteObjectId<'a>> { self.object_id.as_ref() }
708    /// Whether to fetch this node's ancestors, siblings and children. Defaults to true.
709    pub fn fetch_relatives(&self) -> Option<bool> { self.fetch_relatives }
710}
711
712#[derive(Default)]
713pub struct GetPartialAXTreeParamsBuilder<'a> {
714    node_id: Option<crate::dom::NodeId>,
715    backend_node_id: Option<crate::dom::BackendNodeId>,
716    object_id: Option<crate::runtime::RemoteObjectId<'a>>,
717    fetch_relatives: Option<bool>,
718}
719
720impl<'a> GetPartialAXTreeParamsBuilder<'a> {
721    /// Identifier of the node to get the partial accessibility tree for.
722    pub fn node_id(mut self, node_id: crate::dom::NodeId) -> Self { self.node_id = Some(node_id); self }
723    /// Identifier of the backend node to get the partial accessibility tree for.
724    pub fn backend_node_id(mut self, backend_node_id: crate::dom::BackendNodeId) -> Self { self.backend_node_id = Some(backend_node_id); self }
725    /// JavaScript object id of the node wrapper to get the partial accessibility tree for.
726    pub fn object_id(mut self, object_id: crate::runtime::RemoteObjectId<'a>) -> Self { self.object_id = Some(object_id); self }
727    /// Whether to fetch this node's ancestors, siblings and children. Defaults to true.
728    pub fn fetch_relatives(mut self, fetch_relatives: bool) -> Self { self.fetch_relatives = Some(fetch_relatives); self }
729    pub fn build(self) -> GetPartialAXTreeParams<'a> {
730        GetPartialAXTreeParams {
731            node_id: self.node_id,
732            backend_node_id: self.backend_node_id,
733            object_id: self.object_id,
734            fetch_relatives: self.fetch_relatives,
735        }
736    }
737}
738
739/// Fetches the accessibility node and partial accessibility tree for this DOM node, if it exists.
740
741#[derive(Debug, Clone, Serialize, Deserialize, Default)]
742#[serde(rename_all = "camelCase")]
743pub struct GetPartialAXTreeReturns<'a> {
744    /// The 'Accessibility.AXNode' for this DOM node, if it exists, plus its ancestors, siblings and
745    /// children, if requested.
746    nodes: Vec<AXNode<'a>>,
747}
748
749impl<'a> GetPartialAXTreeReturns<'a> {
750    /// Creates a builder for this type with the required parameters:
751    /// * `nodes`: The `Accessibility.AXNode` for this DOM node, if it exists, plus its ancestors, siblings and children, if requested.
752    pub fn builder(nodes: Vec<AXNode<'a>>) -> GetPartialAXTreeReturnsBuilder<'a> {
753        GetPartialAXTreeReturnsBuilder {
754            nodes: nodes,
755        }
756    }
757    /// The 'Accessibility.AXNode' for this DOM node, if it exists, plus its ancestors, siblings and
758    /// children, if requested.
759    pub fn nodes(&self) -> &[AXNode<'a>] { &self.nodes }
760}
761
762
763pub struct GetPartialAXTreeReturnsBuilder<'a> {
764    nodes: Vec<AXNode<'a>>,
765}
766
767impl<'a> GetPartialAXTreeReturnsBuilder<'a> {
768    pub fn build(self) -> GetPartialAXTreeReturns<'a> {
769        GetPartialAXTreeReturns {
770            nodes: self.nodes,
771        }
772    }
773}
774
775impl<'a> GetPartialAXTreeParams<'a> { pub const METHOD: &'static str = "Accessibility.getPartialAXTree"; }
776
777impl<'a> crate::CdpCommand<'a> for GetPartialAXTreeParams<'a> {
778    const METHOD: &'static str = "Accessibility.getPartialAXTree";
779    type Response = GetPartialAXTreeReturns<'a>;
780}
781
782/// Fetches the entire accessibility tree for the root Document
783
784#[derive(Debug, Clone, Serialize, Deserialize, Default)]
785#[serde(rename_all = "camelCase")]
786pub struct GetFullAXTreeParams<'a> {
787    /// The maximum depth at which descendants of the root node should be retrieved.
788    /// If omitted, the full tree is returned.
789    #[serde(skip_serializing_if = "Option::is_none")]
790    depth: Option<i64>,
791    /// The frame for whose document the AX tree should be retrieved.
792    /// If omitted, the root frame is used.
793    #[serde(skip_serializing_if = "Option::is_none", rename = "frameId")]
794    frame_id: Option<crate::page::FrameId<'a>>,
795}
796
797impl<'a> GetFullAXTreeParams<'a> {
798    /// Creates a builder for this type.
799    pub fn builder() -> GetFullAXTreeParamsBuilder<'a> {
800        GetFullAXTreeParamsBuilder {
801            depth: None,
802            frame_id: None,
803        }
804    }
805    /// The maximum depth at which descendants of the root node should be retrieved.
806    /// If omitted, the full tree is returned.
807    pub fn depth(&self) -> Option<i64> { self.depth }
808    /// The frame for whose document the AX tree should be retrieved.
809    /// If omitted, the root frame is used.
810    pub fn frame_id(&self) -> Option<&crate::page::FrameId<'a>> { self.frame_id.as_ref() }
811}
812
813#[derive(Default)]
814pub struct GetFullAXTreeParamsBuilder<'a> {
815    depth: Option<i64>,
816    frame_id: Option<crate::page::FrameId<'a>>,
817}
818
819impl<'a> GetFullAXTreeParamsBuilder<'a> {
820    /// The maximum depth at which descendants of the root node should be retrieved.
821    /// If omitted, the full tree is returned.
822    pub fn depth(mut self, depth: i64) -> Self { self.depth = Some(depth); self }
823    /// The frame for whose document the AX tree should be retrieved.
824    /// If omitted, the root frame is used.
825    pub fn frame_id(mut self, frame_id: crate::page::FrameId<'a>) -> Self { self.frame_id = Some(frame_id); self }
826    pub fn build(self) -> GetFullAXTreeParams<'a> {
827        GetFullAXTreeParams {
828            depth: self.depth,
829            frame_id: self.frame_id,
830        }
831    }
832}
833
834/// Fetches the entire accessibility tree for the root Document
835
836#[derive(Debug, Clone, Serialize, Deserialize, Default)]
837#[serde(rename_all = "camelCase")]
838pub struct GetFullAXTreeReturns<'a> {
839    nodes: Vec<AXNode<'a>>,
840}
841
842impl<'a> GetFullAXTreeReturns<'a> {
843    /// Creates a builder for this type with the required parameters:
844    /// * `nodes`: 
845    pub fn builder(nodes: Vec<AXNode<'a>>) -> GetFullAXTreeReturnsBuilder<'a> {
846        GetFullAXTreeReturnsBuilder {
847            nodes: nodes,
848        }
849    }
850    pub fn nodes(&self) -> &[AXNode<'a>] { &self.nodes }
851}
852
853
854pub struct GetFullAXTreeReturnsBuilder<'a> {
855    nodes: Vec<AXNode<'a>>,
856}
857
858impl<'a> GetFullAXTreeReturnsBuilder<'a> {
859    pub fn build(self) -> GetFullAXTreeReturns<'a> {
860        GetFullAXTreeReturns {
861            nodes: self.nodes,
862        }
863    }
864}
865
866impl<'a> GetFullAXTreeParams<'a> { pub const METHOD: &'static str = "Accessibility.getFullAXTree"; }
867
868impl<'a> crate::CdpCommand<'a> for GetFullAXTreeParams<'a> {
869    const METHOD: &'static str = "Accessibility.getFullAXTree";
870    type Response = GetFullAXTreeReturns<'a>;
871}
872
873/// Fetches the root node.
874/// Requires 'enable()' to have been called previously.
875
876#[derive(Debug, Clone, Serialize, Deserialize, Default)]
877#[serde(rename_all = "camelCase")]
878pub struct GetRootAXNodeParams<'a> {
879    /// The frame in whose document the node resides.
880    /// If omitted, the root frame is used.
881    #[serde(skip_serializing_if = "Option::is_none", rename = "frameId")]
882    frame_id: Option<crate::page::FrameId<'a>>,
883}
884
885impl<'a> GetRootAXNodeParams<'a> {
886    /// Creates a builder for this type.
887    pub fn builder() -> GetRootAXNodeParamsBuilder<'a> {
888        GetRootAXNodeParamsBuilder {
889            frame_id: None,
890        }
891    }
892    /// The frame in whose document the node resides.
893    /// If omitted, the root frame is used.
894    pub fn frame_id(&self) -> Option<&crate::page::FrameId<'a>> { self.frame_id.as_ref() }
895}
896
897#[derive(Default)]
898pub struct GetRootAXNodeParamsBuilder<'a> {
899    frame_id: Option<crate::page::FrameId<'a>>,
900}
901
902impl<'a> GetRootAXNodeParamsBuilder<'a> {
903    /// The frame in whose document the node resides.
904    /// If omitted, the root frame is used.
905    pub fn frame_id(mut self, frame_id: crate::page::FrameId<'a>) -> Self { self.frame_id = Some(frame_id); self }
906    pub fn build(self) -> GetRootAXNodeParams<'a> {
907        GetRootAXNodeParams {
908            frame_id: self.frame_id,
909        }
910    }
911}
912
913/// Fetches the root node.
914/// Requires 'enable()' to have been called previously.
915
916#[derive(Debug, Clone, Serialize, Deserialize, Default)]
917#[serde(rename_all = "camelCase")]
918pub struct GetRootAXNodeReturns<'a> {
919    node: AXNode<'a>,
920}
921
922impl<'a> GetRootAXNodeReturns<'a> {
923    /// Creates a builder for this type with the required parameters:
924    /// * `node`: 
925    pub fn builder(node: AXNode<'a>) -> GetRootAXNodeReturnsBuilder<'a> {
926        GetRootAXNodeReturnsBuilder {
927            node: node,
928        }
929    }
930    pub fn node(&self) -> &AXNode<'a> { &self.node }
931}
932
933
934pub struct GetRootAXNodeReturnsBuilder<'a> {
935    node: AXNode<'a>,
936}
937
938impl<'a> GetRootAXNodeReturnsBuilder<'a> {
939    pub fn build(self) -> GetRootAXNodeReturns<'a> {
940        GetRootAXNodeReturns {
941            node: self.node,
942        }
943    }
944}
945
946impl<'a> GetRootAXNodeParams<'a> { pub const METHOD: &'static str = "Accessibility.getRootAXNode"; }
947
948impl<'a> crate::CdpCommand<'a> for GetRootAXNodeParams<'a> {
949    const METHOD: &'static str = "Accessibility.getRootAXNode";
950    type Response = GetRootAXNodeReturns<'a>;
951}
952
953/// Fetches a node and all ancestors up to and including the root.
954/// Requires 'enable()' to have been called previously.
955
956#[derive(Debug, Clone, Serialize, Deserialize, Default)]
957#[serde(rename_all = "camelCase")]
958pub struct GetAXNodeAndAncestorsParams<'a> {
959    /// Identifier of the node to get.
960    #[serde(skip_serializing_if = "Option::is_none", rename = "nodeId")]
961    node_id: Option<crate::dom::NodeId>,
962    /// Identifier of the backend node to get.
963    #[serde(skip_serializing_if = "Option::is_none", rename = "backendNodeId")]
964    backend_node_id: Option<crate::dom::BackendNodeId>,
965    /// JavaScript object id of the node wrapper to get.
966    #[serde(skip_serializing_if = "Option::is_none", rename = "objectId")]
967    object_id: Option<crate::runtime::RemoteObjectId<'a>>,
968}
969
970impl<'a> GetAXNodeAndAncestorsParams<'a> {
971    /// Creates a builder for this type.
972    pub fn builder() -> GetAXNodeAndAncestorsParamsBuilder<'a> {
973        GetAXNodeAndAncestorsParamsBuilder {
974            node_id: None,
975            backend_node_id: None,
976            object_id: None,
977        }
978    }
979    /// Identifier of the node to get.
980    pub fn node_id(&self) -> Option<&crate::dom::NodeId> { self.node_id.as_ref() }
981    /// Identifier of the backend node to get.
982    pub fn backend_node_id(&self) -> Option<&crate::dom::BackendNodeId> { self.backend_node_id.as_ref() }
983    /// JavaScript object id of the node wrapper to get.
984    pub fn object_id(&self) -> Option<&crate::runtime::RemoteObjectId<'a>> { self.object_id.as_ref() }
985}
986
987#[derive(Default)]
988pub struct GetAXNodeAndAncestorsParamsBuilder<'a> {
989    node_id: Option<crate::dom::NodeId>,
990    backend_node_id: Option<crate::dom::BackendNodeId>,
991    object_id: Option<crate::runtime::RemoteObjectId<'a>>,
992}
993
994impl<'a> GetAXNodeAndAncestorsParamsBuilder<'a> {
995    /// Identifier of the node to get.
996    pub fn node_id(mut self, node_id: crate::dom::NodeId) -> Self { self.node_id = Some(node_id); self }
997    /// Identifier of the backend node to get.
998    pub fn backend_node_id(mut self, backend_node_id: crate::dom::BackendNodeId) -> Self { self.backend_node_id = Some(backend_node_id); self }
999    /// JavaScript object id of the node wrapper to get.
1000    pub fn object_id(mut self, object_id: crate::runtime::RemoteObjectId<'a>) -> Self { self.object_id = Some(object_id); self }
1001    pub fn build(self) -> GetAXNodeAndAncestorsParams<'a> {
1002        GetAXNodeAndAncestorsParams {
1003            node_id: self.node_id,
1004            backend_node_id: self.backend_node_id,
1005            object_id: self.object_id,
1006        }
1007    }
1008}
1009
1010/// Fetches a node and all ancestors up to and including the root.
1011/// Requires 'enable()' to have been called previously.
1012
1013#[derive(Debug, Clone, Serialize, Deserialize, Default)]
1014#[serde(rename_all = "camelCase")]
1015pub struct GetAXNodeAndAncestorsReturns<'a> {
1016    nodes: Vec<AXNode<'a>>,
1017}
1018
1019impl<'a> GetAXNodeAndAncestorsReturns<'a> {
1020    /// Creates a builder for this type with the required parameters:
1021    /// * `nodes`: 
1022    pub fn builder(nodes: Vec<AXNode<'a>>) -> GetAXNodeAndAncestorsReturnsBuilder<'a> {
1023        GetAXNodeAndAncestorsReturnsBuilder {
1024            nodes: nodes,
1025        }
1026    }
1027    pub fn nodes(&self) -> &[AXNode<'a>] { &self.nodes }
1028}
1029
1030
1031pub struct GetAXNodeAndAncestorsReturnsBuilder<'a> {
1032    nodes: Vec<AXNode<'a>>,
1033}
1034
1035impl<'a> GetAXNodeAndAncestorsReturnsBuilder<'a> {
1036    pub fn build(self) -> GetAXNodeAndAncestorsReturns<'a> {
1037        GetAXNodeAndAncestorsReturns {
1038            nodes: self.nodes,
1039        }
1040    }
1041}
1042
1043impl<'a> GetAXNodeAndAncestorsParams<'a> { pub const METHOD: &'static str = "Accessibility.getAXNodeAndAncestors"; }
1044
1045impl<'a> crate::CdpCommand<'a> for GetAXNodeAndAncestorsParams<'a> {
1046    const METHOD: &'static str = "Accessibility.getAXNodeAndAncestors";
1047    type Response = GetAXNodeAndAncestorsReturns<'a>;
1048}
1049
1050/// Fetches a particular accessibility node by AXNodeId.
1051/// Requires 'enable()' to have been called previously.
1052
1053#[derive(Debug, Clone, Serialize, Deserialize, Default)]
1054#[serde(rename_all = "camelCase")]
1055pub struct GetChildAXNodesParams<'a> {
1056    id: AXNodeId<'a>,
1057    /// The frame in whose document the node resides.
1058    /// If omitted, the root frame is used.
1059    #[serde(skip_serializing_if = "Option::is_none", rename = "frameId")]
1060    frame_id: Option<crate::page::FrameId<'a>>,
1061}
1062
1063impl<'a> GetChildAXNodesParams<'a> {
1064    /// Creates a builder for this type with the required parameters:
1065    /// * `id`: 
1066    pub fn builder(id: impl Into<AXNodeId<'a>>) -> GetChildAXNodesParamsBuilder<'a> {
1067        GetChildAXNodesParamsBuilder {
1068            id: id.into(),
1069            frame_id: None,
1070        }
1071    }
1072    pub fn id(&self) -> &AXNodeId<'a> { &self.id }
1073    /// The frame in whose document the node resides.
1074    /// If omitted, the root frame is used.
1075    pub fn frame_id(&self) -> Option<&crate::page::FrameId<'a>> { self.frame_id.as_ref() }
1076}
1077
1078
1079pub struct GetChildAXNodesParamsBuilder<'a> {
1080    id: AXNodeId<'a>,
1081    frame_id: Option<crate::page::FrameId<'a>>,
1082}
1083
1084impl<'a> GetChildAXNodesParamsBuilder<'a> {
1085    /// The frame in whose document the node resides.
1086    /// If omitted, the root frame is used.
1087    pub fn frame_id(mut self, frame_id: crate::page::FrameId<'a>) -> Self { self.frame_id = Some(frame_id); self }
1088    pub fn build(self) -> GetChildAXNodesParams<'a> {
1089        GetChildAXNodesParams {
1090            id: self.id,
1091            frame_id: self.frame_id,
1092        }
1093    }
1094}
1095
1096/// Fetches a particular accessibility node by AXNodeId.
1097/// Requires 'enable()' to have been called previously.
1098
1099#[derive(Debug, Clone, Serialize, Deserialize, Default)]
1100#[serde(rename_all = "camelCase")]
1101pub struct GetChildAXNodesReturns<'a> {
1102    nodes: Vec<AXNode<'a>>,
1103}
1104
1105impl<'a> GetChildAXNodesReturns<'a> {
1106    /// Creates a builder for this type with the required parameters:
1107    /// * `nodes`: 
1108    pub fn builder(nodes: Vec<AXNode<'a>>) -> GetChildAXNodesReturnsBuilder<'a> {
1109        GetChildAXNodesReturnsBuilder {
1110            nodes: nodes,
1111        }
1112    }
1113    pub fn nodes(&self) -> &[AXNode<'a>] { &self.nodes }
1114}
1115
1116
1117pub struct GetChildAXNodesReturnsBuilder<'a> {
1118    nodes: Vec<AXNode<'a>>,
1119}
1120
1121impl<'a> GetChildAXNodesReturnsBuilder<'a> {
1122    pub fn build(self) -> GetChildAXNodesReturns<'a> {
1123        GetChildAXNodesReturns {
1124            nodes: self.nodes,
1125        }
1126    }
1127}
1128
1129impl<'a> GetChildAXNodesParams<'a> { pub const METHOD: &'static str = "Accessibility.getChildAXNodes"; }
1130
1131impl<'a> crate::CdpCommand<'a> for GetChildAXNodesParams<'a> {
1132    const METHOD: &'static str = "Accessibility.getChildAXNodes";
1133    type Response = GetChildAXNodesReturns<'a>;
1134}
1135
1136/// Query a DOM node's accessibility subtree for accessible name and role.
1137/// This command computes the name and role for all nodes in the subtree, including those that are
1138/// ignored for accessibility, and returns those that match the specified name and role. If no DOM
1139/// node is specified, or the DOM node does not exist, the command returns an error. If neither
1140/// 'accessibleName' or 'role' is specified, it returns all the accessibility nodes in the subtree.
1141
1142#[derive(Debug, Clone, Serialize, Deserialize, Default)]
1143#[serde(rename_all = "camelCase")]
1144pub struct QueryAXTreeParams<'a> {
1145    /// Identifier of the node for the root to query.
1146    #[serde(skip_serializing_if = "Option::is_none", rename = "nodeId")]
1147    node_id: Option<crate::dom::NodeId>,
1148    /// Identifier of the backend node for the root to query.
1149    #[serde(skip_serializing_if = "Option::is_none", rename = "backendNodeId")]
1150    backend_node_id: Option<crate::dom::BackendNodeId>,
1151    /// JavaScript object id of the node wrapper for the root to query.
1152    #[serde(skip_serializing_if = "Option::is_none", rename = "objectId")]
1153    object_id: Option<crate::runtime::RemoteObjectId<'a>>,
1154    /// Find nodes with this computed name.
1155    #[serde(skip_serializing_if = "Option::is_none", rename = "accessibleName")]
1156    accessible_name: Option<Cow<'a, str>>,
1157    /// Find nodes with this computed role.
1158    #[serde(skip_serializing_if = "Option::is_none")]
1159    role: Option<Cow<'a, str>>,
1160}
1161
1162impl<'a> QueryAXTreeParams<'a> {
1163    /// Creates a builder for this type.
1164    pub fn builder() -> QueryAXTreeParamsBuilder<'a> {
1165        QueryAXTreeParamsBuilder {
1166            node_id: None,
1167            backend_node_id: None,
1168            object_id: None,
1169            accessible_name: None,
1170            role: None,
1171        }
1172    }
1173    /// Identifier of the node for the root to query.
1174    pub fn node_id(&self) -> Option<&crate::dom::NodeId> { self.node_id.as_ref() }
1175    /// Identifier of the backend node for the root to query.
1176    pub fn backend_node_id(&self) -> Option<&crate::dom::BackendNodeId> { self.backend_node_id.as_ref() }
1177    /// JavaScript object id of the node wrapper for the root to query.
1178    pub fn object_id(&self) -> Option<&crate::runtime::RemoteObjectId<'a>> { self.object_id.as_ref() }
1179    /// Find nodes with this computed name.
1180    pub fn accessible_name(&self) -> Option<&str> { self.accessible_name.as_deref() }
1181    /// Find nodes with this computed role.
1182    pub fn role(&self) -> Option<&str> { self.role.as_deref() }
1183}
1184
1185#[derive(Default)]
1186pub struct QueryAXTreeParamsBuilder<'a> {
1187    node_id: Option<crate::dom::NodeId>,
1188    backend_node_id: Option<crate::dom::BackendNodeId>,
1189    object_id: Option<crate::runtime::RemoteObjectId<'a>>,
1190    accessible_name: Option<Cow<'a, str>>,
1191    role: Option<Cow<'a, str>>,
1192}
1193
1194impl<'a> QueryAXTreeParamsBuilder<'a> {
1195    /// Identifier of the node for the root to query.
1196    pub fn node_id(mut self, node_id: crate::dom::NodeId) -> Self { self.node_id = Some(node_id); self }
1197    /// Identifier of the backend node for the root to query.
1198    pub fn backend_node_id(mut self, backend_node_id: crate::dom::BackendNodeId) -> Self { self.backend_node_id = Some(backend_node_id); self }
1199    /// JavaScript object id of the node wrapper for the root to query.
1200    pub fn object_id(mut self, object_id: crate::runtime::RemoteObjectId<'a>) -> Self { self.object_id = Some(object_id); self }
1201    /// Find nodes with this computed name.
1202    pub fn accessible_name(mut self, accessible_name: impl Into<Cow<'a, str>>) -> Self { self.accessible_name = Some(accessible_name.into()); self }
1203    /// Find nodes with this computed role.
1204    pub fn role(mut self, role: impl Into<Cow<'a, str>>) -> Self { self.role = Some(role.into()); self }
1205    pub fn build(self) -> QueryAXTreeParams<'a> {
1206        QueryAXTreeParams {
1207            node_id: self.node_id,
1208            backend_node_id: self.backend_node_id,
1209            object_id: self.object_id,
1210            accessible_name: self.accessible_name,
1211            role: self.role,
1212        }
1213    }
1214}
1215
1216/// Query a DOM node's accessibility subtree for accessible name and role.
1217/// This command computes the name and role for all nodes in the subtree, including those that are
1218/// ignored for accessibility, and returns those that match the specified name and role. If no DOM
1219/// node is specified, or the DOM node does not exist, the command returns an error. If neither
1220/// 'accessibleName' or 'role' is specified, it returns all the accessibility nodes in the subtree.
1221
1222#[derive(Debug, Clone, Serialize, Deserialize, Default)]
1223#[serde(rename_all = "camelCase")]
1224pub struct QueryAXTreeReturns<'a> {
1225    /// A list of 'Accessibility.AXNode' matching the specified attributes,
1226    /// including nodes that are ignored for accessibility.
1227    nodes: Vec<AXNode<'a>>,
1228}
1229
1230impl<'a> QueryAXTreeReturns<'a> {
1231    /// Creates a builder for this type with the required parameters:
1232    /// * `nodes`: A list of `Accessibility.AXNode` matching the specified attributes, including nodes that are ignored for accessibility.
1233    pub fn builder(nodes: Vec<AXNode<'a>>) -> QueryAXTreeReturnsBuilder<'a> {
1234        QueryAXTreeReturnsBuilder {
1235            nodes: nodes,
1236        }
1237    }
1238    /// A list of 'Accessibility.AXNode' matching the specified attributes,
1239    /// including nodes that are ignored for accessibility.
1240    pub fn nodes(&self) -> &[AXNode<'a>] { &self.nodes }
1241}
1242
1243
1244pub struct QueryAXTreeReturnsBuilder<'a> {
1245    nodes: Vec<AXNode<'a>>,
1246}
1247
1248impl<'a> QueryAXTreeReturnsBuilder<'a> {
1249    pub fn build(self) -> QueryAXTreeReturns<'a> {
1250        QueryAXTreeReturns {
1251            nodes: self.nodes,
1252        }
1253    }
1254}
1255
1256impl<'a> QueryAXTreeParams<'a> { pub const METHOD: &'static str = "Accessibility.queryAXTree"; }
1257
1258impl<'a> crate::CdpCommand<'a> for QueryAXTreeParams<'a> {
1259    const METHOD: &'static str = "Accessibility.queryAXTree";
1260    type Response = QueryAXTreeReturns<'a>;
1261}