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

--HG--
extra : subtree_source : https%3A//hg.mozilla.org/projects/converted-servo-linear
extra : subtree_revision : 970570301f5b6c08fbf3af33533eaad60c440c8a
This commit is contained in:
Hiroyuki Ikezoe 2017-07-10 17:03:19 -07:00
parent 7bed4f1a85
commit 894367bb6a

View File

@ -2272,7 +2272,9 @@ 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 ||
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");