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§
- Compact
Layout Cache - Three-tier compact layout property cache.
- Compact
Node Props - Compact numeric properties for a single node (96 bytes). All dimensions use MSB-sentinel encoding.
- Compact
Text Props - 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§
- Compact
Overflow Props - Overflow properties that couldn’t fit in Tier 1/2 encoding.
Contains the original
CssPropertyvalues for properties that: