From ec40d1db91cb368e82112b56a212c3a867a4d2a1 Mon Sep 17 00:00:00 2001 From: Hiroyuki Ikezoe Date: Wed, 5 Apr 2017 09:09:12 +0900 Subject: [PATCH] Make AnimationValue::from_declaration return computed CSS variable. In Gecko, we resolve CSS variables when we generate keyframes for each animations (i.e. when we create script animations, when we create/update CSS animations). AnimationValue::from_declaration is only called in both cases. --- .../helpers/animated_properties.mako.rs | 42 +++++++++++++++++-- 1 file changed, 38 insertions(+), 4 deletions(-) diff --git a/components/style/properties/helpers/animated_properties.mako.rs b/components/style/properties/helpers/animated_properties.mako.rs index bde0ae8afb4..9c7dada855e 100644 --- a/components/style/properties/helpers/animated_properties.mako.rs +++ b/components/style/properties/helpers/animated_properties.mako.rs @@ -301,7 +301,10 @@ impl AnimationValue { /// Construct an AnimationValue from a property declaration pub fn from_declaration(decl: &PropertyDeclaration, context: &Context, initial: &ComputedValues) -> Option { + use error_reporting::StdoutErrorReporter; use properties::LonghandId; + use properties::DeclaredValue; + match *decl { % for prop in data.longhands: % if prop.animatable: @@ -344,10 +347,41 @@ impl AnimationValue { % endif % endfor } - } - PropertyDeclaration::WithVariables(_, _) => { - // https://bugzilla.mozilla.org/show_bug.cgi?id=1326131 - unimplemented!() + }, + PropertyDeclaration::WithVariables(id, ref variables) => { + let custom_props = context.style().custom_properties(); + let reporter = StdoutErrorReporter; + match id { + % for prop in data.longhands: + % if prop.animatable: + LonghandId::${prop.camel_case} => { + let mut result = None; + ::properties::substitute_variables_${prop.ident}_slow( + &variables.css, + variables.first_token_type, + &variables.url_data, + variables.from_shorthand, + &custom_props, + |v| { + let declaration = match *v { + DeclaredValue::Value(value) => { + PropertyDeclaration::${prop.camel_case}(value.clone()) + }, + DeclaredValue::CSSWideKeyword(keyword) => { + PropertyDeclaration::CSSWideKeyword(id, keyword) + }, + DeclaredValue::WithVariables(_) => unreachable!(), + }; + result = AnimationValue::from_declaration(&declaration, context, initial); + }, + &reporter); + result + }, + % else: + LonghandId::${prop.camel_case} => None, + % endif + % endfor + } }, _ => None // non animatable properties will get included because of shorthands. ignore. }