diff --git a/components/style/gecko/wrapper.rs b/components/style/gecko/wrapper.rs index 657ba4de11b..562135bb94b 100644 --- a/components/style/gecko/wrapper.rs +++ b/components/style/gecko/wrapper.rs @@ -678,6 +678,7 @@ impl<'le> TElement for GeckoElement<'le> { let atom_ptr = PseudoElement::ns_atom_or_null_from_opt(pseudo); unsafe { Gecko_UpdateAnimations(self.0, atom_ptr, + None, computed_values_opt, parent_values_opt, tasks.bits()); diff --git a/components/style/gecko_bindings/bindings.rs b/components/style/gecko_bindings/bindings.rs index cabc1ab4af6..74c78ef7efc 100644 --- a/components/style/gecko_bindings/bindings.rs +++ b/components/style/gecko_bindings/bindings.rs @@ -630,6 +630,8 @@ extern "C" { extern "C" { pub fn Gecko_UpdateAnimations(aElement: RawGeckoElementBorrowed, aPseudoTagOrNull: *mut nsIAtom, + aOldComputedValues: + ServoComputedValuesBorrowedOrNull, aComputedValues: ServoComputedValuesBorrowedOrNull, aParentComputedValues: @@ -1684,6 +1686,13 @@ extern "C" { nsCSSPropertyID) -> RawServoAnimationValueStrong; } +extern "C" { + pub fn Servo_Property_IsAnimatable(property: nsCSSPropertyID) -> bool; +} +extern "C" { + pub fn Servo_Property_IsDiscreteAnimatable(property: nsCSSPropertyID) + -> bool; +} extern "C" { pub fn Servo_AnimationValues_Interpolate(from: RawServoAnimationValueBorrowed, @@ -1692,6 +1701,13 @@ extern "C" { progress: f64) -> RawServoAnimationValueStrong; } +extern "C" { + pub fn Servo_AnimationValues_IsInterpolable(from: + RawServoAnimationValueBorrowed, + to: + RawServoAnimationValueBorrowed) + -> bool; +} extern "C" { pub fn Servo_AnimationValue_Serialize(value: RawServoAnimationValueBorrowed, @@ -1716,6 +1732,11 @@ extern "C" { RawServoAnimationValueBorrowed) -> bool; } +extern "C" { + pub fn Servo_AnimationValue_Uncompute(value: + RawServoAnimationValueBorrowed) + -> RawServoDeclarationBlockStrong; +} extern "C" { pub fn Servo_ParseStyleAttribute(data: *const nsACString, extra_data: *mut RawGeckoURLExtraData) diff --git a/components/style/properties/helpers/animated_properties.mako.rs b/components/style/properties/helpers/animated_properties.mako.rs index 98214519290..ff11c9d5930 100644 --- a/components/style/properties/helpers/animated_properties.mako.rs +++ b/components/style/properties/helpers/animated_properties.mako.rs @@ -104,6 +104,31 @@ impl TransitionProperty { _ => None, } } + + /// Returns true if this TransitionProperty is one of the discrete animatable properties. + pub fn is_discrete(&self) -> bool { + match *self { + % for prop in data.longhands: + % if prop.animation_type == "discrete": + TransitionProperty::${prop.camel_case} => true, + % endif + % endfor + _ => false + } + } +} + +/// Returns true if this nsCSSPropertyID is one of the animatable properties. +#[cfg(feature = "gecko")] +pub fn nscsspropertyid_is_animatable(property: nsCSSPropertyID) -> bool { + match property { + % for prop in data.longhands: + % if prop.animatable: + ${helpers.to_nscsspropertyid(prop.ident)} => true, + % endif + % endfor + _ => false + } } impl ToCss for TransitionProperty { diff --git a/ports/geckolib/glue.rs b/ports/geckolib/glue.rs index fc52eed1159..c0d40c87a83 100644 --- a/ports/geckolib/glue.rs +++ b/ports/geckolib/glue.rs @@ -256,6 +256,15 @@ pub extern "C" fn Servo_AnimationValues_Interpolate(from: RawServoAnimationValue } } +#[no_mangle] +pub extern "C" fn Servo_AnimationValues_IsInterpolable(from: RawServoAnimationValueBorrowed, + to: RawServoAnimationValueBorrowed) + -> bool { + let from_value = AnimationValue::as_arc(&from); + let to_value = AnimationValue::as_arc(&to); + from_value.interpolate(to_value, 0.5).is_ok() +} + #[no_mangle] pub extern "C" fn Servo_AnimationValueMap_Push(value_map: RawServoAnimationValueMapBorrowed, property: nsCSSPropertyID, @@ -401,6 +410,15 @@ pub extern "C" fn Servo_AnimationValue_DeepEqual(this: RawServoAnimationValueBor this_value == other_value } +#[no_mangle] +pub extern "C" fn Servo_AnimationValue_Uncompute(value: RawServoAnimationValueBorrowed) + -> RawServoDeclarationBlockStrong { + let value = AnimationValue::as_arc(&value); + let global_style_data = &*GLOBAL_STYLE_DATA; + Arc::new(global_style_data.shared_lock.wrap( + PropertyDeclarationBlock::with_one(value.uncompute(), Importance::Normal))).into_strong() +} + #[no_mangle] pub extern "C" fn Servo_StyleSet_GetBaseComputedValuesForElement(raw_data: RawServoStyleSetBorrowed, element: RawGeckoElementBorrowed, @@ -443,6 +461,18 @@ pub extern "C" fn Servo_ComputedValues_ExtractAnimationValue(computed_values: Se Arc::new(AnimationValue::from_computed_values(&property_id.into(), computed_values)).into_strong() } +#[no_mangle] +pub extern "C" fn Servo_Property_IsAnimatable(property: nsCSSPropertyID) -> bool { + use style::properties::animated_properties; + animated_properties::nscsspropertyid_is_animatable(property) +} + +#[no_mangle] +pub extern "C" fn Servo_Property_IsDiscreteAnimatable(property: nsCSSPropertyID) -> bool { + let property: TransitionProperty = property.into(); + property.is_discrete() +} + #[no_mangle] pub extern "C" fn Servo_StyleWorkerThreadCount() -> u32 { GLOBAL_STYLE_DATA.num_threads as u32