Factor custom properties in keyframes into compute values in each keyframe

This commit is contained in:
Hiroyuki Ikezoe 2017-09-27 12:50:03 +09:00
parent ded0c713db
commit 1b39041a8c
3 changed files with 90 additions and 16 deletions

View file

@ -26,6 +26,7 @@ use properties::longhands::visibility::computed_value::T as Visibility;
#[cfg(feature = "gecko")] use properties::{PropertyId, PropertyDeclarationId, LonghandId};
#[cfg(feature = "gecko")] use properties::{ShorthandId};
use selectors::parser::SelectorParseError;
use servo_arc::Arc;
use smallvec::SmallVec;
use std::borrow::Cow;
use std::cmp;
@ -568,6 +569,7 @@ impl AnimationValue {
pub fn from_declaration(
decl: &PropertyDeclaration,
context: &mut Context,
extra_custom_properties: &Option<Arc<::custom_properties::CustomPropertiesMap>>,
initial: &ComputedValues
) -> Option<Self> {
use properties::LonghandId;
@ -641,9 +643,14 @@ impl AnimationValue {
}
},
PropertyDeclaration::WithVariables(id, ref unparsed) => {
let custom_props = context.style().custom_properties();
let substituted = unparsed.substitute_variables(id, &custom_props, context.quirks_mode);
AnimationValue::from_declaration(&substituted, context, initial)
let substituted = if extra_custom_properties.is_some() {
unparsed.substitute_variables(
id, &extra_custom_properties, context.quirks_mode)
} else {
unparsed.substitute_variables(
id, &context.style().custom_properties(), context.quirks_mode)
};
AnimationValue::from_declaration(&substituted, context, extra_custom_properties, initial)
},
_ => None // non animatable properties will get included because of shorthands. ignore.
}