Skip to main content

browser_protocol/headlessexperimental/
mod.rs

1//! This domain provides experimental commands only supported in headless mode.
2
3use serde::{Serialize, Deserialize};
4
5/// Encoding options for a screenshot.
6
7#[derive(Debug, Clone, Serialize, Deserialize, Default)]
8#[serde(rename_all = "camelCase")]
9pub struct ScreenshotParams {
10    /// Image compression format (defaults to png).
11
12    #[serde(skip_serializing_if = "Option::is_none")]
13    pub format: Option<String>,
14    /// Compression quality from range \[0..100\] (jpeg and webp only).
15
16    #[serde(skip_serializing_if = "Option::is_none")]
17    pub quality: Option<i64>,
18    /// Optimize image encoding for speed, not for resulting size (defaults to false)
19
20    #[serde(skip_serializing_if = "Option::is_none")]
21    pub optimizeForSpeed: Option<bool>,
22}
23
24/// Sends a BeginFrame to the target and returns when the frame was completed. Optionally captures a
25/// screenshot from the resulting frame. Requires that the target was created with enabled
26/// BeginFrameControl. Designed for use with --run-all-compositor-stages-before-draw, see also
27/// <https://goo.gle/chrome-headless-rendering> for more background.
28
29#[derive(Debug, Clone, Serialize, Deserialize, Default)]
30#[serde(rename_all = "camelCase")]
31pub struct BeginFrameParams {
32    /// Timestamp of this BeginFrame in Renderer TimeTicks (milliseconds of uptime). If not set,
33    /// the current time will be used.
34
35    #[serde(skip_serializing_if = "Option::is_none")]
36    pub frameTimeTicks: Option<f64>,
37    /// The interval between BeginFrames that is reported to the compositor, in milliseconds.
38    /// Defaults to a 60 frames/second interval, i.e. about 16.666 milliseconds.
39
40    #[serde(skip_serializing_if = "Option::is_none")]
41    pub interval: Option<f64>,
42    /// Whether updates should not be committed and drawn onto the display. False by default. If
43    /// true, only side effects of the BeginFrame will be run, such as layout and animations, but
44    /// any visual updates may not be visible on the display or in screenshots.
45
46    #[serde(skip_serializing_if = "Option::is_none")]
47    pub noDisplayUpdates: Option<bool>,
48    /// If set, a screenshot of the frame will be captured and returned in the response. Otherwise,
49    /// no screenshot will be captured. Note that capturing a screenshot can fail, for example,
50    /// during renderer initialization. In such a case, no screenshot data will be returned.
51
52    #[serde(skip_serializing_if = "Option::is_none")]
53    pub screenshot: Option<ScreenshotParams>,
54}
55
56/// Sends a BeginFrame to the target and returns when the frame was completed. Optionally captures a
57/// screenshot from the resulting frame. Requires that the target was created with enabled
58/// BeginFrameControl. Designed for use with --run-all-compositor-stages-before-draw, see also
59/// <https://goo.gle/chrome-headless-rendering> for more background.
60
61#[derive(Debug, Clone, Serialize, Deserialize, Default)]
62#[serde(rename_all = "camelCase")]
63pub struct BeginFrameReturns {
64    /// Whether the BeginFrame resulted in damage and, thus, a new frame was committed to the
65    /// display. Reported for diagnostic uses, may be removed in the future.
66
67    pub hasDamage: bool,
68    /// Base64-encoded image data of the screenshot, if one was requested and successfully taken. (Encoded as a base64 string when passed over JSON)
69
70    #[serde(skip_serializing_if = "Option::is_none")]
71    pub screenshotData: Option<String>,
72}