servo: Merge #17656 - Consider f64 epsilon for add_weighted portions (from hiikezoe:fix-assertion-in-add-weighted); r=birtles
authorHiroyuki Ikezoe <hikezoe@mozilla.com>
Mon, 10 Jul 2017 17:03:19 -0700
changeset 368165 f323fe1f0d48ada9e36dba4cbd7a4b00ad61a73a
parent 368164 a16d92beb70daa33c4e29bf25300ca259ed61b2a
child 368166 3dfb4c796b7b87cc6e90bf83ef7822c8ba9c4767
push id32158
push usercbook@mozilla.com
push dateTue, 11 Jul 2017 10:48:59 +0000
treeherdermozilla-central@5e2692f8a367 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbirtles
milestone56.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
servo: Merge #17656 - Consider f64 epsilon for add_weighted portions (from hiikezoe:fix-assertion-in-add-weighted); 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). <!-- Please describe your changes on the following line: --> https://bugzilla.mozilla.org/show_bug.cgi?id=1379757 --- - [X] `./mach build -d` does not report any errors - [X] `./mach test-tidy` does not report any errors Source-Repo: https://github.com/servo/servo Source-Revision: 2475039e40ec898e377c433836edafa5637d63ae
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)?;