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

Side by Side Diff: third_party/WebKit/Source/core/css/cssom/CSSMatrixComponent.cpp

Issue 2933473003: Remove asMatrix as a JS-exposed method in CSSTransformComponents. (Closed)
Patch Set: update skew expectation for missing "s" 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 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "core/css/cssom/CSSMatrixComponent.h" 5 #include "core/css/cssom/CSSMatrixComponent.h"
6 6
7 #include <cmath>
8 #include <memory>
9 #include "core/css/CSSPrimitiveValue.h" 7 #include "core/css/CSSPrimitiveValue.h"
10 #include "platform/wtf/MathExtras.h" 8 #include "platform/wtf/MathExtras.h"
11 9
12 namespace blink { 10 namespace blink {
13 11
14 CSSMatrixComponent* CSSMatrixComponent::Create(DOMMatrixReadOnly* matrix) { 12 CSSMatrixComponent* CSSMatrixComponent::Create(DOMMatrixReadOnly* matrix) {
15 return new CSSMatrixComponent(matrix); 13 return new CSSMatrixComponent(matrix);
16 } 14 }
17 15
18 CSSFunctionValue* CSSMatrixComponent::ToCSSValue() const { 16 CSSFunctionValue* CSSMatrixComponent::ToCSSValue() const {
(...skipping 15 matching lines...) Expand all
34 matrix()->m41(), matrix()->m42(), matrix()->m43(), matrix()->m44()}; 32 matrix()->m41(), matrix()->m42(), matrix()->m43(), matrix()->m44()};
35 for (double value : values) { 33 for (double value : values) {
36 result->Append(*CSSPrimitiveValue::Create( 34 result->Append(*CSSPrimitiveValue::Create(
37 value, CSSPrimitiveValue::UnitType::kNumber)); 35 value, CSSPrimitiveValue::UnitType::kNumber));
38 } 36 }
39 } 37 }
40 38
41 return result; 39 return result;
42 } 40 }
43 41
44 CSSMatrixComponent* CSSMatrixComponent::Perspective(double length) {
45 DOMMatrix* matrix = DOMMatrix::Create();
46
47 if (length != 0)
48 matrix->setM34(-1 / length);
49 return new CSSMatrixComponent(matrix, kPerspectiveType);
50 }
51
52 CSSMatrixComponent* CSSMatrixComponent::Rotate(double angle) {
53 DOMMatrix* matrix = DOMMatrix::Create();
54
55 matrix->rotateSelf(angle);
56 return new CSSMatrixComponent(matrix, kRotationType);
57 }
58
59 CSSMatrixComponent* CSSMatrixComponent::Rotate3d(double angle,
60 double x,
61 double y,
62 double z) {
63 DOMMatrix* matrix = DOMMatrix::Create();
64
65 matrix->rotateAxisAngleSelf(x, y, z, angle);
66 return new CSSMatrixComponent(matrix, kRotation3DType);
67 }
68
69 CSSMatrixComponent* CSSMatrixComponent::Scale(double x, double y) {
70 DOMMatrix* matrix = DOMMatrix::Create();
71
72 matrix->setM11(x);
73 matrix->setM22(y);
74 return new CSSMatrixComponent(matrix, kScaleType);
75 }
76
77 CSSMatrixComponent* CSSMatrixComponent::Scale3d(double x, double y, double z) {
78 DOMMatrix* matrix = DOMMatrix::Create();
79
80 matrix->setM11(x);
81 matrix->setM22(y);
82 matrix->setM33(z);
83 return new CSSMatrixComponent(matrix, kScale3DType);
84 }
85
86 CSSMatrixComponent* CSSMatrixComponent::Skew(double ax, double ay) {
87 double tan_ax = std::tan(deg2rad(ax));
88 double tan_ay = std::tan(deg2rad(ay));
89
90 DOMMatrix* matrix = DOMMatrix::Create();
91
92 matrix->setM12(tan_ay);
93 matrix->setM21(tan_ax);
94 return new CSSMatrixComponent(matrix, kSkewType);
95 }
96
97 CSSMatrixComponent* CSSMatrixComponent::Translate(double x, double y) {
98 DOMMatrix* matrix = DOMMatrix::Create();
99
100 matrix->setM41(x);
101 matrix->setM42(y);
102 return new CSSMatrixComponent(matrix, kTranslationType);
103 }
104
105 CSSMatrixComponent* CSSMatrixComponent::Translate3d(double x,
106 double y,
107 double z) {
108 DOMMatrix* matrix = DOMMatrix::Create();
109
110 matrix->setM41(x);
111 matrix->setM42(y);
112 matrix->setM43(z);
113 return new CSSMatrixComponent(matrix, kTranslation3DType);
114 }
115
116 CSSMatrixComponent::CSSMatrixComponent(DOMMatrixReadOnly* matrix) 42 CSSMatrixComponent::CSSMatrixComponent(DOMMatrixReadOnly* matrix)
117 : CSSTransformComponent() { 43 : CSSTransformComponent() {
118 matrix_ = DOMMatrix::Create(matrix); 44 matrix_ = DOMMatrix::Create(matrix);
119 is2d_ = matrix->is2D(); 45 is2d_ = matrix->is2D();
120 } 46 }
121 47
122 CSSMatrixComponent::CSSMatrixComponent(DOMMatrixReadOnly* matrix,
123 TransformComponentType from_type)
124 : CSSTransformComponent() {
125 matrix_ = DOMMatrix::Create(matrix);
126 is2d_ = Is2DComponentType(from_type);
127 }
128
129 } // namespace blink 48 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698