Skip to main content

compute_counters

Function compute_counters 

Source
pub fn compute_counters(
    styled_dom: &StyledDom,
    tree: &LayoutTree,
    counters: &mut BTreeMap<(usize, String), i32>,
)
Expand description

Computes CSS counter values for all nodes in the layout tree.

This function traverses the tree in document order and processes counter-reset and counter-increment properties. The computed values are stored in cache.counters.

CSS counters work with a stack-based scoping model:

  • counter-reset creates a new scope and sets the counter to a value
  • counter-increment increments the counter in the current scope
  • When leaving a subtree, counter scopes are popped