Chromium Code Reviews| Index: third_party/WebKit/Source/core/dom/DOMMatrix.cpp |
| diff --git a/third_party/WebKit/Source/core/dom/DOMMatrix.cpp b/third_party/WebKit/Source/core/dom/DOMMatrix.cpp |
| index 14a1d8e9641ce9a097c1a470bc8aea5bfbaccdcb..2c4a40bae56f6f9001b202f5af422a2804001f66 100644 |
| --- a/third_party/WebKit/Source/core/dom/DOMMatrix.cpp |
| +++ b/third_party/WebKit/Source/core/dom/DOMMatrix.cpp |
| @@ -28,29 +28,50 @@ DOMMatrix::DOMMatrix(const TransformationMatrix& matrix, bool is2D) |
| m_is2D = is2D; |
| } |
| +DOMMatrix* DOMMatrix::fromMatrix(DOMMatrixInit& other, ExceptionState& exceptionState) |
| +{ |
| + validateAndFixup(other, exceptionState); |
| + if (exceptionState.hadException()) |
| + return nullptr; |
| + |
| + if (other.is2D()) { |
| + return new DOMMatrix({ |
| + other.m11(), other.m12(), other.m21(), |
| + other.m22(), other.m41(), other.m42()}, other.is2D()); |
| + } |
| + |
| + return new DOMMatrix({ |
| + other.m11(), other.m12(), other.m13(), other.m14(), |
| + other.m21(), other.m22(), other.m23(), other.m24(), |
| + other.m31(), other.m32(), other.m33(), other.m34(), |
| + other.m41(), other.m42(), other.m43(), other.m44()}, other.is2D()); |
| +} |
| + |
| void DOMMatrix::setIs2D(bool value) |
| { |
| if (m_is2D) |
| m_is2D = value; |
| } |
| -DOMMatrix* DOMMatrix::multiplySelf(DOMMatrix* other) |
| +DOMMatrix* DOMMatrix::multiplySelf(DOMMatrixInit& other, ExceptionState& exceptionState) |
| { |
| - if (!other->is2D()) |
| + DOMMatrix* otherMatrix = DOMMatrix::fromMatrix(other, exceptionState); |
| + if (!otherMatrix->is2D()) |
|
dominicc (has gone to gerrit)
2016/08/30 02:13:43
Seems a shame to allocate the whole intermediate D
zino
2016/09/10 10:18:15
I'll try to file a bug.
|
| m_is2D = false; |
| - *m_matrix *= other->matrix(); |
| + *m_matrix *= otherMatrix->matrix(); |
| return this; |
| } |
| -DOMMatrix* DOMMatrix::preMultiplySelf(DOMMatrix* other) |
| +DOMMatrix* DOMMatrix::preMultiplySelf(DOMMatrixInit& other, ExceptionState& exceptionState) |
| { |
| - if (!other->is2D()) |
| + DOMMatrix* otherMatrix = DOMMatrix::fromMatrix(other, exceptionState); |
| + if (!otherMatrix->is2D()) |
| m_is2D = false; |
| TransformationMatrix& matrix = *m_matrix; |
| - *m_matrix = other->matrix() * matrix; |
| + *m_matrix = otherMatrix->matrix() * matrix; |
| return this; |
| } |