Bug 1393605 - Fix gecko assertion and add one crashtest.
MozReview-Commit-ID: 44QIZ8SipWX
new file mode 100644
--- /dev/null
+++ b/dom/animation/test/crashtests/1393605-1.html
@@ -0,0 +1,15 @@
+<!doctype html>
+<html>
+ <head>
+ <title>
+ Bug 1393605 - Still work if determinant of 2d matrix is not 1 or -1
+ </title>
+ </head>
+ <script>
+ document.documentElement.animate(
+ [ { 'transform': 'scale(4)' },
+ { 'transform': 'rotate(3grad) scaleX(0) ' +
+ 'translate(2mm) matrix(2,7,1,.32,7,0)' } ],
+ { fill: 'both' });
+ </script>
+</html>
--- a/dom/animation/test/crashtests/crashtests.list
+++ b/dom/animation/test/crashtests/crashtests.list
@@ -24,8 +24,9 @@ pref(dom.animations-api.core.enabled,tru
pref(dom.animations-api.core.enabled,true) load 1333539-1.html
pref(dom.animations-api.core.enabled,true) load 1333539-2.html
pref(dom.animations-api.core.enabled,true) load 1334583-1.html
pref(dom.animations-api.core.enabled,true) load 1335998-1.html
pref(dom.animations-api.core.enabled,true) load 1343589-1.html
pref(dom.animations-api.core.enabled,true) load 1359658-1.html
pref(dom.animations-api.core.enabled,true) load 1373712-1.html
pref(dom.animations-api.core.enabled,true) load 1379606-1.html
+pref(dom.animations-api.core.enabled,true) load 1393605-1.html
--- a/layout/style/nsStyleTransformMatrix.cpp
+++ b/layout/style/nsStyleTransformMatrix.cpp
@@ -1210,20 +1210,23 @@ Decompose2DMatrix(const Matrix& aMatrix,
C -= A * XYshear;
D -= B * XYshear;
float scaleY = sqrt(C * C + D * D);
C /= scaleY;
D /= scaleY;
XYshear /= scaleY;
- // A*D - B*C should now be 1 or -1
- NS_ASSERTION(0.99 < Abs(A*D - B*C) && Abs(A*D - B*C) < 1.01,
- "determinant should now be 1 or -1");
- if (A * D < B * C) {
+ float determinant = A * D - B * C;
+ // Determinant should now be 1 or -1.
+ if (0.99 > Abs(determinant) || Abs(determinant) > 1.01) {
+ return false;
+ }
+
+ if (determinant < 0) {
A = -A;
B = -B;
C = -C;
D = -D;
XYshear = -XYshear;
scaleX = -scaleX;
}