Expand description
Three-tier numeric property cache for fast style resolution. Compact layout property cache — three-tier numeric encoding
Replaces BTreeMap-based CSS property lookups with cache-friendly arrays.
- Tier 1:
Vec<u64>— ALL 21 enum properties bitpacked (8 B/node) - Tier 2 hot:
Vec<CompactNodeProps>— layout-critical numeric dimensions (68 B/node) - Tier 2 cold:
Vec<CompactNodePropsCold>— paint-only properties (28 B/node) - Tier 2b:
Vec<CompactTextProps>— text/IFC properties (24 B/node)
Non-compact properties (background, box-shadow, transform, etc.) are
resolved via the slow cascade path in CssPropertyCache::get_property_slow().
Structs§
- Compact
Layout Cache - Overflow properties that couldn’t fit in Tier 1/2 encoding.
Contains the original
CssPropertyvalues for properties that: - Compact
Node Props - Layout-hot compact numeric properties for a single node (68 bytes). Only fields accessed during the constraint-solving loop. All dimensions use MSB-sentinel encoding.
- Compact
Node Props Cold - Paint-cold compact properties for a single node. Only accessed during display list generation, table layout, or text shaping.
- Compact
Text Props - Compact text/IFC properties for a single node (24 bytes).
Constants§
- ALIGN_
CONTENT_ SHIFT - ALIGN_
ITEMS_ SHIFT - ALIGN_
MASK - ALIGN_
SELF_ MASK - ALIGN_
SELF_ SHIFT - BORDER_
COLLAPSE_ MASK - BORDER_
COLLAPSE_ SHIFT - BOX_
SIZING_ MASK - BOX_
SIZING_ SHIFT - CLEAR_
MASK - CLEAR_
SHIFT - DIRECTION_
MASK - DIRECTION_
SHIFT - DISPLAY_
MASK - DISPLAY_
SHIFT - DOM_
HAS_ COLUMN_ COUNT - DOM_
HAS_ COLUMN_ GAP - DOM_
HAS_ COLUMN_ WIDTH - DOM_
HAS_ EXCLUSION_ MARGIN - DOM_
HAS_ HANGING_ PUNCTUATION - DOM_
HAS_ HYPHENATION_ LANGUAGE - DOM_
HAS_ HYPHENS - DOM_
HAS_ INITIAL_ LETTER - DOM_
HAS_ INITIAL_ LETTER_ ALIGN - DOM_
HAS_ LINE_ BREAK - DOM_
HAS_ LINE_ CLAMP - DOM_
HAS_ LINE_ HEIGHT - DOM_
HAS_ OVERFLOW_ WRAP - DOM_
HAS_ SHAPE_ INSIDE - DOM_
HAS_ SHAPE_ MARGIN - DOM_
HAS_ SHAPE_ OUTSIDE - DOM_
HAS_ TEXT_ ALIGN_ LAST - DOM_
HAS_ TEXT_ BOX_ TRIM - DOM_
HAS_ TEXT_ COMBINE_ UPRIGHT - DOM_
HAS_ TEXT_ INDENT - DOM_
HAS_ TEXT_ JUSTIFY - DOM_
HAS_ UNICODE_ BIDI - DOM_
HAS_ WORD_ BREAK - EXTRA_
FLAG_ HAS_ BACKDROP_ FILTER - EXTRA_
FLAG_ HAS_ BREAK - EXTRA_
FLAG_ HAS_ COUNTER - EXTRA_
FLAG_ HAS_ FILTER - EXTRA_
FLAG_ HAS_ MIX_ BLEND_ MODE - EXTRA_
FLAG_ HAS_ SCROLLBAR_ CSS - EXTRA_
FLAG_ HAS_ TEXT_ ORIENTATION - EXTRA_
FLAG_ HAS_ TEXT_ SHADOW - FLEX_
DIRECTION_ SHIFT - FLEX_
DIR_ MASK - FLEX_
WRAP_ MASK - FLEX_
WRAP_ SHIFT - FLOAT_
MASK - FLOAT_
SHIFT - FONT_
STYLE_ MASK - FONT_
STYLE_ SHIFT - FONT_
WEIGHT_ MASK - FONT_
WEIGHT_ SHIFT - GRID_
AUTO_ FLOW_ MASK - GRID_
AUTO_ FLOW_ SHIFT - HOT_
FLAG_ HAS_ BACKGROUND - HOT_
FLAG_ HAS_ BOX_ SHADOW - HOT_
FLAG_ HAS_ CLIP_ PATH - HOT_
FLAG_ HAS_ TEXT_ DECORATION - HOT_
FLAG_ HAS_ TRANSFORM - HOT_
FLAG_ HAS_ TRANSFORM_ ORIGIN - HOT_
FLAG_ SCROLLBAR_ GUTTER_ MASK - HOT_
FLAG_ SCROLLBAR_ GUTTER_ SHIFT - 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
- JUSTIFY_
CONTENT_ SHIFT - JUSTIFY_
ITEMS_ MASK - JUSTIFY_
ITEMS_ SHIFT - JUSTIFY_
MASK - JUSTIFY_
SELF_ MASK - JUSTIFY_
SELF_ SHIFT - OPACITY_
SENTINEL - OVERFLOW_
MASK - OVERFLOW_
X_ SHIFT - OVERFLOW_
Y_ SHIFT - POSITION_
MASK - POSITION_
SHIFT - SCROLLBAR_
GUTTER_ AUTO - SCROLLBAR_
GUTTER_ BOTH_ EDGES - SCROLLBAR_
GUTTER_ MIRROR - SCROLLBAR_
GUTTER_ STABLE - TEXT_
ALIGN_ MASK - TEXT_
ALIGN_ SHIFT - TIER1_
POPULATED_ BIT - Special value stored in the spare bits [63:51] to indicate this node has NO tier-1 data (i.e., all defaults). 0 is a valid all-defaults encoding, so we use bit 63 as a “tier1 populated” flag. If bit 63 is 0 and all other bits are 0, it means “all defaults” (Display::Block, Position::Static, etc.). We set bit 63 = 1 to mark that the node HAS been populated.
- 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
- VERTICAL_
ALIGN_ MASK - VERTICAL_
ALIGN_ SHIFT - VISIBILITY_
MASK - VISIBILITY_
SHIFT - WHITE_
SPACE_ MASK - WHITE_
SPACE_ SHIFT - WRITING_
MODE_ MASK - WRITING_
MODE_ SHIFT
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
Noneif 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_
align_ self_ from_ u8 - layout_
align_ self_ to_ u8 - layout_
box_ sizing_ from_ u8 - layout_
box_ sizing_ to_ u8 - layout_
clear_ from_ u8 - layout_
clear_ to_ u8 - layout_
display_ from_ u8 - Decode display from u8. 0 = Block (most common HTML default). Value 31 (0x1F) = sentinel: look up in slow path for uncommon values. Returns default (Block) on invalid input.
- layout_
display_ to_ u8 - Encode display to u8. 0 = Block (most common HTML default).
- layout_
flex_ direction_ from_ u8 - layout_
flex_ direction_ to_ u8 - layout_
flex_ wrap_ from_ u8 - 0 = NoWrap (CSS initial value for flex-wrap)
- layout_
flex_ wrap_ to_ u8 - layout_
float_ from_ u8 - Decode float from u8. 0 = None (CSS initial value).
- layout_
float_ to_ u8 - Encode float to u8. 0 = None (CSS initial value).
- layout_
grid_ auto_ flow_ from_ u8 - layout_
grid_ auto_ flow_ to_ u8 - layout_
justify_ content_ from_ u8 - layout_
justify_ content_ to_ u8 - layout_
justify_ items_ from_ u8 - layout_
justify_ items_ to_ u8 - layout_
justify_ self_ from_ u8 - layout_
justify_ self_ to_ u8 - layout_
overflow_ from_ u8 - Decode overflow from u8. 0 = Visible (CSS initial value).
- layout_
overflow_ to_ u8 - Encode overflow to u8. 0 = Visible (CSS initial value).
- 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 - 0 = Normal/400 (CSS initial value for font-weight)
- style_
font_ weight_ to_ u8 - 0 = Normal/400 (CSS initial value for font-weight)
- 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