Auto merge of #17656 - hiikezoe:fix-assertion-in-add-weighted, r=birtles

Consider f64 epsilon for add_weighted portions.

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
This commit is contained in:
bors-servo 2017-07-10 17:03:19 -07:00 committed by GitHub
commit 2475039e40

View file

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