Skip to main content

promotion_reasons

Function promotion_reasons 

Source
pub fn promotion_reasons(
    props: &Props,
    child_count: usize,
    ineligible_element: bool,
) -> PromotionReasons
Expand description

The promotion rule set — pure, one flag per rule (see the module doc’s extensibility contract). PromotionReasons::FORCED is cache: "always" in the base style, gated only on element eligibility (no visual semantics of its own — no child or groupAlpha gate). PromotionReasons::FILTER is a non-empty filter chain in the base style OR any hover/press/focus variant, gated the same way (the effect is subtree-wide by definition, and a filtered leaf is valid). Like opacity the union is presence-based: interaction must never flip promotion, so a hover-only filter promotes eagerly — the layer (and its capture) exists before the first hover. PromotionReasons::OPACITY:

  • opacity present — value-blind (an explicit opacity: 1 stays promoted, so fades crossing 1.0 never thrash), unioned across the base style, hover/press/focus variants (interaction must never flip promotion), and animated bindings;
  • at least one child (a leaf’s group alpha is visually identical to the per-node fold — promoting it would be pure cost);
  • groupAlpha != false (the opt-out, read from the base style only — the field is no_overlay);
  • the element kind is eligible (ineligible_element = false). v1 ineligible: <text> (its fold already cascades to spans via resolved-style inheritance — group semantics without a layer) and detached roots (<surface>/<root> — separate render paths).