Skip to main content

Module compact_cache

Module compact_cache 

Source
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§

CompactLayoutCache
Overflow properties that couldn’t fit in Tier 1/2 encoding. Contains the original CssProperty values for properties that:
CompactNodeProps
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.
CompactNodePropsCold
Paint-cold compact properties for a single node. Only accessed during display list generation, table layout, or text shaping.
CompactTextProps
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 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_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