mirror of
https://github.com/servo/servo.git
synced 2025-08-08 23:15:33 +01:00
Derive ComputeSquaredDistance
This commit is contained in:
parent
51b740033b
commit
277351da35
22 changed files with 162 additions and 391 deletions
|
@ -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(()) }
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue