Skip to main content

Module prop_cache

Module prop_cache 

Source
Expand description

CSS property cache for efficient per-node style resolution. CSS property cache for efficient style resolution and animation.

This module implements a cache layer between the raw CSS stylesheet and the rendered DOM. It resolves CSS properties for each node, handling:

  • Cascade resolution: Computes final values from CSS rules, inline styles, and inheritance
  • Pseudo-class states: Caches styles for :hover, :active, :focus, etc.
  • Animation support: Tracks animating properties for smooth interpolation
  • Performance: Avoids re-parsing and re-resolving unchanged properties

§Architecture

The cache is organized per-node and per-property-type. Each property has a dedicated getter method that:

  1. Checks if the property is cached
  2. If not, resolves it from CSS rules + inline styles
  3. Caches the result for subsequent frames

§Thread Safety

Not thread-safe. Each window has its own cache instance.

Structs§

CssPropertyCache
CssPropertyCacheBreakdown
Heap-size breakdown of a CssPropertyCache, produced by CssPropertyCache::memory_breakdown. All values in bytes.
CssPropertyCachePtr
CssPropertyWithOrigin
A CSS property with its origin tracking.
FlatVecVec
A flat, cache-friendly replacement for Vec<Vec<T>>.
StatefulCssProperty
A CSS property tagged with its pseudo-state and property type. Replaces the per-pseudo-state BTreeMap approach: instead of 6 BTreeMaps per node (Normal/Hover/Active/Focus/Dragging/DragOver), we store one Vec per node and tag each property with its state. Lookups use .iter().find().

Enums§

CssPropertyOrigin
Tracks the origin of a CSS property value. Used to correctly implement the CSS cascade and inheritance rules.

Functions§

drain_css_prop_counts
Drain the per-thread CSS cascade-walk counter populated by CssPropertyCache::get_property when AZ_PROP_COUNT=1 is set in the environment. Returns (property_label, count) pairs sorted by count descending. Layout-side instrumentation calls this after each layout_document to print which properties drove the most cascade walks.