Make Servo_AnimationValues_ComputeDistance return negative value instead of 0.0 when the function fails to distinguish its failure.

We need to check whether the function fails or not in order to check whether
we support the specified paced animation values.

Current servo returns 0.0 when failed computing distance, so servo doesn't
distinguish its failure. This patch makes Servo_AnimationValue_ComputeDistance
return a negative value when the function fails.
This commit is contained in:
Mantaroh Yoshinaga 2017-08-24 10:25:44 +09:00
parent 8fc7d28758
commit 5e40a806eb

View file

@ -386,7 +386,9 @@ pub extern "C" fn Servo_AnimationValues_ComputeDistance(from: RawServoAnimationV
-> f64 {
let from_value = AnimationValue::as_arc(&from);
let to_value = AnimationValue::as_arc(&to);
from_value.compute_squared_distance(to_value).map(|d| d.sqrt()).unwrap_or(0.0)
// If compute_squared_distance() failed, this function will return negative value
// in order to check whether we support the specified paced animation values.
from_value.compute_squared_distance(to_value).map(|d| d.sqrt()).unwrap_or(-1.0)
}
#[no_mangle]