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
This commit is contained in:
Boris Chiou 2017-04-21 11:30:56 +08:00
parent 57f87007f2
commit f8ac48b78d
2 changed files with 17 additions and 1 deletions

View file

@ -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,

View file

@ -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,