mirror of
https://github.com/servo/servo.git
synced 2025-08-06 06:00:15 +01:00
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:
parent
52bee9a4cf
commit
c0baac4194
1 changed files with 19 additions and 0 deletions
|
@ -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 {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue