From 8fc7d2875844e0aa5a158efecf2f6ec6ee700d78 Mon Sep 17 00:00:00 2001 From: Mantaroh Yoshinaga Date: Thu, 24 Aug 2017 10:23:48 +0900 Subject: [PATCH] Skip adding/accumulating the values which corresponding rect offset is auto. This patch will skip add_weighted() when self_portion + other_portion not equal to zero. (i.e. adding or accumulating). Gecko does same behavior since we can't add two auto value. --- .../helpers/animated_properties.mako.rs | 21 +++++++++++++++++++ components/style/values/computed/mod.rs | 2 +- 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/components/style/properties/helpers/animated_properties.mako.rs b/components/style/properties/helpers/animated_properties.mako.rs index 2f7aaafc63d..68c90d0ce20 100644 --- a/components/style/properties/helpers/animated_properties.mako.rs +++ b/components/style/properties/helpers/animated_properties.mako.rs @@ -1072,6 +1072,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/components/style/values/computed/mod.rs b/components/style/values/computed/mod.rs index 22d958f90a6..ef2234863bc 100644 --- a/components/style/values/computed/mod.rs +++ b/components/style/values/computed/mod.rs @@ -439,7 +439,7 @@ pub type NonNegativeLengthOrPercentageOrNumber = Either,