style: Disallow all CSS-wide keywords in animation shorthand and counter-increment/counter-reset.

Fixes #15054.
This commit is contained in:
Cameron McCormack 2017-04-13 10:28:14 +08:00
parent 9c0d8e44a0
commit 95356c62d1
3 changed files with 40 additions and 24 deletions

View file

@ -816,16 +816,26 @@ ${helpers.single_keyword("overflow-x", "visible hidden scroll auto",
impl Parse for SpecifiedValue {
fn parse(_context: &ParserContext, input: &mut ::cssparser::Parser) -> Result<Self, ()> {
use cssparser::Token;
Ok(match input.next() {
Ok(Token::Ident(ref value)) => SpecifiedValue(if value == "none" {
// FIXME We may want to support `@keyframes ""` at some point.
atom!("")
} else {
Atom::from(&**value)
}),
Ok(Token::QuotedString(value)) => SpecifiedValue(Atom::from(&*value)),
use properties::CSSWideKeyword;
use std::ascii::AsciiExt;
let atom = match input.next() {
Ok(Token::Ident(ref value)) => {
if CSSWideKeyword::from_ident(value).is_some() {
// We allow any ident for the animation-name except one
// of the CSS-wide keywords.
return Err(());
} else if value.eq_ignore_ascii_case("none") {
// FIXME We may want to support `@keyframes ""` at some point.
atom!("")
} else {
Atom::from(&**value)
}
}
Ok(Token::QuotedString(value)) => Atom::from(&*value),
_ => return Err(()),
})
};
Ok(SpecifiedValue(atom))
}
}
no_viewport_percentage!(SpecifiedValue);