| 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()); |
| (...skipping 21 matching lines...) Expand all Loading... |
| 32 ExceptionState& exception_state) { | 32 ExceptionState& exception_state) { |
| 33 if (sequence.size() != 6 && sequence.size() != 16) { | 33 if (sequence.size() != 6 && sequence.size() != 16) { |
| 34 exception_state.ThrowTypeError( | 34 exception_state.ThrowTypeError( |
| 35 "The sequence must contain 6 elements for a 2D matrix or 16 elements " | 35 "The sequence must contain 6 elements for a 2D matrix or 16 elements " |
| 36 "for a 3D matrix."); | 36 "for a 3D matrix."); |
| 37 return nullptr; | 37 return nullptr; |
| 38 } | 38 } |
| 39 return new DOMMatrix(sequence, sequence.size()); | 39 return new DOMMatrix(sequence, sequence.size()); |
| 40 } | 40 } |
| 41 | 41 |
| 42 DOMMatrix* DOMMatrix::fromFloat32Array(NotShared<DOMFloat32Array> float32_array, | 42 DOMMatrix* DOMMatrix::fromFloat32Array(DOMFloat32Array* float32_array, |
| 43 ExceptionState& exception_state) { | 43 ExceptionState& exception_state) { |
| 44 if (float32_array.View()->length() != 6 && | 44 if (float32_array->length() != 6 && float32_array->length() != 16) { |
| 45 float32_array.View()->length() != 16) { | |
| 46 exception_state.ThrowTypeError( | 45 exception_state.ThrowTypeError( |
| 47 "The sequence must contain 6 elements for a 2D matrix or 16 elements " | 46 "The sequence must contain 6 elements for a 2D matrix or 16 elements " |
| 48 "for a 3D matrix."); | 47 "for a 3D matrix."); |
| 49 return nullptr; | 48 return nullptr; |
| 50 } | 49 } |
| 51 return new DOMMatrix(float32_array.View()->Data(), | 50 return new DOMMatrix(float32_array->Data(), float32_array->length()); |
| 52 float32_array.View()->length()); | |
| 53 } | 51 } |
| 54 | 52 |
| 55 DOMMatrix* DOMMatrix::fromFloat64Array(NotShared<DOMFloat64Array> float64_array, | 53 DOMMatrix* DOMMatrix::fromFloat64Array(DOMFloat64Array* float64_array, |
| 56 ExceptionState& exception_state) { | 54 ExceptionState& exception_state) { |
| 57 if (float64_array.View()->length() != 6 && | 55 if (float64_array->length() != 6 && float64_array->length() != 16) { |
| 58 float64_array.View()->length() != 16) { | |
| 59 exception_state.ThrowTypeError( | 56 exception_state.ThrowTypeError( |
| 60 "The sequence must contain 6 elements for a 2D matrix or 16 elements " | 57 "The sequence must contain 6 elements for a 2D matrix or 16 elements " |
| 61 "for a 3D matrix."); | 58 "for a 3D matrix."); |
| 62 return nullptr; | 59 return nullptr; |
| 63 } | 60 } |
| 64 return new DOMMatrix(float64_array.View()->Data(), | 61 return new DOMMatrix(float64_array->Data(), float64_array->length()); |
| 65 float64_array.View()->length()); | |
| 66 } | 62 } |
| 67 | 63 |
| 68 template <typename T> | 64 template <typename T> |
| 69 DOMMatrix::DOMMatrix(T sequence, int size) | 65 DOMMatrix::DOMMatrix(T sequence, int size) |
| 70 : DOMMatrixReadOnly(sequence, size) {} | 66 : DOMMatrixReadOnly(sequence, size) {} |
| 71 | 67 |
| 72 DOMMatrix::DOMMatrix(const TransformationMatrix& matrix, bool is2d) | 68 DOMMatrix::DOMMatrix(const TransformationMatrix& matrix, bool is2d) |
| 73 : DOMMatrixReadOnly(matrix, is2d) {} | 69 : DOMMatrixReadOnly(matrix, is2d) {} |
| 74 | 70 |
| 75 DOMMatrix* DOMMatrix::fromMatrix(DOMMatrixInit& other, | 71 DOMMatrix* DOMMatrix::fromMatrix(DOMMatrixInit& other, |
| (...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 262 return this; | 258 return this; |
| 263 } | 259 } |
| 264 | 260 |
| 265 DOMMatrix* DOMMatrix::setMatrixValue(const String& input_string, | 261 DOMMatrix* DOMMatrix::setMatrixValue(const String& input_string, |
| 266 ExceptionState& exception_state) { | 262 ExceptionState& exception_state) { |
| 267 SetMatrixValueFromString(input_string, exception_state); | 263 SetMatrixValueFromString(input_string, exception_state); |
| 268 return this; | 264 return this; |
| 269 } | 265 } |
| 270 | 266 |
| 271 } // namespace blink | 267 } // namespace blink |
| OLD | NEW |