| 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/DOMMatrixReadOnly.h" | 5 #include "core/geometry/DOMMatrixReadOnly.h" |
| 6 | 6 |
| 7 #include "bindings/core/v8/V8ObjectBuilder.h" | 7 #include "bindings/core/v8/V8ObjectBuilder.h" |
| 8 #include "core/css/CSSIdentifierValue.h" | 8 #include "core/css/CSSIdentifierValue.h" |
| 9 #include "core/css/CSSToLengthConversionData.h" | 9 #include "core/css/CSSToLengthConversionData.h" |
| 10 #include "core/css/CSSValueList.h" | 10 #include "core/css/CSSValueList.h" |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 89 other.m33() != 1 || other.m44() != 1); | 89 other.m33() != 1 || other.m44() != 1); |
| 90 other.setIs2D(is2d); | 90 other.setIs2D(is2d); |
| 91 } | 91 } |
| 92 return true; | 92 return true; |
| 93 } | 93 } |
| 94 | 94 |
| 95 DOMMatrixReadOnly* DOMMatrixReadOnly::Create(ExceptionState& exception_state) { | 95 DOMMatrixReadOnly* DOMMatrixReadOnly::Create(ExceptionState& exception_state) { |
| 96 return new DOMMatrixReadOnly(TransformationMatrix()); | 96 return new DOMMatrixReadOnly(TransformationMatrix()); |
| 97 } | 97 } |
| 98 | 98 |
| 99 DOMMatrixReadOnly* DOMMatrixReadOnly::Create(const String& transform_list, | 99 DOMMatrixReadOnly* DOMMatrixReadOnly::Create( |
| 100 ExceptionState& exception_state) { | 100 StringOrUnrestrictedDoubleSequence& init, |
| 101 DOMMatrixReadOnly* matrix = new DOMMatrixReadOnly(TransformationMatrix()); | 101 ExceptionState& exception_state) { |
| 102 matrix->SetMatrixValueFromString(transform_list, exception_state); | 102 if (init.isString()) { |
| 103 return matrix; | 103 DOMMatrixReadOnly* matrix = new DOMMatrixReadOnly(TransformationMatrix()); |
| 104 } | 104 matrix->SetMatrixValueFromString(init.getAsString(), exception_state); |
| 105 return matrix; |
| 106 } |
| 105 | 107 |
| 106 DOMMatrixReadOnly* DOMMatrixReadOnly::Create(Vector<double> sequence, | 108 if (init.isUnrestrictedDoubleSequence()) { |
| 107 ExceptionState& exception_state) { | 109 const Vector<double>& sequence = init.getAsUnrestrictedDoubleSequence(); |
| 108 if (sequence.size() != 6 && sequence.size() != 16) { | 110 if (sequence.size() != 6 && sequence.size() != 16) { |
| 109 exception_state.ThrowTypeError( | 111 exception_state.ThrowTypeError( |
| 110 "The sequence must contain 6 elements for a 2D matrix or 16 elements " | 112 "The sequence must contain 6 elements for a 2D matrix or 16 elements " |
| 111 "for a 3D matrix."); | 113 "for a 3D matrix."); |
| 112 return nullptr; | 114 return nullptr; |
| 115 } |
| 116 return new DOMMatrixReadOnly(sequence, sequence.size()); |
| 113 } | 117 } |
| 114 return new DOMMatrixReadOnly(sequence, sequence.size()); | 118 |
| 119 NOTREACHED(); |
| 120 return nullptr; |
| 115 } | 121 } |
| 116 | 122 |
| 117 DOMMatrixReadOnly* DOMMatrixReadOnly::fromFloat32Array( | 123 DOMMatrixReadOnly* DOMMatrixReadOnly::fromFloat32Array( |
| 118 NotShared<DOMFloat32Array> float32_array, | 124 NotShared<DOMFloat32Array> float32_array, |
| 119 ExceptionState& exception_state) { | 125 ExceptionState& exception_state) { |
| 120 if (float32_array.View()->length() != 6 && | 126 if (float32_array.View()->length() != 6 && |
| 121 float32_array.View()->length() != 16) { | 127 float32_array.View()->length() != 16) { |
| 122 exception_state.ThrowTypeError( | 128 exception_state.ThrowTypeError( |
| 123 "The sequence must contain 6 elements for a 2D matrix or 16 elements a " | 129 "The sequence must contain 6 elements for a 2D matrix or 16 elements a " |
| 124 "for 3D matrix."); | 130 "for 3D matrix."); |
| (...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 393 | 399 |
| 394 matrix_->MakeIdentity(); | 400 matrix_->MakeIdentity(); |
| 395 operations.Apply(FloatSize(0, 0), *matrix_); | 401 operations.Apply(FloatSize(0, 0), *matrix_); |
| 396 | 402 |
| 397 is2d_ = !operations.Has3DOperation(); | 403 is2d_ = !operations.Has3DOperation(); |
| 398 | 404 |
| 399 return; | 405 return; |
| 400 } | 406 } |
| 401 | 407 |
| 402 } // namespace blink | 408 } // namespace blink |
| OLD | NEW |