From f8ac48b78d6d7eac6b732ddc8d0a0341ad7560df Mon Sep 17 00:00:00 2001 From: Boris Chiou Date: Fri, 21 Apr 2017 11:30:56 +0800 Subject: [PATCH] Bug 1332633 - Part 2: Implement the FFI for compute distance. This FFI will be used by nsDOMWindowUtils::ComputeAnimationDistance, which will be implemented in another bug. MozReview-Commit-ID: 6KmMmRiYIew --- components/style/gecko_bindings/bindings.rs | 7 +++++++ ports/geckolib/glue.rs | 11 ++++++++++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/components/style/gecko_bindings/bindings.rs b/components/style/gecko_bindings/bindings.rs index 2ea1f286db54..603efb2b100a 100644 --- a/components/style/gecko_bindings/bindings.rs +++ b/components/style/gecko_bindings/bindings.rs @@ -1753,6 +1753,13 @@ extern "C" { RawServoAnimationValueBorrowed) -> bool; } +extern "C" { + pub fn Servo_AnimationValues_ComputeDistance(from: + RawServoAnimationValueBorrowed, + to: + RawServoAnimationValueBorrowed) + -> f64; +} extern "C" { pub fn Servo_AnimationValue_Serialize(value: RawServoAnimationValueBorrowed, diff --git a/ports/geckolib/glue.rs b/ports/geckolib/glue.rs index 81c956c31878..426802e615b9 100644 --- a/ports/geckolib/glue.rs +++ b/ports/geckolib/glue.rs @@ -74,7 +74,7 @@ use style::parser::{LengthParsingMode, ParserContext}; use style::properties::{CascadeFlags, ComputedValues, Importance, ParsedDeclaration}; use style::properties::{PropertyDeclarationBlock, PropertyId}; use style::properties::SKIP_ROOT_AND_ITEM_BASED_DISPLAY_FIXUP; -use style::properties::animated_properties::{AnimationValue, Interpolate, TransitionProperty}; +use style::properties::animated_properties::{AnimationValue, ComputeDistance, Interpolate, TransitionProperty}; use style::properties::parse_one_declaration; use style::restyle_hints::{self, RestyleHint}; use style::rule_tree::StyleSource; @@ -265,6 +265,15 @@ pub extern "C" fn Servo_AnimationValues_IsInterpolable(from: RawServoAnimationVa from_value.interpolate(to_value, 0.5).is_ok() } +#[no_mangle] +pub extern "C" fn Servo_AnimationValues_ComputeDistance(from: RawServoAnimationValueBorrowed, + to: RawServoAnimationValueBorrowed) + -> f64 { + let from_value = AnimationValue::as_arc(&from); + let to_value = AnimationValue::as_arc(&to); + from_value.compute_distance(to_value).unwrap_or(0.0) +} + #[no_mangle] pub extern "C" fn Servo_AnimationValueMap_Push(value_map: RawServoAnimationValueMapBorrowed, property: nsCSSPropertyID,