diff --git a/servo/components/style/values/animated/effects.rs b/servo/components/style/values/animated/effects.rs index 8db9f43689b7..f969aef0c39b 100644 --- a/servo/components/style/values/animated/effects.rs +++ b/servo/components/style/values/animated/effects.rs @@ -104,11 +104,24 @@ where } } -impl ComputeSquaredDistance for ShadowList { +impl ComputeSquaredDistance for ShadowList +where + S: ComputeSquaredDistance + ToAnimatedZero, +{ #[inline] - fn compute_squared_distance(&self, _other: &Self) -> Result { - // FIXME: This should be implemented. - Err(()) + fn compute_squared_distance(&self, other: &Self) -> Result { + use itertools::{EitherOrBoth, Itertools}; + + self.0.iter().zip_longest(other.0.iter()).map(|it| { + match it { + EitherOrBoth::Both(from, to) => { + from.compute_squared_distance(to) + }, + EitherOrBoth::Left(list) | EitherOrBoth::Right(list) => { + list.compute_squared_distance(&list.to_animated_zero()?) + }, + } + }).sum() } }