Skip to main content

euv_core/layout/cache/
struct.rs

1use super::*;
2
3/// Available layout space passed down during a layout pass and cached for clean-subtree skipping.
4#[derive(Clone, Copy, Data, Debug, Default, New, PartialEq)]
5pub struct AvailableSpace {
6    /// Available horizontal extent in logical pixels.
7    #[get(type(copy))]
8    pub(crate) width: f32,
9    /// Available vertical extent in logical pixels.
10    #[get(type(copy))]
11    pub(crate) height: f32,
12    /// Root viewport size for `vw`/`vh` length resolution.
13    #[get(type(copy))]
14    pub(crate) viewport: Size,
15    /// Origin X coordinate where this node is placed.
16    #[get(type(copy))]
17    pub(crate) origin_x: f32,
18    /// Origin Y coordinate where this node is placed.
19    #[get(type(copy))]
20    pub(crate) origin_y: f32,
21    /// Whether the parent stretched this node's width to fill `width` when its declared width is `Length::Auto`.
22    #[get(type(copy))]
23    #[new(skip)]
24    pub(crate) stretch_width: bool,
25    /// Whether the parent stretched this node's height to fill `height` when its declared height is `Length::Auto`.
26    #[get(type(copy))]
27    #[new(skip)]
28    pub(crate) stretch_height: bool,
29}
30
31/// Internal container constraint bundle passed to child layout solvers.
32#[derive(Clone, Copy, Data, Debug, Default, New, PartialEq)]
33pub(crate) struct ContainerFrame {
34    /// Parent layout properties.
35    #[get(pub(crate), type(copy))]
36    #[get_mut(pub(crate))]
37    #[set(pub(crate))]
38    pub(crate) parent_layout: LayoutStyle,
39    /// Inner available dimensions inside padding and border.
40    #[get(pub(crate), type(copy))]
41    #[get_mut(pub(crate))]
42    #[set(pub(crate))]
43    pub(crate) inner_avail: Size,
44    /// Root viewport logical size.
45    #[get(pub(crate), type(copy))]
46    #[get_mut(pub(crate))]
47    #[set(pub(crate))]
48    pub(crate) viewport: Size,
49    /// Content origin in root coordinates.
50    #[get(pub(crate), type(copy))]
51    #[get_mut(pub(crate))]
52    #[set(pub(crate))]
53    pub(crate) content_origin: Point,
54    /// Whether the container's outer width is definite (explicit length, aspect ratio, or parent stretch).
55    #[get(pub(crate), type(copy))]
56    #[get_mut(pub(crate))]
57    #[set(pub(crate))]
58    pub(crate) definite_width: bool,
59    /// Whether the container's outer height is definite (explicit length, aspect ratio, or parent stretch).
60    #[get(pub(crate), type(copy))]
61    #[get_mut(pub(crate))]
62    #[set(pub(crate))]
63    pub(crate) definite_height: bool,
64}
65
66/// Telemetry counters recorded per layout pass.
67#[derive(Clone, Copy, Data, Debug, Default, Eq, Hash, New, Ord, PartialEq, PartialOrd)]
68pub struct LayoutStats {
69    /// Number of nodes laid out during this pass.
70    #[get(type(copy))]
71    pub(crate) nodes_computed: usize,
72    /// Number of clean subtrees skipped in O(1) via constraint caching.
73    #[get(type(copy))]
74    pub(crate) subtrees_skipped: usize,
75}