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

Side by Side Diff: third_party/WebKit/LayoutTests/typedcssom/cssRotation.html

Issue 2942653002: [css-typed-om] remove asMatrix() method in CSSTransformComponent.idl (Closed)
Patch Set: rebase 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 var EPSILON = 1e-6; // float epsilon
7 function angle(deg) { 7 function angle(deg) {
8 return new CSSUnitValue(deg, 'deg'); 8 return new CSSUnitValue(deg, 'deg');
9 } 9 }
10 10
11 var values = [ 11 var values = [
12 {input: new CSSRotation(angle(0)), angle: 0, x: 0, y: 0, z: 1, 12 {input: new CSSRotation(angle(0)), angle: 0, x: 0, y: 0, z: 1,
13 is2D: true, cssText: "rotate(0deg)", 13 is2D: true, cssText: "rotate(0deg)"},
14 asMatrix: new CSSMatrixComponent(new DOMMatrixReadOnly([1, 0, 0, 1, 0, 0]))} ,
15 {input: new CSSRotation(angle(10)), angle: 10, x: 0, y: 0, z: 1, 14 {input: new CSSRotation(angle(10)), angle: 10, x: 0, y: 0, z: 1,
16 is2D: true, cssText: "rotate(10deg)", 15 is2D: true, cssText: "rotate(10deg)"},
17 asMatrix: new CSSMatrixComponent(new DOMMatrixReadOnly([0.9848077, 0.1736481 , -0.1736481, 0.9848077, 0, 0]))},
18 {input: new CSSRotation(angle(-21)), angle: -21, x: 0, y: 0, z: 1, 16 {input: new CSSRotation(angle(-21)), angle: -21, x: 0, y: 0, z: 1,
19 is2D: true, cssText: "rotate(-21deg)", 17 is2D: true, cssText: "rotate(-21deg)"},
20 asMatrix: new CSSMatrixComponent(new DOMMatrixReadOnly([0.9335804, -0.358367 9, 0.3583679, 0.9335804, 0, 0]))},
21 {input: new CSSRotation(angle(3.2)), angle: 3.2, x: 0, y: 0, z: 1, 18 {input: new CSSRotation(angle(3.2)), angle: 3.2, x: 0, y: 0, z: 1,
22 is2D: true, cssText: "rotate(3.2deg)", 19 is2D: true, cssText: "rotate(3.2deg)"},
23 asMatrix: new CSSMatrixComponent(new DOMMatrixReadOnly([0.9984407, 0.0558215 , -0.0558215, 0.9984407, 0, 0]))},
24 {input: new CSSRotation(0, 0, 1, angle(90)), angle: 90, x: 0, y: 0, z: 1, 20 {input: new CSSRotation(0, 0, 1, angle(90)), angle: 90, x: 0, y: 0, z: 1,
25 is2D: false, cssText: "rotate3d(0, 0, 1, 90deg)", 21 is2D: false, cssText: "rotate3d(0, 0, 1, 90deg)"},
26 asMatrix: new CSSMatrixComponent(new DOMMatrixReadOnly([0, 1, 0, 0, -1, 0, 0 , 0, 0, 0, 1, 0, 0, 0, 0, 1]))},
27 {input: new CSSRotation(2.7, -3, 4.4, angle(0)), angle: 0, x: 2.7, y: -3, z: 4 .4, 22 {input: new CSSRotation(2.7, -3, 4.4, angle(0)), angle: 0, x: 2.7, y: -3, z: 4 .4,
28 is2D: false, cssText: "rotate3d(2.7, -3, 4.4, 0deg)", 23 is2D: false, cssText: "rotate3d(2.7, -3, 4.4, 0deg)"},
29 asMatrix: new CSSMatrixComponent(new DOMMatrixReadOnly([1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1]))},
30 {input: new CSSRotation(2, 3, 4, angle(10)), angle: 10, x: 2, y: 3, z: 4, 24 {input: new CSSRotation(2, 3, 4, angle(10)), angle: 10, x: 2, y: 3, z: 4,
31 is2D: false, cssText: "rotate3d(2, 3, 4, 10deg)", 25 is2D: false, cssText: "rotate3d(2, 3, 4, 10deg)"},
32 asMatrix: new CSSMatrixComponent(new DOMMatrixReadOnly([0.9869032, 0.1321258 , -0.0925460, 0, -0.1258394,
33 0.9895225, 0.0707777, 0, 0.1009279, -0.0582048, 0.9931896, 0, 0, 0, 0, 1]) )},
34 {input: new CSSRotation(2, 3.7, -4, angle(-1.2)), angle: -1.2, x: 2, y: 3.7, z : -4, 26 {input: new CSSRotation(2, 3.7, -4, angle(-1.2)), angle: -1.2, x: 2, y: 3.7, z : -4,
35 is2D: false, cssText: "rotate3d(2, 3.7, -4, -1.2deg)", 27 is2D: false, cssText: "rotate3d(2, 3.7, -4, -1.2deg)"},
36 asMatrix: new CSSMatrixComponent(new DOMMatrixReadOnly([0.9998067, 0.0144804 9, 0.0132978, 0, -0.0143841,
37 0.9998698, -0.0073125, 0, -0.0134019, 0.0071198, 0.9998848, 0, 0, 0, 0, 1])) },
38 {input: new CSSRotation(1, 0, 0, new CSSUnitValue(0.5, 'turn')), angle: 180, x : 1, y: 0, z: 0, 28 {input: new CSSRotation(1, 0, 0, new CSSUnitValue(0.5, 'turn')), angle: 180, x : 1, y: 0, z: 0,
39 is2D: false, cssText: "rotate3d(1, 0, 0, 0.5turn)", 29 is2D: false, cssText: "rotate3d(1, 0, 0, 0.5turn)"}
40 asMatrix: new CSSMatrixComponent(new DOMMatrixReadOnly([1, 0, 0, 0, 0, -1, 1 .2246467991473532e-16, 0, 0,
41 -1.2246467991473532e-16, -1, 0, 0, 0, 0, 1]))}
42 ]; 30 ];
43 31
44 test(function() { 32 test(function() {
45 for (var i = 0; i < values.length; ++i) { 33 for (var i = 0; i < values.length; ++i) {
46 assert_equals(values[i].input.angle.degrees, values[i].angle); 34 assert_equals(values[i].input.angle.degrees, values[i].angle);
47 assert_equals(values[i].input.x, values[i].x); 35 assert_equals(values[i].input.x, values[i].x);
48 assert_equals(values[i].input.y, values[i].y); 36 assert_equals(values[i].input.y, values[i].y);
49 assert_equals(values[i].input.z, values[i].z); 37 assert_equals(values[i].input.z, values[i].z);
50 } 38 }
51 }, "Test that the (x, y, z, angle) values for CSSRotation are correct."); 39 }, "Test that the (x, y, z, angle) values for CSSRotation are correct.");
52 40
53 test(function() { 41 test(function() {
54 for (var i = 0; i < values.length; ++i) { 42 for (var i = 0; i < values.length; ++i) {
55 assert_equals(values[i].input.is2D(), values[i].is2D); 43 assert_equals(values[i].input.is2D(), values[i].is2D);
56 } 44 }
57 }, "Test that the is2D values for CSSRotation is correct."); 45 }, "Test that the is2D values for CSSRotation is correct.");
58 46
59 test(function() { 47 test(function() {
60 for (var i = 0; i < values.length; ++i) { 48 for (var i = 0; i < values.length; ++i) {
61 assert_equals(values[i].input.toString(), values[i].cssText); 49 assert_equals(values[i].input.toString(), values[i].cssText);
62 } 50 }
63 }, "Test that toString values for CSSRotation is correct."); 51 }, "Test that toString values for CSSRotation is correct.");
64 52
65 test(function() {
66 for (var i = 0; i < values.length; ++i) {
67 var input = values[i].input;
68 var inputAsMatrix = input.asMatrix();
69 assert_equals(inputAsMatrix.is2D(), input.is2D());
70 var expectedMatrix = values[i].asMatrix;
71 for (var attribute in expectedMatrix) {
72 if (attribute == "matrix") {
73 assert_matrix_approx_equals(inputAsMatrix[attribute], expectedMatrix[att ribute]);
74 } else if (attribute != "toString") {
75 // Due to the complex trigonometric calculations required for a CSSRotat ion matrix,
76 // the 6 significant figures of each value in the toString might be diff erent.
77 // Hence, do not check toString.
78 assert_equals(inputAsMatrix[attribute], expectedMatrix[attribute]);
79 }
80 }
81 }
82 }, "Test that asMatrix is constructed correctly for CSSRotation.");
83
84 function assert_array_approx_equals(actual, expected) { 53 function assert_array_approx_equals(actual, expected) {
85 for (var i = 0; i < actual.length; i++) { 54 for (var i = 0; i < actual.length; i++) {
86 assert_approx_equals(actual[i], expected[i], EPSILON); 55 assert_approx_equals(actual[i], expected[i], EPSILON);
87 } 56 }
88 } 57 }
89 58
90 function assert_matrix_approx_equals(actual, expected) { 59 function assert_matrix_approx_equals(actual, expected) {
91 assert_array_approx_equals(actual.toFloat64Array(), expected.toFloat64Array()) ; 60 assert_array_approx_equals(actual.toFloat64Array(), expected.toFloat64Array()) ;
92 } 61 }
93 62
94 </script> 63 </script>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698