Derive Animate for ShapeRadius<L>

This commit is contained in:
Anthony Ramine 2017-08-25 23:37:51 +02:00
parent af560a8fab
commit e49dbc4dfa

View file

@ -94,10 +94,13 @@ pub struct Ellipse<H, V, LengthOrPercentage> {
/// https://drafts.csswg.org/css-shapes/#typedef-shape-radius
#[allow(missing_docs)]
#[cfg_attr(feature = "servo", derive(HeapSizeOf))]
#[derive(Clone, ComputeSquaredDistance, Copy, Debug, PartialEq, ToComputedValue, ToCss)]
#[derive(Animate, Clone, ComputeSquaredDistance, Copy, Debug, PartialEq)]
#[derive(ToComputedValue, ToCss)]
pub enum ShapeRadius<LengthOrPercentage> {
Length(LengthOrPercentage),
#[animation(error)]
ClosestSide,
#[animation(error)]
FarthestSide,
}
@ -191,20 +194,6 @@ impl<L> ToCss for InsetRect<L>
}
}
impl<L> Animate for ShapeRadius<L>
where
L: Animate,
{
fn animate(&self, other: &Self, procedure: Procedure) -> Result<Self, ()> {
match (self, other) {
(&ShapeRadius::Length(ref this), &ShapeRadius::Length(ref other)) => {
Ok(ShapeRadius::Length(this.animate(other, procedure)?))
},
_ => Err(()),
}
}
}
impl<L> Default for ShapeRadius<L> {
#[inline]
fn default() -> Self { ShapeRadius::ClosestSide }