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 namespace blink { | 7 namespace blink { |
8 | 8 |
9 DOMMatrix* DOMMatrix::create() | 9 DOMMatrix* DOMMatrix::create(ExceptionState& exceptionState) |
10 { | 10 { |
11 return new DOMMatrix(TransformationMatrix()); | 11 return new DOMMatrix(TransformationMatrix()); |
12 } | 12 } |
13 | 13 |
14 DOMMatrix* DOMMatrix::create(DOMMatrixReadOnly* other) | 14 DOMMatrix* DOMMatrix::create(DOMMatrixReadOnly* other, ExceptionState& exception
State) |
15 { | 15 { |
16 return new DOMMatrix(other->matrix(), other->is2D()); | 16 return new DOMMatrix(other->matrix(), other->is2D()); |
17 } | 17 } |
18 | 18 |
19 DOMMatrix* DOMMatrix::create(const SkMatrix44& matrix) | 19 DOMMatrix* DOMMatrix::create(const SkMatrix44& matrix, ExceptionState& exception
State) |
20 { | 20 { |
21 TransformationMatrix transformationMatrix(matrix); | 21 TransformationMatrix transformationMatrix(matrix); |
22 return new DOMMatrix(transformationMatrix, transformationMatrix.isAffine()); | 22 return new DOMMatrix(transformationMatrix, transformationMatrix.isAffine()); |
23 } | 23 } |
24 | 24 |
| 25 DOMMatrix* DOMMatrix::create(Vector<double> sequence, ExceptionState& exceptionS
tate) |
| 26 { |
| 27 if (sequence.size() != 6 && sequence.size() != 16) { |
| 28 exceptionState.throwTypeError("The sequence must contain 6 elements for
a 2D matrix or 16 elements for a 3D matrix."); |
| 29 return nullptr; |
| 30 } |
| 31 return new DOMMatrix(sequence, sequence.size()); |
| 32 } |
| 33 |
25 DOMMatrix* DOMMatrix::fromFloat32Array(DOMFloat32Array* float32Array, ExceptionS
tate& exceptionState) | 34 DOMMatrix* DOMMatrix::fromFloat32Array(DOMFloat32Array* float32Array, ExceptionS
tate& exceptionState) |
26 { | 35 { |
27 if (float32Array->length() != 6 && float32Array->length() != 16) { | 36 if (float32Array->length() != 6 && float32Array->length() != 16) { |
28 exceptionState.throwTypeError("The sequence must contain 6 elements for
a 2D matrix or 16 elements for a 3D matrix."); | 37 exceptionState.throwTypeError("The sequence must contain 6 elements for
a 2D matrix or 16 elements for a 3D matrix."); |
29 return nullptr; | 38 return nullptr; |
30 } | 39 } |
31 return new DOMMatrix(float32Array->data(), float32Array->length()); | 40 return new DOMMatrix(float32Array->data(), float32Array->length()); |
32 } | 41 } |
33 | 42 |
34 DOMMatrix* DOMMatrix::fromFloat64Array(DOMFloat64Array* float64Array, ExceptionS
tate& exceptionState) | 43 DOMMatrix* DOMMatrix::fromFloat64Array(DOMFloat64Array* float64Array, ExceptionS
tate& exceptionState) |
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
182 setM41(NAN); | 191 setM41(NAN); |
183 setM42(NAN); | 192 setM42(NAN); |
184 setM43(NAN); | 193 setM43(NAN); |
185 setM44(NAN); | 194 setM44(NAN); |
186 setIs2D(false); | 195 setIs2D(false); |
187 } | 196 } |
188 return this; | 197 return this; |
189 } | 198 } |
190 | 199 |
191 } // namespace blink | 200 } // namespace blink |
OLD | NEW |