Chromium Code Reviews| Index: third_party/WebKit/Source/core/dom/DOMMatrixReadOnly.cpp |
| diff --git a/third_party/WebKit/Source/core/dom/DOMMatrixReadOnly.cpp b/third_party/WebKit/Source/core/dom/DOMMatrixReadOnly.cpp |
| index 252d8e9d058b7cf1a4903d23745e798eada44724..0a4f849bea21f59c96ce2f751cbead4a325c013a 100644 |
| --- a/third_party/WebKit/Source/core/dom/DOMMatrixReadOnly.cpp |
| +++ b/third_party/WebKit/Source/core/dom/DOMMatrixReadOnly.cpp |
| @@ -12,17 +12,18 @@ DOMMatrixReadOnly* DOMMatrixReadOnly::create(Vector<double> sequence, ExceptionS |
| exceptionState.throwTypeError("An invalid number sequence is specified. The sequence must contain 6 elements for 2D matrix and 16 elements for 3D matrix."); |
| return nullptr; |
| } |
| - return new DOMMatrixReadOnly(sequence); |
| + return new DOMMatrixReadOnly(sequence, sequence.size()); |
| } |
| -DOMMatrixReadOnly::DOMMatrixReadOnly(Vector<double> sequence) |
| +template <typename T> |
| +DOMMatrixReadOnly::DOMMatrixReadOnly(T sequence, int size) |
| { |
| - if (sequence.size() == 6) { |
| + if (size == 6) { |
| m_matrix = TransformationMatrix::create( |
| sequence[0], sequence[1], sequence[2], sequence[3], |
| sequence[4], sequence[5]); |
| m_is2D = true; |
| - } else if (sequence.size() == 16) { |
| + } else if (size == 16) { |
| m_matrix = TransformationMatrix::create( |
| sequence[0], sequence[1], sequence[2], sequence[3], |
| sequence[4], sequence[5], sequence[6], sequence[7], |
| @@ -34,6 +35,25 @@ DOMMatrixReadOnly::DOMMatrixReadOnly(Vector<double> sequence) |
| } |
| } |
| +DOMMatrixReadOnly* DOMMatrixReadOnly::fromFloat32Array(DOMFloat32Array* float32Array, ExceptionState& exceptionState) |
| +{ |
| + if (float32Array->length() != 6 && float32Array->length() != 16) { |
| + exceptionState.throwTypeError("An invalid number sequence is specified. The sequence must contain 6 elements for 2D matrix and 16 elements for 3D matrix."); |
|
dominicc (has gone to gerrit)
2016/09/06 17:07:22
and 16 elements -> or 16 elements
Saying 'and' he
Hwanseung Lee
2016/09/07 14:21:47
Done.
|
| + return nullptr; |
| + } |
| + return new DOMMatrixReadOnly(float32Array->data(), float32Array->length()); |
| +} |
| + |
| + |
| +DOMMatrixReadOnly* DOMMatrixReadOnly::fromFloat64Array(DOMFloat64Array* float64Array, ExceptionState& exceptionState) |
| +{ |
| + if (float64Array->length() != 6 && float64Array->length() != 16) { |
| + exceptionState.throwTypeError("An invalid number sequence is specified. The sequence must contain 6 elements for 2D matrix and 16 elements for 3D matrix."); |
| + return nullptr; |
| + } |
| + return new DOMMatrixReadOnly(float64Array->data(), float64Array->length()); |
| +} |
| + |
| DOMMatrixReadOnly::~DOMMatrixReadOnly() |
| { |
| } |