Bug 1379757 - Consider f64 epsilon for add_weighted portions. r?birtles
This patch also degrade assert! to debug_assert! since crash reports don't show
us useful information so far (no assertion messages at all).
MozReview-Commit-ID: AZETljhixo6
--- a/servo/components/style/properties/helpers/animated_properties.mako.rs
+++ b/servo/components/style/properties/helpers/animated_properties.mako.rs
@@ -2267,19 +2267,21 @@ impl Animatable for Perspective {
))
}
}
impl Animatable for MatrixDecomposed3D {
/// https://drafts.csswg.org/css-transforms/#interpolation-of-decomposed-3d-matrix-values
fn add_weighted(&self, other: &Self, self_portion: f64, other_portion: f64)
-> Result<Self, ()> {
- assert!(self_portion + other_portion == 1.0f64 ||
- other_portion == 1.0f64,
- "add_weighted should only be used for interpolating or accumulating transforms");
+ use std::f64;
+
+ debug_assert!((self_portion + other_portion - 1.0f64).abs() <= f64::EPSILON ||
+ other_portion == 1.0f64,
+ "add_weighted should only be used for interpolating or accumulating transforms");
let mut sum = *self;
// Add translate, scale, skew and perspective components.
sum.translate = self.translate.add_weighted(&other.translate, self_portion, other_portion)?;
sum.scale = self.scale.add_weighted(&other.scale, self_portion, other_portion)?;
sum.skew = self.skew.add_weighted(&other.skew, self_portion, other_portion)?;
sum.perspective = self.perspective.add_weighted(&other.perspective, self_portion, other_portion)?;