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 nodeType: i64,
15 nodeName: Cow<'a, str>,
17 nodeValue: Cow<'a, str>,
19 #[serde(skip_serializing_if = "Option::is_none")]
21 textValue: Option<Cow<'a, str>>,
22 #[serde(skip_serializing_if = "Option::is_none")]
24 inputValue: Option<Cow<'a, str>>,
25 #[serde(skip_serializing_if = "Option::is_none")]
27 inputChecked: Option<bool>,
28 #[serde(skip_serializing_if = "Option::is_none")]
30 optionSelected: Option<bool>,
31 backendNodeId: crate::dom::BackendNodeId,
33 #[serde(skip_serializing_if = "Option::is_none")]
36 childNodeIndexes: Option<Vec<i64>>,
37 #[serde(skip_serializing_if = "Option::is_none")]
39 attributes: Option<Vec<NameValue<'a>>>,
40 #[serde(skip_serializing_if = "Option::is_none")]
43 pseudoElementIndexes: Option<Vec<i64>>,
44 #[serde(skip_serializing_if = "Option::is_none")]
47 layoutNodeIndex: Option<u64>,
48 #[serde(skip_serializing_if = "Option::is_none")]
50 documentURL: Option<Cow<'a, str>>,
51 #[serde(skip_serializing_if = "Option::is_none")]
53 baseURL: Option<Cow<'a, str>>,
54 #[serde(skip_serializing_if = "Option::is_none")]
56 contentLanguage: Option<Cow<'a, str>>,
57 #[serde(skip_serializing_if = "Option::is_none")]
59 documentEncoding: Option<Cow<'a, str>>,
60 #[serde(skip_serializing_if = "Option::is_none")]
62 publicId: Option<Cow<'a, str>>,
63 #[serde(skip_serializing_if = "Option::is_none")]
65 systemId: Option<Cow<'a, str>>,
66 #[serde(skip_serializing_if = "Option::is_none")]
68 frameId: Option<crate::page::FrameId<'a>>,
69 #[serde(skip_serializing_if = "Option::is_none")]
72 contentDocumentIndex: Option<u64>,
73 #[serde(skip_serializing_if = "Option::is_none")]
75 pseudoType: Option<crate::dom::PseudoType>,
76 #[serde(skip_serializing_if = "Option::is_none")]
78 shadowRootType: Option<crate::dom::ShadowRootType>,
79 #[serde(skip_serializing_if = "Option::is_none")]
83 isClickable: Option<bool>,
84 #[serde(skip_serializing_if = "Option::is_none")]
86 eventListeners: Option<Vec<crate::domdebugger::EventListener<'a>>>,
87 #[serde(skip_serializing_if = "Option::is_none")]
89 currentSourceURL: Option<Cow<'a, str>>,
90 #[serde(skip_serializing_if = "Option::is_none")]
92 originURL: Option<Cow<'a, str>>,
93 #[serde(skip_serializing_if = "Option::is_none")]
95 scrollOffsetX: Option<f64>,
96 #[serde(skip_serializing_if = "Option::is_none")]
97 scrollOffsetY: Option<f64>,
98}
99
100impl<'a> DOMNode<'a> {
101 pub fn builder(nodeType: i64, nodeName: impl Into<Cow<'a, str>>, nodeValue: impl Into<Cow<'a, str>>, backendNodeId: crate::dom::BackendNodeId) -> DOMNodeBuilder<'a> {
102 DOMNodeBuilder {
103 nodeType: nodeType,
104 nodeName: nodeName.into(),
105 nodeValue: nodeValue.into(),
106 textValue: None,
107 inputValue: None,
108 inputChecked: None,
109 optionSelected: None,
110 backendNodeId: backendNodeId,
111 childNodeIndexes: None,
112 attributes: None,
113 pseudoElementIndexes: None,
114 layoutNodeIndex: None,
115 documentURL: None,
116 baseURL: None,
117 contentLanguage: None,
118 documentEncoding: None,
119 publicId: None,
120 systemId: None,
121 frameId: None,
122 contentDocumentIndex: None,
123 pseudoType: None,
124 shadowRootType: None,
125 isClickable: None,
126 eventListeners: None,
127 currentSourceURL: None,
128 originURL: None,
129 scrollOffsetX: None,
130 scrollOffsetY: None,
131 }
132 }
133 pub fn nodeType(&self) -> i64 { self.nodeType }
134 pub fn nodeName(&self) -> &str { self.nodeName.as_ref() }
135 pub fn nodeValue(&self) -> &str { self.nodeValue.as_ref() }
136 pub fn textValue(&self) -> Option<&str> { self.textValue.as_deref() }
137 pub fn inputValue(&self) -> Option<&str> { self.inputValue.as_deref() }
138 pub fn inputChecked(&self) -> Option<bool> { self.inputChecked }
139 pub fn optionSelected(&self) -> Option<bool> { self.optionSelected }
140 pub fn backendNodeId(&self) -> &crate::dom::BackendNodeId { &self.backendNodeId }
141 pub fn childNodeIndexes(&self) -> Option<&[i64]> { self.childNodeIndexes.as_deref() }
142 pub fn attributes(&self) -> Option<&[NameValue<'a>]> { self.attributes.as_deref() }
143 pub fn pseudoElementIndexes(&self) -> Option<&[i64]> { self.pseudoElementIndexes.as_deref() }
144 pub fn layoutNodeIndex(&self) -> Option<u64> { self.layoutNodeIndex }
145 pub fn documentURL(&self) -> Option<&str> { self.documentURL.as_deref() }
146 pub fn baseURL(&self) -> Option<&str> { self.baseURL.as_deref() }
147 pub fn contentLanguage(&self) -> Option<&str> { self.contentLanguage.as_deref() }
148 pub fn documentEncoding(&self) -> Option<&str> { self.documentEncoding.as_deref() }
149 pub fn publicId(&self) -> Option<&str> { self.publicId.as_deref() }
150 pub fn systemId(&self) -> Option<&str> { self.systemId.as_deref() }
151 pub fn frameId(&self) -> Option<&crate::page::FrameId<'a>> { self.frameId.as_ref() }
152 pub fn contentDocumentIndex(&self) -> Option<u64> { self.contentDocumentIndex }
153 pub fn pseudoType(&self) -> Option<&crate::dom::PseudoType> { self.pseudoType.as_ref() }
154 pub fn shadowRootType(&self) -> Option<&crate::dom::ShadowRootType> { self.shadowRootType.as_ref() }
155 pub fn isClickable(&self) -> Option<bool> { self.isClickable }
156 pub fn eventListeners(&self) -> Option<&[crate::domdebugger::EventListener<'a>]> { self.eventListeners.as_deref() }
157 pub fn currentSourceURL(&self) -> Option<&str> { self.currentSourceURL.as_deref() }
158 pub fn originURL(&self) -> Option<&str> { self.originURL.as_deref() }
159 pub fn scrollOffsetX(&self) -> Option<f64> { self.scrollOffsetX }
160 pub fn scrollOffsetY(&self) -> Option<f64> { self.scrollOffsetY }
161}
162
163
164pub struct DOMNodeBuilder<'a> {
165 nodeType: i64,
166 nodeName: Cow<'a, str>,
167 nodeValue: Cow<'a, str>,
168 textValue: Option<Cow<'a, str>>,
169 inputValue: Option<Cow<'a, str>>,
170 inputChecked: Option<bool>,
171 optionSelected: Option<bool>,
172 backendNodeId: crate::dom::BackendNodeId,
173 childNodeIndexes: Option<Vec<i64>>,
174 attributes: Option<Vec<NameValue<'a>>>,
175 pseudoElementIndexes: Option<Vec<i64>>,
176 layoutNodeIndex: Option<u64>,
177 documentURL: Option<Cow<'a, str>>,
178 baseURL: Option<Cow<'a, str>>,
179 contentLanguage: Option<Cow<'a, str>>,
180 documentEncoding: Option<Cow<'a, str>>,
181 publicId: Option<Cow<'a, str>>,
182 systemId: Option<Cow<'a, str>>,
183 frameId: Option<crate::page::FrameId<'a>>,
184 contentDocumentIndex: Option<u64>,
185 pseudoType: Option<crate::dom::PseudoType>,
186 shadowRootType: Option<crate::dom::ShadowRootType>,
187 isClickable: Option<bool>,
188 eventListeners: Option<Vec<crate::domdebugger::EventListener<'a>>>,
189 currentSourceURL: Option<Cow<'a, str>>,
190 originURL: Option<Cow<'a, str>>,
191 scrollOffsetX: Option<f64>,
192 scrollOffsetY: Option<f64>,
193}
194
195impl<'a> DOMNodeBuilder<'a> {
196 pub fn textValue(mut self, textValue: impl Into<Cow<'a, str>>) -> Self { self.textValue = Some(textValue.into()); self }
198 pub fn inputValue(mut self, inputValue: impl Into<Cow<'a, str>>) -> Self { self.inputValue = Some(inputValue.into()); self }
200 pub fn inputChecked(mut self, inputChecked: bool) -> Self { self.inputChecked = Some(inputChecked); self }
202 pub fn optionSelected(mut self, optionSelected: bool) -> Self { self.optionSelected = Some(optionSelected); self }
204 pub fn childNodeIndexes(mut self, childNodeIndexes: Vec<i64>) -> Self { self.childNodeIndexes = Some(childNodeIndexes); self }
207 pub fn attributes(mut self, attributes: Vec<NameValue<'a>>) -> Self { self.attributes = Some(attributes); self }
209 pub fn pseudoElementIndexes(mut self, pseudoElementIndexes: Vec<i64>) -> Self { self.pseudoElementIndexes = Some(pseudoElementIndexes); self }
212 pub fn layoutNodeIndex(mut self, layoutNodeIndex: u64) -> Self { self.layoutNodeIndex = Some(layoutNodeIndex); self }
215 pub fn documentURL(mut self, documentURL: impl Into<Cow<'a, str>>) -> Self { self.documentURL = Some(documentURL.into()); self }
217 pub fn baseURL(mut self, baseURL: impl Into<Cow<'a, str>>) -> Self { self.baseURL = Some(baseURL.into()); self }
219 pub fn contentLanguage(mut self, contentLanguage: impl Into<Cow<'a, str>>) -> Self { self.contentLanguage = Some(contentLanguage.into()); self }
221 pub fn documentEncoding(mut self, documentEncoding: impl Into<Cow<'a, str>>) -> Self { self.documentEncoding = Some(documentEncoding.into()); self }
223 pub fn publicId(mut self, publicId: impl Into<Cow<'a, str>>) -> Self { self.publicId = Some(publicId.into()); self }
225 pub fn systemId(mut self, systemId: impl Into<Cow<'a, str>>) -> Self { self.systemId = Some(systemId.into()); self }
227 pub fn frameId(mut self, frameId: crate::page::FrameId<'a>) -> Self { self.frameId = Some(frameId); self }
229 pub fn contentDocumentIndex(mut self, contentDocumentIndex: u64) -> Self { self.contentDocumentIndex = Some(contentDocumentIndex); self }
232 pub fn pseudoType(mut self, pseudoType: crate::dom::PseudoType) -> Self { self.pseudoType = Some(pseudoType); self }
234 pub fn shadowRootType(mut self, shadowRootType: crate::dom::ShadowRootType) -> Self { self.shadowRootType = Some(shadowRootType); self }
236 pub fn isClickable(mut self, isClickable: bool) -> Self { self.isClickable = Some(isClickable); self }
240 pub fn eventListeners(mut self, eventListeners: Vec<crate::domdebugger::EventListener<'a>>) -> Self { self.eventListeners = Some(eventListeners); self }
242 pub fn currentSourceURL(mut self, currentSourceURL: impl Into<Cow<'a, str>>) -> Self { self.currentSourceURL = Some(currentSourceURL.into()); self }
244 pub fn originURL(mut self, originURL: impl Into<Cow<'a, str>>) -> Self { self.originURL = Some(originURL.into()); self }
246 pub fn scrollOffsetX(mut self, scrollOffsetX: f64) -> Self { self.scrollOffsetX = Some(scrollOffsetX); self }
248 pub fn scrollOffsetY(mut self, scrollOffsetY: f64) -> Self { self.scrollOffsetY = Some(scrollOffsetY); self }
249 pub fn build(self) -> DOMNode<'a> {
250 DOMNode {
251 nodeType: self.nodeType,
252 nodeName: self.nodeName,
253 nodeValue: self.nodeValue,
254 textValue: self.textValue,
255 inputValue: self.inputValue,
256 inputChecked: self.inputChecked,
257 optionSelected: self.optionSelected,
258 backendNodeId: self.backendNodeId,
259 childNodeIndexes: self.childNodeIndexes,
260 attributes: self.attributes,
261 pseudoElementIndexes: self.pseudoElementIndexes,
262 layoutNodeIndex: self.layoutNodeIndex,
263 documentURL: self.documentURL,
264 baseURL: self.baseURL,
265 contentLanguage: self.contentLanguage,
266 documentEncoding: self.documentEncoding,
267 publicId: self.publicId,
268 systemId: self.systemId,
269 frameId: self.frameId,
270 contentDocumentIndex: self.contentDocumentIndex,
271 pseudoType: self.pseudoType,
272 shadowRootType: self.shadowRootType,
273 isClickable: self.isClickable,
274 eventListeners: self.eventListeners,
275 currentSourceURL: self.currentSourceURL,
276 originURL: self.originURL,
277 scrollOffsetX: self.scrollOffsetX,
278 scrollOffsetY: self.scrollOffsetY,
279 }
280 }
281}
282
283#[derive(Debug, Clone, Serialize, Deserialize, Default)]
287#[serde(rename_all = "camelCase")]
288pub struct InlineTextBox {
289 boundingBox: crate::dom::Rect,
291 startCharacterIndex: u64,
294 numCharacters: i64,
297}
298
299impl InlineTextBox {
300 pub fn builder(boundingBox: crate::dom::Rect, startCharacterIndex: u64, numCharacters: i64) -> InlineTextBoxBuilder {
301 InlineTextBoxBuilder {
302 boundingBox: boundingBox,
303 startCharacterIndex: startCharacterIndex,
304 numCharacters: numCharacters,
305 }
306 }
307 pub fn boundingBox(&self) -> &crate::dom::Rect { &self.boundingBox }
308 pub fn startCharacterIndex(&self) -> u64 { self.startCharacterIndex }
309 pub fn numCharacters(&self) -> i64 { self.numCharacters }
310}
311
312
313pub struct InlineTextBoxBuilder {
314 boundingBox: crate::dom::Rect,
315 startCharacterIndex: u64,
316 numCharacters: i64,
317}
318
319impl InlineTextBoxBuilder {
320 pub fn build(self) -> InlineTextBox {
321 InlineTextBox {
322 boundingBox: self.boundingBox,
323 startCharacterIndex: self.startCharacterIndex,
324 numCharacters: self.numCharacters,
325 }
326 }
327}
328
329#[derive(Debug, Clone, Serialize, Deserialize, Default)]
332#[serde(rename_all = "camelCase")]
333pub struct LayoutTreeNode<'a> {
334 domNodeIndex: u64,
336 boundingBox: crate::dom::Rect,
338 #[serde(skip_serializing_if = "Option::is_none")]
340 layoutText: Option<Cow<'a, str>>,
341 #[serde(skip_serializing_if = "Option::is_none")]
343 inlineTextNodes: Option<Vec<InlineTextBox>>,
344 #[serde(skip_serializing_if = "Option::is_none")]
346 styleIndex: Option<u64>,
347 #[serde(skip_serializing_if = "Option::is_none")]
351 paintOrder: Option<i64>,
352 #[serde(skip_serializing_if = "Option::is_none")]
354 isStackingContext: Option<bool>,
355}
356
357impl<'a> LayoutTreeNode<'a> {
358 pub fn builder(domNodeIndex: u64, boundingBox: crate::dom::Rect) -> LayoutTreeNodeBuilder<'a> {
359 LayoutTreeNodeBuilder {
360 domNodeIndex: domNodeIndex,
361 boundingBox: boundingBox,
362 layoutText: None,
363 inlineTextNodes: None,
364 styleIndex: None,
365 paintOrder: None,
366 isStackingContext: None,
367 }
368 }
369 pub fn domNodeIndex(&self) -> u64 { self.domNodeIndex }
370 pub fn boundingBox(&self) -> &crate::dom::Rect { &self.boundingBox }
371 pub fn layoutText(&self) -> Option<&str> { self.layoutText.as_deref() }
372 pub fn inlineTextNodes(&self) -> Option<&[InlineTextBox]> { self.inlineTextNodes.as_deref() }
373 pub fn styleIndex(&self) -> Option<u64> { self.styleIndex }
374 pub fn paintOrder(&self) -> Option<i64> { self.paintOrder }
375 pub fn isStackingContext(&self) -> Option<bool> { self.isStackingContext }
376}
377
378
379pub struct LayoutTreeNodeBuilder<'a> {
380 domNodeIndex: u64,
381 boundingBox: crate::dom::Rect,
382 layoutText: Option<Cow<'a, str>>,
383 inlineTextNodes: Option<Vec<InlineTextBox>>,
384 styleIndex: Option<u64>,
385 paintOrder: Option<i64>,
386 isStackingContext: Option<bool>,
387}
388
389impl<'a> LayoutTreeNodeBuilder<'a> {
390 pub fn layoutText(mut self, layoutText: impl Into<Cow<'a, str>>) -> Self { self.layoutText = Some(layoutText.into()); self }
392 pub fn inlineTextNodes(mut self, inlineTextNodes: Vec<InlineTextBox>) -> Self { self.inlineTextNodes = Some(inlineTextNodes); self }
394 pub fn styleIndex(mut self, styleIndex: u64) -> Self { self.styleIndex = Some(styleIndex); self }
396 pub fn paintOrder(mut self, paintOrder: i64) -> Self { self.paintOrder = Some(paintOrder); self }
400 pub fn isStackingContext(mut self, isStackingContext: bool) -> Self { self.isStackingContext = Some(isStackingContext); self }
402 pub fn build(self) -> LayoutTreeNode<'a> {
403 LayoutTreeNode {
404 domNodeIndex: self.domNodeIndex,
405 boundingBox: self.boundingBox,
406 layoutText: self.layoutText,
407 inlineTextNodes: self.inlineTextNodes,
408 styleIndex: self.styleIndex,
409 paintOrder: self.paintOrder,
410 isStackingContext: self.isStackingContext,
411 }
412 }
413}
414
415#[derive(Debug, Clone, Serialize, Deserialize, Default)]
418#[serde(rename_all = "camelCase")]
419pub struct ComputedStyle<'a> {
420 properties: Vec<NameValue<'a>>,
422}
423
424impl<'a> ComputedStyle<'a> {
425 pub fn builder(properties: Vec<NameValue<'a>>) -> ComputedStyleBuilder<'a> {
426 ComputedStyleBuilder {
427 properties: properties,
428 }
429 }
430 pub fn properties(&self) -> &[NameValue<'a>] { &self.properties }
431}
432
433
434pub struct ComputedStyleBuilder<'a> {
435 properties: Vec<NameValue<'a>>,
436}
437
438impl<'a> ComputedStyleBuilder<'a> {
439 pub fn build(self) -> ComputedStyle<'a> {
440 ComputedStyle {
441 properties: self.properties,
442 }
443 }
444}
445
446#[derive(Debug, Clone, Serialize, Deserialize, Default)]
449#[serde(rename_all = "camelCase")]
450pub struct NameValue<'a> {
451 name: Cow<'a, str>,
453 value: Cow<'a, str>,
455}
456
457impl<'a> NameValue<'a> {
458 pub fn builder(name: impl Into<Cow<'a, str>>, value: impl Into<Cow<'a, str>>) -> NameValueBuilder<'a> {
459 NameValueBuilder {
460 name: name.into(),
461 value: value.into(),
462 }
463 }
464 pub fn name(&self) -> &str { self.name.as_ref() }
465 pub fn value(&self) -> &str { self.value.as_ref() }
466}
467
468
469pub struct NameValueBuilder<'a> {
470 name: Cow<'a, str>,
471 value: Cow<'a, str>,
472}
473
474impl<'a> NameValueBuilder<'a> {
475 pub fn build(self) -> NameValue<'a> {
476 NameValue {
477 name: self.name,
478 value: self.value,
479 }
480 }
481}
482
483pub type StringIndex = i64;
486
487pub type ArrayOfStrings = Vec<StringIndex>;
490
491#[derive(Debug, Clone, Serialize, Deserialize, Default)]
494#[serde(rename_all = "camelCase")]
495pub struct RareStringData {
496 index: Vec<i64>,
497 value: Vec<StringIndex>,
498}
499
500impl RareStringData {
501 pub fn builder(index: Vec<i64>, value: Vec<StringIndex>) -> RareStringDataBuilder {
502 RareStringDataBuilder {
503 index: index,
504 value: value,
505 }
506 }
507 pub fn index(&self) -> &[i64] { &self.index }
508 pub fn value(&self) -> &[StringIndex] { &self.value }
509}
510
511
512pub struct RareStringDataBuilder {
513 index: Vec<i64>,
514 value: Vec<StringIndex>,
515}
516
517impl RareStringDataBuilder {
518 pub fn build(self) -> RareStringData {
519 RareStringData {
520 index: self.index,
521 value: self.value,
522 }
523 }
524}
525
526
527#[derive(Debug, Clone, Serialize, Deserialize, Default)]
528#[serde(rename_all = "camelCase")]
529pub struct RareBooleanData {
530 index: Vec<i64>,
531}
532
533impl RareBooleanData {
534 pub fn builder(index: Vec<i64>) -> RareBooleanDataBuilder {
535 RareBooleanDataBuilder {
536 index: index,
537 }
538 }
539 pub fn index(&self) -> &[i64] { &self.index }
540}
541
542
543pub struct RareBooleanDataBuilder {
544 index: Vec<i64>,
545}
546
547impl RareBooleanDataBuilder {
548 pub fn build(self) -> RareBooleanData {
549 RareBooleanData {
550 index: self.index,
551 }
552 }
553}
554
555
556#[derive(Debug, Clone, Serialize, Deserialize, Default)]
557#[serde(rename_all = "camelCase")]
558pub struct RareIntegerData {
559 index: Vec<i64>,
560 value: Vec<i64>,
561}
562
563impl RareIntegerData {
564 pub fn builder(index: Vec<i64>, value: Vec<i64>) -> RareIntegerDataBuilder {
565 RareIntegerDataBuilder {
566 index: index,
567 value: value,
568 }
569 }
570 pub fn index(&self) -> &[i64] { &self.index }
571 pub fn value(&self) -> &[i64] { &self.value }
572}
573
574
575pub struct RareIntegerDataBuilder {
576 index: Vec<i64>,
577 value: Vec<i64>,
578}
579
580impl RareIntegerDataBuilder {
581 pub fn build(self) -> RareIntegerData {
582 RareIntegerData {
583 index: self.index,
584 value: self.value,
585 }
586 }
587}
588
589
590pub type Rectangle = Vec<f64>;
591
592#[derive(Debug, Clone, Serialize, Deserialize, Default)]
595#[serde(rename_all = "camelCase")]
596pub struct DocumentSnapshot {
597 documentURL: StringIndex,
599 title: StringIndex,
601 baseURL: StringIndex,
603 contentLanguage: StringIndex,
605 encodingName: StringIndex,
607 publicId: StringIndex,
609 systemId: StringIndex,
611 frameId: StringIndex,
613 nodes: NodeTreeSnapshot,
615 layout: LayoutTreeSnapshot,
617 textBoxes: TextBoxSnapshot,
619 #[serde(skip_serializing_if = "Option::is_none")]
621 scrollOffsetX: Option<f64>,
622 #[serde(skip_serializing_if = "Option::is_none")]
624 scrollOffsetY: Option<f64>,
625 #[serde(skip_serializing_if = "Option::is_none")]
627 contentWidth: Option<f64>,
628 #[serde(skip_serializing_if = "Option::is_none")]
630 contentHeight: Option<f64>,
631}
632
633impl DocumentSnapshot {
634 pub fn builder(documentURL: StringIndex, title: StringIndex, baseURL: StringIndex, contentLanguage: StringIndex, encodingName: StringIndex, publicId: StringIndex, systemId: StringIndex, frameId: StringIndex, nodes: NodeTreeSnapshot, layout: LayoutTreeSnapshot, textBoxes: TextBoxSnapshot) -> DocumentSnapshotBuilder {
635 DocumentSnapshotBuilder {
636 documentURL: documentURL,
637 title: title,
638 baseURL: baseURL,
639 contentLanguage: contentLanguage,
640 encodingName: encodingName,
641 publicId: publicId,
642 systemId: systemId,
643 frameId: frameId,
644 nodes: nodes,
645 layout: layout,
646 textBoxes: textBoxes,
647 scrollOffsetX: None,
648 scrollOffsetY: None,
649 contentWidth: None,
650 contentHeight: None,
651 }
652 }
653 pub fn documentURL(&self) -> &StringIndex { &self.documentURL }
654 pub fn title(&self) -> &StringIndex { &self.title }
655 pub fn baseURL(&self) -> &StringIndex { &self.baseURL }
656 pub fn contentLanguage(&self) -> &StringIndex { &self.contentLanguage }
657 pub fn encodingName(&self) -> &StringIndex { &self.encodingName }
658 pub fn publicId(&self) -> &StringIndex { &self.publicId }
659 pub fn systemId(&self) -> &StringIndex { &self.systemId }
660 pub fn frameId(&self) -> &StringIndex { &self.frameId }
661 pub fn nodes(&self) -> &NodeTreeSnapshot { &self.nodes }
662 pub fn layout(&self) -> &LayoutTreeSnapshot { &self.layout }
663 pub fn textBoxes(&self) -> &TextBoxSnapshot { &self.textBoxes }
664 pub fn scrollOffsetX(&self) -> Option<f64> { self.scrollOffsetX }
665 pub fn scrollOffsetY(&self) -> Option<f64> { self.scrollOffsetY }
666 pub fn contentWidth(&self) -> Option<f64> { self.contentWidth }
667 pub fn contentHeight(&self) -> Option<f64> { self.contentHeight }
668}
669
670
671pub struct DocumentSnapshotBuilder {
672 documentURL: StringIndex,
673 title: StringIndex,
674 baseURL: StringIndex,
675 contentLanguage: StringIndex,
676 encodingName: StringIndex,
677 publicId: StringIndex,
678 systemId: StringIndex,
679 frameId: StringIndex,
680 nodes: NodeTreeSnapshot,
681 layout: LayoutTreeSnapshot,
682 textBoxes: TextBoxSnapshot,
683 scrollOffsetX: Option<f64>,
684 scrollOffsetY: Option<f64>,
685 contentWidth: Option<f64>,
686 contentHeight: Option<f64>,
687}
688
689impl DocumentSnapshotBuilder {
690 pub fn scrollOffsetX(mut self, scrollOffsetX: f64) -> Self { self.scrollOffsetX = Some(scrollOffsetX); self }
692 pub fn scrollOffsetY(mut self, scrollOffsetY: f64) -> Self { self.scrollOffsetY = Some(scrollOffsetY); self }
694 pub fn contentWidth(mut self, contentWidth: f64) -> Self { self.contentWidth = Some(contentWidth); self }
696 pub fn contentHeight(mut self, contentHeight: f64) -> Self { self.contentHeight = Some(contentHeight); self }
698 pub fn build(self) -> DocumentSnapshot {
699 DocumentSnapshot {
700 documentURL: self.documentURL,
701 title: self.title,
702 baseURL: self.baseURL,
703 contentLanguage: self.contentLanguage,
704 encodingName: self.encodingName,
705 publicId: self.publicId,
706 systemId: self.systemId,
707 frameId: self.frameId,
708 nodes: self.nodes,
709 layout: self.layout,
710 textBoxes: self.textBoxes,
711 scrollOffsetX: self.scrollOffsetX,
712 scrollOffsetY: self.scrollOffsetY,
713 contentWidth: self.contentWidth,
714 contentHeight: self.contentHeight,
715 }
716 }
717}
718
719#[derive(Debug, Clone, Serialize, Deserialize, Default)]
722#[serde(rename_all = "camelCase")]
723pub struct NodeTreeSnapshot {
724 #[serde(skip_serializing_if = "Option::is_none")]
726 parentIndex: Option<Vec<i64>>,
727 #[serde(skip_serializing_if = "Option::is_none")]
729 nodeType: Option<Vec<i64>>,
730 #[serde(skip_serializing_if = "Option::is_none")]
732 shadowRootType: Option<RareStringData>,
733 #[serde(skip_serializing_if = "Option::is_none")]
735 nodeName: Option<Vec<StringIndex>>,
736 #[serde(skip_serializing_if = "Option::is_none")]
738 nodeValue: Option<Vec<StringIndex>>,
739 #[serde(skip_serializing_if = "Option::is_none")]
741 backendNodeId: Option<Vec<crate::dom::BackendNodeId>>,
742 #[serde(skip_serializing_if = "Option::is_none")]
744 attributes: Option<Vec<ArrayOfStrings>>,
745 #[serde(skip_serializing_if = "Option::is_none")]
747 textValue: Option<RareStringData>,
748 #[serde(skip_serializing_if = "Option::is_none")]
750 inputValue: Option<RareStringData>,
751 #[serde(skip_serializing_if = "Option::is_none")]
753 inputChecked: Option<RareBooleanData>,
754 #[serde(skip_serializing_if = "Option::is_none")]
756 optionSelected: Option<RareBooleanData>,
757 #[serde(skip_serializing_if = "Option::is_none")]
759 contentDocumentIndex: Option<RareIntegerData>,
760 #[serde(skip_serializing_if = "Option::is_none")]
762 pseudoType: Option<RareStringData>,
763 #[serde(skip_serializing_if = "Option::is_none")]
766 pseudoIdentifier: Option<RareStringData>,
767 #[serde(skip_serializing_if = "Option::is_none")]
771 isClickable: Option<RareBooleanData>,
772 #[serde(skip_serializing_if = "Option::is_none")]
774 currentSourceURL: Option<RareStringData>,
775 #[serde(skip_serializing_if = "Option::is_none")]
777 originURL: Option<RareStringData>,
778}
779
780impl NodeTreeSnapshot {
781 pub fn builder() -> NodeTreeSnapshotBuilder {
782 NodeTreeSnapshotBuilder {
783 parentIndex: None,
784 nodeType: None,
785 shadowRootType: None,
786 nodeName: None,
787 nodeValue: None,
788 backendNodeId: None,
789 attributes: None,
790 textValue: None,
791 inputValue: None,
792 inputChecked: None,
793 optionSelected: None,
794 contentDocumentIndex: None,
795 pseudoType: None,
796 pseudoIdentifier: None,
797 isClickable: None,
798 currentSourceURL: None,
799 originURL: None,
800 }
801 }
802 pub fn parentIndex(&self) -> Option<&[i64]> { self.parentIndex.as_deref() }
803 pub fn nodeType(&self) -> Option<&[i64]> { self.nodeType.as_deref() }
804 pub fn shadowRootType(&self) -> Option<&RareStringData> { self.shadowRootType.as_ref() }
805 pub fn nodeName(&self) -> Option<&[StringIndex]> { self.nodeName.as_deref() }
806 pub fn nodeValue(&self) -> Option<&[StringIndex]> { self.nodeValue.as_deref() }
807 pub fn backendNodeId(&self) -> Option<&[crate::dom::BackendNodeId]> { self.backendNodeId.as_deref() }
808 pub fn attributes(&self) -> Option<&[ArrayOfStrings]> { self.attributes.as_deref() }
809 pub fn textValue(&self) -> Option<&RareStringData> { self.textValue.as_ref() }
810 pub fn inputValue(&self) -> Option<&RareStringData> { self.inputValue.as_ref() }
811 pub fn inputChecked(&self) -> Option<&RareBooleanData> { self.inputChecked.as_ref() }
812 pub fn optionSelected(&self) -> Option<&RareBooleanData> { self.optionSelected.as_ref() }
813 pub fn contentDocumentIndex(&self) -> Option<&RareIntegerData> { self.contentDocumentIndex.as_ref() }
814 pub fn pseudoType(&self) -> Option<&RareStringData> { self.pseudoType.as_ref() }
815 pub fn pseudoIdentifier(&self) -> Option<&RareStringData> { self.pseudoIdentifier.as_ref() }
816 pub fn isClickable(&self) -> Option<&RareBooleanData> { self.isClickable.as_ref() }
817 pub fn currentSourceURL(&self) -> Option<&RareStringData> { self.currentSourceURL.as_ref() }
818 pub fn originURL(&self) -> Option<&RareStringData> { self.originURL.as_ref() }
819}
820
821#[derive(Default)]
822pub struct NodeTreeSnapshotBuilder {
823 parentIndex: Option<Vec<i64>>,
824 nodeType: Option<Vec<i64>>,
825 shadowRootType: Option<RareStringData>,
826 nodeName: Option<Vec<StringIndex>>,
827 nodeValue: Option<Vec<StringIndex>>,
828 backendNodeId: Option<Vec<crate::dom::BackendNodeId>>,
829 attributes: Option<Vec<ArrayOfStrings>>,
830 textValue: Option<RareStringData>,
831 inputValue: Option<RareStringData>,
832 inputChecked: Option<RareBooleanData>,
833 optionSelected: Option<RareBooleanData>,
834 contentDocumentIndex: Option<RareIntegerData>,
835 pseudoType: Option<RareStringData>,
836 pseudoIdentifier: Option<RareStringData>,
837 isClickable: Option<RareBooleanData>,
838 currentSourceURL: Option<RareStringData>,
839 originURL: Option<RareStringData>,
840}
841
842impl NodeTreeSnapshotBuilder {
843 pub fn parentIndex(mut self, parentIndex: Vec<i64>) -> Self { self.parentIndex = Some(parentIndex); self }
845 pub fn nodeType(mut self, nodeType: Vec<i64>) -> Self { self.nodeType = Some(nodeType); self }
847 pub fn shadowRootType(mut self, shadowRootType: RareStringData) -> Self { self.shadowRootType = Some(shadowRootType); self }
849 pub fn nodeName(mut self, nodeName: Vec<StringIndex>) -> Self { self.nodeName = Some(nodeName); self }
851 pub fn nodeValue(mut self, nodeValue: Vec<StringIndex>) -> Self { self.nodeValue = Some(nodeValue); self }
853 pub fn backendNodeId(mut self, backendNodeId: Vec<crate::dom::BackendNodeId>) -> Self { self.backendNodeId = Some(backendNodeId); self }
855 pub fn attributes(mut self, attributes: Vec<ArrayOfStrings>) -> Self { self.attributes = Some(attributes); self }
857 pub fn textValue(mut self, textValue: RareStringData) -> Self { self.textValue = Some(textValue); self }
859 pub fn inputValue(mut self, inputValue: RareStringData) -> Self { self.inputValue = Some(inputValue); self }
861 pub fn inputChecked(mut self, inputChecked: RareBooleanData) -> Self { self.inputChecked = Some(inputChecked); self }
863 pub fn optionSelected(mut self, optionSelected: RareBooleanData) -> Self { self.optionSelected = Some(optionSelected); self }
865 pub fn contentDocumentIndex(mut self, contentDocumentIndex: RareIntegerData) -> Self { self.contentDocumentIndex = Some(contentDocumentIndex); self }
867 pub fn pseudoType(mut self, pseudoType: RareStringData) -> Self { self.pseudoType = Some(pseudoType); self }
869 pub fn pseudoIdentifier(mut self, pseudoIdentifier: RareStringData) -> Self { self.pseudoIdentifier = Some(pseudoIdentifier); self }
872 pub fn isClickable(mut self, isClickable: RareBooleanData) -> Self { self.isClickable = Some(isClickable); self }
876 pub fn currentSourceURL(mut self, currentSourceURL: RareStringData) -> Self { self.currentSourceURL = Some(currentSourceURL); self }
878 pub fn originURL(mut self, originURL: RareStringData) -> Self { self.originURL = Some(originURL); self }
880 pub fn build(self) -> NodeTreeSnapshot {
881 NodeTreeSnapshot {
882 parentIndex: self.parentIndex,
883 nodeType: self.nodeType,
884 shadowRootType: self.shadowRootType,
885 nodeName: self.nodeName,
886 nodeValue: self.nodeValue,
887 backendNodeId: self.backendNodeId,
888 attributes: self.attributes,
889 textValue: self.textValue,
890 inputValue: self.inputValue,
891 inputChecked: self.inputChecked,
892 optionSelected: self.optionSelected,
893 contentDocumentIndex: self.contentDocumentIndex,
894 pseudoType: self.pseudoType,
895 pseudoIdentifier: self.pseudoIdentifier,
896 isClickable: self.isClickable,
897 currentSourceURL: self.currentSourceURL,
898 originURL: self.originURL,
899 }
900 }
901}
902
903#[derive(Debug, Clone, Serialize, Deserialize, Default)]
906#[serde(rename_all = "camelCase")]
907pub struct LayoutTreeSnapshot {
908 nodeIndex: Vec<i64>,
910 styles: Vec<ArrayOfStrings>,
912 bounds: Vec<Rectangle>,
914 text: Vec<StringIndex>,
916 stackingContexts: RareBooleanData,
918 #[serde(skip_serializing_if = "Option::is_none")]
922 paintOrders: Option<Vec<i64>>,
923 #[serde(skip_serializing_if = "Option::is_none")]
925 offsetRects: Option<Vec<Rectangle>>,
926 #[serde(skip_serializing_if = "Option::is_none")]
928 scrollRects: Option<Vec<Rectangle>>,
929 #[serde(skip_serializing_if = "Option::is_none")]
931 clientRects: Option<Vec<Rectangle>>,
932 #[serde(skip_serializing_if = "Option::is_none")]
934 blendedBackgroundColors: Option<Vec<StringIndex>>,
935 #[serde(skip_serializing_if = "Option::is_none")]
937 textColorOpacities: Option<Vec<f64>>,
938}
939
940impl LayoutTreeSnapshot {
941 pub fn builder(nodeIndex: Vec<i64>, styles: Vec<ArrayOfStrings>, bounds: Vec<Rectangle>, text: Vec<StringIndex>, stackingContexts: RareBooleanData) -> LayoutTreeSnapshotBuilder {
942 LayoutTreeSnapshotBuilder {
943 nodeIndex: nodeIndex,
944 styles: styles,
945 bounds: bounds,
946 text: text,
947 stackingContexts: stackingContexts,
948 paintOrders: None,
949 offsetRects: None,
950 scrollRects: None,
951 clientRects: None,
952 blendedBackgroundColors: None,
953 textColorOpacities: None,
954 }
955 }
956 pub fn nodeIndex(&self) -> &[i64] { &self.nodeIndex }
957 pub fn styles(&self) -> &[ArrayOfStrings] { &self.styles }
958 pub fn bounds(&self) -> &[Rectangle] { &self.bounds }
959 pub fn text(&self) -> &[StringIndex] { &self.text }
960 pub fn stackingContexts(&self) -> &RareBooleanData { &self.stackingContexts }
961 pub fn paintOrders(&self) -> Option<&[i64]> { self.paintOrders.as_deref() }
962 pub fn offsetRects(&self) -> Option<&[Rectangle]> { self.offsetRects.as_deref() }
963 pub fn scrollRects(&self) -> Option<&[Rectangle]> { self.scrollRects.as_deref() }
964 pub fn clientRects(&self) -> Option<&[Rectangle]> { self.clientRects.as_deref() }
965 pub fn blendedBackgroundColors(&self) -> Option<&[StringIndex]> { self.blendedBackgroundColors.as_deref() }
966 pub fn textColorOpacities(&self) -> Option<&[f64]> { self.textColorOpacities.as_deref() }
967}
968
969
970pub struct LayoutTreeSnapshotBuilder {
971 nodeIndex: Vec<i64>,
972 styles: Vec<ArrayOfStrings>,
973 bounds: Vec<Rectangle>,
974 text: Vec<StringIndex>,
975 stackingContexts: RareBooleanData,
976 paintOrders: Option<Vec<i64>>,
977 offsetRects: Option<Vec<Rectangle>>,
978 scrollRects: Option<Vec<Rectangle>>,
979 clientRects: Option<Vec<Rectangle>>,
980 blendedBackgroundColors: Option<Vec<StringIndex>>,
981 textColorOpacities: Option<Vec<f64>>,
982}
983
984impl LayoutTreeSnapshotBuilder {
985 pub fn paintOrders(mut self, paintOrders: Vec<i64>) -> Self { self.paintOrders = Some(paintOrders); self }
989 pub fn offsetRects(mut self, offsetRects: Vec<Rectangle>) -> Self { self.offsetRects = Some(offsetRects); self }
991 pub fn scrollRects(mut self, scrollRects: Vec<Rectangle>) -> Self { self.scrollRects = Some(scrollRects); self }
993 pub fn clientRects(mut self, clientRects: Vec<Rectangle>) -> Self { self.clientRects = Some(clientRects); self }
995 pub fn blendedBackgroundColors(mut self, blendedBackgroundColors: Vec<StringIndex>) -> Self { self.blendedBackgroundColors = Some(blendedBackgroundColors); self }
997 pub fn textColorOpacities(mut self, textColorOpacities: Vec<f64>) -> Self { self.textColorOpacities = Some(textColorOpacities); self }
999 pub fn build(self) -> LayoutTreeSnapshot {
1000 LayoutTreeSnapshot {
1001 nodeIndex: self.nodeIndex,
1002 styles: self.styles,
1003 bounds: self.bounds,
1004 text: self.text,
1005 stackingContexts: self.stackingContexts,
1006 paintOrders: self.paintOrders,
1007 offsetRects: self.offsetRects,
1008 scrollRects: self.scrollRects,
1009 clientRects: self.clientRects,
1010 blendedBackgroundColors: self.blendedBackgroundColors,
1011 textColorOpacities: self.textColorOpacities,
1012 }
1013 }
1014}
1015
1016#[derive(Debug, Clone, Serialize, Deserialize, Default)]
1020#[serde(rename_all = "camelCase")]
1021pub struct TextBoxSnapshot {
1022 layoutIndex: Vec<i64>,
1024 bounds: Vec<Rectangle>,
1026 start: Vec<i64>,
1029 length: Vec<i64>,
1032}
1033
1034impl TextBoxSnapshot {
1035 pub fn builder(layoutIndex: Vec<i64>, bounds: Vec<Rectangle>, start: Vec<i64>, length: Vec<i64>) -> TextBoxSnapshotBuilder {
1036 TextBoxSnapshotBuilder {
1037 layoutIndex: layoutIndex,
1038 bounds: bounds,
1039 start: start,
1040 length: length,
1041 }
1042 }
1043 pub fn layoutIndex(&self) -> &[i64] { &self.layoutIndex }
1044 pub fn bounds(&self) -> &[Rectangle] { &self.bounds }
1045 pub fn start(&self) -> &[i64] { &self.start }
1046 pub fn length(&self) -> &[i64] { &self.length }
1047}
1048
1049
1050pub struct TextBoxSnapshotBuilder {
1051 layoutIndex: Vec<i64>,
1052 bounds: Vec<Rectangle>,
1053 start: Vec<i64>,
1054 length: Vec<i64>,
1055}
1056
1057impl TextBoxSnapshotBuilder {
1058 pub fn build(self) -> TextBoxSnapshot {
1059 TextBoxSnapshot {
1060 layoutIndex: self.layoutIndex,
1061 bounds: self.bounds,
1062 start: self.start,
1063 length: self.length,
1064 }
1065 }
1066}
1067
1068#[derive(Debug, Clone, Serialize, Deserialize, Default)]
1069pub struct DisableParams {}
1070
1071impl DisableParams { pub const METHOD: &'static str = "DOMSnapshot.disable"; }
1072
1073impl<'a> crate::CdpCommand<'a> for DisableParams {
1074 const METHOD: &'static str = "DOMSnapshot.disable";
1075 type Response = crate::EmptyReturns;
1076}
1077
1078#[derive(Debug, Clone, Serialize, Deserialize, Default)]
1079pub struct EnableParams {}
1080
1081impl EnableParams { pub const METHOD: &'static str = "DOMSnapshot.enable"; }
1082
1083impl<'a> crate::CdpCommand<'a> for EnableParams {
1084 const METHOD: &'static str = "DOMSnapshot.enable";
1085 type Response = crate::EmptyReturns;
1086}
1087
1088#[derive(Debug, Clone, Serialize, Deserialize, Default)]
1094#[serde(rename_all = "camelCase")]
1095pub struct GetSnapshotParams<'a> {
1096 computedStyleWhitelist: Vec<Cow<'a, str>>,
1098 #[serde(skip_serializing_if = "Option::is_none")]
1100 includeEventListeners: Option<bool>,
1101 #[serde(skip_serializing_if = "Option::is_none")]
1103 includePaintOrder: Option<bool>,
1104 #[serde(skip_serializing_if = "Option::is_none")]
1106 includeUserAgentShadowTree: Option<bool>,
1107}
1108
1109impl<'a> GetSnapshotParams<'a> {
1110 pub fn builder(computedStyleWhitelist: Vec<Cow<'a, str>>) -> GetSnapshotParamsBuilder<'a> {
1111 GetSnapshotParamsBuilder {
1112 computedStyleWhitelist: computedStyleWhitelist,
1113 includeEventListeners: None,
1114 includePaintOrder: None,
1115 includeUserAgentShadowTree: None,
1116 }
1117 }
1118 pub fn computedStyleWhitelist(&self) -> &[Cow<'a, str>] { &self.computedStyleWhitelist }
1119 pub fn includeEventListeners(&self) -> Option<bool> { self.includeEventListeners }
1120 pub fn includePaintOrder(&self) -> Option<bool> { self.includePaintOrder }
1121 pub fn includeUserAgentShadowTree(&self) -> Option<bool> { self.includeUserAgentShadowTree }
1122}
1123
1124
1125pub struct GetSnapshotParamsBuilder<'a> {
1126 computedStyleWhitelist: Vec<Cow<'a, str>>,
1127 includeEventListeners: Option<bool>,
1128 includePaintOrder: Option<bool>,
1129 includeUserAgentShadowTree: Option<bool>,
1130}
1131
1132impl<'a> GetSnapshotParamsBuilder<'a> {
1133 pub fn includeEventListeners(mut self, includeEventListeners: bool) -> Self { self.includeEventListeners = Some(includeEventListeners); self }
1135 pub fn includePaintOrder(mut self, includePaintOrder: bool) -> Self { self.includePaintOrder = Some(includePaintOrder); self }
1137 pub fn includeUserAgentShadowTree(mut self, includeUserAgentShadowTree: bool) -> Self { self.includeUserAgentShadowTree = Some(includeUserAgentShadowTree); self }
1139 pub fn build(self) -> GetSnapshotParams<'a> {
1140 GetSnapshotParams {
1141 computedStyleWhitelist: self.computedStyleWhitelist,
1142 includeEventListeners: self.includeEventListeners,
1143 includePaintOrder: self.includePaintOrder,
1144 includeUserAgentShadowTree: self.includeUserAgentShadowTree,
1145 }
1146 }
1147}
1148
1149#[derive(Debug, Clone, Serialize, Deserialize, Default)]
1155#[serde(rename_all = "camelCase")]
1156pub struct GetSnapshotReturns<'a> {
1157 domNodes: Vec<DOMNode<'a>>,
1159 layoutTreeNodes: Vec<LayoutTreeNode<'a>>,
1161 computedStyles: Vec<ComputedStyle<'a>>,
1163}
1164
1165impl<'a> GetSnapshotReturns<'a> {
1166 pub fn builder(domNodes: Vec<DOMNode<'a>>, layoutTreeNodes: Vec<LayoutTreeNode<'a>>, computedStyles: Vec<ComputedStyle<'a>>) -> GetSnapshotReturnsBuilder<'a> {
1167 GetSnapshotReturnsBuilder {
1168 domNodes: domNodes,
1169 layoutTreeNodes: layoutTreeNodes,
1170 computedStyles: computedStyles,
1171 }
1172 }
1173 pub fn domNodes(&self) -> &[DOMNode<'a>] { &self.domNodes }
1174 pub fn layoutTreeNodes(&self) -> &[LayoutTreeNode<'a>] { &self.layoutTreeNodes }
1175 pub fn computedStyles(&self) -> &[ComputedStyle<'a>] { &self.computedStyles }
1176}
1177
1178
1179pub struct GetSnapshotReturnsBuilder<'a> {
1180 domNodes: Vec<DOMNode<'a>>,
1181 layoutTreeNodes: Vec<LayoutTreeNode<'a>>,
1182 computedStyles: Vec<ComputedStyle<'a>>,
1183}
1184
1185impl<'a> GetSnapshotReturnsBuilder<'a> {
1186 pub fn build(self) -> GetSnapshotReturns<'a> {
1187 GetSnapshotReturns {
1188 domNodes: self.domNodes,
1189 layoutTreeNodes: self.layoutTreeNodes,
1190 computedStyles: self.computedStyles,
1191 }
1192 }
1193}
1194
1195impl<'a> GetSnapshotParams<'a> { pub const METHOD: &'static str = "DOMSnapshot.getSnapshot"; }
1196
1197impl<'a> crate::CdpCommand<'a> for GetSnapshotParams<'a> {
1198 const METHOD: &'static str = "DOMSnapshot.getSnapshot";
1199 type Response = GetSnapshotReturns<'a>;
1200}
1201
1202#[derive(Debug, Clone, Serialize, Deserialize, Default)]
1208#[serde(rename_all = "camelCase")]
1209pub struct CaptureSnapshotParams<'a> {
1210 computedStyles: Vec<Cow<'a, str>>,
1212 #[serde(skip_serializing_if = "Option::is_none")]
1214 includePaintOrder: Option<bool>,
1215 #[serde(skip_serializing_if = "Option::is_none")]
1217 includeDOMRects: Option<bool>,
1218 #[serde(skip_serializing_if = "Option::is_none")]
1222 includeBlendedBackgroundColors: Option<bool>,
1223 #[serde(skip_serializing_if = "Option::is_none")]
1227 includeTextColorOpacities: Option<bool>,
1228}
1229
1230impl<'a> CaptureSnapshotParams<'a> {
1231 pub fn builder(computedStyles: Vec<Cow<'a, str>>) -> CaptureSnapshotParamsBuilder<'a> {
1232 CaptureSnapshotParamsBuilder {
1233 computedStyles: computedStyles,
1234 includePaintOrder: None,
1235 includeDOMRects: None,
1236 includeBlendedBackgroundColors: None,
1237 includeTextColorOpacities: None,
1238 }
1239 }
1240 pub fn computedStyles(&self) -> &[Cow<'a, str>] { &self.computedStyles }
1241 pub fn includePaintOrder(&self) -> Option<bool> { self.includePaintOrder }
1242 pub fn includeDOMRects(&self) -> Option<bool> { self.includeDOMRects }
1243 pub fn includeBlendedBackgroundColors(&self) -> Option<bool> { self.includeBlendedBackgroundColors }
1244 pub fn includeTextColorOpacities(&self) -> Option<bool> { self.includeTextColorOpacities }
1245}
1246
1247
1248pub struct CaptureSnapshotParamsBuilder<'a> {
1249 computedStyles: Vec<Cow<'a, str>>,
1250 includePaintOrder: Option<bool>,
1251 includeDOMRects: Option<bool>,
1252 includeBlendedBackgroundColors: Option<bool>,
1253 includeTextColorOpacities: Option<bool>,
1254}
1255
1256impl<'a> CaptureSnapshotParamsBuilder<'a> {
1257 pub fn includePaintOrder(mut self, includePaintOrder: bool) -> Self { self.includePaintOrder = Some(includePaintOrder); self }
1259 pub fn includeDOMRects(mut self, includeDOMRects: bool) -> Self { self.includeDOMRects = Some(includeDOMRects); self }
1261 pub fn includeBlendedBackgroundColors(mut self, includeBlendedBackgroundColors: bool) -> Self { self.includeBlendedBackgroundColors = Some(includeBlendedBackgroundColors); self }
1265 pub fn includeTextColorOpacities(mut self, includeTextColorOpacities: bool) -> Self { self.includeTextColorOpacities = Some(includeTextColorOpacities); self }
1269 pub fn build(self) -> CaptureSnapshotParams<'a> {
1270 CaptureSnapshotParams {
1271 computedStyles: self.computedStyles,
1272 includePaintOrder: self.includePaintOrder,
1273 includeDOMRects: self.includeDOMRects,
1274 includeBlendedBackgroundColors: self.includeBlendedBackgroundColors,
1275 includeTextColorOpacities: self.includeTextColorOpacities,
1276 }
1277 }
1278}
1279
1280#[derive(Debug, Clone, Serialize, Deserialize, Default)]
1286#[serde(rename_all = "camelCase")]
1287pub struct CaptureSnapshotReturns<'a> {
1288 documents: Vec<DocumentSnapshot>,
1290 strings: Vec<Cow<'a, str>>,
1292}
1293
1294impl<'a> CaptureSnapshotReturns<'a> {
1295 pub fn builder(documents: Vec<DocumentSnapshot>, strings: Vec<Cow<'a, str>>) -> CaptureSnapshotReturnsBuilder<'a> {
1296 CaptureSnapshotReturnsBuilder {
1297 documents: documents,
1298 strings: strings,
1299 }
1300 }
1301 pub fn documents(&self) -> &[DocumentSnapshot] { &self.documents }
1302 pub fn strings(&self) -> &[Cow<'a, str>] { &self.strings }
1303}
1304
1305
1306pub struct CaptureSnapshotReturnsBuilder<'a> {
1307 documents: Vec<DocumentSnapshot>,
1308 strings: Vec<Cow<'a, str>>,
1309}
1310
1311impl<'a> CaptureSnapshotReturnsBuilder<'a> {
1312 pub fn build(self) -> CaptureSnapshotReturns<'a> {
1313 CaptureSnapshotReturns {
1314 documents: self.documents,
1315 strings: self.strings,
1316 }
1317 }
1318}
1319
1320impl<'a> CaptureSnapshotParams<'a> { pub const METHOD: &'static str = "DOMSnapshot.captureSnapshot"; }
1321
1322impl<'a> crate::CdpCommand<'a> for CaptureSnapshotParams<'a> {
1323 const METHOD: &'static str = "DOMSnapshot.captureSnapshot";
1324 type Response = CaptureSnapshotReturns<'a>;
1325}