Closed Bug 1388911 Opened 7 years ago Closed 7 years ago

stylo: Invalid @namespace rule ending with {} is registered in ns map

Categories

(Core :: CSS Parsing and Computation, defect, P3)

defect

Tracking

()

RESOLVED FIXED
mozilla57
Tracking Status
firefox57 --- fixed

People

(Reporter: xidorn, Assigned: xidorn)

References

(Blocks 1 open bug)

Details

In layout/reftests/w3c-css/received/css-namespaces-3/syntax-013.xml, something like
>    @namespace "test" {}
>    t { background:lime }
is broken. The style rule in the second line is not recognized, which causes this test to fail.
Priority: -- → P3
https://github.com/servo/rust-cssparser/blob/master/src/rules_and_declarations.rs should take care of ending an at-rule at the first semicolon or curly-braces block, whichever comes first. I’ll investigate tomorrow.
Assignee: nobody → simon.sapin
Status: NEW → ASSIGNED
So at this moment, this reftest doesn't fail, because .xml files are not handled by stylo regardless of whether stylo is enabled. Enabling stylo for xml files is tracked in bug 1370508.

To reproduce this with a stylo build before bug 1370508 lands, you can change the extension of the test file to .html or .xhtml instead.
Fiddling with devtools after renaming the file to .xhtml, I found that CSSOM for that stylesheet looks as expected: one style rule, no @namespace rule. But the selector still doesn’t match.

This is because, in components/style/stylesheets/rule_parser.rs in <TopLevelRuleParser as AtRuleParser>::parse_prelude, we register a namespace prefix even though the @namespace rule can still be invalid by having a {} block instead of a ; semicolon. We need to either:

* Add to cssparser a callback (AtRuleParser trait method) for the semicolon case. There’s nothing to parse there, but we’d move the side effect of namespace registration there.

* Or move registration up the stack to the users of TopLevelRuleParser. There’s two, in components/style/stylesheets/stylesheet.rs and components/style/stylesheets/mod.rs.
Assignee: simon.sapin → nobody
Status: ASSIGNED → NEW
Summary: stylo: Invalid @namespace rule make parser ignore following content → stylo: Invalid @namespace rule ending with {} is registered in ns map
Blocks: 1389187
No longer blocks: 1389187
Have a working patch. Taking it.
Assignee: nobody → xidorn+moz
Hmmm...
Assignee: xidorn+moz → nobody
Assignee: nobody → xidorn+moz
Pushed by xquan@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/c057e3b320f0
Update expectation for this bug after landing servo/servo#18336.
https://hg.mozilla.org/mozilla-central/rev/c057e3b320f0
Status: NEW → RESOLVED
Closed: 7 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla57
You need to log in before you can comment on or make changes to this bug.