diff --git a/servo/components/style/properties/helpers/animated_properties.mako.rs b/servo/components/style/properties/helpers/animated_properties.mako.rs index 25cc6b47e35c..8358b1e2db12 100644 --- a/servo/components/style/properties/helpers/animated_properties.mako.rs +++ b/servo/components/style/properties/helpers/animated_properties.mako.rs @@ -924,6 +924,27 @@ impl Into for f64 { impl RepeatableListAnimatable for generic_position::Position where H: RepeatableListAnimatable, V: RepeatableListAnimatable {} +/// https://drafts.csswg.org/css-transitions/#animtype-rect +impl Animate for ClipRect { + #[inline] + fn animate(&self, other: &Self, procedure: Procedure) -> Result { + let animate_component = |this: &Option, other: &Option| { + match (this.animate(other, procedure)?, procedure) { + (None, Procedure::Interpolate { .. }) => Ok(None), + (None, _) => Err(()), + (result, _) => Ok(result), + } + }; + + Ok(ClipRect { + top: animate_component(&self.top, &other.top)?, + right: animate_component(&self.right, &other.right)?, + bottom: animate_component(&self.bottom, &other.bottom)?, + left: animate_component(&self.left, &other.left)?, + }) + } +} + impl ToAnimatedZero for ClipRect { #[inline] fn to_animated_zero(&self) -> Result { Err(()) } diff --git a/servo/components/style/values/computed/mod.rs b/servo/components/style/values/computed/mod.rs index 86aaf29b1c54..4d75b7c89546 100644 --- a/servo/components/style/values/computed/mod.rs +++ b/servo/components/style/values/computed/mod.rs @@ -445,7 +445,7 @@ pub type NonNegativeLengthOrPercentageOrNumber = Either, diff --git a/servo/ports/geckolib/glue.rs b/servo/ports/geckolib/glue.rs index a35be024a33e..354bd3c194a9 100644 --- a/servo/ports/geckolib/glue.rs +++ b/servo/ports/geckolib/glue.rs @@ -379,7 +379,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]