Skip to main content

CompactLayoutCache

Struct CompactLayoutCache 

Source
pub struct CompactLayoutCache {
    pub uses_viewport_units: bool,
    pub tier1_enums: Vec<u64>,
    pub tier2_dims: Vec<CompactNodeProps>,
    pub tier2_cold: Vec<CompactNodePropsCold>,
    pub tier2b_text: Vec<CompactTextProps>,
    pub font_dirty_nodes: Vec<usize>,
    pub prev_font_hashes: Vec<u64>,
    pub font_hash_to_families: BTreeMap<u64, StyleFontFamilyVec>,
    pub has_dynamic_conditions: bool,
    pub dom_declared_flags: u32,
    pub inline_viewport_w: Vec<u32>,
    pub inline_viewport_h: Vec<u32>,
}
Expand description

Three-tier compact layout property cache.

Allocated once per restyle, indexed by node index (same as NodeId). Provides O(1) array-indexed access to all layout properties.

Non-compact properties (background, box-shadow, transform, etc.) are resolved via the slow cascade path in CssPropertyCache::get_property_slow().

Fields§

§uses_viewport_units: bool

Whether ANY layout-relevant pixel value in this document uses a viewport-relative unit (vw/vh/vmin/vmax), detected while the build loop extracts those very values (text tier + box dimensions — the set that feeds inline collection and measurement).

Consumers use it to SKIP viewport-based cache invalidation for the overwhelmingly common document that never mentions a viewport unit: solver3’s inline-collection fingerprint folded ctx.viewport_size into EVERY IFC’s key “because vw/vh”, so every resize invalidated every collection (552 re-collections ≈ 19.6 ms per resize on big.md) to protect a feature the document did not use. False negatives are impossible for the covered set (the flag is set from the same values the cache encodes); a property OUTSIDE the covered set cannot reach inline collection, which is the only consumer.

§tier1_enums: Vec<u64>

Tier 1: ALL enum properties bitpacked into u64 per node (8 B/node)

§tier2_dims: Vec<CompactNodeProps>

Tier 2 hot: Layout-critical numeric dimensions per node (68 B/node)

§tier2_cold: Vec<CompactNodePropsCold>

Tier 2 cold: Paint-only properties per node (28 B/node)

§tier2b_text: Vec<CompactTextProps>

Tier 2b: Text/IFC properties per node (24 B/node)

§font_dirty_nodes: Vec<usize>

Indices of nodes whose font_family_hash changed since the last frame.

Enables per-node font dirty tracking instead of the global all-or-nothing font_stacks_hash XOR approach. When this list is non-empty, only the font chains for these specific nodes need to be re-resolved, avoiding O(N) re-resolution when a single node’s font-family changes.

Populated during build_compact_cache() by comparing each node’s font_family_hash against prev_font_hashes.

§prev_font_hashes: Vec<u64>

Previous frame’s per-node font_family_hash values.

Stored after each compact cache build so that the next build can detect which specific nodes’ font-family changed (rather than relying on a collision-prone global XOR hash).

§font_hash_to_families: BTreeMap<u64, StyleFontFamilyVec>

Reverse map: font_family_hash (u64) → actual StyleFontFamilyVec.

Populated during build_compact_cache() as a byproduct of hash computation. Consumers use this to look up font family names from the compact cache hash without going through get_property_slow() (which fails for inherited values on text nodes).

§has_dynamic_conditions: bool

True when any node’s inline style carries a NON-pseudo dynamic condition (viewport/@media, theme, OS, container…). The window uses this to decide whether a DynamicSelectorContext change (a resize crossing a breakpoint, a theme flip) requires rebuilding this cache: for the overwhelmingly common condition-free DOM the answer is a single bool read.

§dom_declared_flags: u32

Bitfield tracking which rare text props are declared anywhere in the DOM. Built once during build_compact_cache_with_inheritance. When a bit is clear, callers (e.g. translate_to_text3_constraints) can skip the cascade walk for that property — its slow path would always return None and fall back to the default. See DOM_HAS_* constants.

§inline_viewport_w: Vec<u32>

Viewport WIDTH thresholds harvested from every inline conditional property in the DOM — where a ViewportWidth condition can flip. Stored as f32::to_bits (this struct derives Eq); sorted + deduped. Together with the author stylesheet’s Css::viewport_breakpoints, these replace the old hardcoded breakpoint guess list in the engine’s resize decision (a widget breakpoint like the ribbon’s 720px was invisible to that list, so shrinking onto the mobile layout never regenerated).

§inline_viewport_h: Vec<u32>

Viewport HEIGHT thresholds, same contract as inline_viewport_w.

Implementations§

Source§

impl CompactLayoutCache

Source

pub const fn empty() -> Self

Create an empty cache (no nodes).

Source

pub fn with_capacity(node_count: usize) -> Self

Create a cache pre-allocated for node_count nodes, filled with defaults.

Source

