| 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/geometry/DOMMatrix.h" | 5 #include "core/geometry/DOMMatrix.h" |
| 6 | 6 |
| 7 namespace blink { | 7 namespace blink { |
| 8 | 8 |
| 9 DOMMatrix* DOMMatrix::Create(ExceptionState& exception_state) { | 9 DOMMatrix* DOMMatrix::Create(ExceptionState& exception_state) { |
| 10 return new DOMMatrix(TransformationMatrix()); | 10 return new DOMMatrix(TransformationMatrix()); |
| 11 } | 11 } |
| 12 | 12 |
| 13 DOMMatrix* DOMMatrix::Create(StringOrUnrestrictedDoubleSequence& init, |
| 14 ExceptionState& exception_state) { |
| 15 if (init.isString()) { |
| 16 DOMMatrix* matrix = new DOMMatrix(TransformationMatrix()); |
| 17 matrix->SetMatrixValueFromString(init.getAsString(), exception_state); |
| 18 return matrix; |
| 19 } |
| 20 |
| 21 if (init.isUnrestrictedDoubleSequence()) { |
| 22 const Vector<double>& sequence = init.getAsUnrestrictedDoubleSequence(); |
| 23 if (sequence.size() != 6 && sequence.size() != 16) { |
| 24 exception_state.ThrowTypeError( |
| 25 "The sequence must contain 6 elements for a 2D matrix or 16 elements " |
| 26 "for a 3D matrix."); |
| 27 return nullptr; |
| 28 } |
| 29 return new DOMMatrix(sequence, sequence.size()); |
| 30 } |
| 31 |
| 32 NOTREACHED(); |
| 33 return nullptr; |
| 34 } |
| 35 |
| 13 DOMMatrix* DOMMatrix::Create(DOMMatrixReadOnly* other, | 36 DOMMatrix* DOMMatrix::Create(DOMMatrixReadOnly* other, |
| 14 ExceptionState& exception_state) { | 37 ExceptionState& exception_state) { |
| 15 return new DOMMatrix(other->Matrix(), other->is2D()); | 38 return new DOMMatrix(other->Matrix(), other->is2D()); |
| 16 } | 39 } |
| 17 | 40 |
| 18 DOMMatrix* DOMMatrix::Create(const SkMatrix44& matrix, | 41 DOMMatrix* DOMMatrix::Create(const SkMatrix44& matrix, |
| 19 ExceptionState& exception_state) { | 42 ExceptionState& exception_state) { |
| 20 TransformationMatrix transformation_matrix(matrix); | 43 TransformationMatrix transformation_matrix(matrix); |
| 21 return new DOMMatrix(transformation_matrix, transformation_matrix.IsAffine()); | 44 return new DOMMatrix(transformation_matrix, transformation_matrix.IsAffine()); |
| 22 } | 45 } |
| 23 | 46 |
| 24 DOMMatrix* DOMMatrix::Create(const String& transform_list, | |
| 25 ExceptionState& exception_state) { | |
| 26 DOMMatrix* matrix = new DOMMatrix(TransformationMatrix()); | |
| 27 matrix->SetMatrixValueFromString(transform_list, exception_state); | |
| 28 return matrix; | |
| 29 } | |
| 30 | |
| 31 DOMMatrix* DOMMatrix::Create(Vector<double> sequence, | |
| 32 ExceptionState& exception_state) { | |
| 33 if (sequence.size() != 6 && sequence.size() != 16) { | |
| 34 exception_state.ThrowTypeError( | |
| 35 "The sequence must contain 6 elements for a 2D matrix or 16 elements " | |
| 36 "for a 3D matrix."); | |
| 37 return nullptr; | |
| 38 } | |
| 39 return new DOMMatrix(sequence, sequence.size()); | |
| 40 } | |
| 41 | |
| 42 DOMMatrix* DOMMatrix::fromFloat32Array(NotShared<DOMFloat32Array> float32_array, | 47 DOMMatrix* DOMMatrix::fromFloat32Array(NotShared<DOMFloat32Array> float32_array, |
| 43 ExceptionState& exception_state) { | 48 ExceptionState& exception_state) { |
| 44 if (float32_array.View()->length() != 6 && | 49 if (float32_array.View()->length() != 6 && |
| 45 float32_array.View()->length() != 16) { | 50 float32_array.View()->length() != 16) { |
| 46 exception_state.ThrowTypeError( | 51 exception_state.ThrowTypeError( |
| 47 "The sequence must contain 6 elements for a 2D matrix or 16 elements " | 52 "The sequence must contain 6 elements for a 2D matrix or 16 elements " |
| 48 "for a 3D matrix."); | 53 "for a 3D matrix."); |
| 49 return nullptr; | 54 return nullptr; |
| 50 } | 55 } |
| 51 return new DOMMatrix(float32_array.View()->Data(), | 56 return new DOMMatrix(float32_array.View()->Data(), |
| (...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 262 return this; | 267 return this; |
| 263 } | 268 } |
| 264 | 269 |
| 265 DOMMatrix* DOMMatrix::setMatrixValue(const String& input_string, | 270 DOMMatrix* DOMMatrix::setMatrixValue(const String& input_string, |
| 266 ExceptionState& exception_state) { | 271 ExceptionState& exception_state) { |
| 267 SetMatrixValueFromString(input_string, exception_state); | 272 SetMatrixValueFromString(input_string, exception_state); |
| 268 return this; | 273 return this; |
| 269 } | 274 } |
| 270 | 275 |
| 271 } // namespace blink | 276 } // namespace blink |
| OLD | NEW |