Auto merge of #18142 - emilio:less-mess-ns, r=SimonSapin

style: Less messy namespace handling.

This PR accounts for the fact that the namespace table is only needed in
`NestedRuleParser`, and only for style rules, in order to simplify the setup and
be able to fix a few bugs wrt parsing of invalid rules.

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/18142)
<!-- Reviewable:end -->
This commit is contained in:
bors-servo 2017-08-18 12:58:46 -05:00 committed by GitHub
commit 941e0dbb5a
9 changed files with 170 additions and 86 deletions

View file

@ -36,9 +36,13 @@ impl CSS {
decl.push_str(&value);
let decl = Declaration(decl);
let url = win.Document().url();
let context = ParserContext::new_for_cssom(&url, win.css_error_reporter(), Some(CssRuleType::Supports),
PARSING_MODE_DEFAULT,
QuirksMode::NoQuirks);
let context = ParserContext::new_for_cssom(
&url,
win.css_error_reporter(),
Some(CssRuleType::Style),
PARSING_MODE_DEFAULT,
QuirksMode::NoQuirks
);
decl.eval(&context)
}
@ -49,9 +53,13 @@ impl CSS {
let cond = parse_condition_or_declaration(&mut input);
if let Ok(cond) = cond {
let url = win.Document().url();
let context = ParserContext::new_for_cssom(&url, win.css_error_reporter(), Some(CssRuleType::Supports),
PARSING_MODE_DEFAULT,
QuirksMode::NoQuirks);
let context = ParserContext::new_for_cssom(
&url,
win.css_error_reporter(),
Some(CssRuleType::Style),
PARSING_MODE_DEFAULT,
QuirksMode::NoQuirks
);
cond.eval(&context)
} else {
false