OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/dom/DOMMatrix.h" | 5 #include "core/dom/DOMMatrix.h" |
6 | 6 |
7 #include "core/css/CSSIdentifierValue.h" | 7 #include "core/css/CSSIdentifierValue.h" |
8 #include "core/css/CSSToLengthConversionData.h" | 8 #include "core/css/CSSToLengthConversionData.h" |
9 #include "core/css/CSSValueList.h" | 9 #include "core/css/CSSValueList.h" |
10 #include "core/css/parser/CSSParser.h" | 10 #include "core/css/parser/CSSParser.h" |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
64 | 64 |
65 template <typename T> | 65 template <typename T> |
66 DOMMatrix::DOMMatrix(T sequence, int size) | 66 DOMMatrix::DOMMatrix(T sequence, int size) |
67 : DOMMatrixReadOnly(sequence, size) {} | 67 : DOMMatrixReadOnly(sequence, size) {} |
68 | 68 |
69 DOMMatrix::DOMMatrix(const TransformationMatrix& matrix, bool is2D) | 69 DOMMatrix::DOMMatrix(const TransformationMatrix& matrix, bool is2D) |
70 : DOMMatrixReadOnly(matrix, is2D) {} | 70 : DOMMatrixReadOnly(matrix, is2D) {} |
71 | 71 |
72 DOMMatrix* DOMMatrix::fromMatrix(DOMMatrixInit& other, | 72 DOMMatrix* DOMMatrix::fromMatrix(DOMMatrixInit& other, |
73 ExceptionState& exceptionState) { | 73 ExceptionState& exceptionState) { |
74 validateAndFixup(other, exceptionState); | 74 if (!validateAndFixup(other, exceptionState)) { |
75 if (exceptionState.hadException()) | 75 DCHECK(exceptionState.hadException()); |
76 return nullptr; | 76 return nullptr; |
77 | 77 } |
78 if (other.is2D()) { | 78 if (other.is2D()) { |
79 return new DOMMatrix({other.m11(), other.m12(), other.m21(), other.m22(), | 79 return new DOMMatrix({other.m11(), other.m12(), other.m21(), other.m22(), |
80 other.m41(), other.m42()}, | 80 other.m41(), other.m42()}, |
81 other.is2D()); | 81 other.is2D()); |
82 } | 82 } |
83 | 83 |
84 return new DOMMatrix({other.m11(), other.m12(), other.m13(), other.m14(), | 84 return new DOMMatrix({other.m11(), other.m12(), other.m13(), other.m14(), |
85 other.m21(), other.m22(), other.m23(), other.m24(), | 85 other.m21(), other.m22(), other.m23(), other.m24(), |
86 other.m31(), other.m32(), other.m33(), other.m34(), | 86 other.m31(), other.m32(), other.m33(), other.m34(), |
87 other.m41(), other.m42(), other.m43(), other.m44()}, | 87 other.m41(), other.m42(), other.m43(), other.m44()}, |
(...skipping 20 matching lines...) Expand all Loading... |
108 m_matrix->setM34(NAN); | 108 m_matrix->setM34(NAN); |
109 m_matrix->setM41(NAN); | 109 m_matrix->setM41(NAN); |
110 m_matrix->setM42(NAN); | 110 m_matrix->setM42(NAN); |
111 m_matrix->setM43(NAN); | 111 m_matrix->setM43(NAN); |
112 m_matrix->setM44(NAN); | 112 m_matrix->setM44(NAN); |
113 } | 113 } |
114 | 114 |
115 DOMMatrix* DOMMatrix::multiplySelf(DOMMatrixInit& other, | 115 DOMMatrix* DOMMatrix::multiplySelf(DOMMatrixInit& other, |
116 ExceptionState& exceptionState) { | 116 ExceptionState& exceptionState) { |
117 DOMMatrix* otherMatrix = DOMMatrix::fromMatrix(other, exceptionState); | 117 DOMMatrix* otherMatrix = DOMMatrix::fromMatrix(other, exceptionState); |
| 118 if (!otherMatrix) { |
| 119 DCHECK(exceptionState.hadException()); |
| 120 return nullptr; |
| 121 } |
118 if (!otherMatrix->is2D()) | 122 if (!otherMatrix->is2D()) |
119 m_is2D = false; | 123 m_is2D = false; |
120 | 124 |
121 *m_matrix *= otherMatrix->matrix(); | 125 *m_matrix *= otherMatrix->matrix(); |
122 | 126 |
123 return this; | 127 return this; |
124 } | 128 } |
125 | 129 |
126 DOMMatrix* DOMMatrix::preMultiplySelf(DOMMatrixInit& other, | 130 DOMMatrix* DOMMatrix::preMultiplySelf(DOMMatrixInit& other, |
127 ExceptionState& exceptionState) { | 131 ExceptionState& exceptionState) { |
128 DOMMatrix* otherMatrix = DOMMatrix::fromMatrix(other, exceptionState); | 132 DOMMatrix* otherMatrix = DOMMatrix::fromMatrix(other, exceptionState); |
| 133 if (!otherMatrix) { |
| 134 DCHECK(exceptionState.hadException()); |
| 135 return nullptr; |
| 136 } |
129 if (!otherMatrix->is2D()) | 137 if (!otherMatrix->is2D()) |
130 m_is2D = false; | 138 m_is2D = false; |
131 | 139 |
132 TransformationMatrix& matrix = *m_matrix; | 140 TransformationMatrix& matrix = *m_matrix; |
133 *m_matrix = otherMatrix->matrix() * matrix; | 141 *m_matrix = otherMatrix->matrix() * matrix; |
134 | 142 |
135 return this; | 143 return this; |
136 } | 144 } |
137 | 145 |
138 DOMMatrix* DOMMatrix::translateSelf(double tx, double ty, double tz) { | 146 DOMMatrix* DOMMatrix::translateSelf(double tx, double ty, double tz) { |
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
294 | 302 |
295 m_matrix->makeIdentity(); | 303 m_matrix->makeIdentity(); |
296 operations.apply(FloatSize(0, 0), *m_matrix); | 304 operations.apply(FloatSize(0, 0), *m_matrix); |
297 | 305 |
298 m_is2D = !operations.has3DOperation(); | 306 m_is2D = !operations.has3DOperation(); |
299 | 307 |
300 return this; | 308 return this; |
301 } | 309 } |
302 | 310 |
303 } // namespace blink | 311 } // namespace blink |
OLD | NEW |