Skip to main content

browser_protocol/domsnapshot/
mod.rs

1//! This domain facilitates obtaining document snapshots with DOM, layout, and style information.
2
3
4use serde::{Serialize, Deserialize};
5use serde_json::Value as JsonValue;
6use std::borrow::Cow;
7
8/// A Node in the DOM tree.
9
10#[derive(Debug, Clone, Serialize, Deserialize, Default)]
11#[serde(rename_all = "camelCase")]
12pub struct DOMNode<'a> {
13    /// 'Node''s nodeType.
14    #[serde(rename = "nodeType")]
15    node_type: i64,
16    /// 'Node''s nodeName.
17    #[serde(rename = "nodeName")]
18    node_name: Cow<'a, str>,
19    /// 'Node''s nodeValue.
20    #[serde(rename = "nodeValue")]
21    node_value: Cow<'a, str>,
22    /// Only set for textarea elements, contains the text value.
23    #[serde(skip_serializing_if = "Option::is_none", rename = "textValue")]
24    text_value: Option<Cow<'a, str>>,
25    /// Only set for input elements, contains the input's associated text value.
26    #[serde(skip_serializing_if = "Option::is_none", rename = "inputValue")]
27    input_value: Option<Cow<'a, str>>,
28    /// Only set for radio and checkbox input elements, indicates if the element has been checked
29    #[serde(skip_serializing_if = "Option::is_none", rename = "inputChecked")]
30    input_checked: Option<bool>,
31    /// Only set for option elements, indicates if the element has been selected
32    #[serde(skip_serializing_if = "Option::is_none", rename = "optionSelected")]
33    option_selected: Option<bool>,
34    /// 'Node''s id, corresponds to DOM.Node.backendNodeId.
35    #[serde(rename = "backendNodeId")]
36    backend_node_id: crate::dom::BackendNodeId,
37    /// The indexes of the node's child nodes in the 'domNodes' array returned by 'getSnapshot', if
38    /// any.
39    #[serde(skip_serializing_if = "Option::is_none", rename = "childNodeIndexes")]
40    child_node_indexes: Option<Vec<i64>>,
41    /// Attributes of an 'Element' node.
42    #[serde(skip_serializing_if = "Option::is_none")]
43    attributes: Option<Vec<NameValue<'a>>>,
44    /// Indexes of pseudo elements associated with this node in the 'domNodes' array returned by
45    /// 'getSnapshot', if any.
46    #[serde(skip_serializing_if = "Option::is_none", rename = "pseudoElementIndexes")]
47    pseudo_element_indexes: Option<Vec<i64>>,
48    /// The index of the node's related layout tree node in the 'layoutTreeNodes' array returned by
49    /// 'getSnapshot', if any.
50    #[serde(skip_serializing_if = "Option::is_none", rename = "layoutNodeIndex")]
51    layout_node_index: Option<u64>,
52    /// Document URL that 'Document' or 'FrameOwner' node points to.
53    #[serde(skip_serializing_if = "Option::is_none", rename = "documentURL")]
54    document_url: Option<Cow<'a, str>>,
55    /// Base URL that 'Document' or 'FrameOwner' node uses for URL completion.
56    #[serde(skip_serializing_if = "Option::is_none", rename = "baseURL")]
57    base_url: Option<Cow<'a, str>>,
58    /// Only set for documents, contains the document's content language.
59    #[serde(skip_serializing_if = "Option::is_none", rename = "contentLanguage")]
60    content_language: Option<Cow<'a, str>>,
61    /// Only set for documents, contains the document's character set encoding.
62    #[serde(skip_serializing_if = "Option::is_none", rename = "documentEncoding")]
63    document_encoding: Option<Cow<'a, str>>,
64    /// 'DocumentType' node's publicId.
65    #[serde(skip_serializing_if = "Option::is_none", rename = "publicId")]
66    public_id: Option<Cow<'a, str>>,
67    /// 'DocumentType' node's systemId.
68    #[serde(skip_serializing_if = "Option::is_none", rename = "systemId")]
69    system_id: Option<Cow<'a, str>>,
70    /// Frame ID for frame owner elements and also for the document node.
71    #[serde(skip_serializing_if = "Option::is_none", rename = "frameId")]
72    frame_id: Option<crate::page::FrameId<'a>>,
73    /// The index of a frame owner element's content document in the 'domNodes' array returned by
74    /// 'getSnapshot', if any.
75    #[serde(skip_serializing_if = "Option::is_none", rename = "contentDocumentIndex")]
76    content_document_index: Option<u64>,
77    /// Type of a pseudo element node.
78    #[serde(skip_serializing_if = "Option::is_none", rename = "pseudoType")]
79    pseudo_type: Option<crate::dom::PseudoType>,
80    /// Shadow root type.
81    #[serde(skip_serializing_if = "Option::is_none", rename = "shadowRootType")]
82    shadow_root_type: Option<crate::dom::ShadowRootType>,
83    /// Whether this DOM node responds to mouse clicks. This includes nodes that have had click
84    /// event listeners attached via JavaScript as well as anchor tags that naturally navigate when
85    /// clicked.
86    #[serde(skip_serializing_if = "Option::is_none", rename = "isClickable")]
87    is_clickable: Option<bool>,
88    /// Details of the node's event listeners, if any.
89    #[serde(skip_serializing_if = "Option::is_none", rename = "eventListeners")]
90    event_listeners: Option<Vec<crate::domdebugger::EventListener<'a>>>,
91    /// The selected url for nodes with a srcset attribute.
92    #[serde(skip_serializing_if = "Option::is_none", rename = "currentSourceURL")]
93    current_source_url: Option<Cow<'a, str>>,
94    /// The url of the script (if any) that generates this node.
95    #[serde(skip_serializing_if = "Option::is_none", rename = "originURL")]
96    origin_url: Option<Cow<'a, str>>,
97    /// Scroll offsets, set when this node is a Document.
98    #[serde(skip_serializing_if = "Option::is_none", rename = "scrollOffsetX")]
99    scroll_offset_x: Option<f64>,
100    #[serde(skip_serializing_if = "Option::is_none", rename = "scrollOffsetY")]
101    scroll_offset_y: Option<f64>,
102}
103
104impl<'a> DOMNode<'a> {
105    /// Creates a builder for this type with the required parameters:
106    /// * `node_type`: `Node`'s nodeType.
107    /// * `node_name`: `Node`'s nodeName.
108    /// * `node_value`: `Node`'s nodeValue.
109    /// * `backend_node_id`: `Node`'s id, corresponds to DOM.Node.backendNodeId.
110    pub fn builder(node_type: i64, node_name: impl Into<Cow<'a, str>>, node_value: impl Into<Cow<'a, str>>, backend_node_id: crate::dom::BackendNodeId) -> DOMNodeBuilder<'a> {
111        DOMNodeBuilder {
112            node_type: node_type,
113            node_name: node_name.into(),
114            node_value: node_value.into(),
115            text_value: None,
116            input_value: None,
117            input_checked: None,
118            option_selected: None,
119            backend_node_id: backend_node_id,
120            child_node_indexes: None,
121            attributes: None,
122            pseudo_element_indexes: None,
123            layout_node_index: None,
124            document_url: None,
125            base_url: None,
126            content_language: None,
127            document_encoding: None,
128            public_id: None,
129            system_id: None,
130            frame_id: None,
131            content_document_index: None,
132            pseudo_type: None,
133            shadow_root_type: None,
134            is_clickable: None,
135            event_listeners: None,
136            current_source_url: None,
137            origin_url: None,
138            scroll_offset_x: None,
139            scroll_offset_y: None,
140        }
141    }
142    /// 'Node''s nodeType.
143    pub fn node_type(&self) -> i64 { self.node_type }
144    /// 'Node''s nodeName.
145    pub fn node_name(&self) -> &str { self.node_name.as_ref() }
146    /// 'Node''s nodeValue.
147    pub fn node_value(&self) -> &str { self.node_value.as_ref() }
148    /// Only set for textarea elements, contains the text value.
149    pub fn text_value(&self) -> Option<&str> { self.text_value.as_deref() }
150    /// Only set for input elements, contains the input's associated text value.
151    pub fn input_value(&self) -> Option<&str> { self.input_value.as_deref() }
152    /// Only set for radio and checkbox input elements, indicates if the element has been checked
153    pub fn input_checked(&self) -> Option<bool> { self.input_checked }
154    /// Only set for option elements, indicates if the element has been selected
155    pub fn option_selected(&self) -> Option<bool> { self.option_selected }
156    /// 'Node''s id, corresponds to DOM.Node.backendNodeId.
157    pub fn backend_node_id(&self) -> &crate::dom::BackendNodeId { &self.backend_node_id }
158    /// The indexes of the node's child nodes in the 'domNodes' array returned by 'getSnapshot', if
159    /// any.
160    pub fn child_node_indexes(&self) -> Option<&[i64]> { self.child_node_indexes.as_deref() }
161    /// Attributes of an 'Element' node.
162    pub fn attributes(&self) -> Option<&[NameValue<'a>]> { self.attributes.as_deref() }
163    /// Indexes of pseudo elements associated with this node in the 'domNodes' array returned by
164    /// 'getSnapshot', if any.
165    pub fn pseudo_element_indexes(&self) -> Option<&[i64]> { self.pseudo_element_indexes.as_deref() }
166    /// The index of the node's related layout tree node in the 'layoutTreeNodes' array returned by
167    /// 'getSnapshot', if any.
168    pub fn layout_node_index(&self) -> Option<u64> { self.layout_node_index }
169    /// Document URL that 'Document' or 'FrameOwner' node points to.
170    pub fn document_url(&self) -> Option<&str> { self.document_url.as_deref() }
171    /// Base URL that 'Document' or 'FrameOwner' node uses for URL completion.
172    pub fn base_url(&self) -> Option<&str> { self.base_url.as_deref() }
173    /// Only set for documents, contains the document's content language.
174    pub fn content_language(&self) -> Option<&str> { self.content_language.as_deref() }
175    /// Only set for documents, contains the document's character set encoding.
176    pub fn document_encoding(&self) -> Option<&str> { self.document_encoding.as_deref() }
177    /// 'DocumentType' node's publicId.
178    pub fn public_id(&self) -> Option<&str> { self.public_id.as_deref() }
179    /// 'DocumentType' node's systemId.
180    pub fn system_id(&self) -> Option<&str> { self.system_id.as_deref() }
181    /// Frame ID for frame owner elements and also for the document node.
182    pub fn frame_id(&self) -> Option<&crate::page::FrameId<'a>> { self.frame_id.as_ref() }
183    /// The index of a frame owner element's content document in the 'domNodes' array returned by
184    /// 'getSnapshot', if any.
185    pub fn content_document_index(&self) -> Option<u64> { self.content_document_index }
186    /// Type of a pseudo element node.
187    pub fn pseudo_type(&self) -> Option<&crate::dom::PseudoType> { self.pseudo_type.as_ref() }
188    /// Shadow root type.
189    pub fn shadow_root_type(&self) -> Option<&crate::dom::ShadowRootType> { self.shadow_root_type.as_ref() }
190    /// Whether this DOM node responds to mouse clicks. This includes nodes that have had click
191    /// event listeners attached via JavaScript as well as anchor tags that naturally navigate when
192    /// clicked.
193    pub fn is_clickable(&self) -> Option<bool> { self.is_clickable }
194    /// Details of the node's event listeners, if any.
195    pub fn event_listeners(&self) -> Option<&[crate::domdebugger::EventListener<'a>]> { self.event_listeners.as_deref() }
196    /// The selected url for nodes with a srcset attribute.
197    pub fn current_source_url(&self) -> Option<&str> { self.current_source_url.as_deref() }
198    /// The url of the script (if any) that generates this node.
199    pub fn origin_url(&self) -> Option<&str> { self.origin_url.as_deref() }
200    /// Scroll offsets, set when this node is a Document.
201    pub fn scroll_offset_x(&self) -> Option<f64> { self.scroll_offset_x }
202    pub fn scroll_offset_y(&self) -> Option<f64> { self.scroll_offset_y }
203}
204
205
206pub struct DOMNodeBuilder<'a> {
207    node_type: i64,
208    node_name: Cow<'a, str>,
209    node_value: Cow<'a, str>,
210    text_value: Option<Cow<'a, str>>,
211    input_value: Option<Cow<'a, str>>,
212    input_checked: Option<bool>,
213    option_selected: Option<bool>,
214    backend_node_id: crate::dom::BackendNodeId,
215    child_node_indexes: Option<Vec<i64>>,
216    attributes: Option<Vec<NameValue<'a>>>,
217    pseudo_element_indexes: Option<Vec<i64>>,
218    layout_node_index: Option<u64>,
219    document_url: Option<Cow<'a, str>>,
220    base_url: Option<Cow<'a, str>>,
221    content_language: Option<Cow<'a, str>>,
222    document_encoding: Option<Cow<'a, str>>,
223    public_id: Option<Cow<'a, str>>,
224    system_id: Option<Cow<'a, str>>,
225    frame_id: Option<crate::page::FrameId<'a>>,
226    content_document_index: Option<u64>,
227    pseudo_type: Option<crate::dom::PseudoType>,
228    shadow_root_type: Option<crate::dom::ShadowRootType>,
229    is_clickable: Option<bool>,
230    event_listeners: Option<Vec<crate::domdebugger::EventListener<'a>>>,
231    current_source_url: Option<Cow<'a, str>>,
232    origin_url: Option<Cow<'a, str>>,
233    scroll_offset_x: Option<f64>,
234    scroll_offset_y: Option<f64>,
235}
236
237impl<'a> DOMNodeBuilder<'a> {
238    /// Only set for textarea elements, contains the text value.
239    pub fn text_value(mut self, text_value: impl Into<Cow<'a, str>>) -> Self { self.text_value = Some(text_value.into()); self }
240    /// Only set for input elements, contains the input's associated text value.
241    pub fn input_value(mut self, input_value: impl Into<Cow<'a, str>>) -> Self { self.input_value = Some(input_value.into()); self }
242    /// Only set for radio and checkbox input elements, indicates if the element has been checked
243    pub fn input_checked(mut self, input_checked: bool) -> Self { self.input_checked = Some(input_checked); self }
244    /// Only set for option elements, indicates if the element has been selected
245    pub fn option_selected(mut self, option_selected: bool) -> Self { self.option_selected = Some(option_selected); self }
246    /// The indexes of the node's child nodes in the 'domNodes' array returned by 'getSnapshot', if
247    /// any.
248    pub fn child_node_indexes(mut self, child_node_indexes: Vec<i64>) -> Self { self.child_node_indexes = Some(child_node_indexes); self }
249    /// Attributes of an 'Element' node.
250    pub fn attributes(mut self, attributes: Vec<NameValue<'a>>) -> Self { self.attributes = Some(attributes); self }
251    /// Indexes of pseudo elements associated with this node in the 'domNodes' array returned by
252    /// 'getSnapshot', if any.
253    pub fn pseudo_element_indexes(mut self, pseudo_element_indexes: Vec<i64>) -> Self { self.pseudo_element_indexes = Some(pseudo_element_indexes); self }
254    /// The index of the node's related layout tree node in the 'layoutTreeNodes' array returned by
255    /// 'getSnapshot', if any.
256    pub fn layout_node_index(mut self, layout_node_index: u64) -> Self { self.layout_node_index = Some(layout_node_index); self }
257    /// Document URL that 'Document' or 'FrameOwner' node points to.
258    pub fn document_url(mut self, document_url: impl Into<Cow<'a, str>>) -> Self { self.document_url = Some(document_url.into()); self }
259    /// Base URL that 'Document' or 'FrameOwner' node uses for URL completion.
260    pub fn base_url(mut self, base_url: impl Into<Cow<'a, str>>) -> Self { self.base_url = Some(base_url.into()); self }
261    /// Only set for documents, contains the document's content language.
262    pub fn content_language(mut self, content_language: impl Into<Cow<'a, str>>) -> Self { self.content_language = Some(content_language.into()); self }
263    /// Only set for documents, contains the document's character set encoding.
264    pub fn document_encoding(mut self, document_encoding: impl Into<Cow<'a, str>>) -> Self { self.document_encoding = Some(document_encoding.into()); self }
265    /// 'DocumentType' node's publicId.
266    pub fn public_id(mut self, public_id: impl Into<Cow<'a, str>>) -> Self { self.public_id = Some(public_id.into()); self }
267    /// 'DocumentType' node's systemId.
268    pub fn system_id(mut self, system_id: impl Into<Cow<'a, str>>) -> Self { self.system_id = Some(system_id.into()); self }
269    /// Frame ID for frame owner elements and also for the document node.
270    pub fn frame_id(mut self, frame_id: crate::page::FrameId<'a>) -> Self { self.frame_id = Some(frame_id); self }
271    /// The index of a frame owner element's content document in the 'domNodes' array returned by
272    /// 'getSnapshot', if any.
273    pub fn content_document_index(mut self, content_document_index: u64) -> Self { self.content_document_index = Some(content_document_index); self }
274    /// Type of a pseudo element node.
275    pub fn pseudo_type(mut self, pseudo_type: crate::dom::PseudoType) -> Self { self.pseudo_type = Some(pseudo_type); self }
276    /// Shadow root type.
277    pub fn shadow_root_type(mut self, shadow_root_type: crate::dom::ShadowRootType) -> Self { self.shadow_root_type = Some(shadow_root_type); self }
278    /// Whether this DOM node responds to mouse clicks. This includes nodes that have had click
279    /// event listeners attached via JavaScript as well as anchor tags that naturally navigate when
280    /// clicked.
281    pub fn is_clickable(mut self, is_clickable: bool) -> Self { self.is_clickable = Some(is_clickable); self }
282    /// Details of the node's event listeners, if any.
283    pub fn event_listeners(mut self, event_listeners: Vec<crate::domdebugger::EventListener<'a>>) -> Self { self.event_listeners = Some(event_listeners); self }
284    /// The selected url for nodes with a srcset attribute.
285    pub fn current_source_url(mut self, current_source_url: impl Into<Cow<'a, str>>) -> Self { self.current_source_url = Some(current_source_url.into()); self }
286    /// The url of the script (if any) that generates this node.
287    pub fn origin_url(mut self, origin_url: impl Into<Cow<'a, str>>) -> Self { self.origin_url = Some(origin_url.into()); self }
288    /// Scroll offsets, set when this node is a Document.
289    pub fn scroll_offset_x(mut self, scroll_offset_x: f64) -> Self { self.scroll_offset_x = Some(scroll_offset_x); self }
290    pub fn scroll_offset_y(mut self, scroll_offset_y: f64) -> Self { self.scroll_offset_y = Some(scroll_offset_y); self }
291    pub fn build(self) -> DOMNode<'a> {
292        DOMNode {
293            node_type: self.node_type,
294            node_name: self.node_name,
295            node_value: self.node_value,
296            text_value: self.text_value,
297            input_value: self.input_value,
298            input_checked: self.input_checked,
299            option_selected: self.option_selected,
300            backend_node_id: self.backend_node_id,
301            child_node_indexes: self.child_node_indexes,
302            attributes: self.attributes,
303            pseudo_element_indexes: self.pseudo_element_indexes,
304            layout_node_index: self.layout_node_index,
305            document_url: self.document_url,
306            base_url: self.base_url,
307            content_language: self.content_language,
308            document_encoding: self.document_encoding,
309            public_id: self.public_id,
310            system_id: self.system_id,
311            frame_id: self.frame_id,
312            content_document_index: self.content_document_index,
313            pseudo_type: self.pseudo_type,
314            shadow_root_type: self.shadow_root_type,
315            is_clickable: self.is_clickable,
316            event_listeners: self.event_listeners,
317            current_source_url: self.current_source_url,
318            origin_url: self.origin_url,
319            scroll_offset_x: self.scroll_offset_x,
320            scroll_offset_y: self.scroll_offset_y,
321        }
322    }
323}
324
325/// Details of post layout rendered text positions. The exact layout should not be regarded as
326/// stable and may change between versions.
327
328#[derive(Debug, Clone, Serialize, Deserialize, Default)]
329#[serde(rename_all = "camelCase")]
330pub struct InlineTextBox {
331    /// The bounding box in document coordinates. Note that scroll offset of the document is ignored.
332    #[serde(rename = "boundingBox")]
333    bounding_box: crate::dom::Rect,
334    /// The starting index in characters, for this post layout textbox substring. Characters that
335    /// would be represented as a surrogate pair in UTF-16 have length 2.
336    #[serde(rename = "startCharacterIndex")]
337    start_character_index: u64,
338    /// The number of characters in this post layout textbox substring. Characters that would be
339    /// represented as a surrogate pair in UTF-16 have length 2.
340    #[serde(rename = "numCharacters")]
341    num_characters: i64,
342}
343
344impl InlineTextBox {
345    /// Creates a builder for this type with the required parameters:
346    /// * `bounding_box`: The bounding box in document coordinates. Note that scroll offset of the document is ignored.
347    /// * `start_character_index`: The starting index in characters, for this post layout textbox substring. Characters that would be represented as a surrogate pair in UTF-16 have length 2.
348    /// * `num_characters`: The number of characters in this post layout textbox substring. Characters that would be represented as a surrogate pair in UTF-16 have length 2.
349    pub fn builder(bounding_box: crate::dom::Rect, start_character_index: u64, num_characters: i64) -> InlineTextBoxBuilder {
350        InlineTextBoxBuilder {
351            bounding_box: bounding_box,
352            start_character_index: start_character_index,
353            num_characters: num_characters,
354        }
355    }
356    /// The bounding box in document coordinates. Note that scroll offset of the document is ignored.
357    pub fn bounding_box(&self) -> &crate::dom::Rect { &self.bounding_box }
358    /// The starting index in characters, for this post layout textbox substring. Characters that
359    /// would be represented as a surrogate pair in UTF-16 have length 2.
360    pub fn start_character_index(&self) -> u64 { self.start_character_index }
361    /// The number of characters in this post layout textbox substring. Characters that would be
362    /// represented as a surrogate pair in UTF-16 have length 2.
363    pub fn num_characters(&self) -> i64 { self.num_characters }
364}
365
366
367pub struct InlineTextBoxBuilder {
368    bounding_box: crate::dom::Rect,
369    start_character_index: u64,
370    num_characters: i64,
371}
372
373impl InlineTextBoxBuilder {
374    pub fn build(self) -> InlineTextBox {
375        InlineTextBox {
376            bounding_box: self.bounding_box,
377            start_character_index: self.start_character_index,
378            num_characters: self.num_characters,
379        }
380    }
381}
382
383/// Details of an element in the DOM tree with a LayoutObject.
384
385#[derive(Debug, Clone, Serialize, Deserialize, Default)]
386#[serde(rename_all = "camelCase")]
387pub struct LayoutTreeNode<'a> {
388    /// The index of the related DOM node in the 'domNodes' array returned by 'getSnapshot'.
389    #[serde(rename = "domNodeIndex")]
390    dom_node_index: u64,
391    /// The bounding box in document coordinates. Note that scroll offset of the document is ignored.
392    #[serde(rename = "boundingBox")]
393    bounding_box: crate::dom::Rect,
394    /// Contents of the LayoutText, if any.
395    #[serde(skip_serializing_if = "Option::is_none", rename = "layoutText")]
396    layout_text: Option<Cow<'a, str>>,
397    /// The post-layout inline text nodes, if any.
398    #[serde(skip_serializing_if = "Option::is_none", rename = "inlineTextNodes")]
399    inline_text_nodes: Option<Vec<InlineTextBox>>,
400    /// Index into the 'computedStyles' array returned by 'getSnapshot'.
401    #[serde(skip_serializing_if = "Option::is_none", rename = "styleIndex")]
402    style_index: Option<u64>,
403    /// Global paint order index, which is determined by the stacking order of the nodes. Nodes
404    /// that are painted together will have the same index. Only provided if includePaintOrder in
405    /// getSnapshot was true.
406    #[serde(skip_serializing_if = "Option::is_none", rename = "paintOrder")]
407    paint_order: Option<i64>,
408    /// Set to true to indicate the element begins a new stacking context.
409    #[serde(skip_serializing_if = "Option::is_none", rename = "isStackingContext")]
410    is_stacking_context: Option<bool>,
411}
412
413impl<'a> LayoutTreeNode<'a> {
414    /// Creates a builder for this type with the required parameters:
415    /// * `dom_node_index`: The index of the related DOM node in the `domNodes` array returned by `getSnapshot`.
416    /// * `bounding_box`: The bounding box in document coordinates. Note that scroll offset of the document is ignored.
417    pub fn builder(dom_node_index: u64, bounding_box: crate::dom::Rect) -> LayoutTreeNodeBuilder<'a> {
418        LayoutTreeNodeBuilder {
419            dom_node_index: dom_node_index,
420            bounding_box: bounding_box,
421            layout_text: None,
422            inline_text_nodes: None,
423            style_index: None,
424            paint_order: None,
425            is_stacking_context: None,
426        }
427    }
428    /// The index of the related DOM node in the 'domNodes' array returned by 'getSnapshot'.
429    pub fn dom_node_index(&self) -> u64 { self.dom_node_index }
430    /// The bounding box in document coordinates. Note that scroll offset of the document is ignored.
431    pub fn bounding_box(&self) -> &crate::dom::Rect { &self.bounding_box }
432    /// Contents of the LayoutText, if any.
433    pub fn layout_text(&self) -> Option<&str> { self.layout_text.as_deref() }
434    /// The post-layout inline text nodes, if any.
435    pub fn inline_text_nodes(&self) -> Option<&[InlineTextBox]> { self.inline_text_nodes.as_deref() }
436    /// Index into the 'computedStyles' array returned by 'getSnapshot'.
437    pub fn style_index(&self) -> Option<u64> { self.style_index }
438    /// Global paint order index, which is determined by the stacking order of the nodes. Nodes
439    /// that are painted together will have the same index. Only provided if includePaintOrder in
440    /// getSnapshot was true.
441    pub fn paint_order(&self) -> Option<i64> { self.paint_order }
442    /// Set to true to indicate the element begins a new stacking context.
443    pub fn is_stacking_context(&self) -> Option<bool> { self.is_stacking_context }
444}
445
446
447pub struct LayoutTreeNodeBuilder<'a> {
448    dom_node_index: u64,
449    bounding_box: crate::dom::Rect,
450    layout_text: Option<Cow<'a, str>>,
451    inline_text_nodes: Option<Vec<InlineTextBox>>,
452    style_index: Option<u64>,
453    paint_order: Option<i64>,
454    is_stacking_context: Option<bool>,
455}
456
457impl<'a> LayoutTreeNodeBuilder<'a> {
458    /// Contents of the LayoutText, if any.
459    pub fn layout_text(mut self, layout_text: impl Into<Cow<'a, str>>) -> Self { self.layout_text = Some(layout_text.into()); self }
460    /// The post-layout inline text nodes, if any.
461    pub fn inline_text_nodes(mut self, inline_text_nodes: Vec<InlineTextBox>) -> Self { self.inline_text_nodes = Some(inline_text_nodes); self }
462    /// Index into the 'computedStyles' array returned by 'getSnapshot'.
463    pub fn style_index(mut self, style_index: u64) -> Self { self.style_index = Some(style_index); self }
464    /// Global paint order index, which is determined by the stacking order of the nodes. Nodes
465    /// that are painted together will have the same index. Only provided if includePaintOrder in
466    /// getSnapshot was true.
467    pub fn paint_order(mut self, paint_order: i64) -> Self { self.paint_order = Some(paint_order); self }
468    /// Set to true to indicate the element begins a new stacking context.
469    pub fn is_stacking_context(mut self, is_stacking_context: bool) -> Self { self.is_stacking_context = Some(is_stacking_context); self }
470    pub fn build(self) -> LayoutTreeNode<'a> {
471        LayoutTreeNode {
472            dom_node_index: self.dom_node_index,
473            bounding_box: self.bounding_box,
474            layout_text: self.layout_text,
475            inline_text_nodes: self.inline_text_nodes,
476            style_index: self.style_index,
477            paint_order: self.paint_order,
478            is_stacking_context: self.is_stacking_context,
479        }
480    }
481}
482
483/// A subset of the full ComputedStyle as defined by the request whitelist.
484
485#[derive(Debug, Clone, Serialize, Deserialize, Default)]
486#[serde(rename_all = "camelCase")]
487pub struct ComputedStyle<'a> {
488    /// Name/value pairs of computed style properties.
489    properties: Vec<NameValue<'a>>,
490}
491
492impl<'a> ComputedStyle<'a> {
493    /// Creates a builder for this type with the required parameters:
494    /// * `properties`: Name/value pairs of computed style properties.
495    pub fn builder(properties: Vec<NameValue<'a>>) -> ComputedStyleBuilder<'a> {
496        ComputedStyleBuilder {
497            properties: properties,
498        }
499    }
500    /// Name/value pairs of computed style properties.
501    pub fn properties(&self) -> &[NameValue<'a>] { &self.properties }
502}
503
504
505pub struct ComputedStyleBuilder<'a> {
506    properties: Vec<NameValue<'a>>,
507}
508
509impl<'a> ComputedStyleBuilder<'a> {
510    pub fn build(self) -> ComputedStyle<'a> {
511        ComputedStyle {
512            properties: self.properties,
513        }
514    }
515}
516
517/// A name/value pair.
518
519#[derive(Debug, Clone, Serialize, Deserialize, Default)]
520#[serde(rename_all = "camelCase")]
521pub struct NameValue<'a> {
522    /// Attribute/property name.
523    name: Cow<'a, str>,
524    /// Attribute/property value.
525    value: Cow<'a, str>,
526}
527
528impl<'a> NameValue<'a> {
529    /// Creates a builder for this type with the required parameters:
530    /// * `name`: Attribute/property name.
531    /// * `value`: Attribute/property value.
532    pub fn builder(name: impl Into<Cow<'a, str>>, value: impl Into<Cow<'a, str>>) -> NameValueBuilder<'a> {
533        NameValueBuilder {
534            name: name.into(),
535            value: value.into(),
536        }
537    }
538    /// Attribute/property name.
539    pub fn name(&self) -> &str { self.name.as_ref() }
540    /// Attribute/property value.
541    pub fn value(&self) -> &str { self.value.as_ref() }
542}
543
544
545pub struct NameValueBuilder<'a> {
546    name: Cow<'a, str>,
547    value: Cow<'a, str>,
548}
549
550impl<'a> NameValueBuilder<'a> {
551    pub fn build(self) -> NameValue<'a> {
552        NameValue {
553            name: self.name,
554            value: self.value,
555        }
556    }
557}
558
559/// Index of the string in the strings table.
560
561pub type StringIndex = i64;
562
563/// Index of the string in the strings table.
564
565pub type ArrayOfStrings = Vec<StringIndex>;
566
567/// Data that is only present on rare nodes.
568
569#[derive(Debug, Clone, Serialize, Deserialize, Default)]
570#[serde(rename_all = "camelCase")]
571pub struct RareStringData {
572    index: Vec<i64>,
573    value: Vec<StringIndex>,
574}
575
576impl RareStringData {
577    /// Creates a builder for this type with the required parameters:
578    /// * `index`: 
579    /// * `value`: 
580    pub fn builder(index: Vec<i64>, value: Vec<StringIndex>) -> RareStringDataBuilder {
581        RareStringDataBuilder {
582            index: index,
583            value: value,
584        }
585    }
586    pub fn index(&self) -> &[i64] { &self.index }
587    pub fn value(&self) -> &[StringIndex] { &self.value }
588}
589
590
591pub struct RareStringDataBuilder {
592    index: Vec<i64>,
593    value: Vec<StringIndex>,
594}
595
596impl RareStringDataBuilder {
597    pub fn build(self) -> RareStringData {
598        RareStringData {
599            index: self.index,
600            value: self.value,
601        }
602    }
603}
604
605
606#[derive(Debug, Clone, Serialize, Deserialize, Default)]
607#[serde(rename_all = "camelCase")]
608pub struct RareBooleanData {
609    index: Vec<i64>,
610}
611
612impl RareBooleanData {
613    /// Creates a builder for this type with the required parameters:
614    /// * `index`: 
615    pub fn builder(index: Vec<i64>) -> RareBooleanDataBuilder {
616        RareBooleanDataBuilder {
617            index: index,
618        }
619    }
620    pub fn index(&self) -> &[i64] { &self.index }
621}
622
623
624pub struct RareBooleanDataBuilder {
625    index: Vec<i64>,
626}
627
628impl RareBooleanDataBuilder {
629    pub fn build(self) -> RareBooleanData {
630        RareBooleanData {
631            index: self.index,
632        }
633    }
634}
635
636
637#[derive(Debug, Clone, Serialize, Deserialize, Default)]
638#[serde(rename_all = "camelCase")]
639pub struct RareIntegerData {
640    index: Vec<i64>,
641    value: Vec<i64>,
642}
643
644impl RareIntegerData {
645    /// Creates a builder for this type with the required parameters:
646    /// * `index`: 
647    /// * `value`: 
648    pub fn builder(index: Vec<i64>, value: Vec<i64>) -> RareIntegerDataBuilder {
649        RareIntegerDataBuilder {
650            index: index,
651            value: value,
652        }
653    }
654    pub fn index(&self) -> &[i64] { &self.index }
655    pub fn value(&self) -> &[i64] { &self.value }
656}
657
658
659pub struct RareIntegerDataBuilder {
660    index: Vec<i64>,
661    value: Vec<i64>,
662}
663
664impl RareIntegerDataBuilder {
665    pub fn build(self) -> RareIntegerData {
666        RareIntegerData {
667            index: self.index,
668            value: self.value,
669        }
670    }
671}
672
673
674pub type Rectangle = Vec<f64>;
675
676/// Document snapshot.
677
678#[derive(Debug, Clone, Serialize, Deserialize, Default)]
679#[serde(rename_all = "camelCase")]
680pub struct DocumentSnapshot {
681    /// Document URL that 'Document' or 'FrameOwner' node points to.
682    #[serde(rename = "documentURL")]
683    document_url: StringIndex,
684    /// Document title.
685    title: StringIndex,
686    /// Base URL that 'Document' or 'FrameOwner' node uses for URL completion.
687    #[serde(rename = "baseURL")]
688    base_url: StringIndex,
689    /// Contains the document's content language.
690    #[serde(rename = "contentLanguage")]
691    content_language: StringIndex,
692    /// Contains the document's character set encoding.
693    #[serde(rename = "encodingName")]
694    encoding_name: StringIndex,
695    /// 'DocumentType' node's publicId.
696    #[serde(rename = "publicId")]
697    public_id: StringIndex,
698    /// 'DocumentType' node's systemId.
699    #[serde(rename = "systemId")]
700    system_id: StringIndex,
701    /// Frame ID for frame owner elements and also for the document node.
702    #[serde(rename = "frameId")]
703    frame_id: StringIndex,
704    /// A table with dom nodes.
705    nodes: NodeTreeSnapshot,
706    /// The nodes in the layout tree.
707    layout: LayoutTreeSnapshot,
708    /// The post-layout inline text nodes.
709    #[serde(rename = "textBoxes")]
710    text_boxes: TextBoxSnapshot,
711    /// Horizontal scroll offset.
712    #[serde(skip_serializing_if = "Option::is_none", rename = "scrollOffsetX")]
713    scroll_offset_x: Option<f64>,
714    /// Vertical scroll offset.
715    #[serde(skip_serializing_if = "Option::is_none", rename = "scrollOffsetY")]
716    scroll_offset_y: Option<f64>,
717    /// Document content width.
718    #[serde(skip_serializing_if = "Option::is_none", rename = "contentWidth")]
719    content_width: Option<f64>,
720    /// Document content height.
721    #[serde(skip_serializing_if = "Option::is_none", rename = "contentHeight")]
722    content_height: Option<f64>,
723}
724
725impl DocumentSnapshot {
726    /// Creates a builder for this type with the required parameters:
727    /// * `document_url`: Document URL that `Document` or `FrameOwner` node points to.
728    /// * `title`: Document title.
729    /// * `base_url`: Base URL that `Document` or `FrameOwner` node uses for URL completion.
730    /// * `content_language`: Contains the document's content language.
731    /// * `encoding_name`: Contains the document's character set encoding.
732    /// * `public_id`: `DocumentType` node's publicId.
733    /// * `system_id`: `DocumentType` node's systemId.
734    /// * `frame_id`: Frame ID for frame owner elements and also for the document node.
735    /// * `nodes`: A table with dom nodes.
736    /// * `layout`: The nodes in the layout tree.
737    /// * `text_boxes`: The post-layout inline text nodes.
738    pub fn builder(document_url: StringIndex, title: StringIndex, base_url: StringIndex, content_language: StringIndex, encoding_name: StringIndex, public_id: StringIndex, system_id: StringIndex, frame_id: StringIndex, nodes: NodeTreeSnapshot, layout: LayoutTreeSnapshot, text_boxes: TextBoxSnapshot) -> DocumentSnapshotBuilder {
739        DocumentSnapshotBuilder {
740            document_url: document_url,
741            title: title,
742            base_url: base_url,
743            content_language: content_language,
744            encoding_name: encoding_name,
745            public_id: public_id,
746            system_id: system_id,
747            frame_id: frame_id,
748            nodes: nodes,
749            layout: layout,
750            text_boxes: text_boxes,
751            scroll_offset_x: None,
752            scroll_offset_y: None,
753            content_width: None,
754            content_height: None,
755        }
756    }
757    /// Document URL that 'Document' or 'FrameOwner' node points to.
758    pub fn document_url(&self) -> &StringIndex { &self.document_url }
759    /// Document title.
760    pub fn title(&self) -> &StringIndex { &self.title }
761    /// Base URL that 'Document' or 'FrameOwner' node uses for URL completion.
762    pub fn base_url(&self) -> &StringIndex { &self.base_url }
763    /// Contains the document's content language.
764    pub fn content_language(&self) -> &StringIndex { &self.content_language }
765    /// Contains the document's character set encoding.
766    pub fn encoding_name(&self) -> &StringIndex { &self.encoding_name }
767    /// 'DocumentType' node's publicId.
768    pub fn public_id(&self) -> &StringIndex { &self.public_id }
769    /// 'DocumentType' node's systemId.
770    pub fn system_id(&self) -> &StringIndex { &self.system_id }
771    /// Frame ID for frame owner elements and also for the document node.
772    pub fn frame_id(&self) -> &StringIndex { &self.frame_id }
773    /// A table with dom nodes.
774    pub fn nodes(&self) -> &NodeTreeSnapshot { &self.nodes }
775    /// The nodes in the layout tree.
776    pub fn layout(&self) -> &LayoutTreeSnapshot { &self.layout }
777    /// The post-layout inline text nodes.
778    pub fn text_boxes(&self) -> &TextBoxSnapshot { &self.text_boxes }
779    /// Horizontal scroll offset.
780    pub fn scroll_offset_x(&self) -> Option<f64> { self.scroll_offset_x }
781    /// Vertical scroll offset.
782    pub fn scroll_offset_y(&self) -> Option<f64> { self.scroll_offset_y }
783    /// Document content width.
784    pub fn content_width(&self) -> Option<f64> { self.content_width }
785    /// Document content height.
786    pub fn content_height(&self) -> Option<f64> { self.content_height }
787}
788
789
790pub struct DocumentSnapshotBuilder {
791    document_url: StringIndex,
792    title: StringIndex,
793    base_url: StringIndex,
794    content_language: StringIndex,
795    encoding_name: StringIndex,
796    public_id: StringIndex,
797    system_id: StringIndex,
798    frame_id: StringIndex,
799    nodes: NodeTreeSnapshot,
800    layout: LayoutTreeSnapshot,
801    text_boxes: TextBoxSnapshot,
802    scroll_offset_x: Option<f64>,
803    scroll_offset_y: Option<f64>,
804    content_width: Option<f64>,
805    content_height: Option<f64>,
806}
807
808impl DocumentSnapshotBuilder {
809    /// Horizontal scroll offset.
810    pub fn scroll_offset_x(mut self, scroll_offset_x: f64) -> Self { self.scroll_offset_x = Some(scroll_offset_x); self }
811    /// Vertical scroll offset.
812    pub fn scroll_offset_y(mut self, scroll_offset_y: f64) -> Self { self.scroll_offset_y = Some(scroll_offset_y); self }
813    /// Document content width.
814    pub fn content_width(mut self, content_width: f64) -> Self { self.content_width = Some(content_width); self }
815    /// Document content height.
816    pub fn content_height(mut self, content_height: f64) -> Self { self.content_height = Some(content_height); self }
817    pub fn build(self) -> DocumentSnapshot {
818        DocumentSnapshot {
819            document_url: self.document_url,
820            title: self.title,
821            base_url: self.base_url,
822            content_language: self.content_language,
823            encoding_name: self.encoding_name,
824            public_id: self.public_id,
825            system_id: self.system_id,
826            frame_id: self.frame_id,
827            nodes: self.nodes,
828            layout: self.layout,
829            text_boxes: self.text_boxes,
830            scroll_offset_x: self.scroll_offset_x,
831            scroll_offset_y: self.scroll_offset_y,
832            content_width: self.content_width,
833            content_height: self.content_height,
834        }
835    }
836}
837
838/// Table containing nodes.
839
840#[derive(Debug, Clone, Serialize, Deserialize, Default)]
841#[serde(rename_all = "camelCase")]
842pub struct NodeTreeSnapshot {
843    /// Parent node index.
844    #[serde(skip_serializing_if = "Option::is_none", rename = "parentIndex")]
845    parent_index: Option<Vec<i64>>,
846    /// 'Node''s nodeType.
847    #[serde(skip_serializing_if = "Option::is_none", rename = "nodeType")]
848    node_type: Option<Vec<i64>>,
849    /// Type of the shadow root the 'Node' is in. String values are equal to the 'ShadowRootType' enum.
850    #[serde(skip_serializing_if = "Option::is_none", rename = "shadowRootType")]
851    shadow_root_type: Option<RareStringData>,
852    /// 'Node''s nodeName.
853    #[serde(skip_serializing_if = "Option::is_none", rename = "nodeName")]
854    node_name: Option<Vec<StringIndex>>,
855    /// 'Node''s nodeValue.
856    #[serde(skip_serializing_if = "Option::is_none", rename = "nodeValue")]
857    node_value: Option<Vec<StringIndex>>,
858    /// 'Node''s id, corresponds to DOM.Node.backendNodeId.
859    #[serde(skip_serializing_if = "Option::is_none", rename = "backendNodeId")]
860    backend_node_id: Option<Vec<crate::dom::BackendNodeId>>,
861    /// Attributes of an 'Element' node. Flatten name, value pairs.
862    #[serde(skip_serializing_if = "Option::is_none")]
863    attributes: Option<Vec<ArrayOfStrings>>,
864    /// Only set for textarea elements, contains the text value.
865    #[serde(skip_serializing_if = "Option::is_none", rename = "textValue")]
866    text_value: Option<RareStringData>,
867    /// Only set for input elements, contains the input's associated text value.
868    #[serde(skip_serializing_if = "Option::is_none", rename = "inputValue")]
869    input_value: Option<RareStringData>,
870    /// Only set for radio and checkbox input elements, indicates if the element has been checked
871    #[serde(skip_serializing_if = "Option::is_none", rename = "inputChecked")]
872    input_checked: Option<RareBooleanData>,
873    /// Only set for option elements, indicates if the element has been selected
874    #[serde(skip_serializing_if = "Option::is_none", rename = "optionSelected")]
875    option_selected: Option<RareBooleanData>,
876    /// The index of the document in the list of the snapshot documents.
877    #[serde(skip_serializing_if = "Option::is_none", rename = "contentDocumentIndex")]
878    content_document_index: Option<RareIntegerData>,
879    /// Type of a pseudo element node.
880    #[serde(skip_serializing_if = "Option::is_none", rename = "pseudoType")]
881    pseudo_type: Option<RareStringData>,
882    /// Pseudo element identifier for this node. Only present if there is a
883    /// valid pseudoType.
884    #[serde(skip_serializing_if = "Option::is_none", rename = "pseudoIdentifier")]
885    pseudo_identifier: Option<RareStringData>,
886    /// Whether this DOM node responds to mouse clicks. This includes nodes that have had click
887    /// event listeners attached via JavaScript as well as anchor tags that naturally navigate when
888    /// clicked.
889    #[serde(skip_serializing_if = "Option::is_none", rename = "isClickable")]
890    is_clickable: Option<RareBooleanData>,
891    /// The selected url for nodes with a srcset attribute.
892    #[serde(skip_serializing_if = "Option::is_none", rename = "currentSourceURL")]
893    current_source_url: Option<RareStringData>,
894    /// The url of the script (if any) that generates this node.
895    #[serde(skip_serializing_if = "Option::is_none", rename = "originURL")]
896    origin_url: Option<RareStringData>,
897}
898
899impl NodeTreeSnapshot {
900    /// Creates a builder for this type.
901    pub fn builder() -> NodeTreeSnapshotBuilder {
902        NodeTreeSnapshotBuilder {
903            parent_index: None,
904            node_type: None,
905            shadow_root_type: None,
906            node_name: None,
907            node_value: None,
908            backend_node_id: None,
909            attributes: None,
910            text_value: None,
911            input_value: None,
912            input_checked: None,
913            option_selected: None,
914            content_document_index: None,
915            pseudo_type: None,
916            pseudo_identifier: None,
917            is_clickable: None,
918            current_source_url: None,
919            origin_url: None,
920        }
921    }
922    /// Parent node index.
923    pub fn parent_index(&self) -> Option<&[i64]> { self.parent_index.as_deref() }
924    /// 'Node''s nodeType.
925    pub fn node_type(&self) -> Option<&[i64]> { self.node_type.as_deref() }
926    /// Type of the shadow root the 'Node' is in. String values are equal to the 'ShadowRootType' enum.
927    pub fn shadow_root_type(&self) -> Option<&RareStringData> { self.shadow_root_type.as_ref() }
928    /// 'Node''s nodeName.
929    pub fn node_name(&self) -> Option<&[StringIndex]> { self.node_name.as_deref() }
930    /// 'Node''s nodeValue.
931    pub fn node_value(&self) -> Option<&[StringIndex]> { self.node_value.as_deref() }
932    /// 'Node''s id, corresponds to DOM.Node.backendNodeId.
933    pub fn backend_node_id(&self) -> Option<&[crate::dom::BackendNodeId]> { self.backend_node_id.as_deref() }
934    /// Attributes of an 'Element' node. Flatten name, value pairs.
935    pub fn attributes(&self) -> Option<&[ArrayOfStrings]> { self.attributes.as_deref() }
936    /// Only set for textarea elements, contains the text value.
937    pub fn text_value(&self) -> Option<&RareStringData> { self.text_value.as_ref() }
938    /// Only set for input elements, contains the input's associated text value.
939    pub fn input_value(&self) -> Option<&RareStringData> { self.input_value.as_ref() }
940    /// Only set for radio and checkbox input elements, indicates if the element has been checked
941    pub fn input_checked(&self) -> Option<&RareBooleanData> { self.input_checked.as_ref() }
942    /// Only set for option elements, indicates if the element has been selected
943    pub fn option_selected(&self) -> Option<&RareBooleanData> { self.option_selected.as_ref() }
944    /// The index of the document in the list of the snapshot documents.
945    pub fn content_document_index(&self) -> Option<&RareIntegerData> { self.content_document_index.as_ref() }
946    /// Type of a pseudo element node.
947    pub fn pseudo_type(&self) -> Option<&RareStringData> { self.pseudo_type.as_ref() }
948    /// Pseudo element identifier for this node. Only present if there is a
949    /// valid pseudoType.
950    pub fn pseudo_identifier(&self) -> Option<&RareStringData> { self.pseudo_identifier.as_ref() }
951    /// Whether this DOM node responds to mouse clicks. This includes nodes that have had click
952    /// event listeners attached via JavaScript as well as anchor tags that naturally navigate when
953    /// clicked.
954    pub fn is_clickable(&self) -> Option<&RareBooleanData> { self.is_clickable.as_ref() }
955    /// The selected url for nodes with a srcset attribute.
956    pub fn current_source_url(&self) -> Option<&RareStringData> { self.current_source_url.as_ref() }
957    /// The url of the script (if any) that generates this node.
958    pub fn origin_url(&self) -> Option<&RareStringData> { self.origin_url.as_ref() }
959}
960
961#[derive(Default)]
962pub struct NodeTreeSnapshotBuilder {
963    parent_index: Option<Vec<i64>>,
964    node_type: Option<Vec<i64>>,
965    shadow_root_type: Option<RareStringData>,
966    node_name: Option<Vec<StringIndex>>,
967    node_value: Option<Vec<StringIndex>>,
968    backend_node_id: Option<Vec<crate::dom::BackendNodeId>>,
969    attributes: Option<Vec<ArrayOfStrings>>,
970    text_value: Option<RareStringData>,
971    input_value: Option<RareStringData>,
972    input_checked: Option<RareBooleanData>,
973    option_selected: Option<RareBooleanData>,
974    content_document_index: Option<RareIntegerData>,
975    pseudo_type: Option<RareStringData>,
976    pseudo_identifier: Option<RareStringData>,
977    is_clickable: Option<RareBooleanData>,
978    current_source_url: Option<RareStringData>,
979    origin_url: Option<RareStringData>,
980}
981
982impl NodeTreeSnapshotBuilder {
983    /// Parent node index.
984    pub fn parent_index(mut self, parent_index: Vec<i64>) -> Self { self.parent_index = Some(parent_index); self }
985    /// 'Node''s nodeType.
986    pub fn node_type(mut self, node_type: Vec<i64>) -> Self { self.node_type = Some(node_type); self }
987    /// Type of the shadow root the 'Node' is in. String values are equal to the 'ShadowRootType' enum.
988    pub fn shadow_root_type(mut self, shadow_root_type: RareStringData) -> Self { self.shadow_root_type = Some(shadow_root_type); self }
989    /// 'Node''s nodeName.
990    pub fn node_name(mut self, node_name: Vec<StringIndex>) -> Self { self.node_name = Some(node_name); self }
991    /// 'Node''s nodeValue.
992    pub fn node_value(mut self, node_value: Vec<StringIndex>) -> Self { self.node_value = Some(node_value); self }
993    /// 'Node''s id, corresponds to DOM.Node.backendNodeId.
994    pub fn backend_node_id(mut self, backend_node_id: Vec<crate::dom::BackendNodeId>) -> Self { self.backend_node_id = Some(backend_node_id); self }
995    /// Attributes of an 'Element' node. Flatten name, value pairs.
996    pub fn attributes(mut self, attributes: Vec<ArrayOfStrings>) -> Self { self.attributes = Some(attributes); self }
997    /// Only set for textarea elements, contains the text value.
998    pub fn text_value(mut self, text_value: RareStringData) -> Self { self.text_value = Some(text_value); self }
999    /// Only set for input elements, contains the input's associated text value.
1000    pub fn input_value(mut self, input_value: RareStringData) -> Self { self.input_value = Some(input_value); self }
1001    /// Only set for radio and checkbox input elements, indicates if the element has been checked
1002    pub fn input_checked(mut self, input_checked: RareBooleanData) -> Self { self.input_checked = Some(input_checked); self }
1003    /// Only set for option elements, indicates if the element has been selected
1004    pub fn option_selected(mut self, option_selected: RareBooleanData) -> Self { self.option_selected = Some(option_selected); self }
1005    /// The index of the document in the list of the snapshot documents.
1006    pub fn content_document_index(mut self, content_document_index: RareIntegerData) -> Self { self.content_document_index = Some(content_document_index); self }
1007    /// Type of a pseudo element node.
1008    pub fn pseudo_type(mut self, pseudo_type: RareStringData) -> Self { self.pseudo_type = Some(pseudo_type); self }
1009    /// Pseudo element identifier for this node. Only present if there is a
1010    /// valid pseudoType.
1011    pub fn pseudo_identifier(mut self, pseudo_identifier: RareStringData) -> Self { self.pseudo_identifier = Some(pseudo_identifier); self }
1012    /// Whether this DOM node responds to mouse clicks. This includes nodes that have had click
1013    /// event listeners attached via JavaScript as well as anchor tags that naturally navigate when
1014    /// clicked.
1015    pub fn is_clickable(mut self, is_clickable: RareBooleanData) -> Self { self.is_clickable = Some(is_clickable); self }
1016    /// The selected url for nodes with a srcset attribute.
1017    pub fn current_source_url(mut self, current_source_url: RareStringData) -> Self { self.current_source_url = Some(current_source_url); self }
1018    /// The url of the script (if any) that generates this node.
1019    pub fn origin_url(mut self, origin_url: RareStringData) -> Self { self.origin_url = Some(origin_url); self }
1020    pub fn build(self) -> NodeTreeSnapshot {
1021        NodeTreeSnapshot {
1022            parent_index: self.parent_index,
1023            node_type: self.node_type,
1024            shadow_root_type: self.shadow_root_type,
1025            node_name: self.node_name,
1026            node_value: self.node_value,
1027            backend_node_id: self.backend_node_id,
1028            attributes: self.attributes,
1029            text_value: self.text_value,
1030            input_value: self.input_value,
1031            input_checked: self.input_checked,
1032            option_selected: self.option_selected,
1033            content_document_index: self.content_document_index,
1034            pseudo_type: self.pseudo_type,
1035            pseudo_identifier: self.pseudo_identifier,
1036            is_clickable: self.is_clickable,
1037            current_source_url: self.current_source_url,
1038            origin_url: self.origin_url,
1039        }
1040    }
1041}
1042
1043/// Table of details of an element in the DOM tree with a LayoutObject.
1044
1045#[derive(Debug, Clone, Serialize, Deserialize, Default)]
1046#[serde(rename_all = "camelCase")]
1047pub struct LayoutTreeSnapshot {
1048    /// Index of the corresponding node in the 'NodeTreeSnapshot' array returned by 'captureSnapshot'.
1049    #[serde(rename = "nodeIndex")]
1050    node_index: Vec<i64>,
1051    /// Array of indexes specifying computed style strings, filtered according to the 'computedStyles' parameter passed to 'captureSnapshot'.
1052    styles: Vec<ArrayOfStrings>,
1053    /// The absolute position bounding box.
1054    bounds: Vec<Rectangle>,
1055    /// Contents of the LayoutText, if any.
1056    text: Vec<StringIndex>,
1057    /// Stacking context information.
1058    #[serde(rename = "stackingContexts")]
1059    stacking_contexts: RareBooleanData,
1060    /// Global paint order index, which is determined by the stacking order of the nodes. Nodes
1061    /// that are painted together will have the same index. Only provided if includePaintOrder in
1062    /// captureSnapshot was true.
1063    #[serde(skip_serializing_if = "Option::is_none", rename = "paintOrders")]
1064    paint_orders: Option<Vec<i64>>,
1065    /// The offset rect of nodes. Only available when includeDOMRects is set to true
1066    #[serde(skip_serializing_if = "Option::is_none", rename = "offsetRects")]
1067    offset_rects: Option<Vec<Rectangle>>,
1068    /// The scroll rect of nodes. Only available when includeDOMRects is set to true
1069    #[serde(skip_serializing_if = "Option::is_none", rename = "scrollRects")]
1070    scroll_rects: Option<Vec<Rectangle>>,
1071    /// The client rect of nodes. Only available when includeDOMRects is set to true
1072    #[serde(skip_serializing_if = "Option::is_none", rename = "clientRects")]
1073    client_rects: Option<Vec<Rectangle>>,
1074    /// The list of background colors that are blended with colors of overlapping elements.
1075    #[serde(skip_serializing_if = "Option::is_none", rename = "blendedBackgroundColors")]
1076    blended_background_colors: Option<Vec<StringIndex>>,
1077    /// The list of computed text opacities.
1078    #[serde(skip_serializing_if = "Option::is_none", rename = "textColorOpacities")]
1079    text_color_opacities: Option<Vec<f64>>,
1080}
1081
1082impl LayoutTreeSnapshot {
1083    /// Creates a builder for this type with the required parameters:
1084    /// * `node_index`: Index of the corresponding node in the `NodeTreeSnapshot` array returned by `captureSnapshot`.
1085    /// * `styles`: Array of indexes specifying computed style strings, filtered according to the `computedStyles` parameter passed to `captureSnapshot`.
1086    /// * `bounds`: The absolute position bounding box.
1087    /// * `text`: Contents of the LayoutText, if any.
1088    /// * `stacking_contexts`: Stacking context information.
1089    pub fn builder(node_index: Vec<i64>, styles: Vec<ArrayOfStrings>, bounds: Vec<Rectangle>, text: Vec<StringIndex>, stacking_contexts: RareBooleanData) -> LayoutTreeSnapshotBuilder {
1090        LayoutTreeSnapshotBuilder {
1091            node_index: node_index,
1092            styles: styles,
1093            bounds: bounds,
1094            text: text,
1095            stacking_contexts: stacking_contexts,
1096            paint_orders: None,
1097            offset_rects: None,
1098            scroll_rects: None,
1099            client_rects: None,
1100            blended_background_colors: None,
1101            text_color_opacities: None,
1102        }
1103    }
1104    /// Index of the corresponding node in the 'NodeTreeSnapshot' array returned by 'captureSnapshot'.
1105    pub fn node_index(&self) -> &[i64] { &self.node_index }
1106    /// Array of indexes specifying computed style strings, filtered according to the 'computedStyles' parameter passed to 'captureSnapshot'.
1107    pub fn styles(&self) -> &[ArrayOfStrings] { &self.styles }
1108    /// The absolute position bounding box.
1109    pub fn bounds(&self) -> &[Rectangle] { &self.bounds }
1110    /// Contents of the LayoutText, if any.
1111    pub fn text(&self) -> &[StringIndex] { &self.text }
1112    /// Stacking context information.
1113    pub fn stacking_contexts(&self) -> &RareBooleanData { &self.stacking_contexts }
1114    /// Global paint order index, which is determined by the stacking order of the nodes. Nodes
1115    /// that are painted together will have the same index. Only provided if includePaintOrder in
1116    /// captureSnapshot was true.
1117    pub fn paint_orders(&self) -> Option<&[i64]> { self.paint_orders.as_deref() }
1118    /// The offset rect of nodes. Only available when includeDOMRects is set to true
1119    pub fn offset_rects(&self) -> Option<&[Rectangle]> { self.offset_rects.as_deref() }
1120    /// The scroll rect of nodes. Only available when includeDOMRects is set to true
1121    pub fn scroll_rects(&self) -> Option<&[Rectangle]> { self.scroll_rects.as_deref() }
1122    /// The client rect of nodes. Only available when includeDOMRects is set to true
1123    pub fn client_rects(&self) -> Option<&[Rectangle]> { self.client_rects.as_deref() }
1124    /// The list of background colors that are blended with colors of overlapping elements.
1125    pub fn blended_background_colors(&self) -> Option<&[StringIndex]> { self.blended_background_colors.as_deref() }
1126    /// The list of computed text opacities.
1127    pub fn text_color_opacities(&self) -> Option<&[f64]> { self.text_color_opacities.as_deref() }
1128}
1129
1130
1131pub struct LayoutTreeSnapshotBuilder {
1132    node_index: Vec<i64>,
1133    styles: Vec<ArrayOfStrings>,
1134    bounds: Vec<Rectangle>,
1135    text: Vec<StringIndex>,
1136    stacking_contexts: RareBooleanData,
1137    paint_orders: Option<Vec<i64>>,
1138    offset_rects: Option<Vec<Rectangle>>,
1139    scroll_rects: Option<Vec<Rectangle>>,
1140    client_rects: Option<Vec<Rectangle>>,
1141    blended_background_colors: Option<Vec<StringIndex>>,
1142    text_color_opacities: Option<Vec<f64>>,
1143}
1144
1145impl LayoutTreeSnapshotBuilder {
1146    /// Global paint order index, which is determined by the stacking order of the nodes. Nodes
1147    /// that are painted together will have the same index. Only provided if includePaintOrder in
1148    /// captureSnapshot was true.
1149    pub fn paint_orders(mut self, paint_orders: Vec<i64>) -> Self { self.paint_orders = Some(paint_orders); self }
1150    /// The offset rect of nodes. Only available when includeDOMRects is set to true
1151    pub fn offset_rects(mut self, offset_rects: Vec<Rectangle>) -> Self { self.offset_rects = Some(offset_rects); self }
1152    /// The scroll rect of nodes. Only available when includeDOMRects is set to true
1153    pub fn scroll_rects(mut self, scroll_rects: Vec<Rectangle>) -> Self { self.scroll_rects = Some(scroll_rects); self }
1154    /// The client rect of nodes. Only available when includeDOMRects is set to true
1155    pub fn client_rects(mut self, client_rects: Vec<Rectangle>) -> Self { self.client_rects = Some(client_rects); self }
1156    /// The list of background colors that are blended with colors of overlapping elements.
1157    pub fn blended_background_colors(mut self, blended_background_colors: Vec<StringIndex>) -> Self { self.blended_background_colors = Some(blended_background_colors); self }
1158    /// The list of computed text opacities.
1159    pub fn text_color_opacities(mut self, text_color_opacities: Vec<f64>) -> Self { self.text_color_opacities = Some(text_color_opacities); self }
1160    pub fn build(self) -> LayoutTreeSnapshot {
1161        LayoutTreeSnapshot {
1162            node_index: self.node_index,
1163            styles: self.styles,
1164            bounds: self.bounds,
1165            text: self.text,
1166            stacking_contexts: self.stacking_contexts,
1167            paint_orders: self.paint_orders,
1168            offset_rects: self.offset_rects,
1169            scroll_rects: self.scroll_rects,
1170            client_rects: self.client_rects,
1171            blended_background_colors: self.blended_background_colors,
1172            text_color_opacities: self.text_color_opacities,
1173        }
1174    }
1175}
1176
1177/// Table of details of the post layout rendered text positions. The exact layout should not be regarded as
1178/// stable and may change between versions.
1179
1180#[derive(Debug, Clone, Serialize, Deserialize, Default)]
1181#[serde(rename_all = "camelCase")]
1182pub struct TextBoxSnapshot {
1183    /// Index of the layout tree node that owns this box collection.
1184    #[serde(rename = "layoutIndex")]
1185    layout_index: Vec<i64>,
1186    /// The absolute position bounding box.
1187    bounds: Vec<Rectangle>,
1188    /// The starting index in characters, for this post layout textbox substring. Characters that
1189    /// would be represented as a surrogate pair in UTF-16 have length 2.
1190    start: Vec<i64>,
1191    /// The number of characters in this post layout textbox substring. Characters that would be
1192    /// represented as a surrogate pair in UTF-16 have length 2.
1193    length: Vec<i64>,
1194}
1195
1196impl TextBoxSnapshot {
1197    /// Creates a builder for this type with the required parameters:
1198    /// * `layout_index`: Index of the layout tree node that owns this box collection.
1199    /// * `bounds`: The absolute position bounding box.
1200    /// * `start`: The starting index in characters, for this post layout textbox substring. Characters that would be represented as a surrogate pair in UTF-16 have length 2.
1201    /// * `length`: The number of characters in this post layout textbox substring. Characters that would be represented as a surrogate pair in UTF-16 have length 2.
1202    pub fn builder(layout_index: Vec<i64>, bounds: Vec<Rectangle>, start: Vec<i64>, length: Vec<i64>) -> TextBoxSnapshotBuilder {
1203        TextBoxSnapshotBuilder {
1204            layout_index: layout_index,
1205            bounds: bounds,
1206            start: start,
1207            length: length,
1208        }
1209    }
1210    /// Index of the layout tree node that owns this box collection.
1211    pub fn layout_index(&self) -> &[i64] { &self.layout_index }
1212    /// The absolute position bounding box.
1213    pub fn bounds(&self) -> &[Rectangle] { &self.bounds }
1214    /// The starting index in characters, for this post layout textbox substring. Characters that
1215    /// would be represented as a surrogate pair in UTF-16 have length 2.
1216    pub fn start(&self) -> &[i64] { &self.start }
1217    /// The number of characters in this post layout textbox substring. Characters that would be
1218    /// represented as a surrogate pair in UTF-16 have length 2.
1219    pub fn length(&self) -> &[i64] { &self.length }
1220}
1221
1222
1223pub struct TextBoxSnapshotBuilder {
1224    layout_index: Vec<i64>,
1225    bounds: Vec<Rectangle>,
1226    start: Vec<i64>,
1227    length: Vec<i64>,
1228}
1229
1230impl TextBoxSnapshotBuilder {
1231    pub fn build(self) -> TextBoxSnapshot {
1232        TextBoxSnapshot {
1233            layout_index: self.layout_index,
1234            bounds: self.bounds,
1235            start: self.start,
1236            length: self.length,
1237        }
1238    }
1239}
1240
1241#[derive(Debug, Clone, Serialize, Deserialize, Default)]
1242pub struct DisableParams {}
1243
1244impl DisableParams { pub const METHOD: &'static str = "DOMSnapshot.disable"; }
1245
1246impl<'a> crate::CdpCommand<'a> for DisableParams {
1247    const METHOD: &'static str = "DOMSnapshot.disable";
1248    type Response = crate::EmptyReturns;
1249}
1250
1251#[derive(Debug, Clone, Serialize, Deserialize, Default)]
1252pub struct EnableParams {}
1253
1254impl EnableParams { pub const METHOD: &'static str = "DOMSnapshot.enable"; }
1255
1256impl<'a> crate::CdpCommand<'a> for EnableParams {
1257    const METHOD: &'static str = "DOMSnapshot.enable";
1258    type Response = crate::EmptyReturns;
1259}
1260
1261/// Returns a document snapshot, including the full DOM tree of the root node (including iframes,
1262/// template contents, and imported documents) in a flattened array, as well as layout and
1263/// white-listed computed style information for the nodes. Shadow DOM in the returned DOM tree is
1264/// flattened.
1265
1266#[derive(Debug, Clone, Serialize, Deserialize, Default)]
1267#[serde(rename_all = "camelCase")]
1268pub struct GetSnapshotParams<'a> {
1269    /// Whitelist of computed styles to return.
1270    #[serde(rename = "computedStyleWhitelist")]
1271    computed_style_whitelist: Vec<Cow<'a, str>>,
1272    /// Whether or not to retrieve details of DOM listeners (default false).
1273    #[serde(skip_serializing_if = "Option::is_none", rename = "includeEventListeners")]
1274    include_event_listeners: Option<bool>,
1275    /// Whether to determine and include the paint order index of LayoutTreeNodes (default false).
1276    #[serde(skip_serializing_if = "Option::is_none", rename = "includePaintOrder")]
1277    include_paint_order: Option<bool>,
1278    /// Whether to include UA shadow tree in the snapshot (default false).
1279    #[serde(skip_serializing_if = "Option::is_none", rename = "includeUserAgentShadowTree")]
1280    include_user_agent_shadow_tree: Option<bool>,
1281}
1282
1283impl<'a> GetSnapshotParams<'a> {
1284    /// Creates a builder for this type with the required parameters:
1285    /// * `computed_style_whitelist`: Whitelist of computed styles to return.
1286    pub fn builder(computed_style_whitelist: Vec<Cow<'a, str>>) -> GetSnapshotParamsBuilder<'a> {
1287        GetSnapshotParamsBuilder {
1288            computed_style_whitelist: computed_style_whitelist,
1289            include_event_listeners: None,
1290            include_paint_order: None,
1291            include_user_agent_shadow_tree: None,
1292        }
1293    }
1294    /// Whitelist of computed styles to return.
1295    pub fn computed_style_whitelist(&self) -> &[Cow<'a, str>] { &self.computed_style_whitelist }
1296    /// Whether or not to retrieve details of DOM listeners (default false).
1297    pub fn include_event_listeners(&self) -> Option<bool> { self.include_event_listeners }
1298    /// Whether to determine and include the paint order index of LayoutTreeNodes (default false).
1299    pub fn include_paint_order(&self) -> Option<bool> { self.include_paint_order }
1300    /// Whether to include UA shadow tree in the snapshot (default false).
1301    pub fn include_user_agent_shadow_tree(&self) -> Option<bool> { self.include_user_agent_shadow_tree }
1302}
1303
1304
1305pub struct GetSnapshotParamsBuilder<'a> {
1306    computed_style_whitelist: Vec<Cow<'a, str>>,
1307    include_event_listeners: Option<bool>,
1308    include_paint_order: Option<bool>,
1309    include_user_agent_shadow_tree: Option<bool>,
1310}
1311
1312impl<'a> GetSnapshotParamsBuilder<'a> {
1313    /// Whether or not to retrieve details of DOM listeners (default false).
1314    pub fn include_event_listeners(mut self, include_event_listeners: bool) -> Self { self.include_event_listeners = Some(include_event_listeners); self }
1315    /// Whether to determine and include the paint order index of LayoutTreeNodes (default false).
1316    pub fn include_paint_order(mut self, include_paint_order: bool) -> Self { self.include_paint_order = Some(include_paint_order); self }
1317    /// Whether to include UA shadow tree in the snapshot (default false).
1318    pub fn include_user_agent_shadow_tree(mut self, include_user_agent_shadow_tree: bool) -> Self { self.include_user_agent_shadow_tree = Some(include_user_agent_shadow_tree); self }
1319    pub fn build(self) -> GetSnapshotParams<'a> {
1320        GetSnapshotParams {
1321            computed_style_whitelist: self.computed_style_whitelist,
1322            include_event_listeners: self.include_event_listeners,
1323            include_paint_order: self.include_paint_order,
1324            include_user_agent_shadow_tree: self.include_user_agent_shadow_tree,
1325        }
1326    }
1327}
1328
1329/// Returns a document snapshot, including the full DOM tree of the root node (including iframes,
1330/// template contents, and imported documents) in a flattened array, as well as layout and
1331/// white-listed computed style information for the nodes. Shadow DOM in the returned DOM tree is
1332/// flattened.
1333
1334#[derive(Debug, Clone, Serialize, Deserialize, Default)]
1335#[serde(rename_all = "camelCase")]
1336pub struct GetSnapshotReturns<'a> {
1337    /// The nodes in the DOM tree. The DOMNode at index 0 corresponds to the root document.
1338    #[serde(rename = "domNodes")]
1339    dom_nodes: Vec<DOMNode<'a>>,
1340    /// The nodes in the layout tree.
1341    #[serde(rename = "layoutTreeNodes")]
1342    layout_tree_nodes: Vec<LayoutTreeNode<'a>>,
1343    /// Whitelisted ComputedStyle properties for each node in the layout tree.
1344    #[serde(rename = "computedStyles")]
1345    computed_styles: Vec<ComputedStyle<'a>>,
1346}
1347
1348impl<'a> GetSnapshotReturns<'a> {
1349    /// Creates a builder for this type with the required parameters:
1350    /// * `dom_nodes`: The nodes in the DOM tree. The DOMNode at index 0 corresponds to the root document.
1351    /// * `layout_tree_nodes`: The nodes in the layout tree.
1352    /// * `computed_styles`: Whitelisted ComputedStyle properties for each node in the layout tree.
1353    pub fn builder(dom_nodes: Vec<DOMNode<'a>>, layout_tree_nodes: Vec<LayoutTreeNode<'a>>, computed_styles: Vec<ComputedStyle<'a>>) -> GetSnapshotReturnsBuilder<'a> {
1354        GetSnapshotReturnsBuilder {
1355            dom_nodes: dom_nodes,
1356            layout_tree_nodes: layout_tree_nodes,
1357            computed_styles: computed_styles,
1358        }
1359    }
1360    /// The nodes in the DOM tree. The DOMNode at index 0 corresponds to the root document.
1361    pub fn dom_nodes(&self) -> &[DOMNode<'a>] { &self.dom_nodes }
1362    /// The nodes in the layout tree.
1363    pub fn layout_tree_nodes(&self) -> &[LayoutTreeNode<'a>] { &self.layout_tree_nodes }
1364    /// Whitelisted ComputedStyle properties for each node in the layout tree.
1365    pub fn computed_styles(&self) -> &[ComputedStyle<'a>] { &self.computed_styles }
1366}
1367
1368
1369pub struct GetSnapshotReturnsBuilder<'a> {
1370    dom_nodes: Vec<DOMNode<'a>>,
1371    layout_tree_nodes: Vec<LayoutTreeNode<'a>>,
1372    computed_styles: Vec<ComputedStyle<'a>>,
1373}
1374
1375impl<'a> GetSnapshotReturnsBuilder<'a> {
1376    pub fn build(self) -> GetSnapshotReturns<'a> {
1377        GetSnapshotReturns {
1378            dom_nodes: self.dom_nodes,
1379            layout_tree_nodes: self.layout_tree_nodes,
1380            computed_styles: self.computed_styles,
1381        }
1382    }
1383}
1384
1385impl<'a> GetSnapshotParams<'a> { pub const METHOD: &'static str = "DOMSnapshot.getSnapshot"; }
1386
1387impl<'a> crate::CdpCommand<'a> for GetSnapshotParams<'a> {
1388    const METHOD: &'static str = "DOMSnapshot.getSnapshot";
1389    type Response = GetSnapshotReturns<'a>;
1390}
1391
1392/// Returns a document snapshot, including the full DOM tree of the root node (including iframes,
1393/// template contents, and imported documents) in a flattened array, as well as layout and
1394/// white-listed computed style information for the nodes. Shadow DOM in the returned DOM tree is
1395/// flattened.
1396
1397#[derive(Debug, Clone, Serialize, Deserialize, Default)]
1398#[serde(rename_all = "camelCase")]
1399pub struct CaptureSnapshotParams<'a> {
1400    /// Whitelist of computed styles to return.
1401    #[serde(rename = "computedStyles")]
1402    computed_styles: Vec<Cow<'a, str>>,
1403    /// Whether to include layout object paint orders into the snapshot.
1404    #[serde(skip_serializing_if = "Option::is_none", rename = "includePaintOrder")]
1405    include_paint_order: Option<bool>,
1406    /// Whether to include DOM rectangles (offsetRects, clientRects, scrollRects) into the snapshot
1407    #[serde(skip_serializing_if = "Option::is_none", rename = "includeDOMRects")]
1408    include_dom_rects: Option<bool>,
1409    /// Whether to include blended background colors in the snapshot (default: false).
1410    /// Blended background color is achieved by blending background colors of all elements
1411    /// that overlap with the current element.
1412    #[serde(skip_serializing_if = "Option::is_none", rename = "includeBlendedBackgroundColors")]
1413    include_blended_background_colors: Option<bool>,
1414    /// Whether to include text color opacity in the snapshot (default: false).
1415    /// An element might have the opacity property set that affects the text color of the element.
1416    /// The final text color opacity is computed based on the opacity of all overlapping elements.
1417    #[serde(skip_serializing_if = "Option::is_none", rename = "includeTextColorOpacities")]
1418    include_text_color_opacities: Option<bool>,
1419}
1420
1421impl<'a> CaptureSnapshotParams<'a> {
1422    /// Creates a builder for this type with the required parameters:
1423    /// * `computed_styles`: Whitelist of computed styles to return.
1424    pub fn builder(computed_styles: Vec<Cow<'a, str>>) -> CaptureSnapshotParamsBuilder<'a> {
1425        CaptureSnapshotParamsBuilder {
1426            computed_styles: computed_styles,
1427            include_paint_order: None,
1428            include_dom_rects: None,
1429            include_blended_background_colors: None,
1430            include_text_color_opacities: None,
1431        }
1432    }
1433    /// Whitelist of computed styles to return.
1434    pub fn computed_styles(&self) -> &[Cow<'a, str>] { &self.computed_styles }
1435    /// Whether to include layout object paint orders into the snapshot.
1436    pub fn include_paint_order(&self) -> Option<bool> { self.include_paint_order }
1437    /// Whether to include DOM rectangles (offsetRects, clientRects, scrollRects) into the snapshot
1438    pub fn include_dom_rects(&self) -> Option<bool> { self.include_dom_rects }
1439    /// Whether to include blended background colors in the snapshot (default: false).
1440    /// Blended background color is achieved by blending background colors of all elements
1441    /// that overlap with the current element.
1442    pub fn include_blended_background_colors(&self) -> Option<bool> { self.include_blended_background_colors }
1443    /// Whether to include text color opacity in the snapshot (default: false).
1444    /// An element might have the opacity property set that affects the text color of the element.
1445    /// The final text color opacity is computed based on the opacity of all overlapping elements.
1446    pub fn include_text_color_opacities(&self) -> Option<bool> { self.include_text_color_opacities }
1447}
1448
1449
1450pub struct CaptureSnapshotParamsBuilder<'a> {
1451    computed_styles: Vec<Cow<'a, str>>,
1452    include_paint_order: Option<bool>,
1453    include_dom_rects: Option<bool>,
1454    include_blended_background_colors: Option<bool>,
1455    include_text_color_opacities: Option<bool>,
1456}
1457
1458impl<'a> CaptureSnapshotParamsBuilder<'a> {
1459    /// Whether to include layout object paint orders into the snapshot.
1460    pub fn include_paint_order(mut self, include_paint_order: bool) -> Self { self.include_paint_order = Some(include_paint_order); self }
1461    /// Whether to include DOM rectangles (offsetRects, clientRects, scrollRects) into the snapshot
1462    pub fn include_dom_rects(mut self, include_dom_rects: bool) -> Self { self.include_dom_rects = Some(include_dom_rects); self }
1463    /// Whether to include blended background colors in the snapshot (default: false).
1464    /// Blended background color is achieved by blending background colors of all elements
1465    /// that overlap with the current element.
1466    pub fn include_blended_background_colors(mut self, include_blended_background_colors: bool) -> Self { self.include_blended_background_colors = Some(include_blended_background_colors); self }
1467    /// Whether to include text color opacity in the snapshot (default: false).
1468    /// An element might have the opacity property set that affects the text color of the element.
1469    /// The final text color opacity is computed based on the opacity of all overlapping elements.
1470    pub fn include_text_color_opacities(mut self, include_text_color_opacities: bool) -> Self { self.include_text_color_opacities = Some(include_text_color_opacities); self }
1471    pub fn build(self) -> CaptureSnapshotParams<'a> {
1472        CaptureSnapshotParams {
1473            computed_styles: self.computed_styles,
1474            include_paint_order: self.include_paint_order,
1475            include_dom_rects: self.include_dom_rects,
1476            include_blended_background_colors: self.include_blended_background_colors,
1477            include_text_color_opacities: self.include_text_color_opacities,
1478        }
1479    }
1480}
1481
1482/// Returns a document snapshot, including the full DOM tree of the root node (including iframes,
1483/// template contents, and imported documents) in a flattened array, as well as layout and
1484/// white-listed computed style information for the nodes. Shadow DOM in the returned DOM tree is
1485/// flattened.
1486
1487#[derive(Debug, Clone, Serialize, Deserialize, Default)]
1488#[serde(rename_all = "camelCase")]
1489pub struct CaptureSnapshotReturns<'a> {
1490    /// The nodes in the DOM tree. The DOMNode at index 0 corresponds to the root document.
1491    documents: Vec<DocumentSnapshot>,
1492    /// Shared string table that all string properties refer to with indexes.
1493    strings: Vec<Cow<'a, str>>,
1494}
1495
1496impl<'a> CaptureSnapshotReturns<'a> {
1497    /// Creates a builder for this type with the required parameters:
1498    /// * `documents`: The nodes in the DOM tree. The DOMNode at index 0 corresponds to the root document.
1499    /// * `strings`: Shared string table that all string properties refer to with indexes.
1500    pub fn builder(documents: Vec<DocumentSnapshot>, strings: Vec<Cow<'a, str>>) -> CaptureSnapshotReturnsBuilder<'a> {
1501        CaptureSnapshotReturnsBuilder {
1502            documents: documents,
1503            strings: strings,
1504        }
1505    }
1506    /// The nodes in the DOM tree. The DOMNode at index 0 corresponds to the root document.
1507    pub fn documents(&self) -> &[DocumentSnapshot] { &self.documents }
1508    /// Shared string table that all string properties refer to with indexes.
1509    pub fn strings(&self) -> &[Cow<'a, str>] { &self.strings }
1510}
1511
1512
1513pub struct CaptureSnapshotReturnsBuilder<'a> {
1514    documents: Vec<DocumentSnapshot>,
1515    strings: Vec<Cow<'a, str>>,
1516}
1517
1518impl<'a> CaptureSnapshotReturnsBuilder<'a> {
1519    pub fn build(self) -> CaptureSnapshotReturns<'a> {
1520        CaptureSnapshotReturns {
1521            documents: self.documents,
1522            strings: self.strings,
1523        }
1524    }
1525}
1526
1527impl<'a> CaptureSnapshotParams<'a> { pub const METHOD: &'static str = "DOMSnapshot.captureSnapshot"; }
1528
1529impl<'a> crate::CdpCommand<'a> for CaptureSnapshotParams<'a> {
1530    const METHOD: &'static str = "DOMSnapshot.captureSnapshot";
1531    type Response = CaptureSnapshotReturns<'a>;
1532}