pub const fn node_count(&self) -> usize

Number of nodes in this cache.

Source

pub fn get_display(&self, node_idx: usize) -> LayoutDisplay

Source

pub fn get_position(&self, node_idx: usize) -> LayoutPosition

Source

pub fn get_float(&self, node_idx: usize) -> LayoutFloat

Source

pub fn get_overflow_x(&self, node_idx: usize) -> LayoutOverflow

Source

pub fn get_overflow_y(&self, node_idx: usize) -> LayoutOverflow

Source

pub fn get_box_sizing(&self, node_idx: usize) -> LayoutBoxSizing

Source

pub fn get_flex_direction(&self, node_idx: usize) -> LayoutFlexDirection

Source

pub fn get_flex_wrap(&self, node_idx: usize) -> LayoutFlexWrap

Source

pub fn get_justify_content(&self, node_idx: usize) -> LayoutJustifyContent

Source

pub fn get_align_items(&self, node_idx: usize) -> LayoutAlignItems

Source

pub fn get_align_content(&self, node_idx: usize) -> LayoutAlignContent

Source

pub fn get_writing_mode(&self, node_idx: usize) -> LayoutWritingMode

Source

pub fn get_clear(&self, node_idx: usize) -> LayoutClear

Source

pub fn get_font_weight(&self, node_idx: usize) -> StyleFontWeight

Source

pub fn get_font_style(&self, node_idx: usize) -> StyleFontStyle

Source

pub fn get_text_align(&self, node_idx: usize) -> StyleTextAlign

Source

pub fn get_visibility(&self, node_idx: usize) -> StyleVisibility

Source

pub fn get_white_space(&self, node_idx: usize) -> StyleWhiteSpace

Source

pub fn get_direction(&self, node_idx: usize) -> StyleDirection

Source

pub fn get_vertical_align(&self, node_idx: usize) -> StyleVerticalAlign

Source

pub fn get_border_collapse(&self, node_idx: usize) -> StyleBorderCollapse

Source

pub fn get_width_raw(&self, node_idx: usize) -> u32

Get width as encoded u32 (use decode_pixel_value_u32 or check sentinel).

Source

pub fn get_height_raw(&self, node_idx: usize) -> u32

Source

pub fn get_min_width_raw(&self, node_idx: usize) -> u32

Source

pub fn get_max_width_raw(&self, node_idx: usize) -> u32

Source

pub fn get_min_height_raw(&self, node_idx: usize) -> u32

Source

pub fn get_max_height_raw(&self, node_idx: usize) -> u32

Source

pub fn get_font_size_raw(&self, node_idx: usize) -> u32

Source

pub fn get_flex_basis_raw(&self, node_idx: usize) -> u32

Source

pub fn get_padding_top(&self, node_idx: usize) -> Option<f32>

Get padding-top as resolved px. Returns None if sentinel (needs slow path).

Source

pub fn get_padding_right(&self, node_idx: usize) -> Option<f32>

Source

pub fn get_padding_bottom(&self, node_idx: usize) -> Option<f32>

Source

pub fn get_padding_left(&self, node_idx: usize) -> Option<f32>

Source

pub fn get_margin_top(&self, node_idx: usize) -> Option<f32>

Source

pub fn get_margin_right(&self, node_idx: usize) -> Option<f32>

Source

pub fn get_margin_bottom(&self, node_idx: usize) -> Option<f32>

Source

pub fn get_margin_left(&self, node_idx: usize) -> Option<f32>

Source

pub fn is_margin_top_auto(&self, node_idx: usize) -> bool

Check if margin is Auto (important for centering logic).

Source

pub fn is_margin_right_auto(&self, node_idx: usize) -> bool

Source

pub fn is_margin_bottom_auto(&self, node_idx: usize) -> bool

Source

pub fn is_margin_left_auto(&self, node_idx: usize) -> bool

Source

pub fn get_border_top_width(&self, node_idx: usize) -> Option<f32>

Source

pub fn get_border_right_width(&self, node_idx: usize) -> Option<f32>

Source

pub fn get_border_bottom_width(&self, node_idx: usize) -> Option<f32>

Source

pub fn get_border_left_width(&self, node_idx: usize) -> Option<f32>

Source

pub fn get_padding_top_raw(&self, node_idx: usize) -> i16

Source

pub fn get_padding_right_raw(&self, node_idx: usize) -> i16

Source

pub fn get_padding_bottom_raw(&self, node_idx: usize) -> i16

Source

pub fn get_padding_left_raw(&self, node_idx: usize) -> i16

Source

pub fn get_margin_top_raw(&self, node_idx: usize) -> i16

Source

pub fn get_margin_right_raw(&self, node_idx: usize) -> i16

Source

pub fn get_margin_bottom_raw(&self, node_idx: usize) -> i16

Source

pub fn get_margin_left_raw(&self, node_idx: usize) -> i16

Source

