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

Side by Side 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, 6 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 unified diff | Download patch
OLDNEW
1 <!DOCTYPE html> 1 <!DOCTYPE html>
2 <script src="../resources/testharness.js"></script> 2 <script src="../resources/testharness.js"></script>
3 <script src="../resources/testharnessreport.js"></script> 3 <script src="../resources/testharnessreport.js"></script>
4 4
5 <script> 5 <script>
6 var EPSILON = 1e-6; // float epsilon
6 7
7 test(function() { 8 test(function() {
8 var transformValueObject = new CSSTransformValue(); 9 var transformValueObject = new CSSTransformValue();
9 assert_equals(transformValueObject.constructor.name, CSSTransformValue.name); 10 assert_equals(transformValueObject.constructor.name, CSSTransformValue.name);
10 }, "A CSSTransformValue object can be constructed"); 11 }, "A CSSTransformValue object can be constructed");
11 12
12 test(function() { 13 test(function() {
13 var transformArray = [ 14 var transformArray = [
14 new CSSScale(2, 2), 15 new CSSScale(2, 2),
15 new CSSMatrixComponent(new DOMMatrixReadOnly([1, 1, 1, 1, 1, 1])), 16 new CSSMatrixComponent(new DOMMatrixReadOnly([1, 1, 1, 1, 1, 1])),
(...skipping 21 matching lines...) Expand all
37 ]; 38 ];
38 var transformValue = new CSSTransformValue(transformArray); 39 var transformValue = new CSSTransformValue(transformArray);
39 40
40 var newTransformArray = [...transformValue]; 41 var newTransformArray = [...transformValue];
41 assert_true(newTransformArray.length == 3); 42 assert_true(newTransformArray.length == 3);
42 assert_equals(newTransformArray[0].constructor.name, CSSScale.name); 43 assert_equals(newTransformArray[0].constructor.name, CSSScale.name);
43 assert_equals(newTransformArray[1].constructor.name, CSSMatrixComponent.name); 44 assert_equals(newTransformArray[1].constructor.name, CSSMatrixComponent.name);
44 assert_equals(newTransformArray[2].constructor.name, CSSScale.name); 45 assert_equals(newTransformArray[2].constructor.name, CSSScale.name);
45 }, "CSSTransformValue can iterate through all its all its transformComponent mem bers"); 46 }, "CSSTransformValue can iterate through all its all its transformComponent mem bers");
46 47
48 test(function() {
49 var transformArray = [new CSSScale(2,2)];
50 var transformValue = new CSSTransformValue(transformArray);
51
52 var expectedMatrix = new DOMMatrix();
53 expectedMatrix.scaleSelf(2, 2);
54
55 assert_matrix_approx_equals(transformValue.toMatrix(), expectedMatrix);
56 }, "toMatrix() returns DOMMatrix Object - single CSSTransformComponent");
57
58 test(function() {
59 var transformMatrix = new DOMMatrixReadOnly([1,1,1,1,1,1]);
60 var transformArray = [new CSSScale(2,2) , new CSSMatrixComponent(transformMatr ix), new CSSScale(5,6)];
61 var transformValue = new CSSTransformValue(transformArray);
62
63 var expectedMatrix = new DOMMatrix();
64 expectedMatrix.scaleSelf(2, 2);
65 expectedMatrix.multiplySelf(transformMatrix);
66 expectedMatrix.scaleSelf(5, 6);
67
68 assert_matrix_approx_equals(transformValue.toMatrix(), expectedMatrix);
69 }, "toMatrix() returns DOMMatrix Object - multiple CSSTransformComponent");
70
71 function assert_array_approx_equals(actual, expected) {
72 for (var i = 0; i < actual.length; i++) {
73 assert_approx_equals(actual[i], expected[i], EPSILON);
74 }
75 }
76
77 function assert_matrix_approx_equals(actual, expected) {
78 assert_array_approx_equals(actual.toFloat64Array(), expected.toFloat64Array()) ;
79 }
80
47 </script> 81 </script>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698