diff --git a/components/style/properties/properties.mako.rs b/components/style/properties/properties.mako.rs index 8cb60c257cb..59536af635d 100644 --- a/components/style/properties/properties.mako.rs +++ b/components/style/properties/properties.mako.rs @@ -215,43 +215,6 @@ pub mod shorthands { <% data.declare_shorthand("all", [p.name for p in data.longhands if p.name not in ['direction', 'unicode-bidi']], spec="https://drafts.csswg.org/css-cascade-3/#all-shorthand") %> - pub mod all { - use cssparser::Parser; - use parser::ParserContext; - use properties::{SourcePropertyDeclaration, AllShorthand, ShorthandId, UnparsedValue}; - use stylearc::Arc; - use style_traits::{ParseError, StyleParseError}; - - pub fn parse_into<'i, 't>(declarations: &mut SourcePropertyDeclaration, - context: &ParserContext, input: &mut Parser<'i, 't>) - -> Result<(), ParseError<'i>> { - // This function is like the parse() that is generated by - // helpers:shorthand, but since the only values for the 'all' - // shorthand when not just a single CSS-wide keyword is one - // with variable references, we can make this function a - // little simpler. - // - // FIXME(heycam) Try to share code with the helpers:shorthand - // definition. - input.look_for_var_functions(); - let start = input.position(); - while let Ok(_) = input.next() {} // Look for var() - if input.seen_var_functions() { - input.reset(start); - let (first_token_type, css) = - ::custom_properties::parse_non_custom_with_var(input)?; - declarations.all_shorthand = AllShorthand::WithVariables(Arc::new(UnparsedValue { - css: css.into_owned(), - first_token_type: first_token_type, - url_data: context.url_data.clone(), - from_shorthand: Some(ShorthandId::All), - })); - Ok(()) - } else { - Err(StyleParseError::UnspecifiedError.into()) - } - } - } } /// A module with all the code related to animated properties. @@ -863,11 +826,13 @@ impl ShorthandId { context: &ParserContext, input: &mut Parser<'i, 't>) -> Result<(), ParseError<'i>> { match *self { - % for shorthand in data.shorthands: + % for shorthand in data.shorthands_except_all(): ShorthandId::${shorthand.camel_case} => { shorthands::${shorthand.ident}::parse_into(declarations, context, input) } % endfor + // 'all' accepts no value other than CSS-wide keywords + ShorthandId::All => Err(StyleParseError::UnspecifiedError.into()) } } } @@ -1603,10 +1568,14 @@ impl PropertyDeclaration { url_data: context.url_data.clone(), from_shorthand: Some(id), }); - for &longhand in id.longhands() { - declarations.push( - PropertyDeclaration::WithVariables(longhand, unparsed.clone()) - ) + if id == ShorthandId::All { + declarations.all_shorthand = AllShorthand::WithVariables(unparsed) + } else { + for &longhand in id.longhands() { + declarations.push( + PropertyDeclaration::WithVariables(longhand, unparsed.clone()) + ) + } } Ok(()) } else {