Chromium Code Reviews| Index: third_party/WebKit/Source/core/geometry/DOMMatrixReadOnly.cpp |
| diff --git a/third_party/WebKit/Source/core/geometry/DOMMatrixReadOnly.cpp b/third_party/WebKit/Source/core/geometry/DOMMatrixReadOnly.cpp |
| index fd09781ae4727015e83006bf86f86971163d5b6c..876729c9d273ea17eb17a8eaa8c750d523d9b25e 100644 |
| --- a/third_party/WebKit/Source/core/geometry/DOMMatrixReadOnly.cpp |
| +++ b/third_party/WebKit/Source/core/geometry/DOMMatrixReadOnly.cpp |
| @@ -96,22 +96,28 @@ DOMMatrixReadOnly* DOMMatrixReadOnly::Create(ExceptionState& exception_state) { |
| return new DOMMatrixReadOnly(TransformationMatrix()); |
| } |
| -DOMMatrixReadOnly* DOMMatrixReadOnly::Create(const String& transform_list, |
| - ExceptionState& exception_state) { |
| - DOMMatrixReadOnly* matrix = new DOMMatrixReadOnly(TransformationMatrix()); |
| - matrix->SetMatrixValueFromString(transform_list, exception_state); |
| - return matrix; |
| -} |
| +DOMMatrixReadOnly* DOMMatrixReadOnly::Create( |
| + StringOrUnrestrictedDoubleSequence& init, |
| + ExceptionState& exception_state) { |
| + if (init.isString()) { |
| + DOMMatrixReadOnly* matrix = new DOMMatrixReadOnly(TransformationMatrix()); |
| + matrix->SetMatrixValueFromString(init.getAsString(), exception_state); |
| + return matrix; |
| + } |
| -DOMMatrixReadOnly* DOMMatrixReadOnly::Create(Vector<double> sequence, |
| - ExceptionState& exception_state) { |
| - if (sequence.size() != 6 && sequence.size() != 16) { |
| - exception_state.ThrowTypeError( |
| - "The sequence must contain 6 elements for a 2D matrix or 16 elements " |
| - "for a 3D matrix."); |
| - return nullptr; |
| + if (init.isUnrestrictedDoubleSequence()) { |
|
Justin Novosad
2017/05/04 21:03:58
Could this just be a DCHECK insted of an if? Then
|
| + const Vector<double>& sequence = init.getAsUnrestrictedDoubleSequence(); |
| + if (sequence.size() != 6 && sequence.size() != 16) { |
| + exception_state.ThrowTypeError( |
| + "The sequence must contain 6 elements for a 2D matrix or 16 elements " |
| + "for a 3D matrix."); |
| + return nullptr; |
| + } |
| + return new DOMMatrixReadOnly(sequence, sequence.size()); |
| } |
| - return new DOMMatrixReadOnly(sequence, sequence.size()); |
| + |
| + NOTREACHED(); |
| + return nullptr; |
| } |
| DOMMatrixReadOnly* DOMMatrixReadOnly::fromFloat32Array( |