pub fn get_border_top_width_raw(&self, node_idx: usize) -> i16

Source

pub fn get_border_right_width_raw(&self, node_idx: usize) -> i16

Source

pub fn get_border_bottom_width_raw(&self, node_idx: usize) -> i16

Source

pub fn get_border_left_width_raw(&self, node_idx: usize) -> i16

Source

pub fn get_top(&self, node_idx: usize) -> i16

Source

pub fn get_right(&self, node_idx: usize) -> i16

Source

pub fn get_bottom(&self, node_idx: usize) -> i16

Source

pub fn get_left(&self, node_idx: usize) -> i16

Source

pub fn get_flex_grow(&self, node_idx: usize) -> Option<f32>

Source

pub fn get_flex_shrink(&self, node_idx: usize) -> Option<f32>

Source

pub fn get_z_index(&self, node_idx: usize) -> i16

Source

pub fn get_border_top_color_raw(&self, node_idx: usize) -> u32

Source

pub fn get_border_right_color_raw(&self, node_idx: usize) -> u32

Source

pub fn get_border_bottom_color_raw(&self, node_idx: usize) -> u32

Source

pub fn get_border_left_color_raw(&self, node_idx: usize) -> u32

Source

pub fn get_border_styles_packed(&self, node_idx: usize) -> u16

Source

pub fn get_border_top_style(&self, node_idx: usize) -> BorderStyle

Source

pub fn get_border_right_style(&self, node_idx: usize) -> BorderStyle

Source

pub fn get_border_bottom_style(&self, node_idx: usize) -> BorderStyle

Source

pub fn get_border_left_style(&self, node_idx: usize) -> BorderStyle

Source

pub fn get_border_spacing_h_raw(&self, node_idx: usize) -> i16

Source

pub fn get_border_spacing_v_raw(&self, node_idx: usize) -> i16

Source

pub fn get_tab_size_raw(&self, node_idx: usize) -> i16

Source

pub fn get_border_top_left_radius_raw(&self, node_idx: usize) -> i16

Source

pub fn get_border_top_right_radius_raw(&self, node_idx: usize) -> i16

Source

pub fn get_border_bottom_left_radius_raw(&self, node_idx: usize) -> i16

Source

pub fn get_border_bottom_right_radius_raw(&self, node_idx: usize) -> i16

Source

pub fn get_opacity_raw(&self, node_idx: usize) -> u8

Raw opacity byte. OPACITY_SENTINEL (255) = unset (default = 1.0). Otherwise value / 254.0 yields the opacity in [0.0, 1.0].

Source

pub fn get_hot_flags(&self, node_idx: usize) -> u8

Source

pub fn has_transform(&self, node_idx: usize) -> bool

Source

pub fn has_transform_origin(&self, node_idx: usize) -> bool

Source

pub fn has_box_shadow(&self, node_idx: usize) -> bool

Source

pub fn has_text_decoration(&self, node_idx: usize) -> bool

Source

pub fn has_background(&self, node_idx: usize) -> bool

Source

pub fn has_clip_path(&self, node_idx: usize) -> bool

Source

pub fn has_scrollbar_css(&self, node_idx: usize) -> bool

Source

pub fn has_counter(&self, node_idx: usize) -> bool

Source

pub fn has_break(&self, node_idx: usize) -> bool

Source

pub fn has_text_orientation(&self, node_idx: usize) -> bool

Source

pub fn has_text_shadow(&self, node_idx: usize) -> bool

Source

pub fn has_backdrop_filter(&self, node_idx: usize) -> bool

Source

pub fn has_filter(&self, node_idx: usize) -> bool

Source

pub fn has_mix_blend_mode(&self, node_idx: usize) -> bool

Source

pub const fn dom_declared(&self, flag: u32) -> bool

DOM-level fast-path check: returns true if the given flag bit is set (some node in this DOM declared the corresponding property).

Source

pub fn get_scrollbar_gutter_bits(&self, node_idx: usize) -> u8

Scrollbar-gutter: 0 = auto (default), 1 = stable, 2 = both-edges, 3 = mirror.

Source

pub fn get_text_color_raw(&self, node_idx: usize) -> u32

Source

pub fn get_font_family_hash(&self, node_idx: usize) -> u64

Source

pub fn get_line_height(&self, node_idx: usize) -> Option<f32>

Source

pub fn get_letter_spacing(&self, node_idx: usize) -> Option<f32>

Source

pub fn get_word_spacing(&self, node_idx: usize) -> Option<f32>

Source

pub fn get_text_indent(&self, node_idx: usize) -> Option<f32>

Trait Implementations§

Source§

impl Clone for CompactLayoutCache

Source§

fn clone(&self) -> CompactLayoutCache

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for CompactLayoutCache

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Eq for CompactLayoutCache

Source§

impl PartialEq for CompactLayoutCache

Source§

fn eq(&self, other: &CompactLayoutCache) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for CompactLayoutCache

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.