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

Side by Side Diff: third_party/WebKit/Source/core/css/CSSMatrix.h

Issue 2688533002: Test code
Patch Set: Storing InspectorRevalidateDOMTask object whenever binding/unbinding node. Created 3 years, 10 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
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/css/CSSMatrix.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2008 Apple Inc. All Rights Reserved. 2 * Copyright (C) 2008 Apple Inc. All Rights Reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution. 11 * documentation and/or other materials provided with the distribution.
12 * 12 *
13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY 13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR 16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY 20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24 */ 24 */
25 25
26 #ifndef CSSMatrix_h 26 #ifndef CSSMatrix_h
27 #define CSSMatrix_h 27 #define CSSMatrix_h
28 28
29 #include "bindings/core/v8/ScriptWrappable.h" 29 #include <memory>
30 #include "platform/transforms/TransformationMatrix.h" 30 #include "core/dom/DOMMatrix.h"
31 #include "wtf/text/WTFString.h" 31 #include "wtf/text/WTFString.h"
32 #include <memory>
33 32
34 namespace blink { 33 namespace blink {
35 34
36 class ExceptionState; 35 class ExceptionState;
37 class ExecutionContext; 36 class ExecutionContext;
38 37
39 class CSSMatrix final : public GarbageCollectedFinalized<CSSMatrix>, 38 class CSSMatrix final : public DOMMatrix {
40 public ScriptWrappable {
41 DEFINE_WRAPPERTYPEINFO(); 39 DEFINE_WRAPPERTYPEINFO();
42 40
43 public: 41 public:
44 static CSSMatrix* create(const TransformationMatrix& m) { 42 static CSSMatrix* create(const TransformationMatrix& m) {
45 return new CSSMatrix(m); 43 return new CSSMatrix(m);
46 } 44 }
47 static CSSMatrix* create(ExecutionContext*, const String&, ExceptionState&); 45 static CSSMatrix* create(ExecutionContext*, const String&, ExceptionState&);
48 46
49 double a() const { return m_matrix->a(); }
50 double b() const { return m_matrix->b(); }
51 double c() const { return m_matrix->c(); }
52 double d() const { return m_matrix->d(); }
53 double e() const { return m_matrix->e(); }
54 double f() const { return m_matrix->f(); }
55
56 void setA(double f) { m_matrix->setA(f); }
57 void setB(double f) { m_matrix->setB(f); }
58 void setC(double f) { m_matrix->setC(f); }
59 void setD(double f) { m_matrix->setD(f); }
60 void setE(double f) { m_matrix->setE(f); }
61 void setF(double f) { m_matrix->setF(f); }
62
63 double m11() const { return m_matrix->m11(); }
64 double m12() const { return m_matrix->m12(); }
65 double m13() const { return m_matrix->m13(); }
66 double m14() const { return m_matrix->m14(); }
67 double m21() const { return m_matrix->m21(); }
68 double m22() const { return m_matrix->m22(); }
69 double m23() const { return m_matrix->m23(); }
70 double m24() const { return m_matrix->m24(); }
71 double m31() const { return m_matrix->m31(); }
72 double m32() const { return m_matrix->m32(); }
73 double m33() const { return m_matrix->m33(); }
74 double m34() const { return m_matrix->m34(); }
75 double m41() const { return m_matrix->m41(); }
76 double m42() const { return m_matrix->m42(); }
77 double m43() const { return m_matrix->m43(); }
78 double m44() const { return m_matrix->m44(); }
79
80 void setM11(double f) { m_matrix->setM11(f); }
81 void setM12(double f) { m_matrix->setM12(f); }
82 void setM13(double f) { m_matrix->setM13(f); }
83 void setM14(double f) { m_matrix->setM14(f); }
84 void setM21(double f) { m_matrix->setM21(f); }
85 void setM22(double f) { m_matrix->setM22(f); }
86 void setM23(double f) { m_matrix->setM23(f); }
87 void setM24(double f) { m_matrix->setM24(f); }
88 void setM31(double f) { m_matrix->setM31(f); }
89 void setM32(double f) { m_matrix->setM32(f); }
90 void setM33(double f) { m_matrix->setM33(f); }
91 void setM34(double f) { m_matrix->setM34(f); }
92 void setM41(double f) { m_matrix->setM41(f); }
93 void setM42(double f) { m_matrix->setM42(f); }
94 void setM43(double f) { m_matrix->setM43(f); }
95 void setM44(double f) { m_matrix->setM44(f); }
96
97 void setMatrixValue(const String&, ExceptionState&); 47 void setMatrixValue(const String&, ExceptionState&);
98 48
99 // The following math function return a new matrix with the 49 // The following math function return a new matrix with the
100 // specified operation applied. The this value is not modified. 50 // specified operation applied. The this value is not modified.
101 51
102 // Multiply this matrix by secondMatrix, on the right 52 // Multiply this matrix by secondMatrix, on the right
103 // (result = this * secondMatrix) 53 // (result = this * secondMatrix)
104 CSSMatrix* multiply(CSSMatrix* secondMatrix) const; 54 CSSMatrix* multiply(CSSMatrix* secondMatrix, ExceptionState&);
105 55
106 // Return the inverse of this matrix. Throw an exception if the matrix is not 56 // Return the inverse of this matrix. Throw an exception if the matrix is not
107 // invertible. 57 // invertible.
108 CSSMatrix* inverse(ExceptionState&) const; 58 CSSMatrix* inverse(ExceptionState&);
109 59
110 // Return this matrix translated by the passed values. 60 // Return this matrix translated by the passed values.
111 // Passing a NaN will use a value of 0. This allows the 3D form to used for 2D 61 // Passing a NaN will use a value of 0. This allows the 3D form to used for 2D
112 // operations. 62 // operations.
113 // Operation is performed as though the this matrix is multiplied by a matrix 63 // Operation is performed as though the this matrix is multiplied by a matrix
114 // with the translation values on the left 64 // with the translation values on the left
115 // (result = translation(x,y,z) * this) 65 // (result = translation(x,y,z) * this)
116 CSSMatrix* translate(double x, double y, double z) const; 66 CSSMatrix* translate(double x, double y, double z);
117 67
118 // Returns this matrix scaled by the passed values. 68 // Returns this matrix scaled by the passed values.
119 // Passing scaleX or scaleZ as NaN uses a value of 1, but passing scaleY of 69 // Passing scaleX or scaleZ as NaN uses a value of 1, but passing scaleY of
120 // NaN makes it the same as scaleX. This allows the 3D form to used for 2D 70 // NaN makes it the same as scaleX. This allows the 3D form to used for 2D
121 // operations Operation is performed as though the this matrix is multiplied 71 // operations Operation is performed as though the this matrix is multiplied
122 // by a matrix with the scale values on the left 72 // by a matrix with the scale values on the left
123 // (result = scale(x,y,z) * this) 73 // (result = scale(x,y,z) * this)
124 CSSMatrix* scale(double scaleX, double scaleY, double scaleZ) const; 74 CSSMatrix* scale(double scaleX, double scaleY, double scaleZ);
125 75
126 // Returns this matrix rotated by the passed values. 76 // Returns this matrix rotated by the passed values.
127 // If rotY and rotZ are NaN, rotate about Z (rotX=0, rotateY=0, rotateZ=rotX). 77 // If rotY and rotZ are NaN, rotate about Z (rotX=0, rotateY=0, rotateZ=rotX).
128 // Otherwise use a rotation value of 0 for any passed NaN. 78 // Otherwise use a rotation value of 0 for any passed NaN.
129 // Operation is performed as though the this matrix is multiplied by a matrix 79 // Operation is performed as though the this matrix is multiplied by a matrix
130 // with the rotation values on the left (result = rotation(x,y,z) * this) 80 // with the rotation values on the left (result = rotation(x,y,z) * this)
131 CSSMatrix* rotate(double rotX, double rotY, double rotZ) const; 81 CSSMatrix* rotate(double rotX, double rotY, double rotZ);
132 82
133 // Returns this matrix rotated about the passed axis by the passed angle. 83 // Returns this matrix rotated about the passed axis by the passed angle.
134 // Passing a NaN will use a value of 0. If the axis is (0,0,0) use a value 84 // Passing a NaN will use a value of 0. If the axis is (0,0,0) use a value
135 // Operation is performed as though the this matrix is multiplied by a matrix 85 // Operation is performed as though the this matrix is multiplied by a matrix
136 // with the rotation values on the left 86 // with the rotation values on the left
137 // (result = rotation(x,y,z,angle) * this) 87 // (result = rotation(x,y,z,angle) * this)
138 CSSMatrix* rotateAxisAngle(double x, double y, double z, double angle) const; 88 CSSMatrix* rotateAxisAngle(double x, double y, double z, double angle);
139 89
140 // Return this matrix skewed along the X axis by the passed values. 90 // Return this matrix skewed along the X axis by the passed values.
141 // Passing a NaN will use a value of 0. 91 // Passing a NaN will use a value of 0.
142 // Operation is performed as though the this matrix is multiplied by a matrix 92 // Operation is performed as though the this matrix is multiplied by a matrix
143 // with the skew values on the left (result = skewX(angle) * this) 93 // with the skew values on the left (result = skewX(angle) * this)
144 CSSMatrix* skewX(double angle) const; 94 CSSMatrix* skewX(double angle);
145 95
146 // Return this matrix skewed along the Y axis by the passed values. 96 // Return this matrix skewed along the Y axis by the passed values.
147 // Passing a NaN will use a value of 0. 97 // Passing a NaN will use a value of 0.
148 // Operation is performed as though the this matrix is multiplied by a matrix 98 // Operation is performed as though the this matrix is multiplied by a matrix
149 // with the skew values on the left (result = skewY(angle) * this) 99 // with the skew values on the left (result = skewY(angle) * this)
150 CSSMatrix* skewY(double angle) const; 100 CSSMatrix* skewY(double angle);
151 101
152 const TransformationMatrix& transform() const { return *m_matrix; } 102 String toString();
153
154 String toString() const;
155
156 DEFINE_INLINE_TRACE() {}
157 103
158 protected: 104 protected:
159 CSSMatrix(const TransformationMatrix&); 105 CSSMatrix(const TransformationMatrix&);
160 CSSMatrix(const String&, ExceptionState&); 106 CSSMatrix(const String&, ExceptionState&);
161
162 // TransformationMatrix needs to be 16-byte aligned. PartitionAlloc
163 // supports 16-byte alignment but Oilpan doesn't. So we use an std::unique_ptr
164 // to allocate TransformationMatrix on PartitionAlloc.
165 // TODO(oilpan): Oilpan should support 16-byte aligned allocations.
166 std::unique_ptr<TransformationMatrix> m_matrix;
167 }; 107 };
168 108
169 } // namespace blink 109 } // namespace blink
170 110
171 #endif // CSSMatrix_h 111 #endif // CSSMatrix_h
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/css/CSSMatrix.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698