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

2
Cargo.lock generated
View file

@ -1068,6 +1068,7 @@ dependencies = [
"parking_lot 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)",
"selectors 0.19.0",
"servo_arc 0.0.1",
"smallvec 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)",
"style 0.0.1",
"style_traits 0.0.1",
"stylo_tests 0.0.1",
@ -3235,6 +3236,7 @@ dependencies = [
"regex 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
"selectors 0.19.0",
"size_of_test 0.0.1",
"smallvec 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)",
"style 0.0.1",
"style_traits 0.0.1",
]

View file

@ -1514,6 +1514,12 @@ impl PropertyDeclaration {
}
}
/// Returns true if this property is a custom property, false
/// otherwise.
pub fn is_custom(&self) -> bool {
matches!(*self, PropertyDeclaration::Custom(_, _))
}
/// The `context` parameter controls this:
///
/// https://drafts.csswg.org/css-animations/#keyframes

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;

View file

@ -22,6 +22,7 @@ log = {version = "0.3.5", features = ["release_max_level_info"]}
malloc_size_of = {path = "../../../components/malloc_size_of"}
selectors = {path = "../../../components/selectors", features = ["gecko_like_types"]}
size_of_test = {path = "../../../components/size_of_test"}
smallvec = "0.4"
style_traits = {path = "../../../components/style_traits"}
style = {path = "../../../components/style", features = ["gecko"]}

View file

@ -9,6 +9,7 @@ extern crate geckoservo;
#[macro_use] extern crate log;
extern crate malloc_size_of;
extern crate selectors;
extern crate smallvec;
#[macro_use] extern crate size_of_test;
#[macro_use] extern crate style;
extern crate style_traits;