Setting DOMMatrix.m33 or m44 to 1 should preserve is2D

Per [1], setting a value other than one (1) should clear the is2D flag.
We had the logic reversed.

[1] https://drafts.fxtf.org/geometry/#dommatrix-attributes

Bug: 756789
Change-Id: I37fcd4e20fedee6ba29bb164e81cdf324971f9a1
Reviewed-on: https://chromium-review.googlesource.com/623410
Commit-Queue: Dominic Cooney <dominicc@chromium.org>
Reviewed-by: Dominic Cooney <dominicc@chromium.org>
Cr-Commit-Position: refs/heads/master@{#496224}
diff --git a/third_party/WebKit/LayoutTests/external/wpt/css/geometry-1/DOMMatrix-attributes.html b/third_party/WebKit/LayoutTests/external/wpt/css/geometry-1/DOMMatrix-attributes.html
new file mode 100644
index 0000000..f1d0529
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/external/wpt/css/geometry-1/DOMMatrix-attributes.html
@@ -0,0 +1,64 @@
+<!DOCTYPE html>
+<title>Geometry Interfaces: DOMMatrix attributes</title>
+<link rel="help" href="https://drafts.fxtf.org/geometry/#dommatrix-attributes">
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script>
+const initial = {
+    m11: 1, m12: 0, m13: 0, m14: 0,
+    m21: 0, m22: 1, m23: 0, m24: 0,
+    m31: 0, m32: 0, m33: 1, m34: 0,
+    m41: 0, m42: 0, m43: 0, m44: 1,
+};
+
+// Attributes that always preserve is2D.
+["m11", "m12", "m21", "m22", "m41", "m42" ].forEach(attribute => {
+    test(() => {
+        let m = new DOMMatrix();
+        assert_true(m.is2D);
+        assert_equals(m[attribute], initial[attribute]);
+        m[attribute] = 42;
+        assert_true(m.is2D);
+        assert_equals(m[attribute], 42);
+    }, `DOMMatrix.${attribute}`);
+});
+
+// Attributes that clear is2D for values other than 0 or -0.
+["m13", "m14", "m23", "m24", "m31", "m32", "m34", "m43" ].forEach(attribute => {
+    test(() => {
+        let m = new DOMMatrix();
+        assert_true(m.is2D);
+        assert_equals(m[attribute], initial[attribute]);
+        m[attribute] = 0;
+        assert_true(m.is2D, "0 preserves is2D");
+        assert_equals(m[attribute], 0);
+        m[attribute] = -0;
+        assert_true(m.is2D, "-0 preserves is2D");
+        assert_equals(m[attribute], -0);
+        m[attribute] = 42;
+        assert_false(m.is2D, "a value other than 0 or -0 clears is2D");
+        assert_equals(m[attribute], 42);
+        m[attribute] = 0;
+        assert_false(m.is2D, "is2D can never be set to true after having been set to false");
+        assert_equals(m[attribute], 0);
+    }, `DOMMatrix.${attribute}`);
+});
+
+// Attributes that clear is2D for values other than 1.
+["m33", "m44" ].forEach(attribute => {
+    test(() => {
+        let m = new DOMMatrix();
+        assert_true(m.is2D);
+        assert_equals(m[attribute], initial[attribute]);
+        m[attribute] = 1;
+        assert_true(m.is2D, "1 preserves is2D");
+        assert_equals(m[attribute], 1);
+        m[attribute] = 42;
+        assert_false(m.is2D, "a value other than 1 clears is2D");
+        assert_equals(m[attribute], 42);
+        m[attribute] = 1;
+        assert_false(m.is2D, "is2D can never be set to true after having been set to false");
+        assert_equals(m[attribute], 1);
+    }, `DOMMatrix.${attribute}`);
+});
+</script>
diff --git a/third_party/WebKit/Source/core/geometry/DOMMatrix.h b/third_party/WebKit/Source/core/geometry/DOMMatrix.h
index 1a3a1398..fa0ac68 100644
--- a/third_party/WebKit/Source/core/geometry/DOMMatrix.h
+++ b/third_party/WebKit/Source/core/geometry/DOMMatrix.h
@@ -70,7 +70,7 @@
   }
   void setM33(double value) {
     matrix_->SetM33(value);
-    SetIs2D(value != 1);
+    SetIs2D(value == 1);
   }
   void setM34(double value) {
     matrix_->SetM34(value);
@@ -84,7 +84,7 @@
   }
   void setM44(double value) {
     matrix_->SetM44(value);
-    SetIs2D(value != 1);
+    SetIs2D(value == 1);
   }
 
   DOMMatrix* multiplySelf(DOMMatrixInit&, ExceptionState&);