Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(384)

Unified Diff: third_party/WebKit/Source/core/geometry/DOMMatrix.cpp

Issue 2859293002: Use union instead of overload fo DOMMatrix/DOMMatrixReadOnly (Closed)
Patch Set: x Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/core/geometry/DOMMatrix.cpp
diff --git a/third_party/WebKit/Source/core/geometry/DOMMatrix.cpp b/third_party/WebKit/Source/core/geometry/DOMMatrix.cpp
index 3dc15d7929111e2723e3f8769401a51ef0541f2a..b87df838606e3c2599dc4e4769fcdb35e2ca82b0 100644
--- a/third_party/WebKit/Source/core/geometry/DOMMatrix.cpp
+++ b/third_party/WebKit/Source/core/geometry/DOMMatrix.cpp
@@ -10,6 +10,29 @@ DOMMatrix* DOMMatrix::Create(ExceptionState& exception_state) {
return new DOMMatrix(TransformationMatrix());
}
+DOMMatrix* DOMMatrix::Create(StringOrUnrestrictedDoubleSequence& init,
+ ExceptionState& exception_state) {
+ if (init.isString()) {
+ DOMMatrix* matrix = new DOMMatrix(TransformationMatrix());
+ matrix->SetMatrixValueFromString(init.getAsString(), exception_state);
+ return matrix;
+ }
+
+ if (init.isUnrestrictedDoubleSequence()) {
+ 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 DOMMatrix(sequence, sequence.size());
+ }
+
+ NOTREACHED();
+ return nullptr;
+}
+
DOMMatrix* DOMMatrix::Create(DOMMatrixReadOnly* other,
ExceptionState& exception_state) {
return new DOMMatrix(other->Matrix(), other->is2D());
@@ -21,24 +44,6 @@ DOMMatrix* DOMMatrix::Create(const SkMatrix44& matrix,
return new DOMMatrix(transformation_matrix, transformation_matrix.IsAffine());
}
-DOMMatrix* DOMMatrix::Create(const String& transform_list,
- ExceptionState& exception_state) {
- DOMMatrix* matrix = new DOMMatrix(TransformationMatrix());
- matrix->SetMatrixValueFromString(transform_list, exception_state);
- return matrix;
-}
-
-DOMMatrix* DOMMatrix::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;
- }
- return new DOMMatrix(sequence, sequence.size());
-}
-
DOMMatrix* DOMMatrix::fromFloat32Array(NotShared<DOMFloat32Array> float32_array,
ExceptionState& exception_state) {
if (float32_array.View()->length() != 6 &&
« no previous file with comments | « third_party/WebKit/Source/core/geometry/DOMMatrix.h ('k') | third_party/WebKit/Source/core/geometry/DOMMatrix.idl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698