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..fe02208c98ae624e04e172c274de0de52a1875e7 100644 |
--- a/third_party/WebKit/Source/core/dom/DOMMatrixReadOnly.cpp |
+++ b/third_party/WebKit/Source/core/dom/DOMMatrixReadOnly.cpp |
@@ -9,20 +9,21 @@ namespace blink { |
DOMMatrixReadOnly* DOMMatrixReadOnly::create(Vector<double> sequence, ExceptionState& exceptionState) |
{ |
if (sequence.size() != 6 && sequence.size() != 16) { |
- exceptionState.throwTypeError("An invalid number sequence is specified. The sequence must contain 6 elements for 2D matrix and 16 elements for 3D matrix."); |
+ exceptionState.throwTypeError("The sequence must contain 6 elements for a 2D matrix or 16 elements for a 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("The sequence must contain 6 elements for a 2D matrix or 16 elements a for 3D matrix."); |
+ 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("The sequence must contain 6 elements for a 2D matrix or 16 elements for a 3D matrix."); |
+ return nullptr; |
+ } |
+ return new DOMMatrixReadOnly(float64Array->data(), float64Array->length()); |
+} |
+ |
DOMMatrixReadOnly::~DOMMatrixReadOnly() |
{ |
} |