Auto merge of #17173 - Manishearth:supports-fixes, r=upsuper

Stop parsing @supports rules before Delimiter::Bang

Fixes #15482

Shorthand parsing uses `parse_entirely`, so we have to ask it to stop before the `!important`.

An alternate fix is to not use `parse_entirely` there and ensuring that all callers of `PropertyDeclaration::parse_into()` check that the input is exhausted. Two of the three callers do that anyway because they check for `!important`.

We also weren't checking for the end of the parser for `CSS.supports()`.

<!-- 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/17173)
<!-- Reviewable:end -->
This commit is contained in:
bors-servo 2017-06-05 23:19:31 -07:00 committed by GitHub
commit eaa01223a7
2 changed files with 6 additions and 3 deletions

View file

@ -4,7 +4,7 @@
//! [@supports rules](https://drafts.csswg.org/css-conditional-3/#at-supports)
use cssparser::{parse_important, Parser, SourceLocation, Token};
use cssparser::{Delimiter, parse_important, Parser, SourceLocation, Token};
use parser::ParserContext;
use properties::{PropertyId, PropertyDeclaration, SourcePropertyDeclaration};
use shared_lock::{DeepCloneWithLock, Locked, SharedRwLock, SharedRwLockReadGuard, ToCssWithGuard};
@ -263,7 +263,10 @@ impl Declaration {
let mut input = Parser::new(&self.val);
let context = ParserContext::new_with_rule_type(cx, Some(CssRuleType::Style));
let mut declarations = SourcePropertyDeclaration::new();
let res = PropertyDeclaration::parse_into(&mut declarations, id, &context, &mut input);
let res = input.parse_until_before(Delimiter::Bang, |input| {
PropertyDeclaration::parse_into(&mut declarations, id, &context, input)
.map_err(|_| ())
});
let _ = input.try(parse_important);
res.is_ok() && input.is_exhausted()
}