mirror of
https://github.com/servo/servo.git
synced 2025-08-03 12:40:06 +01:00
Check context to test keyframe rule_type
Now that the `context` contains the `rule_type`, we can remove the `in_keyframe` arg and check the `rule_type` to achieve the same thing. MozReview-Commit-ID: oXrFBPuKMz
This commit is contained in:
parent
997015a4f7
commit
1ae1d370f2
5 changed files with 8 additions and 9 deletions
|
@ -405,7 +405,7 @@ impl<'a, 'b> DeclarationParser for KeyframeDeclarationParser<'a, 'b> {
|
|||
|
||||
fn parse_value(&mut self, name: &str, input: &mut Parser) -> Result<ParsedDeclaration, ()> {
|
||||
let id = try!(PropertyId::parse(name.into()));
|
||||
match ParsedDeclaration::parse(id, self.context, input, true) {
|
||||
match ParsedDeclaration::parse(id, self.context, input) {
|
||||
Ok(parsed) => {
|
||||
// In case there is still unparsed text in the declaration, we should roll back.
|
||||
if !input.is_exhausted() {
|
||||
|
|
|
@ -628,7 +628,7 @@ pub fn parse_one_declaration(id: PropertyId,
|
|||
-> Result<ParsedDeclaration, ()> {
|
||||
let context = ParserContext::new(Origin::Author, url_data, error_reporter, Some(CssRuleType::Style));
|
||||
Parser::new(input).parse_entirely(|parser| {
|
||||
ParsedDeclaration::parse(id, &context, parser, false)
|
||||
ParsedDeclaration::parse(id, &context, parser)
|
||||
.map_err(|_| ())
|
||||
})
|
||||
}
|
||||
|
@ -653,7 +653,7 @@ impl<'a, 'b> DeclarationParser for PropertyDeclarationParser<'a, 'b> {
|
|||
-> Result<(ParsedDeclaration, Importance), ()> {
|
||||
let id = try!(PropertyId::parse(name.into()));
|
||||
let parsed = input.parse_until_before(Delimiter::Bang, |input| {
|
||||
ParsedDeclaration::parse(id, self.context, input, false)
|
||||
ParsedDeclaration::parse(id, self.context, input)
|
||||
.map_err(|_| ())
|
||||
})?;
|
||||
let importance = match input.try(parse_important) {
|
||||
|
|
|
@ -976,8 +976,7 @@ impl ParsedDeclaration {
|
|||
/// This will not actually parse Importance values, and will always set things
|
||||
/// to Importance::Normal. Parsing Importance values is the job of PropertyDeclarationParser,
|
||||
/// we only set them here so that we don't have to reallocate
|
||||
pub fn parse(id: PropertyId, context: &ParserContext, input: &mut Parser,
|
||||
in_keyframe_block: bool)
|
||||
pub fn parse(id: PropertyId, context: &ParserContext, input: &mut Parser)
|
||||
-> Result<ParsedDeclaration, PropertyDeclarationParseError> {
|
||||
let rule_type = context.rule_type();
|
||||
debug_assert!(rule_type == CssRuleType::Keyframe ||
|
||||
|
@ -1000,7 +999,7 @@ impl ParsedDeclaration {
|
|||
LonghandId::${property.camel_case} => {
|
||||
% if not property.derived_from:
|
||||
% if not property.allowed_in_keyframe_block:
|
||||
if in_keyframe_block {
|
||||
if rule_type == CssRuleType::Keyframe {
|
||||
return Err(PropertyDeclarationParseError::AnimationPropertyInKeyframeBlock)
|
||||
}
|
||||
% endif
|
||||
|
@ -1033,7 +1032,7 @@ impl ParsedDeclaration {
|
|||
% for shorthand in data.shorthands:
|
||||
ShorthandId::${shorthand.camel_case} => {
|
||||
% if not shorthand.allowed_in_keyframe_block:
|
||||
if in_keyframe_block {
|
||||
if rule_type == CssRuleType::Keyframe {
|
||||
return Err(PropertyDeclarationParseError::AnimationPropertyInKeyframeBlock)
|
||||
}
|
||||
% endif
|
||||
|
|
|
@ -213,7 +213,7 @@ impl Declaration {
|
|||
};
|
||||
let mut input = Parser::new(&self.val);
|
||||
let context = ParserContext::new_with_rule_type(cx, Some(CssRuleType::Style));
|
||||
let res = ParsedDeclaration::parse(id, &context, &mut input, /* in_keyframe */ false);
|
||||
let res = ParsedDeclaration::parse(id, &context, &mut input);
|
||||
let _ = input.try(parse_important);
|
||||
res.is_ok() && input.is_exhausted()
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue