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

@ -8,7 +8,6 @@ use properties::animated_properties::{Animatable, RepeatableListAnimatable};
use properties::longhands::background_size::computed_value::T as BackgroundSizeList;
use values::animated::{ToAnimatedValue, ToAnimatedZero};
use values::computed::length::LengthOrPercentageOrAuto;
use values::distance::{ComputeSquaredDistance, SquaredDistance};
use values::generics::background::BackgroundSize as GenericBackgroundSize;
/// A computed value for the `background-size` property.
@ -33,24 +32,6 @@ impl Animatable for BackgroundSize {
}
}
impl ComputeSquaredDistance for BackgroundSize {
#[inline]
fn compute_squared_distance(&self, other: &Self) -> Result<SquaredDistance, ()> {
match (self, other) {
(
&GenericBackgroundSize::Explicit { width: self_width, height: self_height },
&GenericBackgroundSize::Explicit { width: other_width, height: other_height },
) => {
Ok(
self_width.compute_squared_distance(&other_width)? +
self_height.compute_squared_distance(&other_height)?
)
}
_ => Err(()),
}
}
}
impl ToAnimatedZero for BackgroundSize {
#[inline]
fn to_animated_zero(&self) -> Result<Self, ()> { Err(()) }