use serde::{Serialize, Deserialize};
use serde_json::Value as JsonValue;
use std::borrow::Cow;
#[derive(Debug, Clone, Serialize, Deserialize, Default)]
#[serde(rename_all = "camelCase")]
pub struct DOMNode<'a> {
nodeType: i64,
nodeName: Cow<'a, str>,
nodeValue: Cow<'a, str>,
#[serde(skip_serializing_if = "Option::is_none")]
textValue: Option<Cow<'a, str>>,
#[serde(skip_serializing_if = "Option::is_none")]
inputValue: Option<Cow<'a, str>>,
#[serde(skip_serializing_if = "Option::is_none")]
inputChecked: Option<bool>,
#[serde(skip_serializing_if = "Option::is_none")]
optionSelected: Option<bool>,
backendNodeId: crate::dom::BackendNodeId,
#[serde(skip_serializing_if = "Option::is_none")]
childNodeIndexes: Option<Vec<i64>>,
#[serde(skip_serializing_if = "Option::is_none")]
attributes: Option<Vec<NameValue<'a>>>,
#[serde(skip_serializing_if = "Option::is_none")]
pseudoElementIndexes: Option<Vec<i64>>,
#[serde(skip_serializing_if = "Option::is_none")]
layoutNodeIndex: Option<u64>,
#[serde(skip_serializing_if = "Option::is_none")]
documentURL: Option<Cow<'a, str>>,
#[serde(skip_serializing_if = "Option::is_none")]
baseURL: Option<Cow<'a, str>>,
#[serde(skip_serializing_if = "Option::is_none")]
contentLanguage: Option<Cow<'a, str>>,
#[serde(skip_serializing_if = "Option::is_none")]
documentEncoding: Option<Cow<'a, str>>,
#[serde(skip_serializing_if = "Option::is_none")]
publicId: Option<Cow<'a, str>>,
#[serde(skip_serializing_if = "Option::is_none")]
systemId: Option<Cow<'a, str>>,
#[serde(skip_serializing_if = "Option::is_none")]
frameId: Option<crate::page::FrameId<'a>>,
#[serde(skip_serializing_if = "Option::is_none")]
contentDocumentIndex: Option<u64>,
#[serde(skip_serializing_if = "Option::is_none")]
pseudoType: Option<crate::dom::PseudoType>,
#[serde(skip_serializing_if = "Option::is_none")]
shadowRootType: Option<crate::dom::ShadowRootType>,
#[serde(skip_serializing_if = "Option::is_none")]
isClickable: Option<bool>,
#[serde(skip_serializing_if = "Option::is_none")]
eventListeners: Option<Vec<crate::domdebugger::EventListener<'a>>>,
#[serde(skip_serializing_if = "Option::is_none")]
currentSourceURL: Option<Cow<'a, str>>,
#[serde(skip_serializing_if = "Option::is_none")]
originURL: Option<Cow<'a, str>>,
#[serde(skip_serializing_if = "Option::is_none")]
scrollOffsetX: Option<f64>,
#[serde(skip_serializing_if = "Option::is_none")]
scrollOffsetY: Option<f64>,
}
impl<'a> DOMNode<'a> {
pub fn builder(nodeType: i64, nodeName: impl Into<Cow<'a, str>>, nodeValue: impl Into<Cow<'a, str>>, backendNodeId: crate::dom::BackendNodeId) -> DOMNodeBuilder<'a> {
DOMNodeBuilder {
nodeType: nodeType,
nodeName: nodeName.into(),
nodeValue: nodeValue.into(),
textValue: None,
inputValue: None,
inputChecked: None,
optionSelected: None,
backendNodeId: backendNodeId,
childNodeIndexes: None,
attributes: None,
pseudoElementIndexes: None,
layoutNodeIndex: None,
documentURL: None,
baseURL: None,
contentLanguage: None,
documentEncoding: None,
publicId: None,
systemId: None,
frameId: None,
contentDocumentIndex: None,
pseudoType: None,
shadowRootType: None,
isClickable: None,
eventListeners: None,
currentSourceURL: None,
originURL: None,
scrollOffsetX: None,
scrollOffsetY: None,
}
}
pub fn nodeType(&self) -> i64 { self.nodeType }
pub fn nodeName(&self) -> &str { self.nodeName.as_ref() }
pub fn nodeValue(&self) -> &str { self.nodeValue.as_ref() }
pub fn textValue(&self) -> Option<&str> { self.textValue.as_deref() }
pub fn inputValue(&self) -> Option<&str> { self.inputValue.as_deref() }
pub fn inputChecked(&self) -> Option<bool> { self.inputChecked }
pub fn optionSelected(&self) -> Option<bool> { self.optionSelected }
pub fn backendNodeId(&self) -> &crate::dom::BackendNodeId { &self.backendNodeId }
pub fn childNodeIndexes(&self) -> Option<&[i64]> { self.childNodeIndexes.as_deref() }
pub fn attributes(&self) -> Option<&[NameValue<'a>]> { self.attributes.as_deref() }
pub fn pseudoElementIndexes(&self) -> Option<&[i64]> { self.pseudoElementIndexes.as_deref() }
pub fn layoutNodeIndex(&self) -> Option<u64> { self.layoutNodeIndex }
pub fn documentURL(&self) -> Option<&str> { self.documentURL.as_deref() }
pub fn baseURL(&self) -> Option<&str> { self.baseURL.as_deref() }
pub fn contentLanguage(&self) -> Option<&str> { self.contentLanguage.as_deref() }
pub fn documentEncoding(&self) -> Option<&str> { self.documentEncoding.as_deref() }
pub fn publicId(&self) -> Option<&str> { self.publicId.as_deref() }
pub fn systemId(&self) -> Option<&str> { self.systemId.as_deref() }
pub fn frameId(&self) -> Option<&crate::page::FrameId<'a>> { self.frameId.as_ref() }
pub fn contentDocumentIndex(&self) -> Option<u64> { self.contentDocumentIndex }
pub fn pseudoType(&self) -> Option<&crate::dom::PseudoType> { self.pseudoType.as_ref() }
pub fn shadowRootType(&self) -> Option<&crate::dom::ShadowRootType> { self.shadowRootType.as_ref() }
pub fn isClickable(&self) -> Option<bool> { self.isClickable }
pub fn eventListeners(&self) -> Option<&[crate::domdebugger::EventListener<'a>]> { self.eventListeners.as_deref() }
pub fn currentSourceURL(&self) -> Option<&str> { self.currentSourceURL.as_deref() }
pub fn originURL(&self) -> Option<&str> { self.originURL.as_deref() }
pub fn scrollOffsetX(&self) -> Option<f64> { self.scrollOffsetX }
pub fn scrollOffsetY(&self) -> Option<f64> { self.scrollOffsetY }
}
pub struct DOMNodeBuilder<'a> {
nodeType: i64,
nodeName: Cow<'a, str>,
nodeValue: Cow<'a, str>,
textValue: Option<Cow<'a, str>>,
inputValue: Option<Cow<'a, str>>,
inputChecked: Option<bool>,
optionSelected: Option<bool>,
backendNodeId: crate::dom::BackendNodeId,
childNodeIndexes: Option<Vec<i64>>,
attributes: Option<Vec<NameValue<'a>>>,
pseudoElementIndexes: Option<Vec<i64>>,
layoutNodeIndex: Option<u64>,
documentURL: Option<Cow<'a, str>>,
baseURL: Option<Cow<'a, str>>,
contentLanguage: Option<Cow<'a, str>>,
documentEncoding: Option<Cow<'a, str>>,
publicId: Option<Cow<'a, str>>,
systemId: Option<Cow<'a, str>>,
frameId: Option<crate::page::FrameId<'a>>,
contentDocumentIndex: Option<u64>,
pseudoType: Option<crate::dom::PseudoType>,
shadowRootType: Option<crate::dom::ShadowRootType>,
isClickable: Option<bool>,
eventListeners: Option<Vec<crate::domdebugger::EventListener<'a>>>,
currentSourceURL: Option<Cow<'a, str>>,
originURL: Option<Cow<'a, str>>,
scrollOffsetX: Option<f64>,
scrollOffsetY: Option<f64>,
}
impl<'a> DOMNodeBuilder<'a> {
pub fn textValue(mut self, textValue: impl Into<Cow<'a, str>>) -> Self { self.textValue = Some(textValue.into()); self }
pub fn inputValue(mut self, inputValue: impl Into<Cow<'a, str>>) -> Self { self.inputValue = Some(inputValue.into()); self }
pub fn inputChecked(mut self, inputChecked: bool) -> Self { self.inputChecked = Some(inputChecked); self }
pub fn optionSelected(mut self, optionSelected: bool) -> Self { self.optionSelected = Some(optionSelected); self }
pub fn childNodeIndexes(mut self, childNodeIndexes: Vec<i64>) -> Self { self.childNodeIndexes = Some(childNodeIndexes); self }
pub fn attributes(mut self, attributes: Vec<NameValue<'a>>) -> Self { self.attributes = Some(attributes); self }
pub fn pseudoElementIndexes(mut self, pseudoElementIndexes: Vec<i64>) -> Self { self.pseudoElementIndexes = Some(pseudoElementIndexes); self }
pub fn layoutNodeIndex(mut self, layoutNodeIndex: u64) -> Self { self.layoutNodeIndex = Some(layoutNodeIndex); self }
pub fn documentURL(mut self, documentURL: impl Into<Cow<'a, str>>) -> Self { self.documentURL = Some(documentURL.into()); self }
pub fn baseURL(mut self, baseURL: impl Into<Cow<'a, str>>) -> Self { self.baseURL = Some(baseURL.into()); self }
pub fn contentLanguage(mut self, contentLanguage: impl Into<Cow<'a, str>>) -> Self { self.contentLanguage = Some(contentLanguage.into()); self }
pub fn documentEncoding(mut self, documentEncoding: impl Into<Cow<'a, str>>) -> Self { self.documentEncoding = Some(documentEncoding.into()); self }
pub fn publicId(mut self, publicId: impl Into<Cow<'a, str>>) -> Self { self.publicId = Some(publicId.into()); self }
pub fn systemId(mut self, systemId: impl Into<Cow<'a, str>>) -> Self { self.systemId = Some(systemId.into()); self }
pub fn frameId(mut self, frameId: crate::page::FrameId<'a>) -> Self { self.frameId = Some(frameId); self }
pub fn contentDocumentIndex(mut self, contentDocumentIndex: u64) -> Self { self.contentDocumentIndex = Some(contentDocumentIndex); self }
pub fn pseudoType(mut self, pseudoType: crate::dom::PseudoType) -> Self { self.pseudoType = Some(pseudoType); self }
pub fn shadowRootType(mut self, shadowRootType: crate::dom::ShadowRootType) -> Self { self.shadowRootType = Some(shadowRootType); self }
pub fn isClickable(mut self, isClickable: bool) -> Self { self.isClickable = Some(isClickable); self }
pub fn eventListeners(mut self, eventListeners: Vec<crate::domdebugger::EventListener<'a>>) -> Self { self.eventListeners = Some(eventListeners); self }
pub fn currentSourceURL(mut self, currentSourceURL: impl Into<Cow<'a, str>>) -> Self { self.currentSourceURL = Some(currentSourceURL.into()); self }
pub fn originURL(mut self, originURL: impl Into<Cow<'a, str>>) -> Self { self.originURL = Some(originURL.into()); self }
pub fn scrollOffsetX(mut self, scrollOffsetX: f64) -> Self { self.scrollOffsetX = Some(scrollOffsetX); self }
pub fn scrollOffsetY(mut self, scrollOffsetY: f64) -> Self { self.scrollOffsetY = Some(scrollOffsetY); self }
pub fn build(self) -> DOMNode<'a> {
DOMNode {
nodeType: self.nodeType,
nodeName: self.nodeName,
nodeValue: self.nodeValue,
textValue: self.textValue,
inputValue: self.inputValue,
inputChecked: self.inputChecked,
optionSelected: self.optionSelected,
backendNodeId: self.backendNodeId,
childNodeIndexes: self.childNodeIndexes,
attributes: self.attributes,
pseudoElementIndexes: self.pseudoElementIndexes,
layoutNodeIndex: self.layoutNodeIndex,
documentURL: self.documentURL,
baseURL: self.baseURL,
contentLanguage: self.contentLanguage,
documentEncoding: self.documentEncoding,
publicId: self.publicId,
systemId: self.systemId,
frameId: self.frameId,
contentDocumentIndex: self.contentDocumentIndex,
pseudoType: self.pseudoType,
shadowRootType: self.shadowRootType,
isClickable: self.isClickable,
eventListeners: self.eventListeners,
currentSourceURL: self.currentSourceURL,
originURL: self.originURL,
scrollOffsetX: self.scrollOffsetX,
scrollOffsetY: self.scrollOffsetY,
}
}
}
#[derive(Debug, Clone, Serialize, Deserialize, Default)]
#[serde(rename_all = "camelCase")]
pub struct InlineTextBox {
boundingBox: crate::dom::Rect,
startCharacterIndex: u64,
numCharacters: i64,
}
impl InlineTextBox {
pub fn builder(boundingBox: crate::dom::Rect, startCharacterIndex: u64, numCharacters: i64) -> InlineTextBoxBuilder {
InlineTextBoxBuilder {
boundingBox: boundingBox,
startCharacterIndex: startCharacterIndex,
numCharacters: numCharacters,
}
}
pub fn boundingBox(&self) -> &crate::dom::Rect { &self.boundingBox }
pub fn startCharacterIndex(&self) -> u64 { self.startCharacterIndex }
pub fn numCharacters(&self) -> i64 { self.numCharacters }
}
pub struct InlineTextBoxBuilder {
boundingBox: crate::dom::Rect,
startCharacterIndex: u64,
numCharacters: i64,
}
impl InlineTextBoxBuilder {
pub fn build(self) -> InlineTextBox {
InlineTextBox {
boundingBox: self.boundingBox,
startCharacterIndex: self.startCharacterIndex,
numCharacters: self.numCharacters,
}
}
}
#[derive(Debug, Clone, Serialize, Deserialize, Default)]
#[serde(rename_all = "camelCase")]
pub struct LayoutTreeNode<'a> {
domNodeIndex: u64,
boundingBox: crate::dom::Rect,
#[serde(skip_serializing_if = "Option::is_none")]
layoutText: Option<Cow<'a, str>>,
#[serde(skip_serializing_if = "Option::is_none")]
inlineTextNodes: Option<Vec<InlineTextBox>>,
#[serde(skip_serializing_if = "Option::is_none")]
styleIndex: Option<u64>,
#[serde(skip_serializing_if = "Option::is_none")]
paintOrder: Option<i64>,
#[serde(skip_serializing_if = "Option::is_none")]
isStackingContext: Option<bool>,
}
impl<'a> LayoutTreeNode<'a> {
pub fn builder(domNodeIndex: u64, boundingBox: crate::dom::Rect) -> LayoutTreeNodeBuilder<'a> {
LayoutTreeNodeBuilder {
domNodeIndex: domNodeIndex,
boundingBox: boundingBox,
layoutText: None,
inlineTextNodes: None,
styleIndex: None,
paintOrder: None,
isStackingContext: None,
}
}
pub fn domNodeIndex(&self) -> u64 { self.domNodeIndex }
pub fn boundingBox(&self) -> &crate::dom::Rect { &self.boundingBox }
pub fn layoutText(&self) -> Option<&str> { self.layoutText.as_deref() }
pub fn inlineTextNodes(&self) -> Option<&[InlineTextBox]> { self.inlineTextNodes.as_deref() }
pub fn styleIndex(&self) -> Option<u64> { self.styleIndex }
pub fn paintOrder(&self) -> Option<i64> { self.paintOrder }
pub fn isStackingContext(&self) -> Option<bool> { self.isStackingContext }
}
pub struct LayoutTreeNodeBuilder<'a> {
domNodeIndex: u64,
boundingBox: crate::dom::Rect,
layoutText: Option<Cow<'a, str>>,
inlineTextNodes: Option<Vec<InlineTextBox>>,
styleIndex: Option<u64>,
paintOrder: Option<i64>,
isStackingContext: Option<bool>,
}
impl<'a> LayoutTreeNodeBuilder<'a> {
pub fn layoutText(mut self, layoutText: impl Into<Cow<'a, str>>) -> Self { self.layoutText = Some(layoutText.into()); self }
pub fn inlineTextNodes(mut self, inlineTextNodes: Vec<InlineTextBox>) -> Self { self.inlineTextNodes = Some(inlineTextNodes); self }
pub fn styleIndex(mut self, styleIndex: u64) -> Self { self.styleIndex = Some(styleIndex); self }
pub fn paintOrder(mut self, paintOrder: i64) -> Self { self.paintOrder = Some(paintOrder); self }
pub fn isStackingContext(mut self, isStackingContext: bool) -> Self { self.isStackingContext = Some(isStackingContext); self }
pub fn build(self) -> LayoutTreeNode<'a> {
LayoutTreeNode {
domNodeIndex: self.domNodeIndex,
boundingBox: self.boundingBox,
layoutText: self.layoutText,
inlineTextNodes: self.inlineTextNodes,
styleIndex: self.styleIndex,
paintOrder: self.paintOrder,
isStackingContext: self.isStackingContext,
}
}
}
#[derive(Debug, Clone, Serialize, Deserialize, Default)]
#[serde(rename_all = "camelCase")]
pub struct ComputedStyle<'a> {
properties: Vec<NameValue<'a>>,
}
impl<'a> ComputedStyle<'a> {
pub fn builder(properties: Vec<NameValue<'a>>) -> ComputedStyleBuilder<'a> {
ComputedStyleBuilder {
properties: properties,
}
}
pub fn properties(&self) -> &[NameValue<'a>] { &self.properties }
}
pub struct ComputedStyleBuilder<'a> {
properties: Vec<NameValue<'a>>,
}
impl<'a> ComputedStyleBuilder<'a> {
pub fn build(self) -> ComputedStyle<'a> {
ComputedStyle {
properties: self.properties,
}
}
}
#[derive(Debug, Clone, Serialize, Deserialize, Default)]
#[serde(rename_all = "camelCase")]
pub struct NameValue<'a> {
name: Cow<'a, str>,
value: Cow<'a, str>,
}
impl<'a> NameValue<'a> {
pub fn builder(name: impl Into<Cow<'a, str>>, value: impl Into<Cow<'a, str>>) -> NameValueBuilder<'a> {
NameValueBuilder {
name: name.into(),
value: value.into(),
}
}
pub fn name(&self) -> &str { self.name.as_ref() }
pub fn value(&self) -> &str { self.value.as_ref() }
}
pub struct NameValueBuilder<'a> {
name: Cow<'a, str>,
value: Cow<'a, str>,
}
impl<'a> NameValueBuilder<'a> {
pub fn build(self) -> NameValue<'a> {
NameValue {
name: self.name,
value: self.value,
}
}
}
pub type StringIndex = i64;
pub type ArrayOfStrings = Vec<StringIndex>;
#[derive(Debug, Clone, Serialize, Deserialize, Default)]
#[serde(rename_all = "camelCase")]
pub struct RareStringData {
index: Vec<i64>,
value: Vec<StringIndex>,
}
impl RareStringData {
pub fn builder(index: Vec<i64>, value: Vec<StringIndex>) -> RareStringDataBuilder {
RareStringDataBuilder {
index: index,
value: value,
}
}
pub fn index(&self) -> &[i64] { &self.index }
pub fn value(&self) -> &[StringIndex] { &self.value }
}
pub struct RareStringDataBuilder {
index: Vec<i64>,
value: Vec<StringIndex>,
}
impl RareStringDataBuilder {
pub fn build(self) -> RareStringData {
RareStringData {
index: self.index,
value: self.value,
}
}
}
#[derive(Debug, Clone, Serialize, Deserialize, Default)]
#[serde(rename_all = "camelCase")]
pub struct RareBooleanData {
index: Vec<i64>,
}
impl RareBooleanData {
pub fn builder(index: Vec<i64>) -> RareBooleanDataBuilder {
RareBooleanDataBuilder {
index: index,
}
}
pub fn index(&self) -> &[i64] { &self.index }
}
pub struct RareBooleanDataBuilder {
index: Vec<i64>,
}
impl RareBooleanDataBuilder {
pub fn build(self) -> RareBooleanData {
RareBooleanData {
index: self.index,
}
}
}
#[derive(Debug, Clone, Serialize, Deserialize, Default)]
#[serde(rename_all = "camelCase")]
pub struct RareIntegerData {
index: Vec<i64>,
value: Vec<i64>,
}
impl RareIntegerData {
pub fn builder(index: Vec<i64>, value: Vec<i64>) -> RareIntegerDataBuilder {
RareIntegerDataBuilder {
index: index,
value: value,
}
}
pub fn index(&self) -> &[i64] { &self.index }
pub fn value(&self) -> &[i64] { &self.value }
}
pub struct RareIntegerDataBuilder {
index: Vec<i64>,
value: Vec<i64>,
}
impl RareIntegerDataBuilder {
pub fn build(self) -> RareIntegerData {
RareIntegerData {
index: self.index,
value: self.value,
}
}
}
pub type Rectangle = Vec<f64>;
#[derive(Debug, Clone, Serialize, Deserialize, Default)]
#[serde(rename_all = "camelCase")]
pub struct DocumentSnapshot {
documentURL: StringIndex,
title: StringIndex,
baseURL: StringIndex,
contentLanguage: StringIndex,
encodingName: StringIndex,
publicId: StringIndex,
systemId: StringIndex,
frameId: StringIndex,
nodes: NodeTreeSnapshot,
layout: LayoutTreeSnapshot,
textBoxes: TextBoxSnapshot,
#[serde(skip_serializing_if = "Option::is_none")]
scrollOffsetX: Option<f64>,
#[serde(skip_serializing_if = "Option::is_none")]
scrollOffsetY: Option<f64>,
#[serde(skip_serializing_if = "Option::is_none")]
contentWidth: Option<f64>,
#[serde(skip_serializing_if = "Option::is_none")]
contentHeight: Option<f64>,
}
impl DocumentSnapshot {
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 {
DocumentSnapshotBuilder {
documentURL: documentURL,
title: title,
baseURL: baseURL,
contentLanguage: contentLanguage,
encodingName: encodingName,
publicId: publicId,
systemId: systemId,
frameId: frameId,
nodes: nodes,
layout: layout,
textBoxes: textBoxes,
scrollOffsetX: None,
scrollOffsetY: None,
contentWidth: None,
contentHeight: None,
}
}
pub fn documentURL(&self) -> &StringIndex { &self.documentURL }
pub fn title(&self) -> &StringIndex { &self.title }
pub fn baseURL(&self) -> &StringIndex { &self.baseURL }
pub fn contentLanguage(&self) -> &StringIndex { &self.contentLanguage }
pub fn encodingName(&self) -> &StringIndex { &self.encodingName }
pub fn publicId(&self) -> &StringIndex { &self.publicId }
pub fn systemId(&self) -> &StringIndex { &self.systemId }
pub fn frameId(&self) -> &StringIndex { &self.frameId }
pub fn nodes(&self) -> &NodeTreeSnapshot { &self.nodes }
pub fn layout(&self) -> &LayoutTreeSnapshot { &self.layout }
pub fn textBoxes(&self) -> &TextBoxSnapshot { &self.textBoxes }
pub fn scrollOffsetX(&self) -> Option<f64> { self.scrollOffsetX }
pub fn scrollOffsetY(&self) -> Option<f64> { self.scrollOffsetY }
pub fn contentWidth(&self) -> Option<f64> { self.contentWidth }
pub fn contentHeight(&self) -> Option<f64> { self.contentHeight }
}
pub struct DocumentSnapshotBuilder {
documentURL: StringIndex,
title: StringIndex,
baseURL: StringIndex,
contentLanguage: StringIndex,
encodingName: StringIndex,
publicId: StringIndex,
systemId: StringIndex,
frameId: StringIndex,
nodes: NodeTreeSnapshot,
layout: LayoutTreeSnapshot,
textBoxes: TextBoxSnapshot,
scrollOffsetX: Option<f64>,
scrollOffsetY: Option<f64>,
contentWidth: Option<f64>,
contentHeight: Option<f64>,
}
impl DocumentSnapshotBuilder {
pub fn scrollOffsetX(mut self, scrollOffsetX: f64) -> Self { self.scrollOffsetX = Some(scrollOffsetX); self }
pub fn scrollOffsetY(mut self, scrollOffsetY: f64) -> Self { self.scrollOffsetY = Some(scrollOffsetY); self }
pub fn contentWidth(mut self, contentWidth: f64) -> Self { self.contentWidth = Some(contentWidth); self }
pub fn contentHeight(mut self, contentHeight: f64) -> Self { self.contentHeight = Some(contentHeight); self }
pub fn build(self) -> DocumentSnapshot {
DocumentSnapshot {
documentURL: self.documentURL,
title: self.title,
baseURL: self.baseURL,
contentLanguage: self.contentLanguage,
encodingName: self.encodingName,
publicId: self.publicId,
systemId: self.systemId,
frameId: self.frameId,
nodes: self.nodes,
layout: self.layout,
textBoxes: self.textBoxes,
scrollOffsetX: self.scrollOffsetX,
scrollOffsetY: self.scrollOffsetY,
contentWidth: self.contentWidth,
contentHeight: self.contentHeight,
}
}
}
#[derive(Debug, Clone, Serialize, Deserialize, Default)]
#[serde(rename_all = "camelCase")]
pub struct NodeTreeSnapshot {
#[serde(skip_serializing_if = "Option::is_none")]
parentIndex: Option<Vec<i64>>,
#[serde(skip_serializing_if = "Option::is_none")]
nodeType: Option<Vec<i64>>,
#[serde(skip_serializing_if = "Option::is_none")]
shadowRootType: Option<RareStringData>,
#[serde(skip_serializing_if = "Option::is_none")]
nodeName: Option<Vec<StringIndex>>,
#[serde(skip_serializing_if = "Option::is_none")]
nodeValue: Option<Vec<StringIndex>>,
#[serde(skip_serializing_if = "Option::is_none")]
backendNodeId: Option<Vec<crate::dom::BackendNodeId>>,
#[serde(skip_serializing_if = "Option::is_none")]
attributes: Option<Vec<ArrayOfStrings>>,
#[serde(skip_serializing_if = "Option::is_none")]
textValue: Option<RareStringData>,
#[serde(skip_serializing_if = "Option::is_none")]
inputValue: Option<RareStringData>,
#[serde(skip_serializing_if = "Option::is_none")]
inputChecked: Option<RareBooleanData>,
#[serde(skip_serializing_if = "Option::is_none")]
optionSelected: Option<RareBooleanData>,
#[serde(skip_serializing_if = "Option::is_none")]
contentDocumentIndex: Option<RareIntegerData>,
#[serde(skip_serializing_if = "Option::is_none")]
pseudoType: Option<RareStringData>,
#[serde(skip_serializing_if = "Option::is_none")]
pseudoIdentifier: Option<RareStringData>,
#[serde(skip_serializing_if = "Option::is_none")]
isClickable: Option<RareBooleanData>,
#[serde(skip_serializing_if = "Option::is_none")]
currentSourceURL: Option<RareStringData>,
#[serde(skip_serializing_if = "Option::is_none")]
originURL: Option<RareStringData>,
}
impl NodeTreeSnapshot {
pub fn builder() -> NodeTreeSnapshotBuilder {
NodeTreeSnapshotBuilder {
parentIndex: None,
nodeType: None,
shadowRootType: None,
nodeName: None,
nodeValue: None,
backendNodeId: None,
attributes: None,
textValue: None,
inputValue: None,
inputChecked: None,
optionSelected: None,
contentDocumentIndex: None,
pseudoType: None,
pseudoIdentifier: None,
isClickable: None,
currentSourceURL: None,
originURL: None,
}
}
pub fn parentIndex(&self) -> Option<&[i64]> { self.parentIndex.as_deref() }
pub fn nodeType(&self) -> Option<&[i64]> { self.nodeType.as_deref() }
pub fn shadowRootType(&self) -> Option<&RareStringData> { self.shadowRootType.as_ref() }
pub fn nodeName(&self) -> Option<&[StringIndex]> { self.nodeName.as_deref() }
pub fn nodeValue(&self) -> Option<&[StringIndex]> { self.nodeValue.as_deref() }
pub fn backendNodeId(&self) -> Option<&[crate::dom::BackendNodeId]> { self.backendNodeId.as_deref() }
pub fn attributes(&self) -> Option<&[ArrayOfStrings]> { self.attributes.as_deref() }
pub fn textValue(&self) -> Option<&RareStringData> { self.textValue.as_ref() }
pub fn inputValue(&self) -> Option<&RareStringData> { self.inputValue.as_ref() }
pub fn inputChecked(&self) -> Option<&RareBooleanData> { self.inputChecked.as_ref() }
pub fn optionSelected(&self) -> Option<&RareBooleanData> { self.optionSelected.as_ref() }
pub fn contentDocumentIndex(&self) -> Option<&RareIntegerData> { self.contentDocumentIndex.as_ref() }
pub fn pseudoType(&self) -> Option<&RareStringData> { self.pseudoType.as_ref() }
pub fn pseudoIdentifier(&self) -> Option<&RareStringData> { self.pseudoIdentifier.as_ref() }
pub fn isClickable(&self) -> Option<&RareBooleanData> { self.isClickable.as_ref() }
pub fn currentSourceURL(&self) -> Option<&RareStringData> { self.currentSourceURL.as_ref() }
pub fn originURL(&self) -> Option<&RareStringData> { self.originURL.as_ref() }
}
#[derive(Default)]
pub struct NodeTreeSnapshotBuilder {
parentIndex: Option<Vec<i64>>,
nodeType: Option<Vec<i64>>,
shadowRootType: Option<RareStringData>,
nodeName: Option<Vec<StringIndex>>,
nodeValue: Option<Vec<StringIndex>>,
backendNodeId: Option<Vec<crate::dom::BackendNodeId>>,
attributes: Option<Vec<ArrayOfStrings>>,
textValue: Option<RareStringData>,
inputValue: Option<RareStringData>,
inputChecked: Option<RareBooleanData>,
optionSelected: Option<RareBooleanData>,
contentDocumentIndex: Option<RareIntegerData>,
pseudoType: Option<RareStringData>,
pseudoIdentifier: Option<RareStringData>,
isClickable: Option<RareBooleanData>,
currentSourceURL: Option<RareStringData>,
originURL: Option<RareStringData>,
}
impl NodeTreeSnapshotBuilder {
pub fn parentIndex(mut self, parentIndex: Vec<i64>) -> Self { self.parentIndex = Some(parentIndex); self }
pub fn nodeType(mut self, nodeType: Vec<i64>) -> Self { self.nodeType = Some(nodeType); self }
pub fn shadowRootType(mut self, shadowRootType: RareStringData) -> Self { self.shadowRootType = Some(shadowRootType); self }
pub fn nodeName(mut self, nodeName: Vec<StringIndex>) -> Self { self.nodeName = Some(nodeName); self }
pub fn nodeValue(mut self, nodeValue: Vec<StringIndex>) -> Self { self.nodeValue = Some(nodeValue); self }
pub fn backendNodeId(mut self, backendNodeId: Vec<crate::dom::BackendNodeId>) -> Self { self.backendNodeId = Some(backendNodeId); self }
pub fn attributes(mut self, attributes: Vec<ArrayOfStrings>) -> Self { self.attributes = Some(attributes); self }
pub fn textValue(mut self, textValue: RareStringData) -> Self { self.textValue = Some(textValue); self }
pub fn inputValue(mut self, inputValue: RareStringData) -> Self { self.inputValue = Some(inputValue); self }
pub fn inputChecked(mut self, inputChecked: RareBooleanData) -> Self { self.inputChecked = Some(inputChecked); self }
pub fn optionSelected(mut self, optionSelected: RareBooleanData) -> Self { self.optionSelected = Some(optionSelected); self }
pub fn contentDocumentIndex(mut self, contentDocumentIndex: RareIntegerData) -> Self { self.contentDocumentIndex = Some(contentDocumentIndex); self }
pub fn pseudoType(mut self, pseudoType: RareStringData) -> Self { self.pseudoType = Some(pseudoType); self }
pub fn pseudoIdentifier(mut self, pseudoIdentifier: RareStringData) -> Self { self.pseudoIdentifier = Some(pseudoIdentifier); self }
pub fn isClickable(mut self, isClickable: RareBooleanData) -> Self { self.isClickable = Some(isClickable); self }
pub fn currentSourceURL(mut self, currentSourceURL: RareStringData) -> Self { self.currentSourceURL = Some(currentSourceURL); self }
pub fn originURL(mut self, originURL: RareStringData) -> Self { self.originURL = Some(originURL); self }
pub fn build(self) -> NodeTreeSnapshot {
NodeTreeSnapshot {
parentIndex: self.parentIndex,
nodeType: self.nodeType,
shadowRootType: self.shadowRootType,
nodeName: self.nodeName,
nodeValue: self.nodeValue,
backendNodeId: self.backendNodeId,
attributes: self.attributes,
textValue: self.textValue,
inputValue: self.inputValue,
inputChecked: self.inputChecked,
optionSelected: self.optionSelected,
contentDocumentIndex: self.contentDocumentIndex,
pseudoType: self.pseudoType,
pseudoIdentifier: self.pseudoIdentifier,
isClickable: self.isClickable,
currentSourceURL: self.currentSourceURL,
originURL: self.originURL,
}
}
}
#[derive(Debug, Clone, Serialize, Deserialize, Default)]
#[serde(rename_all = "camelCase")]
pub struct LayoutTreeSnapshot {
nodeIndex: Vec<i64>,
styles: Vec<ArrayOfStrings>,
bounds: Vec<Rectangle>,
text: Vec<StringIndex>,
stackingContexts: RareBooleanData,
#[serde(skip_serializing_if = "Option::is_none")]
paintOrders: Option<Vec<i64>>,
#[serde(skip_serializing_if = "Option::is_none")]
offsetRects: Option<Vec<Rectangle>>,
#[serde(skip_serializing_if = "Option::is_none")]
scrollRects: Option<Vec<Rectangle>>,
#[serde(skip_serializing_if = "Option::is_none")]
clientRects: Option<Vec<Rectangle>>,
#[serde(skip_serializing_if = "Option::is_none")]
blendedBackgroundColors: Option<Vec<StringIndex>>,
#[serde(skip_serializing_if = "Option::is_none")]
textColorOpacities: Option<Vec<f64>>,
}
impl LayoutTreeSnapshot {
pub fn builder(nodeIndex: Vec<i64>, styles: Vec<ArrayOfStrings>, bounds: Vec<Rectangle>, text: Vec<StringIndex>, stackingContexts: RareBooleanData) -> LayoutTreeSnapshotBuilder {
LayoutTreeSnapshotBuilder {
nodeIndex: nodeIndex,
styles: styles,
bounds: bounds,
text: text,
stackingContexts: stackingContexts,
paintOrders: None,
offsetRects: None,
scrollRects: None,
clientRects: None,
blendedBackgroundColors: None,
textColorOpacities: None,
}
}
pub fn nodeIndex(&self) -> &[i64] { &self.nodeIndex }
pub fn styles(&self) -> &[ArrayOfStrings] { &self.styles }
pub fn bounds(&self) -> &[Rectangle] { &self.bounds }
pub fn text(&self) -> &[StringIndex] { &self.text }
pub fn stackingContexts(&self) -> &RareBooleanData { &self.stackingContexts }
pub fn paintOrders(&self) -> Option<&[i64]> { self.paintOrders.as_deref() }
pub fn offsetRects(&self) -> Option<&[Rectangle]> { self.offsetRects.as_deref() }
pub fn scrollRects(&self) -> Option<&[Rectangle]> { self.scrollRects.as_deref() }
pub fn clientRects(&self) -> Option<&[Rectangle]> { self.clientRects.as_deref() }
pub fn blendedBackgroundColors(&self) -> Option<&[StringIndex]> { self.blendedBackgroundColors.as_deref() }
pub fn textColorOpacities(&self) -> Option<&[f64]> { self.textColorOpacities.as_deref() }
}
pub struct LayoutTreeSnapshotBuilder {
nodeIndex: Vec<i64>,
styles: Vec<ArrayOfStrings>,
bounds: Vec<Rectangle>,
text: Vec<StringIndex>,
stackingContexts: RareBooleanData,
paintOrders: Option<Vec<i64>>,
offsetRects: Option<Vec<Rectangle>>,
scrollRects: Option<Vec<Rectangle>>,
clientRects: Option<Vec<Rectangle>>,
blendedBackgroundColors: Option<Vec<StringIndex>>,
textColorOpacities: Option<Vec<f64>>,
}
impl LayoutTreeSnapshotBuilder {
pub fn paintOrders(mut self, paintOrders: Vec<i64>) -> Self { self.paintOrders = Some(paintOrders); self }
pub fn offsetRects(mut self, offsetRects: Vec<Rectangle>) -> Self { self.offsetRects = Some(offsetRects); self }
pub fn scrollRects(mut self, scrollRects: Vec<Rectangle>) -> Self { self.scrollRects = Some(scrollRects); self }
pub fn clientRects(mut self, clientRects: Vec<Rectangle>) -> Self { self.clientRects = Some(clientRects); self }
pub fn blendedBackgroundColors(mut self, blendedBackgroundColors: Vec<StringIndex>) -> Self { self.blendedBackgroundColors = Some(blendedBackgroundColors); self }
pub fn textColorOpacities(mut self, textColorOpacities: Vec<f64>) -> Self { self.textColorOpacities = Some(textColorOpacities); self }
pub fn build(self) -> LayoutTreeSnapshot {
LayoutTreeSnapshot {
nodeIndex: self.nodeIndex,
styles: self.styles,
bounds: self.bounds,
text: self.text,
stackingContexts: self.stackingContexts,
paintOrders: self.paintOrders,
offsetRects: self.offsetRects,
scrollRects: self.scrollRects,
clientRects: self.clientRects,
blendedBackgroundColors: self.blendedBackgroundColors,
textColorOpacities: self.textColorOpacities,
}
}
}
#[derive(Debug, Clone, Serialize, Deserialize, Default)]
#[serde(rename_all = "camelCase")]
pub struct TextBoxSnapshot {
layoutIndex: Vec<i64>,
bounds: Vec<Rectangle>,
start: Vec<i64>,
length: Vec<i64>,
}
impl TextBoxSnapshot {
pub fn builder(layoutIndex: Vec<i64>, bounds: Vec<Rectangle>, start: Vec<i64>, length: Vec<i64>) -> TextBoxSnapshotBuilder {
TextBoxSnapshotBuilder {
layoutIndex: layoutIndex,
bounds: bounds,
start: start,
length: length,
}
}
pub fn layoutIndex(&self) -> &[i64] { &self.layoutIndex }
pub fn bounds(&self) -> &[Rectangle] { &self.bounds }
pub fn start(&self) -> &[i64] { &self.start }
pub fn length(&self) -> &[i64] { &self.length }
}
pub struct TextBoxSnapshotBuilder {
layoutIndex: Vec<i64>,
bounds: Vec<Rectangle>,
start: Vec<i64>,
length: Vec<i64>,
}
impl TextBoxSnapshotBuilder {
pub fn build(self) -> TextBoxSnapshot {
TextBoxSnapshot {
layoutIndex: self.layoutIndex,
bounds: self.bounds,
start: self.start,
length: self.length,
}
}
}
#[derive(Debug, Clone, Serialize, Deserialize, Default)]
pub struct DisableParams {}
impl DisableParams { pub const METHOD: &'static str = "DOMSnapshot.disable"; }
impl<'a> crate::CdpCommand<'a> for DisableParams {
const METHOD: &'static str = "DOMSnapshot.disable";
type Response = crate::EmptyReturns;
}
#[derive(Debug, Clone, Serialize, Deserialize, Default)]
pub struct EnableParams {}
impl EnableParams { pub const METHOD: &'static str = "DOMSnapshot.enable"; }
impl<'a> crate::CdpCommand<'a> for EnableParams {
const METHOD: &'static str = "DOMSnapshot.enable";
type Response = crate::EmptyReturns;
}
#[derive(Debug, Clone, Serialize, Deserialize, Default)]
#[serde(rename_all = "camelCase")]
pub struct GetSnapshotParams<'a> {
computedStyleWhitelist: Vec<Cow<'a, str>>,
#[serde(skip_serializing_if = "Option::is_none")]
includeEventListeners: Option<bool>,
#[serde(skip_serializing_if = "Option::is_none")]
includePaintOrder: Option<bool>,
#[serde(skip_serializing_if = "Option::is_none")]
includeUserAgentShadowTree: Option<bool>,
}
impl<'a> GetSnapshotParams<'a> {
pub fn builder(computedStyleWhitelist: Vec<Cow<'a, str>>) -> GetSnapshotParamsBuilder<'a> {
GetSnapshotParamsBuilder {
computedStyleWhitelist: computedStyleWhitelist,
includeEventListeners: None,
includePaintOrder: None,
includeUserAgentShadowTree: None,
}
}
pub fn computedStyleWhitelist(&self) -> &[Cow<'a, str>] { &self.computedStyleWhitelist }
pub fn includeEventListeners(&self) -> Option<bool> { self.includeEventListeners }
pub fn includePaintOrder(&self) -> Option<bool> { self.includePaintOrder }
pub fn includeUserAgentShadowTree(&self) -> Option<bool> { self.includeUserAgentShadowTree }
}
pub struct GetSnapshotParamsBuilder<'a> {
computedStyleWhitelist: Vec<Cow<'a, str>>,
includeEventListeners: Option<bool>,
includePaintOrder: Option<bool>,
includeUserAgentShadowTree: Option<bool>,
}
impl<'a> GetSnapshotParamsBuilder<'a> {
pub fn includeEventListeners(mut self, includeEventListeners: bool) -> Self { self.includeEventListeners = Some(includeEventListeners); self }
pub fn includePaintOrder(mut self, includePaintOrder: bool) -> Self { self.includePaintOrder = Some(includePaintOrder); self }
pub fn includeUserAgentShadowTree(mut self, includeUserAgentShadowTree: bool) -> Self { self.includeUserAgentShadowTree = Some(includeUserAgentShadowTree); self }
pub fn build(self) -> GetSnapshotParams<'a> {
GetSnapshotParams {
computedStyleWhitelist: self.computedStyleWhitelist,
includeEventListeners: self.includeEventListeners,
includePaintOrder: self.includePaintOrder,
includeUserAgentShadowTree: self.includeUserAgentShadowTree,
}
}
}
#[derive(Debug, Clone, Serialize, Deserialize, Default)]
#[serde(rename_all = "camelCase")]
pub struct GetSnapshotReturns<'a> {
domNodes: Vec<DOMNode<'a>>,
layoutTreeNodes: Vec<LayoutTreeNode<'a>>,
computedStyles: Vec<ComputedStyle<'a>>,
}
impl<'a> GetSnapshotReturns<'a> {
pub fn builder(domNodes: Vec<DOMNode<'a>>, layoutTreeNodes: Vec<LayoutTreeNode<'a>>, computedStyles: Vec<ComputedStyle<'a>>) -> GetSnapshotReturnsBuilder<'a> {
GetSnapshotReturnsBuilder {
domNodes: domNodes,
layoutTreeNodes: layoutTreeNodes,
computedStyles: computedStyles,
}
}
pub fn domNodes(&self) -> &[DOMNode<'a>] { &self.domNodes }
pub fn layoutTreeNodes(&self) -> &[LayoutTreeNode<'a>] { &self.layoutTreeNodes }
pub fn computedStyles(&self) -> &[ComputedStyle<'a>] { &self.computedStyles }
}
pub struct GetSnapshotReturnsBuilder<'a> {
domNodes: Vec<DOMNode<'a>>,
layoutTreeNodes: Vec<LayoutTreeNode<'a>>,
computedStyles: Vec<ComputedStyle<'a>>,
}
impl<'a> GetSnapshotReturnsBuilder<'a> {
pub fn build(self) -> GetSnapshotReturns<'a> {
GetSnapshotReturns {
domNodes: self.domNodes,
layoutTreeNodes: self.layoutTreeNodes,
computedStyles: self.computedStyles,
}
}
}
impl<'a> GetSnapshotParams<'a> { pub const METHOD: &'static str = "DOMSnapshot.getSnapshot"; }
impl<'a> crate::CdpCommand<'a> for GetSnapshotParams<'a> {
const METHOD: &'static str = "DOMSnapshot.getSnapshot";
type Response = GetSnapshotReturns<'a>;
}
#[derive(Debug, Clone, Serialize, Deserialize, Default)]
#[serde(rename_all = "camelCase")]
pub struct CaptureSnapshotParams<'a> {
computedStyles: Vec<Cow<'a, str>>,
#[serde(skip_serializing_if = "Option::is_none")]
includePaintOrder: Option<bool>,
#[serde(skip_serializing_if = "Option::is_none")]
includeDOMRects: Option<bool>,
#[serde(skip_serializing_if = "Option::is_none")]
includeBlendedBackgroundColors: Option<bool>,
#[serde(skip_serializing_if = "Option::is_none")]
includeTextColorOpacities: Option<bool>,
}
impl<'a> CaptureSnapshotParams<'a> {
pub fn builder(computedStyles: Vec<Cow<'a, str>>) -> CaptureSnapshotParamsBuilder<'a> {
CaptureSnapshotParamsBuilder {
computedStyles: computedStyles,
includePaintOrder: None,
includeDOMRects: None,
includeBlendedBackgroundColors: None,
includeTextColorOpacities: None,
}
}
pub fn computedStyles(&self) -> &[Cow<'a, str>] { &self.computedStyles }
pub fn includePaintOrder(&self) -> Option<bool> { self.includePaintOrder }
pub fn includeDOMRects(&self) -> Option<bool> { self.includeDOMRects }
pub fn includeBlendedBackgroundColors(&self) -> Option<bool> { self.includeBlendedBackgroundColors }
pub fn includeTextColorOpacities(&self) -> Option<bool> { self.includeTextColorOpacities }
}
pub struct CaptureSnapshotParamsBuilder<'a> {
computedStyles: Vec<Cow<'a, str>>,
includePaintOrder: Option<bool>,
includeDOMRects: Option<bool>,
includeBlendedBackgroundColors: Option<bool>,
includeTextColorOpacities: Option<bool>,
}
impl<'a> CaptureSnapshotParamsBuilder<'a> {
pub fn includePaintOrder(mut self, includePaintOrder: bool) -> Self { self.includePaintOrder = Some(includePaintOrder); self }
pub fn includeDOMRects(mut self, includeDOMRects: bool) -> Self { self.includeDOMRects = Some(includeDOMRects); self }
pub fn includeBlendedBackgroundColors(mut self, includeBlendedBackgroundColors: bool) -> Self { self.includeBlendedBackgroundColors = Some(includeBlendedBackgroundColors); self }
pub fn includeTextColorOpacities(mut self, includeTextColorOpacities: bool) -> Self { self.includeTextColorOpacities = Some(includeTextColorOpacities); self }
pub fn build(self) -> CaptureSnapshotParams<'a> {
CaptureSnapshotParams {
computedStyles: self.computedStyles,
includePaintOrder: self.includePaintOrder,
includeDOMRects: self.includeDOMRects,
includeBlendedBackgroundColors: self.includeBlendedBackgroundColors,
includeTextColorOpacities: self.includeTextColorOpacities,
}
}
}
#[derive(Debug, Clone, Serialize, Deserialize, Default)]
#[serde(rename_all = "camelCase")]
pub struct CaptureSnapshotReturns<'a> {
documents: Vec<DocumentSnapshot>,
strings: Vec<Cow<'a, str>>,
}
impl<'a> CaptureSnapshotReturns<'a> {
pub fn builder(documents: Vec<DocumentSnapshot>, strings: Vec<Cow<'a, str>>) -> CaptureSnapshotReturnsBuilder<'a> {
CaptureSnapshotReturnsBuilder {
documents: documents,
strings: strings,
}
}
pub fn documents(&self) -> &[DocumentSnapshot] { &self.documents }
pub fn strings(&self) -> &[Cow<'a, str>] { &self.strings }
}
pub struct CaptureSnapshotReturnsBuilder<'a> {
documents: Vec<DocumentSnapshot>,
strings: Vec<Cow<'a, str>>,
}
impl<'a> CaptureSnapshotReturnsBuilder<'a> {
pub fn build(self) -> CaptureSnapshotReturns<'a> {
CaptureSnapshotReturns {
documents: self.documents,
strings: self.strings,
}
}
}
impl<'a> CaptureSnapshotParams<'a> { pub const METHOD: &'static str = "DOMSnapshot.captureSnapshot"; }
impl<'a> crate::CdpCommand<'a> for CaptureSnapshotParams<'a> {
const METHOD: &'static str = "DOMSnapshot.captureSnapshot";
type Response = CaptureSnapshotReturns<'a>;
}