viewpoint_cdp/protocol/dom_snapshot/
mod.rs1use serde::{Deserialize, Serialize};
6
7#[derive(Debug, Clone, Serialize, Default)]
13#[serde(rename_all = "camelCase")]
14pub struct CaptureSnapshotParams {
15 pub computed_styles: Vec<String>,
17 #[serde(skip_serializing_if = "Option::is_none")]
19 pub include_dom_rects: Option<bool>,
20 #[serde(skip_serializing_if = "Option::is_none")]
22 pub include_blended_background_colors: Option<bool>,
23 #[serde(skip_serializing_if = "Option::is_none")]
25 pub include_text_color_opacities: Option<bool>,
26 #[serde(skip_serializing_if = "Option::is_none")]
28 pub include_paint_order: Option<bool>,
29}
30
31impl CaptureSnapshotParams {
32 pub fn new() -> Self {
34 Self {
35 computed_styles: vec![
36 "display".to_string(),
37 "visibility".to_string(),
38 "opacity".to_string(),
39 ],
40 include_dom_rects: Some(true),
41 ..Default::default()
42 }
43 }
44
45 pub fn with_styles(styles: Vec<String>) -> Self {
47 Self {
48 computed_styles: styles,
49 ..Default::default()
50 }
51 }
52
53 #[must_use]
55 pub fn include_dom_rects(mut self, include: bool) -> Self {
56 self.include_dom_rects = Some(include);
57 self
58 }
59
60 #[must_use]
62 pub fn include_blended_background_colors(mut self, include: bool) -> Self {
63 self.include_blended_background_colors = Some(include);
64 self
65 }
66}
67
68#[derive(Debug, Clone, Serialize, Deserialize)]
70#[serde(rename_all = "camelCase")]
71pub struct CaptureSnapshotResult {
72 pub documents: Vec<DocumentSnapshot>,
74 pub strings: Vec<String>,
76}
77
78#[derive(Debug, Clone, Serialize, Deserialize)]
80#[serde(rename_all = "camelCase")]
81pub struct DocumentSnapshot {
82 pub document_url: i32,
84 pub title: i32,
86 pub base_url: i32,
88 pub content_language: i32,
90 pub encoding_name: i32,
92 pub public_id: i32,
94 pub system_id: i32,
96 pub frame_id: i32,
98 pub nodes: NodeTreeSnapshot,
100 pub layout: LayoutTreeSnapshot,
102 pub text_boxes: TextBoxSnapshot,
104 #[serde(default)]
106 pub scroll_offset_x: Option<f64>,
107 #[serde(default)]
109 pub scroll_offset_y: Option<f64>,
110 #[serde(default)]
112 pub content_width: Option<f64>,
113 #[serde(default)]
115 pub content_height: Option<f64>,
116}
117
118#[derive(Debug, Clone, Serialize, Deserialize)]
120#[serde(rename_all = "camelCase")]
121pub struct NodeTreeSnapshot {
122 #[serde(default)]
124 pub parent_index: Option<Vec<i32>>,
125 #[serde(default)]
127 pub node_type: Option<Vec<i32>>,
128 #[serde(default)]
130 pub shadow_root_type: Option<RareStringData>,
131 #[serde(default)]
133 pub node_name: Option<Vec<i32>>,
134 #[serde(default)]
136 pub node_value: Option<Vec<i32>>,
137 #[serde(default)]
139 pub backend_node_id: Option<Vec<i32>>,
140 #[serde(default)]
142 pub attributes: Option<Vec<ArrayOfStrings>>,
143 #[serde(default)]
145 pub text_value: Option<RareStringData>,
146 #[serde(default)]
148 pub input_value: Option<RareStringData>,
149 #[serde(default)]
151 pub input_checked: Option<RareBooleanData>,
152 #[serde(default)]
154 pub option_selected: Option<RareBooleanData>,
155 #[serde(default)]
157 pub content_document_index: Option<RareIntegerData>,
158 #[serde(default)]
160 pub pseudo_type: Option<RareStringData>,
161 #[serde(default)]
163 pub pseudo_identifier: Option<RareStringData>,
164 #[serde(default)]
166 pub is_clickable: Option<RareBooleanData>,
167 #[serde(default)]
169 pub current_source_url: Option<RareStringData>,
170 #[serde(default)]
172 pub origin_url: Option<RareStringData>,
173}
174
175#[derive(Debug, Clone, Serialize, Deserialize)]
177#[serde(rename_all = "camelCase")]
178pub struct LayoutTreeSnapshot {
179 pub node_index: Vec<i32>,
181 pub styles: Vec<ArrayOfStrings>,
183 pub bounds: Vec<Rectangle>,
185 pub text: Vec<i32>,
187 #[serde(default)]
189 pub stacking_contexts: Option<RareBooleanData>,
190 #[serde(default)]
192 pub paint_orders: Option<Vec<i32>>,
193 #[serde(default)]
195 pub offset_rects: Option<Vec<Rectangle>>,
196 #[serde(default)]
198 pub scroll_rects: Option<Vec<Rectangle>>,
199 #[serde(default)]
201 pub client_rects: Option<Vec<Rectangle>>,
202 #[serde(default)]
204 pub blended_background_colors: Option<Vec<i32>>,
205 #[serde(default)]
207 pub text_color_opacities: Option<Vec<f64>>,
208}
209
210#[derive(Debug, Clone, Serialize, Deserialize)]
212#[serde(rename_all = "camelCase")]
213pub struct TextBoxSnapshot {
214 pub layout_index: Vec<i32>,
216 pub bounds: Vec<Rectangle>,
218 pub start: Vec<i32>,
220 pub length: Vec<i32>,
222}
223
224pub type Rectangle = Vec<f64>;
226
227pub type ArrayOfStrings = Vec<i32>;
229
230#[derive(Debug, Clone, Serialize, Deserialize)]
232pub struct RareStringData {
233 pub index: Vec<i32>,
235 pub value: Vec<i32>,
237}
238
239#[derive(Debug, Clone, Serialize, Deserialize)]
241pub struct RareBooleanData {
242 pub index: Vec<i32>,
244}
245
246#[derive(Debug, Clone, Serialize, Deserialize)]
248pub struct RareIntegerData {
249 pub index: Vec<i32>,
251 pub value: Vec<i32>,
253}
254
255#[derive(Debug, Clone, Serialize, Default)]
261pub struct DisableParams {}
262
263#[derive(Debug, Clone, Serialize, Default)]
269pub struct EnableParams {}