Derive ComputeSquaredDistance

This commit is contained in:
Anthony Ramine 2017-08-13 00:50:36 +02:00
parent 51b740033b
commit 277351da35
22 changed files with 162 additions and 391 deletions

View file

@ -9,7 +9,6 @@ use values::{CSSInteger, CSSFloat};
use values::animated::ToAnimatedZero;
use values::computed::{NonNegativeAu, NonNegativeNumber};
use values::computed::length::{Length, LengthOrPercentage};
use values::distance::{ComputeSquaredDistance, SquaredDistance};
use values::generics::text::InitialLetter as GenericInitialLetter;
use values::generics::text::LineHeight as GenericLineHeight;
use values::generics::text::Spacing;
@ -48,28 +47,6 @@ impl Animatable for LineHeight {
}
}
impl ComputeSquaredDistance for LineHeight {
#[inline]
fn compute_squared_distance(&self, other: &Self) -> Result<SquaredDistance, ()> {
match (self, other) {
(&GenericLineHeight::Length(ref this), &GenericLineHeight::Length(ref other)) => {
this.compute_squared_distance(other)
},
(&GenericLineHeight::Number(ref this), &GenericLineHeight::Number(ref other)) => {
this.compute_squared_distance(other)
},
(&GenericLineHeight::Normal, &GenericLineHeight::Normal) => {
Ok(SquaredDistance::Value(0.))
},
#[cfg(feature = "gecko")]
(&GenericLineHeight::MozBlockHeight, &GenericLineHeight::MozBlockHeight) => {
Ok(SquaredDistance::Value(0.))
},
_ => Err(()),
}
}
}
impl ToAnimatedZero for LineHeight {
#[inline]
fn to_animated_zero(&self) -> Result<Self, ()> { Err(()) }