mirror of
https://github.com/servo/servo.git
synced 2025-08-03 12:40:06 +01:00
Implement compute_distance for Angle.
When computing the distance between two filter functions, e.g. HueRotate(0deg) and HueRotate(-360deg), we got an Err(()) and unwrap it immediately in compute_filter_square_distance(), which causes a crash. The root-cause is that we don't implement computed_distance of Angle, and we assume we always get a valid result from compute_squared_distance() for each filter function.
This commit is contained in:
parent
b38d3f2976
commit
20e3508ca3
1 changed files with 7 additions and 0 deletions
|
@ -925,6 +925,13 @@ impl Animatable for Angle {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn compute_distance(&self, other: &Self) -> Result<f64, ()> {
|
||||
// Use the formula for calculating the distance between angles defined in SVG:
|
||||
// https://www.w3.org/TR/SVG/animate.html#complexDistances
|
||||
Ok((self.radians64() - other.radians64()).abs())
|
||||
}
|
||||
}
|
||||
|
||||
/// https://drafts.csswg.org/css-transitions/#animtype-percentage
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue