diff --git a/components/style/gecko/generated/bindings.rs b/components/style/gecko/generated/bindings.rs index f21f90058677..d80a8f1eae64 100644 --- a/components/style/gecko/generated/bindings.rs +++ b/components/style/gecko/generated/bindings.rs @@ -2628,6 +2628,10 @@ extern "C" { list: *mut RefPtr); } +extern "C" { + pub fn Servo_AnimationValue_Transform(list: *const nsCSSValueSharedList) + -> RawServoAnimationValueStrong; +} extern "C" { pub fn Servo_AnimationValue_DeepEqual(arg1: RawServoAnimationValueBorrowed, diff --git a/components/style/gecko_bindings/sugar/ns_css_value.rs b/components/style/gecko_bindings/sugar/ns_css_value.rs index 8c1d83c8ffda..2a930b5cd1a4 100644 --- a/components/style/gecko_bindings/sugar/ns_css_value.rs +++ b/components/style/gecko_bindings/sugar/ns_css_value.rs @@ -23,6 +23,12 @@ impl nsCSSValue { unsafe { mem::zeroed() } } + /// Returns true if this nsCSSValue is none. + #[inline] + pub fn is_none(&self) -> bool { + self.mUnit == nsCSSUnit::eCSSUnit_None + } + /// Returns this nsCSSValue value as an integer, unchecked in release /// builds. pub fn integer_unchecked(&self) -> i32 { diff --git a/components/style/properties/gecko.mako.rs b/components/style/properties/gecko.mako.rs index cb0866df0c44..e8236806d7bf 100644 --- a/components/style/properties/gecko.mako.rs +++ b/components/style/properties/gecko.mako.rs @@ -3097,18 +3097,32 @@ fn static_assert() { } } pub fn clone_transform(&self) -> longhands::transform::computed_value::T { - use properties::longhands::transform::computed_value; - if self.gecko.mSpecifiedTransform.mRawPtr.is_null() { - return computed_value::T(None); + return longhands::transform::computed_value::T(None); } let list = unsafe { (*self.gecko.mSpecifiedTransform.to_safe().get()).mHead.as_ref() }; - let result = list.map(|list| { - list.into_iter() - .map(|value| Self::clone_single_transform_function(value)) - .collect() - }); - computed_value::T(result) + Self::clone_transform_from_list(list) + } + pub fn clone_transform_from_list(list: Option< &structs::root::nsCSSValueList>) + -> longhands::transform::computed_value::T { + let result = match list { + Some(list) => { + let vec: Vec<_> = list + .into_iter() + .filter_map(|value| { + // Handle none transform. + if value.is_none() { + None + } else { + Some(Self::clone_single_transform_function(value)) + } + }) + .collect(); + if !vec.is_empty() { Some(vec) } else { None } + }, + _ => None, + }; + longhands::transform::computed_value::T(result) } ${impl_transition_time_value('delay', 'Delay')} diff --git a/ports/geckolib/glue.rs b/ports/geckolib/glue.rs index 169ea08d2540..31ea90e21f28 100644 --- a/ports/geckolib/glue.rs +++ b/ports/geckolib/glue.rs @@ -653,9 +653,10 @@ pub extern "C" fn Servo_AnimationValue_Opacity( } #[no_mangle] -pub extern "C" fn Servo_AnimationValue_GetTransform(value: RawServoAnimationValueBorrowed, - list: *mut structs::RefPtr) -{ +pub extern "C" fn Servo_AnimationValue_GetTransform( + value: RawServoAnimationValueBorrowed, + list: *mut structs::RefPtr +) { let value = AnimationValue::as_arc(&value); if let AnimationValue::Transform(ref servo_list) = **value { let list = unsafe { &mut *list }; @@ -672,6 +673,15 @@ pub extern "C" fn Servo_AnimationValue_GetTransform(value: RawServoAnimationValu } } +#[no_mangle] +pub extern "C" fn Servo_AnimationValue_Transform( + list: *const nsCSSValueSharedList +) -> RawServoAnimationValueStrong { + let list = unsafe { (&*list).mHead.as_ref() }; + let transform = style_structs::Box::clone_transform_from_list(list); + Arc::new(AnimationValue::Transform(transform)).into_strong() +} + #[no_mangle] pub extern "C" fn Servo_AnimationValue_DeepEqual(this: RawServoAnimationValueBorrowed, other: RawServoAnimationValueBorrowed)