Skip to content

Commit

Permalink
Bug 1332633 - Part 2: Implement the FFI for compute distance.
Browse files Browse the repository at this point in the history
This FFI will be used by nsDOMWindowUtils::ComputeAnimationDistance,
which will be implemented in another bug.

MozReview-Commit-ID: 6KmMmRiYIew
  • Loading branch information
BorisChiou committed Apr 21, 2017
1 parent 57f8700 commit f8ac48b
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
7 changes: 7 additions & 0 deletions components/style/gecko_bindings/bindings.rs
Expand Up @@ -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,
Expand Down
11 changes: 10 additions & 1 deletion ports/geckolib/glue.rs
Expand Up @@ -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;
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit f8ac48b

Please sign in to comment.