mirror of
https://github.com/servo/servo.git
synced 2025-08-05 13:40:08 +01:00
Store custom properties in keyframes into servo's PropertyDeclarationBlock
This commit is contained in:
parent
54f8a131ea
commit
ded0c713db
7 changed files with 33 additions and 0 deletions
2
Cargo.lock
generated
2
Cargo.lock
generated
|
@ -1068,6 +1068,7 @@ dependencies = [
|
||||||
"parking_lot 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
"parking_lot 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"selectors 0.19.0",
|
"selectors 0.19.0",
|
||||||
"servo_arc 0.0.1",
|
"servo_arc 0.0.1",
|
||||||
|
"smallvec 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"style 0.0.1",
|
"style 0.0.1",
|
||||||
"style_traits 0.0.1",
|
"style_traits 0.0.1",
|
||||||
"stylo_tests 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)",
|
"regex 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"selectors 0.19.0",
|
"selectors 0.19.0",
|
||||||
"size_of_test 0.0.1",
|
"size_of_test 0.0.1",
|
||||||
|
"smallvec 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"style 0.0.1",
|
"style 0.0.1",
|
||||||
"style_traits 0.0.1",
|
"style_traits 0.0.1",
|
||||||
]
|
]
|
||||||
|
|
|
@ -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:
|
/// The `context` parameter controls this:
|
||||||
///
|
///
|
||||||
/// https://drafts.csswg.org/css-animations/#keyframes
|
/// https://drafts.csswg.org/css-animations/#keyframes
|
||||||
|
|
|
@ -28,6 +28,7 @@ parking_lot = "0.4"
|
||||||
# for the cargo problem behind this.
|
# for the cargo problem behind this.
|
||||||
selectors = {path = "../../components/selectors", features = ["gecko_like_types"]}
|
selectors = {path = "../../components/selectors", features = ["gecko_like_types"]}
|
||||||
servo_arc = {path = "../../components/servo_arc"}
|
servo_arc = {path = "../../components/servo_arc"}
|
||||||
|
smallvec = "0.4"
|
||||||
style = {path = "../../components/style", features = ["gecko"]}
|
style = {path = "../../components/style", features = ["gecko"]}
|
||||||
style_traits = {path = "../../components/style_traits"}
|
style_traits = {path = "../../components/style_traits"}
|
||||||
|
|
||||||
|
|
|
@ -3552,6 +3552,8 @@ pub extern "C" fn Servo_StyleSet_GetKeyframesForName(raw_data: RawServoStyleSetB
|
||||||
name: *const nsACString,
|
name: *const nsACString,
|
||||||
inherited_timing_function: nsTimingFunctionBorrowed,
|
inherited_timing_function: nsTimingFunctionBorrowed,
|
||||||
keyframes: RawGeckoKeyframeListBorrowedMut) -> bool {
|
keyframes: RawGeckoKeyframeListBorrowedMut) -> bool {
|
||||||
|
use smallvec::SmallVec;
|
||||||
|
|
||||||
debug_assert!(keyframes.len() == 0,
|
debug_assert!(keyframes.len() == 0,
|
||||||
"keyframes should be initially empty");
|
"keyframes should be initially empty");
|
||||||
|
|
||||||
|
@ -3623,6 +3625,25 @@ pub extern "C" fn Servo_StyleSet_GetKeyframesForName(raw_data: RawServoStyleSetB
|
||||||
guard.normal_declaration_iter()
|
guard.normal_declaration_iter()
|
||||||
.filter(|declaration| declaration.is_animatable());
|
.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 {
|
for declaration in animatable {
|
||||||
let property = AnimatableLonghand::from_declaration(declaration).unwrap();
|
let property = AnimatableLonghand::from_declaration(declaration).unwrap();
|
||||||
// Skip the 'display' property because although it is animatable from SMIL,
|
// Skip the 'display' property because although it is animatable from SMIL,
|
||||||
|
|
|
@ -11,6 +11,7 @@ extern crate libc;
|
||||||
extern crate malloc_size_of;
|
extern crate malloc_size_of;
|
||||||
extern crate selectors;
|
extern crate selectors;
|
||||||
extern crate servo_arc;
|
extern crate servo_arc;
|
||||||
|
extern crate smallvec;
|
||||||
#[macro_use] extern crate style;
|
#[macro_use] extern crate style;
|
||||||
extern crate style_traits;
|
extern crate style_traits;
|
||||||
|
|
||||||
|
|
|
@ -22,6 +22,7 @@ log = {version = "0.3.5", features = ["release_max_level_info"]}
|
||||||
malloc_size_of = {path = "../../../components/malloc_size_of"}
|
malloc_size_of = {path = "../../../components/malloc_size_of"}
|
||||||
selectors = {path = "../../../components/selectors", features = ["gecko_like_types"]}
|
selectors = {path = "../../../components/selectors", features = ["gecko_like_types"]}
|
||||||
size_of_test = {path = "../../../components/size_of_test"}
|
size_of_test = {path = "../../../components/size_of_test"}
|
||||||
|
smallvec = "0.4"
|
||||||
style_traits = {path = "../../../components/style_traits"}
|
style_traits = {path = "../../../components/style_traits"}
|
||||||
style = {path = "../../../components/style", features = ["gecko"]}
|
style = {path = "../../../components/style", features = ["gecko"]}
|
||||||
|
|
||||||
|
|
|
@ -9,6 +9,7 @@ extern crate geckoservo;
|
||||||
#[macro_use] extern crate log;
|
#[macro_use] extern crate log;
|
||||||
extern crate malloc_size_of;
|
extern crate malloc_size_of;
|
||||||
extern crate selectors;
|
extern crate selectors;
|
||||||
|
extern crate smallvec;
|
||||||
#[macro_use] extern crate size_of_test;
|
#[macro_use] extern crate size_of_test;
|
||||||
#[macro_use] extern crate style;
|
#[macro_use] extern crate style;
|
||||||
extern crate style_traits;
|
extern crate style_traits;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue