Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1521)

Unified Diff: third_party/WebKit/LayoutTests/typedcssom/cssTransformValue.html

Issue 2907973002: [css-typed-om] add toMatrix() method in CSSTransformValue.idl (Closed)
Patch Set: add toMatrix() Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/LayoutTests/typedcssom/cssTransformValue.html
diff --git a/third_party/WebKit/LayoutTests/typedcssom/cssTransformValue.html b/third_party/WebKit/LayoutTests/typedcssom/cssTransformValue.html
index 3e8623197176ed0b28ad94af2a6bd7d196c28a72..2b3eecb65eefa4ac3951f27d8a38016c600afbd5 100644
--- a/third_party/WebKit/LayoutTests/typedcssom/cssTransformValue.html
+++ b/third_party/WebKit/LayoutTests/typedcssom/cssTransformValue.html
@@ -3,6 +3,7 @@
<script src="../resources/testharnessreport.js"></script>
<script>
+var EPSILON = 1e-6; // float epsilon
test(function() {
var transformValueObject = new CSSTransformValue();
@@ -38,6 +39,39 @@ test(function() {
assert_equals(newTransformArray[2].constructor.name, CSSScale.name);
}, "CSSTransformValue can iterate through all its all its transformComponent members");
+test(function() {
+ var transformArray = [new CSSScale(2,2)];
+ var transformValue = new CSSTransformValue(transformArray);
+
+ var expectedMatrix = new DOMMatrix();
+ expectedMatrix.scaleSelf(2, 2);
+
+ assert_matrix_approx_equals(transformValue.toMatrix(), expectedMatrix);
+}, "toMatrix() returns DOMMatrix Object - single CSSTransformComponent");
+
+test(function() {
+ var transformMatrix = new DOMMatrixReadOnly([1,1,1,1,1,1]);
+ var transformArray = [new CSSScale(2,2) , new CSSMatrixComponent(transformMatrix), new CSSScale(5,6)];
+ var transformValue = new CSSTransformValue(transformArray);
+
+ var expectedMatrix = new DOMMatrix();
+ expectedMatrix.scaleSelf(2, 2);
+ expectedMatrix.multiplySelf(transformMatrix);
+ expectedMatrix.scaleSelf(5, 6);
+
+ assert_matrix_approx_equals(transformValue.toMatrix(), expectedMatrix);
+}, "toMatrix() returns DOMMatrix Object - multiple CSSTransformComponent");
+
+function assert_array_approx_equals(actual, expected) {
+ for (var i = 0; i < actual.length; i++) {
+ assert_approx_equals(actual[i], expected[i], EPSILON);
+ }
+}
+
+function assert_matrix_approx_equals(actual, expected) {
+ assert_array_approx_equals(actual.toFloat64Array(), expected.toFloat64Array());
+}
+
</script>
<body>

Powered by Google App Engine
This is Rietveld 408576698