Bug 1393605 - Fix gecko assertion and add one crashtest. draft
authorBoris Chiou <boris.chiou@gmail.com>
Thu, 31 Aug 2017 11:11:09 +0800
changeset 656351 1bd6180f9e39daa12b578eb84b33f658919a4872
parent 656350 ee18275fa279cfca9830d5aaa753f8be878559ff
child 729110 f735b9339f897d7ef5b409458bc182c29ebf9ab3
push id77180
push userbmo:boris.chiou@gmail.com
push dateThu, 31 Aug 2017 03:19:24 +0000
bugs1393605
milestone57.0a1
Bug 1393605 - Fix gecko assertion and add one crashtest. MozReview-Commit-ID: 44QIZ8SipWX
dom/animation/test/crashtests/1393605-1.html
dom/animation/test/crashtests/crashtests.list
layout/style/nsStyleTransformMatrix.cpp
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;
   }