diff --git a/components/style/properties/helpers/animated_properties.mako.rs b/components/style/properties/helpers/animated_properties.mako.rs index feda388935b..af32c77a64e 100644 --- a/components/style/properties/helpers/animated_properties.mako.rs +++ b/components/style/properties/helpers/animated_properties.mako.rs @@ -2871,25 +2871,6 @@ impl ToAnimatedZero for AnimatedFilter { } } -// FIXME(nox): This should be derived. -impl ComputeSquaredDistance for AnimatedFilter { - fn compute_squared_distance(&self, other: &Self) -> Result { - match (self, other) { - % for func in FILTER_FUNCTIONS: - (&Filter::${func}(ref this), &Filter::${func}(ref other)) => { - this.compute_squared_distance(other) - }, - % endfor - % if product == "gecko": - (&Filter::DropShadow(ref this), &Filter::DropShadow(ref other)) => { - this.compute_squared_distance(other) - }, - % endif - _ => Err(()), - } - } -} - impl Animate for AnimatedFilterList { #[inline] fn animate( diff --git a/components/style/values/generics/effects.rs b/components/style/values/generics/effects.rs index b4fcbb0c505..a43e4f53ba2 100644 --- a/components/style/values/generics/effects.rs +++ b/components/style/values/generics/effects.rs @@ -24,7 +24,8 @@ pub struct BoxShadow { /// A generic value for a single `filter`. #[cfg_attr(feature = "servo", derive(Deserialize, Serialize))] -#[derive(Clone, Debug, MallocSizeOf, PartialEq, ToAnimatedValue, ToComputedValue, ToCss)] +#[derive(Clone, ComputeSquaredDistance, Debug, MallocSizeOf, PartialEq)] +#[derive(ToAnimatedValue, ToComputedValue, ToCss)] pub enum Filter { /// `blur()` #[css(function)] @@ -57,6 +58,7 @@ pub enum Filter { #[css(function)] DropShadow(DropShadow), /// `` + #[animation(error)] #[cfg(feature = "gecko")] Url(SpecifiedUrl), } diff --git a/components/style/values/mod.rs b/components/style/values/mod.rs index e5ad8624015..95a9f7ef817 100644 --- a/components/style/values/mod.rs +++ b/components/style/values/mod.rs @@ -16,6 +16,7 @@ use selectors::parser::SelectorParseErrorKind; use std::fmt::{self, Debug, Write}; use std::hash; use style_traits::{CssWriter, ParseError, StyleParseErrorKind, ToCss}; +use values::distance::{ComputeSquaredDistance, SquaredDistance}; pub mod animated; pub mod computed; @@ -66,6 +67,18 @@ where #[derive(Clone, Copy, Debug, PartialEq, ToComputedValue, ToCss)] pub enum Impossible {} +// FIXME(nox): This should be derived but the derive code cannot cope +// with uninhabited enums. +impl ComputeSquaredDistance for Impossible { + #[inline] + fn compute_squared_distance( + &self, + _other: &Self, + ) -> Result { + match *self {} + } +} + impl Parse for Impossible { fn parse<'i, 't>( _context: &ParserContext,