diff options
author | Hiroyuki Ikezoe <hikezoe@mozilla.com> | 2017-09-27 12:49:15 +0900 |
---|---|---|
committer | Hiroyuki Ikezoe <hikezoe@mozilla.com> | 2017-09-27 18:27:48 +0900 |
commit | ded0c713dbe2fccfb481b8e6776b536d92a42e8e (patch) | |
tree | e7c89ad54d17440f448385b7b4f32b09fec49b41 | |
parent | 54f8a131ea50fe8b0480d9f146acc97e13bc45d6 (diff) | |
download | servo-ded0c713dbe2fccfb481b8e6776b536d92a42e8e.tar.gz servo-ded0c713dbe2fccfb481b8e6776b536d92a42e8e.zip |
Store custom properties in keyframes into servo's PropertyDeclarationBlock
-rw-r--r-- | Cargo.lock | 2 | ||||
-rw-r--r-- | components/style/properties/properties.mako.rs | 6 | ||||
-rw-r--r-- | ports/geckolib/Cargo.toml | 1 | ||||
-rw-r--r-- | ports/geckolib/glue.rs | 21 | ||||
-rw-r--r-- | ports/geckolib/lib.rs | 1 | ||||
-rw-r--r-- | tests/unit/stylo/Cargo.toml | 1 | ||||
-rw-r--r-- | tests/unit/stylo/lib.rs | 1 |
7 files changed, 33 insertions, 0 deletions
diff --git a/Cargo.lock b/Cargo.lock index 040dd59c0ba..4625445a166 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -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", ] diff --git a/components/style/properties/properties.mako.rs b/components/style/properties/properties.mako.rs index 31693b1a85a..e372277901c 100644 --- a/components/style/properties/properties.mako.rs +++ b/components/style/properties/properties.mako.rs @@ -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 diff --git a/ports/geckolib/Cargo.toml b/ports/geckolib/Cargo.toml index fd711610a27..4043e9beb56 100644 --- a/ports/geckolib/Cargo.toml +++ b/ports/geckolib/Cargo.toml @@ -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"} diff --git a/ports/geckolib/glue.rs b/ports/geckolib/glue.rs index ccdd19b1bf6..69ea011a979 100644 --- a/ports/geckolib/glue.rs +++ b/ports/geckolib/glue.rs @@ -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, diff --git a/ports/geckolib/lib.rs b/ports/geckolib/lib.rs index f1222823730..ca57307c245 100644 --- a/ports/geckolib/lib.rs +++ b/ports/geckolib/lib.rs @@ -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; diff --git a/tests/unit/stylo/Cargo.toml b/tests/unit/stylo/Cargo.toml index 2d430835681..40248fb0420 100644 --- a/tests/unit/stylo/Cargo.toml +++ b/tests/unit/stylo/Cargo.toml @@ -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"]} diff --git a/tests/unit/stylo/lib.rs b/tests/unit/stylo/lib.rs index a00d6d44c55..6b460558953 100644 --- a/tests/unit/stylo/lib.rs +++ b/tests/unit/stylo/lib.rs @@ -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; |