From 8fc7d2875844e0aa5a158efecf2f6ec6ee700d78 Mon Sep 17 00:00:00 2001 From: Mantaroh Yoshinaga Date: Thu, 24 Aug 2017 10:23:48 +0900 Subject: [PATCH 1/2] 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, From 5e40a806ebd689385164958be48008a2dc638f78 Mon Sep 17 00:00:00 2001 From: Mantaroh Yoshinaga Date: Thu, 24 Aug 2017 10:25:44 +0900 Subject: [PATCH 2/2] 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. --- ports/geckolib/glue.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/ports/geckolib/glue.rs b/ports/geckolib/glue.rs index eca3ba79d68..684a1992c8b 100644 --- a/ports/geckolib/glue.rs +++ b/ports/geckolib/glue.rs @@ -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]