Skip to main content

apply_ua_style_defaults

Function apply_ua_style_defaults 

Source
pub fn apply_ua_style_defaults(
    tag: &str,
    attrs: &Attributes,
    page_gate: bool,
    style: &mut Style,
)
Expand description

The UA-origin per-tag sizing defaults (D3 / task #29) live in skins/ua.css now - an always-on stylesheet folded into the cascade beneath any skin and beneath app CSS (see crate::skins::UA and run::loading::load_ir), so a skinless app still gets a sizing floor without a Rust-side table to keep in sync.

Four cases don’t fit a plain CSS rule and stay here, running at spawn and at every restyle after the cascade and inline attrs have been folded into attrs:

  • <switch> wants its UA min-width only when width is ALSO unset (an explicit width already gives it a usable footprint). CSS has no “set this property only if that other property is unset” syntax, so this stays a Rust conditional instead of a ua.css rule.
  • A page host box fills the window. A multi-page app mounts each page inside a synthetic gate keyed on the reserved active-page signal, and that gate is the page’s containing block: left at its content size, a page whose shell asks for height: 100% resolves the percentage against the shell itself and the bottom of the shell lands past the bottom of the window. Pinning the gate to <root>’s padding box gives every page the same full-window rect, which is what Qt’s QStackedWidget and Slint’s page containers do; taking it out of flow at the same time is what keeps the gates of the pages that are NOT mounted - one empty sibling per page file - from dividing the window between them. The gate is spelled <if>, and an author’s own <if> is an ordinary in-flow element, so the rule keys on the signal rather than the tag and cannot be a ua.css selector.
  • A <dialog> covers its parent: position: absolute with every inset 0, unless a rule or an attribute placed it. The rule would fit in ua.css, but that sheet also reaches the web target’s stylesheet, where a modal dialog sits in the browser’s top layer and has to stay position: fixed.
  • <input> / <textarea> default to overflow: hidden only when neither the overflow shorthand nor overflow-x / overflow-y was authored anywhere. lumen_ir::css never expands the overflow shorthand into the longhands - they’re independent properties to the cascade, reconciled only afterward in lumen_ir::convert via .or(), which doesn’t know about origin. A plain ua.css overflow-x rule would therefore out-rank an author’s shorthand-only overflow: visible, instead of losing to it as the current behavior requires - so this checks the fully-resolved attrs directly instead.