enabled: true touches: [crates/dom/**, roadmap.md] depends-on: [] #
Read the inline style="" attribute into the cascade #
held-out-rerun's WPT re-measurement found that every remaining failure in that
corpus traces to one gap: style="..." attribute values are never read into the
cascade, only <style> block rulesets are. TElement::style_attribute() in
crates/dom/src/style.rs is a hard-coded stub returning None — Stylo's own hook
for this, left unimplemented since Phase 0's corpus styled everything through
<style>, never style="...". ElementData::attr (crates/dom/src/node.rs)
already returns the raw attribute string verbatim, proven by parse.rs's
attributes_are_captured_with_name_and_value test — no parser change is needed.
Implement style_attribute() to look up self.element().attr("style") and, when
present and non-empty, parse it with Stylo's own
style::properties::declaration_block::parse_style_attribute — the same function
Servo and Gecko use for this — then cache the resulting
Arc<Locked<PropertyDeclarationBlock>> somewhere ElementData can own it; today
it has nowhere to. Document::parse (crates/dom/src/style.rs) already
constructs the UrlExtraData, QuirksMode and shared lock this needs; retain
whichever of those the cache requires.
Stylo's rule collector already inserts the style attribute at the correct cascade
level the moment style_attribute() stops returning None —
same_tree_author_normal() after stylesheet author-normal rules, and
same_tree_author_important() separately for !important declarations. No
specificity or cascade-origin logic belongs in this codebase; do not add any —
correctness comes from Stylo's own rule tree, not from anything written here.
Requirements:
- A
style=""attribute with no matching stylesheet rule applies on its own. - An inline declaration overrides a stylesheet rule on the same property, and a
stylesheet
!importantdeclaration still overrides a plain inline one. Model both as new tests incrates/dom/src/computed.rs, followingan_author_margin_on_body_overrides_the_user_agent_default. crates/dom/src/bin/style_check.rs's corpus (built fromcrates/harness/src/cases.rs) has nostyle=fixture today. Add one, or say in the Result section why it wasn't needed to prove the fix — don't leave the question unanswered.
The float-exclusion gap held-out-rerun also found on
auto-margins-used-values-with-floats.tentative.html (a float: right box
declared in a <style> block never excluded from the block formatting context)
is a separate, independent defect. Do not fix it here.
cargo test --workspace must pass. style_check and box_check must report the
same 2958/2958 corpus figure they do today, unless a new style= fixture was
deliberately added to the corpus for this work — if any other count moves, a
recipe was relying on the gap; report it in the Result section rather than
adjusting the recipe. Do not run held_out_check here; a future re-measurement
spec does that once this has landed, so the before-and-after is measured on a
committed base.