1use serde::{Serialize, Deserialize};
5use serde_json::Value as JsonValue;
6use std::borrow::Cow;
7
8#[derive(Debug, Clone, Serialize, Deserialize, Default)]
11#[serde(rename_all = "camelCase")]
12pub struct DOMNode<'a> {
13 #[serde(rename = "nodeType")]
15 node_type: i64,
16 #[serde(rename = "nodeName")]
18 node_name: Cow<'a, str>,
19 #[serde(rename = "nodeValue")]
21 node_value: Cow<'a, str>,
22 #[serde(skip_serializing_if = "Option::is_none", rename = "textValue")]
24 text_value: Option<Cow<'a, str>>,
25 #[serde(skip_serializing_if = "Option::is_none", rename = "inputValue")]
27 input_value: Option<Cow<'a, str>>,
28 #[serde(skip_serializing_if = "Option::is_none", rename = "inputChecked")]
30 input_checked: Option<bool>,
31 #[serde(skip_serializing_if = "Option::is_none", rename = "optionSelected")]
33 option_selected: Option<bool>,
34 #[serde(rename = "backendNodeId")]
36 backend_node_id: crate::dom::BackendNodeId,
37 #[serde(skip_serializing_if = "Option::is_none", rename = "childNodeIndexes")]
40 child_node_indexes: Option<Vec<i64>>,
41 #[serde(skip_serializing_if = "Option::is_none")]
43 attributes: Option<Vec<NameValue<'a>>>,
44 #[serde(skip_serializing_if = "Option::is_none", rename = "pseudoElementIndexes")]
47 pseudo_element_indexes: Option<Vec<i64>>,
48 #[serde(skip_serializing_if = "Option::is_none", rename = "layoutNodeIndex")]
51 layout_node_index: Option<u64>,
52 #[serde(skip_serializing_if = "Option::is_none", rename = "documentURL")]
54 document_url: Option<Cow<'a, str>>,
55 #[serde(skip_serializing_if = "Option::is_none", rename = "baseURL")]
57 base_url: Option<Cow<'a, str>>,
58 #[serde(skip_serializing_if = "Option::is_none", rename = "contentLanguage")]
60 content_language: Option<Cow<'a, str>>,
61 #[serde(skip_serializing_if = "Option::is_none", rename = "documentEncoding")]
63 document_encoding: Option<Cow<'a, str>>,
64 #[serde(skip_serializing_if = "Option::is_none", rename = "publicId")]
66 public_id: Option<Cow<'a, str>>,
67 #[serde(skip_serializing_if = "Option::is_none", rename = "systemId")]
69 system_id: Option<Cow<'a, str>>,
70 #[serde(skip_serializing_if = "Option::is_none", rename = "frameId")]
72 frame_id: Option<crate::page::FrameId<'a>>,
73 #[serde(skip_serializing_if = "Option::is_none", rename = "contentDocumentIndex")]
76 content_document_index: Option<u64>,
77 #[serde(skip_serializing_if = "Option::is_none", rename = "pseudoType")]
79 pseudo_type: Option<crate::dom::PseudoType>,
80 #[serde(skip_serializing_if = "Option::is_none", rename = "shadowRootType")]
82 shadow_root_type: Option<crate::dom::ShadowRootType>,
83 #[serde(skip_serializing_if = "Option::is_none", rename = "isClickable")]
87 is_clickable: Option<bool>,
88 #[serde(skip_serializing_if = "Option::is_none", rename = "eventListeners")]
90 event_listeners: Option<Vec<crate::domdebugger::EventListener<'a>>>,
91 #[serde(skip_serializing_if = "Option::is_none", rename = "currentSourceURL")]
93 current_source_url: Option<Cow<'a, str>>,
94 #[serde(skip_serializing_if = "Option::is_none", rename = "originURL")]
96 origin_url: Option<Cow<'a, str>>,
97 #[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 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 pub fn node_type(&self) -> i64 { self.node_type }
144 pub fn node_name(&self) -> &str { self.node_name.as_ref() }
146 pub fn node_value(&self) -> &str { self.node_value.as_ref() }
148 pub fn text_value(&self) -> Option<&str> { self.text_value.as_deref() }
150 pub fn input_value(&self) -> Option<&str> { self.input_value.as_deref() }
152 pub fn input_checked(&self) -> Option<bool> { self.input_checked }
154 pub fn option_selected(&self) -> Option<bool> { self.option_selected }
156 pub fn backend_node_id(&self) -> &crate::dom::BackendNodeId { &self.backend_node_id }
158 pub fn child_node_indexes(&self) -> Option<&[i64]> { self.child_node_indexes.as_deref() }
161 pub fn attributes(&self) -> Option<&[NameValue<'a>]> { self.attributes.as_deref() }
163 pub fn pseudo_element_indexes(&self) -> Option<&[i64]> { self.pseudo_element_indexes.as_deref() }
166 pub fn layout_node_index(&self) -> Option<u64> { self.layout_node_index }
169 pub fn document_url(&self) -> Option<&str> { self.document_url.as_deref() }
171 pub fn base_url(&self) -> Option<&str> { self.base_url.as_deref() }
173 pub fn content_language(&self) -> Option<&str> { self.content_language.as_deref() }
175 pub fn document_encoding(&self) -> Option<&str> { self.document_encoding.as_deref() }
177 pub fn public_id(&self) -> Option<&str> { self.public_id.as_deref() }
179 pub fn system_id(&self) -> Option<&str> { self.system_id.as_deref() }
181 pub fn frame_id(&self) -> Option<&crate::page::FrameId<'a>> { self.frame_id.as_ref() }
183 pub fn content_document_index(&self) -> Option<u64> { self.content_document_index }
186 pub fn pseudo_type(&self) -> Option<&crate::dom::PseudoType> { self.pseudo_type.as_ref() }
188 pub fn shadow_root_type(&self) -> Option<&crate::dom::ShadowRootType> { self.shadow_root_type.as_ref() }
190 pub fn is_clickable(&self) -> Option<bool> { self.is_clickable }
194 pub fn event_listeners(&self) -> Option<&[crate::domdebugger::EventListener<'a>]> { self.event_listeners.as_deref() }
196 pub fn current_source_url(&self) -> Option<&str> { self.current_source_url.as_deref() }
198 pub fn origin_url(&self) -> Option<&str> { self.origin_url.as_deref() }
200 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 pub fn text_value(mut self, text_value: impl Into<Cow<'a, str>>) -> Self { self.text_value = Some(text_value.into()); self }
240 pub fn input_value(mut self, input_value: impl Into<Cow<'a, str>>) -> Self { self.input_value = Some(input_value.into()); self }
242 pub fn input_checked(mut self, input_checked: bool) -> Self { self.input_checked = Some(input_checked); self }
244 pub fn option_selected(mut self, option_selected: bool) -> Self { self.option_selected = Some(option_selected); self }
246 pub fn child_node_indexes(mut self, child_node_indexes: Vec<i64>) -> Self { self.child_node_indexes = Some(child_node_indexes); self }
249 pub fn attributes(mut self, attributes: Vec<NameValue<'a>>) -> Self { self.attributes = Some(attributes); self }
251 pub fn pseudo_element_indexes(mut self, pseudo_element_indexes: Vec<i64>) -> Self { self.pseudo_element_indexes = Some(pseudo_element_indexes); self }
254 pub fn layout_node_index(mut self, layout_node_index: u64) -> Self { self.layout_node_index = Some(layout_node_index); self }
257 pub fn document_url(mut self, document_url: impl Into<Cow<'a, str>>) -> Self { self.document_url = Some(document_url.into()); self }
259 pub fn base_url(mut self, base_url: impl Into<Cow<'a, str>>) -> Self { self.base_url = Some(base_url.into()); self }
261 pub fn content_language(mut self, content_language: impl Into<Cow<'a, str>>) -> Self { self.content_language = Some(content_language.into()); self }
263 pub fn document_encoding(mut self, document_encoding: impl Into<Cow<'a, str>>) -> Self { self.document_encoding = Some(document_encoding.into()); self }
265 pub fn public_id(mut self, public_id: impl Into<Cow<'a, str>>) -> Self { self.public_id = Some(public_id.into()); self }
267 pub fn system_id(mut self, system_id: impl Into<Cow<'a, str>>) -> Self { self.system_id = Some(system_id.into()); self }
269 pub fn frame_id(mut self, frame_id: crate::page::FrameId<'a>) -> Self { self.frame_id = Some(frame_id); self }
271 pub fn content_document_index(mut self, content_document_index: u64) -> Self { self.content_document_index = Some(content_document_index); self }
274 pub fn pseudo_type(mut self, pseudo_type: crate::dom::PseudoType) -> Self { self.pseudo_type = Some(pseudo_type); self }
276 pub fn shadow_root_type(mut self, shadow_root_type: crate::dom::ShadowRootType) -> Self { self.shadow_root_type = Some(shadow_root_type); self }
278 pub fn is_clickable(mut self, is_clickable: bool) -> Self { self.is_clickable = Some(is_clickable); self }
282 pub fn event_listeners(mut self, event_listeners: Vec<crate::domdebugger::EventListener<'a>>) -> Self { self.event_listeners = Some(event_listeners); self }
284 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 pub fn origin_url(mut self, origin_url: impl Into<Cow<'a, str>>) -> Self { self.origin_url = Some(origin_url.into()); self }
288 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#[derive(Debug, Clone, Serialize, Deserialize, Default)]
329#[serde(rename_all = "camelCase")]
330pub struct InlineTextBox {
331 #[serde(rename = "boundingBox")]
333 bounding_box: crate::dom::Rect,
334 #[serde(rename = "startCharacterIndex")]
337 start_character_index: u64,
338 #[serde(rename = "numCharacters")]
341 num_characters: i64,
342}
343
344impl InlineTextBox {
345 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 pub fn bounding_box(&self) -> &crate::dom::Rect { &self.bounding_box }
358 pub fn start_character_index(&self) -> u64 { self.start_character_index }
361 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#[derive(Debug, Clone, Serialize, Deserialize, Default)]
386#[serde(rename_all = "camelCase")]
387pub struct LayoutTreeNode<'a> {
388 #[serde(rename = "domNodeIndex")]
390 dom_node_index: u64,
391 #[serde(rename = "boundingBox")]
393 bounding_box: crate::dom::Rect,
394 #[serde(skip_serializing_if = "Option::is_none", rename = "layoutText")]
396 layout_text: Option<Cow<'a, str>>,
397 #[serde(skip_serializing_if = "Option::is_none", rename = "inlineTextNodes")]
399 inline_text_nodes: Option<Vec<InlineTextBox>>,
400 #[serde(skip_serializing_if = "Option::is_none", rename = "styleIndex")]
402 style_index: Option<u64>,
403 #[serde(skip_serializing_if = "Option::is_none", rename = "paintOrder")]
407 paint_order: Option<i64>,
408 #[serde(skip_serializing_if = "Option::is_none", rename = "isStackingContext")]
410 is_stacking_context: Option<bool>,
411}
412
413impl<'a> LayoutTreeNode<'a> {
414 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 pub fn dom_node_index(&self) -> u64 { self.dom_node_index }
430 pub fn bounding_box(&self) -> &crate::dom::Rect { &self.bounding_box }
432 pub fn layout_text(&self) -> Option<&str> { self.layout_text.as_deref() }
434 pub fn inline_text_nodes(&self) -> Option<&[InlineTextBox]> { self.inline_text_nodes.as_deref() }
436 pub fn style_index(&self) -> Option<u64> { self.style_index }
438 pub fn paint_order(&self) -> Option<i64> { self.paint_order }
442 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 pub fn layout_text(mut self, layout_text: impl Into<Cow<'a, str>>) -> Self { self.layout_text = Some(layout_text.into()); self }
460 pub fn inline_text_nodes(mut self, inline_text_nodes: Vec<InlineTextBox>) -> Self { self.inline_text_nodes = Some(inline_text_nodes); self }
462 pub fn style_index(mut self, style_index: u64) -> Self { self.style_index = Some(style_index); self }
464 pub fn paint_order(mut self, paint_order: i64) -> Self { self.paint_order = Some(paint_order); self }
468 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#[derive(Debug, Clone, Serialize, Deserialize, Default)]
486#[serde(rename_all = "camelCase")]
487pub struct ComputedStyle<'a> {
488 properties: Vec<NameValue<'a>>,
490}
491
492impl<'a> ComputedStyle<'a> {
493 pub fn builder(properties: Vec<NameValue<'a>>) -> ComputedStyleBuilder<'a> {
496 ComputedStyleBuilder {
497 properties: properties,
498 }
499 }
500 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#[derive(Debug, Clone, Serialize, Deserialize, Default)]
520#[serde(rename_all = "camelCase")]
521pub struct NameValue<'a> {
522 name: Cow<'a, str>,
524 value: Cow<'a, str>,
526}
527
528impl<'a> NameValue<'a> {
529 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 pub fn name(&self) -> &str { self.name.as_ref() }
540 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
559pub type StringIndex = i64;
562
563pub type ArrayOfStrings = Vec<StringIndex>;
566
567#[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 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 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 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#[derive(Debug, Clone, Serialize, Deserialize, Default)]
679#[serde(rename_all = "camelCase")]
680pub struct DocumentSnapshot {
681 #[serde(rename = "documentURL")]
683 document_url: StringIndex,
684 title: StringIndex,
686 #[serde(rename = "baseURL")]
688 base_url: StringIndex,
689 #[serde(rename = "contentLanguage")]
691 content_language: StringIndex,
692 #[serde(rename = "encodingName")]
694 encoding_name: StringIndex,
695 #[serde(rename = "publicId")]
697 public_id: StringIndex,
698 #[serde(rename = "systemId")]
700 system_id: StringIndex,
701 #[serde(rename = "frameId")]
703 frame_id: StringIndex,
704 nodes: NodeTreeSnapshot,
706 layout: LayoutTreeSnapshot,
708 #[serde(rename = "textBoxes")]
710 text_boxes: TextBoxSnapshot,
711 #[serde(skip_serializing_if = "Option::is_none", rename = "scrollOffsetX")]
713 scroll_offset_x: Option<f64>,
714 #[serde(skip_serializing_if = "Option::is_none", rename = "scrollOffsetY")]
716 scroll_offset_y: Option<f64>,
717 #[serde(skip_serializing_if = "Option::is_none", rename = "contentWidth")]
719 content_width: Option<f64>,
720 #[serde(skip_serializing_if = "Option::is_none", rename = "contentHeight")]
722 content_height: Option<f64>,
723}
724
725impl DocumentSnapshot {
726 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 pub fn document_url(&self) -> &StringIndex { &self.document_url }
759 pub fn title(&self) -> &StringIndex { &self.title }
761 pub fn base_url(&self) -> &StringIndex { &self.base_url }
763 pub fn content_language(&self) -> &StringIndex { &self.content_language }
765 pub fn encoding_name(&self) -> &StringIndex { &self.encoding_name }
767 pub fn public_id(&self) -> &StringIndex { &self.public_id }
769 pub fn system_id(&self) -> &StringIndex { &self.system_id }
771 pub fn frame_id(&self) -> &StringIndex { &self.frame_id }
773 pub fn nodes(&self) -> &NodeTreeSnapshot { &self.nodes }
775 pub fn layout(&self) -> &LayoutTreeSnapshot { &self.layout }
777 pub fn text_boxes(&self) -> &TextBoxSnapshot { &self.text_boxes }
779 pub fn scroll_offset_x(&self) -> Option<f64> { self.scroll_offset_x }
781 pub fn scroll_offset_y(&self) -> Option<f64> { self.scroll_offset_y }
783 pub fn content_width(&self) -> Option<f64> { self.content_width }
785 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 pub fn scroll_offset_x(mut self, scroll_offset_x: f64) -> Self { self.scroll_offset_x = Some(scroll_offset_x); self }
811 pub fn scroll_offset_y(mut self, scroll_offset_y: f64) -> Self { self.scroll_offset_y = Some(scroll_offset_y); self }
813 pub fn content_width(mut self, content_width: f64) -> Self { self.content_width = Some(content_width); self }
815 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#[derive(Debug, Clone, Serialize, Deserialize, Default)]
841#[serde(rename_all = "camelCase")]
842pub struct NodeTreeSnapshot {
843 #[serde(skip_serializing_if = "Option::is_none", rename = "parentIndex")]
845 parent_index: Option<Vec<i64>>,
846 #[serde(skip_serializing_if = "Option::is_none", rename = "nodeType")]
848 node_type: Option<Vec<i64>>,
849 #[serde(skip_serializing_if = "Option::is_none", rename = "shadowRootType")]
851 shadow_root_type: Option<RareStringData>,
852 #[serde(skip_serializing_if = "Option::is_none", rename = "nodeName")]
854 node_name: Option<Vec<StringIndex>>,
855 #[serde(skip_serializing_if = "Option::is_none", rename = "nodeValue")]
857 node_value: Option<Vec<StringIndex>>,
858 #[serde(skip_serializing_if = "Option::is_none", rename = "backendNodeId")]
860 backend_node_id: Option<Vec<crate::dom::BackendNodeId>>,
861 #[serde(skip_serializing_if = "Option::is_none")]
863 attributes: Option<Vec<ArrayOfStrings>>,
864 #[serde(skip_serializing_if = "Option::is_none", rename = "textValue")]
866 text_value: Option<RareStringData>,
867 #[serde(skip_serializing_if = "Option::is_none", rename = "inputValue")]
869 input_value: Option<RareStringData>,
870 #[serde(skip_serializing_if = "Option::is_none", rename = "inputChecked")]
872 input_checked: Option<RareBooleanData>,
873 #[serde(skip_serializing_if = "Option::is_none", rename = "optionSelected")]
875 option_selected: Option<RareBooleanData>,
876 #[serde(skip_serializing_if = "Option::is_none", rename = "contentDocumentIndex")]
878 content_document_index: Option<RareIntegerData>,
879 #[serde(skip_serializing_if = "Option::is_none", rename = "pseudoType")]
881 pseudo_type: Option<RareStringData>,
882 #[serde(skip_serializing_if = "Option::is_none", rename = "pseudoIdentifier")]
885 pseudo_identifier: Option<RareStringData>,
886 #[serde(skip_serializing_if = "Option::is_none", rename = "isClickable")]
890 is_clickable: Option<RareBooleanData>,
891 #[serde(skip_serializing_if = "Option::is_none", rename = "currentSourceURL")]
893 current_source_url: Option<RareStringData>,
894 #[serde(skip_serializing_if = "Option::is_none", rename = "originURL")]
896 origin_url: Option<RareStringData>,
897}
898
899impl NodeTreeSnapshot {
900 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 pub fn parent_index(&self) -> Option<&[i64]> { self.parent_index.as_deref() }
924 pub fn node_type(&self) -> Option<&[i64]> { self.node_type.as_deref() }
926 pub fn shadow_root_type(&self) -> Option<&RareStringData> { self.shadow_root_type.as_ref() }
928 pub fn node_name(&self) -> Option<&[StringIndex]> { self.node_name.as_deref() }
930 pub fn node_value(&self) -> Option<&[StringIndex]> { self.node_value.as_deref() }
932 pub fn backend_node_id(&self) -> Option<&[crate::dom::BackendNodeId]> { self.backend_node_id.as_deref() }
934 pub fn attributes(&self) -> Option<&[ArrayOfStrings]> { self.attributes.as_deref() }
936 pub fn text_value(&self) -> Option<&RareStringData> { self.text_value.as_ref() }
938 pub fn input_value(&self) -> Option<&RareStringData> { self.input_value.as_ref() }
940 pub fn input_checked(&self) -> Option<&RareBooleanData> { self.input_checked.as_ref() }
942 pub fn option_selected(&self) -> Option<&RareBooleanData> { self.option_selected.as_ref() }
944 pub fn content_document_index(&self) -> Option<&RareIntegerData> { self.content_document_index.as_ref() }
946 pub fn pseudo_type(&self) -> Option<&RareStringData> { self.pseudo_type.as_ref() }
948 pub fn pseudo_identifier(&self) -> Option<&RareStringData> { self.pseudo_identifier.as_ref() }
951 pub fn is_clickable(&self) -> Option<&RareBooleanData> { self.is_clickable.as_ref() }
955 pub fn current_source_url(&self) -> Option<&RareStringData> { self.current_source_url.as_ref() }
957 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 pub fn parent_index(mut self, parent_index: Vec<i64>) -> Self { self.parent_index = Some(parent_index); self }
985 pub fn node_type(mut self, node_type: Vec<i64>) -> Self { self.node_type = Some(node_type); self }
987 pub fn shadow_root_type(mut self, shadow_root_type: RareStringData) -> Self { self.shadow_root_type = Some(shadow_root_type); self }
989 pub fn node_name(mut self, node_name: Vec<StringIndex>) -> Self { self.node_name = Some(node_name); self }
991 pub fn node_value(mut self, node_value: Vec<StringIndex>) -> Self { self.node_value = Some(node_value); self }
993 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 pub fn attributes(mut self, attributes: Vec<ArrayOfStrings>) -> Self { self.attributes = Some(attributes); self }
997 pub fn text_value(mut self, text_value: RareStringData) -> Self { self.text_value = Some(text_value); self }
999 pub fn input_value(mut self, input_value: RareStringData) -> Self { self.input_value = Some(input_value); self }
1001 pub fn input_checked(mut self, input_checked: RareBooleanData) -> Self { self.input_checked = Some(input_checked); self }
1003 pub fn option_selected(mut self, option_selected: RareBooleanData) -> Self { self.option_selected = Some(option_selected); self }
1005 pub fn content_document_index(mut self, content_document_index: RareIntegerData) -> Self { self.content_document_index = Some(content_document_index); self }
1007 pub fn pseudo_type(mut self, pseudo_type: RareStringData) -> Self { self.pseudo_type = Some(pseudo_type); self }
1009 pub fn pseudo_identifier(mut self, pseudo_identifier: RareStringData) -> Self { self.pseudo_identifier = Some(pseudo_identifier); self }
1012 pub fn is_clickable(mut self, is_clickable: RareBooleanData) -> Self { self.is_clickable = Some(is_clickable); self }
1016 pub fn current_source_url(mut self, current_source_url: RareStringData) -> Self { self.current_source_url = Some(current_source_url); self }
1018 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#[derive(Debug, Clone, Serialize, Deserialize, Default)]
1046#[serde(rename_all = "camelCase")]
1047pub struct LayoutTreeSnapshot {
1048 #[serde(rename = "nodeIndex")]
1050 node_index: Vec<i64>,
1051 styles: Vec<ArrayOfStrings>,
1053 bounds: Vec<Rectangle>,
1055 text: Vec<StringIndex>,
1057 #[serde(rename = "stackingContexts")]
1059 stacking_contexts: RareBooleanData,
1060 #[serde(skip_serializing_if = "Option::is_none", rename = "paintOrders")]
1064 paint_orders: Option<Vec<i64>>,
1065 #[serde(skip_serializing_if = "Option::is_none", rename = "offsetRects")]
1067 offset_rects: Option<Vec<Rectangle>>,
1068 #[serde(skip_serializing_if = "Option::is_none", rename = "scrollRects")]
1070 scroll_rects: Option<Vec<Rectangle>>,
1071 #[serde(skip_serializing_if = "Option::is_none", rename = "clientRects")]
1073 client_rects: Option<Vec<Rectangle>>,
1074 #[serde(skip_serializing_if = "Option::is_none", rename = "blendedBackgroundColors")]
1076 blended_background_colors: Option<Vec<StringIndex>>,
1077 #[serde(skip_serializing_if = "Option::is_none", rename = "textColorOpacities")]
1079 text_color_opacities: Option<Vec<f64>>,
1080}
1081
1082impl LayoutTreeSnapshot {
1083 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 pub fn node_index(&self) -> &[i64] { &self.node_index }
1106 pub fn styles(&self) -> &[ArrayOfStrings] { &self.styles }
1108 pub fn bounds(&self) -> &[Rectangle] { &self.bounds }
1110 pub fn text(&self) -> &[StringIndex] { &self.text }
1112 pub fn stacking_contexts(&self) -> &RareBooleanData { &self.stacking_contexts }
1114 pub fn paint_orders(&self) -> Option<&[i64]> { self.paint_orders.as_deref() }
1118 pub fn offset_rects(&self) -> Option<&[Rectangle]> { self.offset_rects.as_deref() }
1120 pub fn scroll_rects(&self) -> Option<&[Rectangle]> { self.scroll_rects.as_deref() }
1122 pub fn client_rects(&self) -> Option<&[Rectangle]> { self.client_rects.as_deref() }
1124 pub fn blended_background_colors(&self) -> Option<&[StringIndex]> { self.blended_background_colors.as_deref() }
1126 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 pub fn paint_orders(mut self, paint_orders: Vec<i64>) -> Self { self.paint_orders = Some(paint_orders); self }
1150 pub fn offset_rects(mut self, offset_rects: Vec<Rectangle>) -> Self { self.offset_rects = Some(offset_rects); self }
1152 pub fn scroll_rects(mut self, scroll_rects: Vec<Rectangle>) -> Self { self.scroll_rects = Some(scroll_rects); self }
1154 pub fn client_rects(mut self, client_rects: Vec<Rectangle>) -> Self { self.client_rects = Some(client_rects); self }
1156 pub fn blended_background_colors(mut self, blended_background_colors: Vec<StringIndex>) -> Self { self.blended_background_colors = Some(blended_background_colors); self }
1158 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#[derive(Debug, Clone, Serialize, Deserialize, Default)]
1181#[serde(rename_all = "camelCase")]
1182pub struct TextBoxSnapshot {
1183 #[serde(rename = "layoutIndex")]
1185 layout_index: Vec<i64>,
1186 bounds: Vec<Rectangle>,
1188 start: Vec<i64>,
1191 length: Vec<i64>,
1194}
1195
1196impl TextBoxSnapshot {
1197 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 pub fn layout_index(&self) -> &[i64] { &self.layout_index }
1212 pub fn bounds(&self) -> &[Rectangle] { &self.bounds }
1214 pub fn start(&self) -> &[i64] { &self.start }
1217 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#[derive(Debug, Clone, Serialize, Deserialize, Default)]
1267#[serde(rename_all = "camelCase")]
1268pub struct GetSnapshotParams<'a> {
1269 #[serde(rename = "computedStyleWhitelist")]
1271 computed_style_whitelist: Vec<Cow<'a, str>>,
1272 #[serde(skip_serializing_if = "Option::is_none", rename = "includeEventListeners")]
1274 include_event_listeners: Option<bool>,
1275 #[serde(skip_serializing_if = "Option::is_none", rename = "includePaintOrder")]
1277 include_paint_order: Option<bool>,
1278 #[serde(skip_serializing_if = "Option::is_none", rename = "includeUserAgentShadowTree")]
1280 include_user_agent_shadow_tree: Option<bool>,
1281}
1282
1283impl<'a> GetSnapshotParams<'a> {
1284 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 pub fn computed_style_whitelist(&self) -> &[Cow<'a, str>] { &self.computed_style_whitelist }
1296 pub fn include_event_listeners(&self) -> Option<bool> { self.include_event_listeners }
1298 pub fn include_paint_order(&self) -> Option<bool> { self.include_paint_order }
1300 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 pub fn include_event_listeners(mut self, include_event_listeners: bool) -> Self { self.include_event_listeners = Some(include_event_listeners); self }
1315 pub fn include_paint_order(mut self, include_paint_order: bool) -> Self { self.include_paint_order = Some(include_paint_order); self }
1317 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#[derive(Debug, Clone, Serialize, Deserialize, Default)]
1335#[serde(rename_all = "camelCase")]
1336pub struct GetSnapshotReturns<'a> {
1337 #[serde(rename = "domNodes")]
1339 dom_nodes: Vec<DOMNode<'a>>,
1340 #[serde(rename = "layoutTreeNodes")]
1342 layout_tree_nodes: Vec<LayoutTreeNode<'a>>,
1343 #[serde(rename = "computedStyles")]
1345 computed_styles: Vec<ComputedStyle<'a>>,
1346}
1347
1348impl<'a> GetSnapshotReturns<'a> {
1349 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 pub fn dom_nodes(&self) -> &[DOMNode<'a>] { &self.dom_nodes }
1362 pub fn layout_tree_nodes(&self) -> &[LayoutTreeNode<'a>] { &self.layout_tree_nodes }
1364 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#[derive(Debug, Clone, Serialize, Deserialize, Default)]
1398#[serde(rename_all = "camelCase")]
1399pub struct CaptureSnapshotParams<'a> {
1400 #[serde(rename = "computedStyles")]
1402 computed_styles: Vec<Cow<'a, str>>,
1403 #[serde(skip_serializing_if = "Option::is_none", rename = "includePaintOrder")]
1405 include_paint_order: Option<bool>,
1406 #[serde(skip_serializing_if = "Option::is_none", rename = "includeDOMRects")]
1408 include_dom_rects: Option<bool>,
1409 #[serde(skip_serializing_if = "Option::is_none", rename = "includeBlendedBackgroundColors")]
1413 include_blended_background_colors: Option<bool>,
1414 #[serde(skip_serializing_if = "Option::is_none", rename = "includeTextColorOpacities")]
1418 include_text_color_opacities: Option<bool>,
1419}
1420
1421impl<'a> CaptureSnapshotParams<'a> {
1422 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 pub fn computed_styles(&self) -> &[Cow<'a, str>] { &self.computed_styles }
1435 pub fn include_paint_order(&self) -> Option<bool> { self.include_paint_order }
1437 pub fn include_dom_rects(&self) -> Option<bool> { self.include_dom_rects }
1439 pub fn include_blended_background_colors(&self) -> Option<bool> { self.include_blended_background_colors }
1443 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 pub fn include_paint_order(mut self, include_paint_order: bool) -> Self { self.include_paint_order = Some(include_paint_order); self }
1461 pub fn include_dom_rects(mut self, include_dom_rects: bool) -> Self { self.include_dom_rects = Some(include_dom_rects); self }
1463 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 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#[derive(Debug, Clone, Serialize, Deserialize, Default)]
1488#[serde(rename_all = "camelCase")]
1489pub struct CaptureSnapshotReturns<'a> {
1490 documents: Vec<DocumentSnapshot>,
1492 strings: Vec<Cow<'a, str>>,
1494}
1495
1496impl<'a> CaptureSnapshotReturns<'a> {
1497 pub fn builder(documents: Vec<DocumentSnapshot>, strings: Vec<Cow<'a, str>>) -> CaptureSnapshotReturnsBuilder<'a> {
1501 CaptureSnapshotReturnsBuilder {
1502 documents: documents,
1503 strings: strings,
1504 }
1505 }
1506 pub fn documents(&self) -> &[DocumentSnapshot] { &self.documents }
1508 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}