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

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

Issue 2907973002: [css-typed-om] add toMatrix() method in CSSTransformValue.idl (Closed)
Patch Set: make Create() function in DOMMatrix 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 15e5224ce93c49a2b71603c0437c06cb06a98c37..69119fb2a0f7d5eabde47c9759045d7af1ac4251 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();
@@ -44,4 +45,37 @@ 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>

Powered by Google App Engine
This is Rietveld 408576698