Derive ComputeSquaredDistance for animated filters

This commit is contained in:
Anthony Ramine 2018-02-08 03:14:23 +01:00
parent cf4f89c36e
commit f017743a55
3 changed files with 16 additions and 20 deletions

View file

@ -24,7 +24,8 @@ pub struct BoxShadow<Color, SizeLength, BlurShapeLength, ShapeLength> {
/// 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<Angle, Factor, Length, DropShadow> {
/// `blur(<length>)`
#[css(function)]
@ -57,6 +58,7 @@ pub enum Filter<Angle, Factor, Length, DropShadow> {
#[css(function)]
DropShadow(DropShadow),
/// `<url>`
#[animation(error)]
#[cfg(feature = "gecko")]
Url(SpecifiedUrl),
}

View file

@ -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;
@ -47,6 +48,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<SquaredDistance, ()> {
match *self {}
}
}
impl Parse for Impossible {
fn parse<'i, 't>(
_context: &ParserContext,