From 4a1b812ee4c1741e573b72bb599e43fa80db94bd Mon Sep 17 00:00:00 2001 From: Boris Chiou Date: Wed, 12 Apr 2017 15:51:42 +0800 Subject: [PATCH 1/5] Bug 1343753 - Add Servo_AnimationValue_Uncompute. MozReview-Commit-ID: KJnVbXmXlug --- components/style/gecko_bindings/bindings.rs | 5 +++++ ports/geckolib/glue.rs | 9 +++++++++ 2 files changed, 14 insertions(+) diff --git a/components/style/gecko_bindings/bindings.rs b/components/style/gecko_bindings/bindings.rs index cabc1ab4af6..e0c8de4ac40 100644 --- a/components/style/gecko_bindings/bindings.rs +++ b/components/style/gecko_bindings/bindings.rs @@ -1716,6 +1716,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/ports/geckolib/glue.rs b/ports/geckolib/glue.rs index ed24e8e68b6..c78be1a196c 100644 --- a/ports/geckolib/glue.rs +++ b/ports/geckolib/glue.rs @@ -401,6 +401,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, From 2867bbcacc0718d6fdac8afd8d881c88f35ada89 Mon Sep 17 00:00:00 2001 From: Boris Chiou Date: Wed, 12 Apr 2017 16:27:59 +0800 Subject: [PATCH 2/5] Bug 1343753 - Add Servo_Animationvalues_IsInterpolable. MozReview-Commit-ID: gaj9lJ7NYV --- components/style/gecko_bindings/bindings.rs | 7 +++++++ ports/geckolib/glue.rs | 9 +++++++++ 2 files changed, 16 insertions(+) diff --git a/components/style/gecko_bindings/bindings.rs b/components/style/gecko_bindings/bindings.rs index e0c8de4ac40..6c118e92bdc 100644 --- a/components/style/gecko_bindings/bindings.rs +++ b/components/style/gecko_bindings/bindings.rs @@ -1692,6 +1692,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, diff --git a/ports/geckolib/glue.rs b/ports/geckolib/glue.rs index c78be1a196c..bb7267cd175 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, From 28db6788b1455949f40b649d4e100e9fb0ef801b Mon Sep 17 00:00:00 2001 From: Boris Chiou Date: Wed, 12 Apr 2017 16:32:11 +0800 Subject: [PATCH 3/5] Bug 1343753 - Add Servo_Property_IsDiscreteAnimatable. MozReview-Commit-ID: 5pMw7Wynv2q --- components/style/gecko_bindings/bindings.rs | 4 ++++ .../properties/helpers/animated_properties.mako.rs | 12 ++++++++++++ ports/geckolib/glue.rs | 6 ++++++ 3 files changed, 22 insertions(+) diff --git a/components/style/gecko_bindings/bindings.rs b/components/style/gecko_bindings/bindings.rs index 6c118e92bdc..e65e3ce76c5 100644 --- a/components/style/gecko_bindings/bindings.rs +++ b/components/style/gecko_bindings/bindings.rs @@ -1684,6 +1684,10 @@ extern "C" { nsCSSPropertyID) -> RawServoAnimationValueStrong; } +extern "C" { + pub fn Servo_Property_IsDiscreteAnimatable(property: nsCSSPropertyID) + -> bool; +} extern "C" { pub fn Servo_AnimationValues_Interpolate(from: RawServoAnimationValueBorrowed, diff --git a/components/style/properties/helpers/animated_properties.mako.rs b/components/style/properties/helpers/animated_properties.mako.rs index 98214519290..b38cd04db72 100644 --- a/components/style/properties/helpers/animated_properties.mako.rs +++ b/components/style/properties/helpers/animated_properties.mako.rs @@ -104,6 +104,18 @@ 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 + } + } } impl ToCss for TransitionProperty { diff --git a/ports/geckolib/glue.rs b/ports/geckolib/glue.rs index bb7267cd175..d1205a0f574 100644 --- a/ports/geckolib/glue.rs +++ b/ports/geckolib/glue.rs @@ -461,6 +461,12 @@ 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_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 From 9a3905f834424fea8021c3c2e52cfa8124a1de1f Mon Sep 17 00:00:00 2001 From: Boris Chiou Date: Wed, 12 Apr 2017 16:34:56 +0800 Subject: [PATCH 4/5] Bug 1343753 - Pass None before change style to Gecko_UpdateAnimations. CSS Transition is not supported yet, so use None as the parameter. MozReview-Commit-ID: Kv77lN92ny5 --- components/style/gecko/wrapper.rs | 1 + components/style/gecko_bindings/bindings.rs | 2 ++ 2 files changed, 3 insertions(+) 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 e65e3ce76c5..978a1ef8250 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: From 51ad646c962dbfb444a3b281aec46cecb341c708 Mon Sep 17 00:00:00 2001 From: Boris Chiou Date: Wed, 12 Apr 2017 16:38:01 +0800 Subject: [PATCH 5/5] Bug 1343753 - Add Servo_Property_IsAnimatable. MozReview-Commit-ID: 343Md43bpij --- components/style/gecko_bindings/bindings.rs | 3 +++ .../properties/helpers/animated_properties.mako.rs | 13 +++++++++++++ ports/geckolib/glue.rs | 6 ++++++ 3 files changed, 22 insertions(+) diff --git a/components/style/gecko_bindings/bindings.rs b/components/style/gecko_bindings/bindings.rs index 978a1ef8250..74c78ef7efc 100644 --- a/components/style/gecko_bindings/bindings.rs +++ b/components/style/gecko_bindings/bindings.rs @@ -1686,6 +1686,9 @@ extern "C" { nsCSSPropertyID) -> RawServoAnimationValueStrong; } +extern "C" { + pub fn Servo_Property_IsAnimatable(property: nsCSSPropertyID) -> bool; +} extern "C" { pub fn Servo_Property_IsDiscreteAnimatable(property: nsCSSPropertyID) -> bool; diff --git a/components/style/properties/helpers/animated_properties.mako.rs b/components/style/properties/helpers/animated_properties.mako.rs index b38cd04db72..ff11c9d5930 100644 --- a/components/style/properties/helpers/animated_properties.mako.rs +++ b/components/style/properties/helpers/animated_properties.mako.rs @@ -118,6 +118,19 @@ impl TransitionProperty { } } +/// 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 { fn to_css(&self, dest: &mut W) -> fmt::Result where W: fmt::Write, diff --git a/ports/geckolib/glue.rs b/ports/geckolib/glue.rs index d1205a0f574..06b6d9bc6b2 100644 --- a/ports/geckolib/glue.rs +++ b/ports/geckolib/glue.rs @@ -461,6 +461,12 @@ 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();