From 59a3142200269bec7d65b48f3f3fb2ed2e9e24e1 Mon Sep 17 00:00:00 2001 From: Brian Birtles Date: Thu, 6 Jul 2017 06:38:17 +0900 Subject: [PATCH 1/2] Handle zero-length lists in add_weighted --- .../style/properties/helpers/animated_properties.mako.rs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/components/style/properties/helpers/animated_properties.mako.rs b/components/style/properties/helpers/animated_properties.mako.rs index 3f5d91ba467..e68faeb8924 100644 --- a/components/style/properties/helpers/animated_properties.mako.rs +++ b/components/style/properties/helpers/animated_properties.mako.rs @@ -828,6 +828,10 @@ macro_rules! repeated_vec_impl { $(impl Animatable for $ty { fn add_weighted(&self, other: &Self, self_portion: f64, other_portion: f64) -> Result { + // If the length of either list is zero, the least common multiple is undefined. + if cmp::min(self.len(), other.len()) < 1 { + return Err(()); + } use num_integer::lcm; let len = lcm(self.len(), other.len()); self.iter().cycle().zip(other.iter().cycle()).take(len).map(|(me, you)| { @@ -842,6 +846,10 @@ macro_rules! repeated_vec_impl { #[inline] fn compute_squared_distance(&self, other: &Self) -> Result { + // If the length of either list is zero, the least common multiple is undefined. + if cmp::min(self.len(), other.len()) < 1 { + return Err(()); + } use num_integer::lcm; let len = lcm(self.len(), other.len()); self.iter().cycle().zip(other.iter().cycle()).take(len).map(|(me, you)| { From 4b36f1e9c4986126d10b5adda9c0664a585274d4 Mon Sep 17 00:00:00 2001 From: Brian Birtles Date: Thu, 6 Jul 2017 06:38:57 +0900 Subject: [PATCH 2/2] Use the value of the progress through the keyframe interval when falling back to 50% flip behavior --- ports/geckolib/glue.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ports/geckolib/glue.rs b/ports/geckolib/glue.rs index 2b023147b02..56b99babed7 100644 --- a/ports/geckolib/glue.rs +++ b/ports/geckolib/glue.rs @@ -545,7 +545,7 @@ pub extern "C" fn Servo_AnimationCompose(raw_value_map: RawServoAnimationValueMa }; if let Ok(value) = from_value.interpolate(to_value, position) { value_map.insert(property, value); - } else if progress < 0.5 { + } else if position < 0.5 { value_map.insert(property, from_value.clone()); } else { value_map.insert(property, to_value.clone());