Store custom properties in keyframes into servo's PropertyDeclarationBlock

This commit is contained in:
Hiroyuki Ikezoe 2017-09-27 12:49:15 +09:00
parent 54f8a131ea
commit ded0c713db
7 changed files with 33 additions and 0 deletions

View file

@ -28,6 +28,7 @@ parking_lot = "0.4"
# for the cargo problem behind this.
selectors = {path = "../../components/selectors", features = ["gecko_like_types"]}
servo_arc = {path = "../../components/servo_arc"}
smallvec = "0.4"
style = {path = "../../components/style", features = ["gecko"]}
style_traits = {path = "../../components/style_traits"}

View file

@ -3552,6 +3552,8 @@ pub extern "C" fn Servo_StyleSet_GetKeyframesForName(raw_data: RawServoStyleSetB
name: *const nsACString,
inherited_timing_function: nsTimingFunctionBorrowed,
keyframes: RawGeckoKeyframeListBorrowedMut) -> bool {
use smallvec::SmallVec;
debug_assert!(keyframes.len() == 0,
"keyframes should be initially empty");
@ -3623,6 +3625,25 @@ pub extern "C" fn Servo_StyleSet_GetKeyframesForName(raw_data: RawServoStyleSetB
guard.normal_declaration_iter()
.filter(|declaration| declaration.is_animatable());
let custom_properties: SmallVec<[&PropertyDeclaration; 1]> =
guard.normal_declaration_iter()
.filter(|declaration| declaration.is_custom())
.collect();
if custom_properties.len() > 0 {
let mut pdb = PropertyDeclarationBlock::new();
for custom in custom_properties.iter() {
pdb.push((*custom).clone(), Importance::Normal);
}
unsafe {
let pair =
Gecko_AppendPropertyValuePair(&mut (*keyframe).mPropertyValues,
nsCSSPropertyID::eCSSPropertyExtra_variable);
(*pair).mServoDeclarationBlock.set_arc_leaky(
Arc::new(global_style_data.shared_lock.wrap(pdb)));
}
}
for declaration in animatable {
let property = AnimatableLonghand::from_declaration(declaration).unwrap();
// Skip the 'display' property because although it is animatable from SMIL,

View file

@ -11,6 +11,7 @@ extern crate libc;
extern crate malloc_size_of;
extern crate selectors;
extern crate servo_arc;
extern crate smallvec;
#[macro_use] extern crate style;
extern crate style_traits;