chromiumoxide/handler/
viewport.rs

1/// Page viewport configuration used when emulating screen metrics.
2///
3/// Width/height are in CSS pixels. Optional fields allow tuning device pixel
4/// ratio, mobile emulation, orientation, and touch support.
5#[derive(Debug, Clone, PartialEq)]
6pub struct Viewport {
7    /// CSS pixel width of the viewport (layout viewport, not device pixels).
8    pub width: u32,
9    /// CSS pixel height of the viewport.
10    pub height: u32,
11    /// Device pixel ratio (DPR). If `None`, the browser default is used.
12    /// Common values: `1.0` for standard displays, `2.0` for “Retina”-like.
13    pub device_scale_factor: Option<f64>,
14    /// Simulate a mobile device (affects UA hints/metrics in some engines).
15    /// Set to `true` to enable mobile-specific layout behavior.
16    pub emulating_mobile: bool,
17    /// Treat the viewport as landscape (`true`) or portrait (`false`).
18    pub is_landscape: bool,
19    /// Advertise touch support (affects input/event capability).
20    /// Set to `true` to enable touch-enabled emulation.
21    pub has_touch: bool,
22}
23
24impl Default for Viewport {
25    /// Default viewport size.
26    fn default() -> Self {
27        Viewport {
28            width: 800,
29            height: 600,
30            device_scale_factor: None,
31            emulating_mobile: false,
32            is_landscape: false,
33            has_touch: false,
34        }
35    }
36}