diff options
-rw-r--r-- | components/style/properties/helpers/animated_properties.mako.rs | 21 | ||||
-rw-r--r-- | components/style/values/computed/mod.rs | 2 | ||||
-rw-r--r-- | ports/geckolib/glue.rs | 4 |
3 files changed, 25 insertions, 2 deletions
diff --git a/components/style/properties/helpers/animated_properties.mako.rs b/components/style/properties/helpers/animated_properties.mako.rs index 25cc6b47e35..8358b1e2db1 100644 --- a/components/style/properties/helpers/animated_properties.mako.rs +++ b/components/style/properties/helpers/animated_properties.mako.rs @@ -924,6 +924,27 @@ impl Into<FontStretch> for f64 { impl<H, V> RepeatableListAnimatable for generic_position::Position<H, V> 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<Self, ()> { + let animate_component = |this: &Option<Au>, other: &Option<Au>| { + 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<Self, ()> { Err(()) } diff --git a/components/style/values/computed/mod.rs b/components/style/values/computed/mod.rs index 86aaf29b1c5..4d75b7c8954 100644 --- a/components/style/values/computed/mod.rs +++ b/components/style/values/computed/mod.rs @@ -445,7 +445,7 @@ pub type NonNegativeLengthOrPercentageOrNumber = Either<NonNegativeNumber, NonNe #[allow(missing_docs)] #[cfg_attr(feature = "servo", derive(HeapSizeOf))] -#[derive(Animate, Clone, ComputeSquaredDistance, Copy, Debug, Eq, PartialEq)] +#[derive(Clone, ComputeSquaredDistance, Copy, Debug, Eq, PartialEq)] /// A computed cliprect for clip and image-region pub struct ClipRect { pub top: Option<Au>, diff --git a/ports/geckolib/glue.rs b/ports/geckolib/glue.rs index a35be024a33..354bd3c194a 100644 --- a/ports/geckolib/glue.rs +++ b/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] |