mirror of
https://github.com/servo/servo.git
synced 2025-08-16 19:05:33 +01:00
Introduce ComputeSquaredDistance
This allows us to merge the former Animatable methods compute_distance and compute_squared_distance, reducing code size.
This commit is contained in:
parent
b14e68f915
commit
51b740033b
21 changed files with 641 additions and 551 deletions
|
@ -132,6 +132,7 @@
|
|||
% if need_animatable or animation_value_type == "ComputedValue":
|
||||
use properties::animated_properties::Animatable;
|
||||
use values::animated::ToAnimatedZero;
|
||||
use values::distance::{ComputeSquaredDistance, SquaredDistance};
|
||||
|
||||
impl Animatable for T {
|
||||
fn add_weighted(&self, other: &Self, self_portion: f64, other_portion: f64)
|
||||
|
@ -142,14 +143,11 @@
|
|||
fn add(&self, other: &Self) -> Result<Self, ()> {
|
||||
self.0.add(&other.0).map(T)
|
||||
}
|
||||
}
|
||||
|
||||
impl ComputeSquaredDistance for T {
|
||||
#[inline]
|
||||
fn compute_distance(&self, other: &Self) -> Result<f64, ()> {
|
||||
self.0.compute_distance(&other.0)
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn compute_squared_distance(&self, other: &Self) -> Result<f64, ()> {
|
||||
fn compute_squared_distance(&self, other: &Self) -> Result<SquaredDistance, ()> {
|
||||
self.0.compute_squared_distance(&other.0)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue