Bug 1379757 - Consider f64 epsilon for add_weighted portions. r?birtles draft
authorHiroyuki Ikezoe <hikezoe@mozilla.com>
Tue, 11 Jul 2017 07:51:34 +0900
changeset 606420 61317ec6d58107e0dc5add96fbe016dba579a3ce
parent 606416 5d794bf4c4653153e602631f1b8818acd559d8f5
child 636761 c87861b741069a1bee5eefd12718c40222af6c6e
push id67694
push userhikezoe@mozilla.com
push dateMon, 10 Jul 2017 22:51:47 +0000
reviewersbirtles
bugs1379757
milestone56.0a1
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
servo/components/style/properties/helpers/animated_properties.mako.rs
--- 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)?;