Add a function to convert AnimationValueMap to PropertyDeclarationBlock.

We need to convert all AnimationValue (AnimationValueMap) on an element
to PropertyDeclarationBlock in order to push the value inside the CSS cascade.

Two reasons we did not add the function in AnimationValueMap:

 1) All members of PropertyDeclarationBlock are private.
 2) Rust does not allow us impl for type alias, so if we do impl the function
    in AnimationValueMap we need to make AnimationValueMap as a tuple or struct.
This commit is contained in:
Hiroyuki Ikezoe 2017-03-17 12:30:00 +09:00
parent 52bee9a4cf
commit c0baac4194

View file

@ -15,6 +15,7 @@ use std::fmt;
use style_traits::ToCss;
use stylesheets::Origin;
use super::*;
#[cfg(feature = "gecko")] use properties::animated_properties::AnimationValueMap;
/// A declaration [importance][importance].
///
@ -341,6 +342,24 @@ impl PropertyDeclarationBlock {
}
}
}
/// Convert AnimationValueMap to PropertyDeclarationBlock.
#[cfg(feature = "gecko")]
pub fn from_animation_value_map(animation_value_map: &AnimationValueMap) -> Self {
let mut declarations = vec![];
let mut longhands = LonghandIdSet::new();
for (property, animation_value) in animation_value_map.iter() {
longhands.set_transition_property_bit(property);
declarations.push((animation_value.uncompute(), Importance::Normal));
}
PropertyDeclarationBlock {
declarations: declarations,
important_count: 0,
longhands: longhands,
}
}
}
impl ToCss for PropertyDeclarationBlock {