Skip to main content

Module compact_cache

Module compact_cache 

Source
Expand description

Compact layout property cache — three-tier numeric encoding

Replaces BTreeMap-based CSS property lookups with cache-friendly arrays. See scripts/COMPACT_CACHE_PLAN.md for design rationale.

  • Tier 1: Vec<u64> — ALL 21 enum properties bitpacked (8 B/node)
  • Tier 2: Vec<CompactNodeProps> — numeric dimensions + border colors/styles (96 B/node)
  • Tier 2b: Vec<CompactTextProps> — text/IFC properties (24 B/node)
  • Tier 3: Vec<Option<Box<CompactOverflowProps>>> — rare/complex (8 B/node)

Structs§

CompactLayoutCache
Three-tier compact layout property cache.
CompactNodeProps
Compact numeric properties for a single node (96 bytes). All dimensions use MSB-sentinel encoding.
CompactTextProps
Compact text/IFC properties for a single node (24 bytes).

Constants§

I16_AUTO
I16_INHERIT
I16_INITIAL
I16_SENTINEL
i16 sentinel values (for signed resolved-px ×10)
I16_SENTINEL_THRESHOLD
Any i16 value >= this threshold is a sentinel
U16_AUTO
U16_INHERIT
U16_INITIAL
U16_MAX_CONTENT
U16_MIN_CONTENT
U16_NONE
U16_SENTINEL
u16 sentinel values (for resolved-px ×10 and flex ×100)
U16_SENTINEL_THRESHOLD
Any u16 value >= this threshold is a sentinel, not a real value
U32_AUTO
U32_INHERIT
U32_INITIAL
U32_MAX_CONTENT
U32_MIN_CONTENT
U32_NONE
U32_SENTINEL
u32 sentinel values (for dimension properties with unit info)
U32_SENTINEL_THRESHOLD
Any u32 value >= this threshold is a sentinel

Functions§

border_collapse_from_u8
border_collapse_to_u8
border_style_from_u8
border_style_to_u8
decode_align_content
decode_align_items
decode_border_bottom_style
Decode border-bottom-style from packed u16
decode_border_collapse
decode_border_left_style
Decode border-left-style from packed u16
decode_border_right_style
Decode border-right-style from packed u16
decode_border_top_style
Decode border-top-style from packed u16
decode_box_sizing
decode_clear
decode_color_u32
Decode a u32 back to ColorU. Returns None if sentinel (0x00000000).
decode_direction
decode_display
Decode individual enum properties from a Tier 1 u64. Each function is #[inline(always)] for zero-cost extraction.
decode_flex_direction
decode_flex_u16
Decode a u16 flex value back to f32. Returns None for sentinel values.
decode_flex_wrap
decode_float
decode_font_style
decode_font_weight
decode_justify_content
decode_overflow_x
decode_overflow_y
decode_pixel_value_u32
Decode a u32 back to PixelValue. Returns None for sentinel values.
decode_position
decode_resolved_px_i16
Decode an i16 back to resolved px. Returns None for sentinel values.
decode_text_align
decode_vertical_align
decode_visibility
decode_white_space
decode_writing_mode
encode_border_styles_packed
Encode 4 border styles into a u16: [3:0]=top, [7:4]=right, [11:8]=bottom, [15:12]=left
encode_color_u32
Encode a ColorU as u32 (0xRRGGBBAA). Returns 0 for sentinel/unset.
encode_css_pixel_as_i16
Resolve a CssPropertyValue to an i16 ×10 encoding. Only handles Exact(px(...)) values. Everything else → sentinel. For the compact cache builder, we only pre-resolve absolute pixel values. Relative units (em, %, etc.) get sentinel and fall back to the slow path.
encode_flex_u16
Encode a u16 flex value (×100). Returns U16_SENTINEL if out of range. Range: 0.00 ..= 655.27 at 0.01 precision.
encode_pixel_value_u32
u32 encoding for dimension properties (width, height, min-, max-, flex-basis, font-size).
encode_resolved_px_i16
Encode an i16 resolved px value (×10). Returns I16_SENTINEL if out of range. Range: -3276.8 ..= +3276.3 px at 0.1px precision.
encode_tier1
Pack all 21 enum properties into a single u64.
layout_align_content_from_u8
layout_align_content_to_u8
layout_align_items_from_u8
layout_align_items_to_u8
layout_box_sizing_from_u8
layout_box_sizing_to_u8
layout_clear_from_u8
layout_clear_to_u8
layout_display_from_u8
Convert raw bits back to LayoutDisplay. Returns default on invalid input.
layout_display_to_u8
Convert LayoutDisplay to its discriminant value (matching #[repr(C)] order).
layout_flex_direction_from_u8
layout_flex_direction_to_u8
layout_flex_wrap_from_u8
layout_flex_wrap_to_u8
layout_float_from_u8
layout_float_to_u8
layout_justify_content_from_u8
layout_justify_content_to_u8
layout_overflow_from_u8
layout_overflow_to_u8
layout_position_from_u8
layout_position_to_u8
layout_writing_mode_from_u8
layout_writing_mode_to_u8
size_metric_from_u8
u8 → SizeMetric
size_metric_to_u8
SizeMetric → u8 (4 bits, 12 variants)
style_direction_from_u8
style_direction_to_u8
style_font_style_from_u8
style_font_style_to_u8
style_font_weight_from_u8
style_font_weight_to_u8
style_text_align_from_u8
style_text_align_to_u8
style_vertical_align_from_u8
style_vertical_align_to_u8
style_visibility_from_u8
style_visibility_to_u8
style_white_space_from_u8
style_white_space_to_u8
tier1_is_populated
Returns true if the tier1 u64 was actually populated by encode_tier1.

Type Aliases§

CompactOverflowProps
Overflow properties that couldn’t fit in Tier 1/2 encoding. Contains the original CssProperty values for properties that: