Derive the most trivial ToAnimatedZero impls

This commit is contained in:
Anthony Ramine 2017-08-22 15:30:43 +02:00
parent 8ca9542de6
commit faaf31411a
15 changed files with 112 additions and 174 deletions

View file

@ -879,23 +879,6 @@ impl Animate for LengthOrPercentage {
}
}
impl ToAnimatedZero for LengthOrPercentage {
#[inline]
fn to_animated_zero(&self) -> Result<Self, ()> {
match *self {
LengthOrPercentage::Length(ref length) => {
Ok(LengthOrPercentage::Length(length.to_animated_zero()?))
},
LengthOrPercentage::Percentage(ref percentage) => {
Ok(LengthOrPercentage::Percentage(percentage.to_animated_zero()?))
},
LengthOrPercentage::Calc(ref calc) => {
Ok(LengthOrPercentage::Calc(calc.to_animated_zero()?))
},
}
}
}
/// https://drafts.csswg.org/css-transitions/#animtype-lpcalc
impl Animate for LengthOrPercentageOrAuto {
#[inline]
@ -1134,20 +1117,6 @@ where
}
}
impl<H, V> ToAnimatedZero for generic_position::Position<H, V>
where
H: ToAnimatedZero,
V: ToAnimatedZero,
{
#[inline]
fn to_animated_zero(&self) -> Result<Self, ()> {
Ok(generic_position::Position {
horizontal: self.horizontal.to_animated_zero()?,
vertical: self.vertical.to_animated_zero()?,
})
}
}
impl<H, V> RepeatableListAnimatable for generic_position::Position<H, V>
where H: RepeatableListAnimatable, V: RepeatableListAnimatable {}
@ -2689,28 +2658,6 @@ where
}
}
impl<L, N> ToAnimatedZero for SvgLengthOrPercentageOrNumber<L, N>
where
L: ToAnimatedZero,
N: ToAnimatedZero,
{
#[inline]
fn to_animated_zero(&self) -> Result<Self, ()> {
match *self {
SvgLengthOrPercentageOrNumber::LengthOrPercentage(ref lop) => {
Ok(SvgLengthOrPercentageOrNumber::LengthOrPercentage(
lop.to_animated_zero()?,
))
},
SvgLengthOrPercentageOrNumber::Number(ref num) => {
Ok(SvgLengthOrPercentageOrNumber::Number(
num.to_animated_zero()?,
))
},
}
}
}
impl<L> Animate for SVGLength<L>
where
L: Animate + Clone,
@ -2732,21 +2679,6 @@ where
}
}
impl<L> ToAnimatedZero for SVGLength<L>
where
L: ToAnimatedZero,
{
#[inline]
fn to_animated_zero(&self) -> Result<Self, ()> {
match *self {
SVGLength::Length(ref length) => {
Ok(SVGLength::Length(length.to_animated_zero()?))
},
SVGLength::ContextValue => Ok(SVGLength::ContextValue),
}
}
}
/// https://www.w3.org/TR/SVG11/painting.html#StrokeDasharrayProperty
impl<L> Animate for SVGStrokeDashArray<L>
where
@ -2772,7 +2704,7 @@ where
impl<L> ToAnimatedZero for SVGStrokeDashArray<L>
where
L: Clone + ToAnimatedZero
L: ToAnimatedZero,
{
#[inline]
fn to_animated_zero(&self) -> Result<Self, ()> {
@ -2808,19 +2740,6 @@ where
}
}
impl<OpacityType> ToAnimatedZero for SVGOpacity<OpacityType>
where OpacityType: ToAnimatedZero + Clone
{
#[inline]
fn to_animated_zero(&self) -> Result<Self, ()> {
match self {
&SVGOpacity::Opacity(ref opacity) =>
opacity.to_animated_zero().map(SVGOpacity::Opacity),
other => Ok(other.clone()),
}
}
}
<%
FILTER_FUNCTIONS = [ 'Blur', 'Brightness', 'Contrast', 'Grayscale',
'HueRotate', 'Invert', 'Opacity', 'Saturate',
@ -2877,7 +2796,6 @@ impl ToAnimatedZero for AnimatedFilter {
}
}
// FIXME(nox): This should be derived.
impl ComputeSquaredDistance for AnimatedFilter {
fn compute_squared_distance(&self, other: &Self) -> Result<SquaredDistance, ()> {
@ -3004,15 +2922,6 @@ where
}
}
impl<T> ToAnimatedZero for NonNegative<T>
where T: ToAnimatedZero
{
#[inline]
fn to_animated_zero(&self) -> Result<Self, ()> {
self.0.to_animated_zero().map(NonNegative::<T>)
}
}
impl<T> Animate for GreaterThanOrEqualToOne<T>
where
T: Animate,
@ -3022,12 +2931,3 @@ where
Ok(GreaterThanOrEqualToOne(self.0.animate(&other.0, procedure)?))
}
}
impl<T> ToAnimatedZero for GreaterThanOrEqualToOne<T>
where T: ToAnimatedZero
{
#[inline]
fn to_animated_zero(&self) -> Result<Self, ()> {
self.0.to_animated_zero().map(GreaterThanOrEqualToOne::<T>)
}
}