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

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

Issue 2957603002: [CSS Typed OM] Re-implement ToCSSValue and AsMatrix for CSSRotation (Closed)
Patch Set: rebase Created 3 years, 5 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
« no previous file with comments | « no previous file | third_party/WebKit/LayoutTests/typedcssom/cssRotation-expected.txt » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/LayoutTests/typedcssom/cssRotation.html
diff --git a/third_party/WebKit/LayoutTests/typedcssom/cssRotation.html b/third_party/WebKit/LayoutTests/typedcssom/cssRotation.html
index 194a7c04f732112fff5a59c1de345c3a4e9ce85f..8bc64a7b9e0b21d4570977eb7fab8be58a648952 100644
--- a/third_party/WebKit/LayoutTests/typedcssom/cssRotation.html
+++ b/third_party/WebKit/LayoutTests/typedcssom/cssRotation.html
@@ -139,16 +139,47 @@ for (let params of testParams) {
}, "toString value is correct for " + params.cssText);
}
+test(() => {
+ let rotation = new CSSRotation(1, 2, 3, CSS.deg(10));
+ assert_equals(rotation.toString(), 'rotate3d(1, 2, 3, 10deg)');
+ rotation.is2D = true;
+ assert_true(rotation.is2D);
+ assert_equals(rotation.toString(), 'rotate(10deg)');
+}, "x, y, and z components are not included in toString when is2D is true");
+
for (let params of testParams) {
- var input = params.input;
+ let input = params.input;
test(() => {
var transformValue = new CSSTransformValue([input]);
var result = transformValue.toMatrix();
- assert_equals(result.is2D, input.is2D, 'is2D');
assert_matrix_approx_equals(result, params.asMatrix, EPSILON);
- }, "toMatrix works for " + params.cssText);
+ }, "toMatrix works for " + params.cssText + " in a CSSTransformValue");
}
+test(() => {
+ // Obtained by doing the following in a console:
+ // $0.style.transform = 'rotate3d(1, 2, 3, 10rad)';
+ // getComputedStyle($0).transform
+ let expected3DMatrix = new DOMMatrixReadOnly(
+ [-0.707709, -0.173463, 0.684878, 0,
+ 0.698912, -0.313623, 0.642778, 0,
+ 0.103295, 0.933569, 0.343189, 0,
+ 0, 0, 0, 1]);
+ let expected2DMatrix = new DOMMatrixReadOnly(
+ [Math.cos(10), Math.sin(10), -Math.sin(10), Math.cos(10), 0, 0]);
+
+ let rotation = new CSSRotation(1, 2, 3, CSS.rad(10));
+ let transformValue = new CSSTransformValue([rotation]);
+
+ assert_matrix_approx_equals(
+ transformValue.toMatrix(), expected3DMatrix, EPSILON);
+
+ rotation.is2D = true;
+
+ assert_matrix_approx_equals(
+ transformValue.toMatrix(), expected2DMatrix, EPSILON);
+}, "x, y, and z attributes have no effect on toMatrix if is2D is set to true");
+
for (let attribute of ["x", "y", "z"]) {
test(() => {
let rotation = new CSSRotation(1, 2, 3, new CSSUnitValue(10, 'deg'));
« no previous file with comments | « no previous file | third_party/WebKit/LayoutTests/typedcssom/cssRotation-expected.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698