Chromium Code Reviews| Index: third_party/WebKit/Source/core/dom/DOMPointReadOnly.cpp |
| diff --git a/third_party/WebKit/Source/core/dom/DOMPointReadOnly.cpp b/third_party/WebKit/Source/core/dom/DOMPointReadOnly.cpp |
| index 6857417126483ece74e48bc256f035885c371f75..d8c93677b60a5f59a469345851e99452d5c45547 100644 |
| --- a/third_party/WebKit/Source/core/dom/DOMPointReadOnly.cpp |
| +++ b/third_party/WebKit/Source/core/dom/DOMPointReadOnly.cpp |
| @@ -4,8 +4,12 @@ |
| #include "core/dom/DOMPointReadOnly.h" |
| +#include "bindings/core/v8/ExceptionState.h" |
| #include "bindings/core/v8/ScriptValue.h" |
| #include "bindings/core/v8/V8ObjectBuilder.h" |
| +#include "core/dom/DOMMatrixInit.h" |
| +#include "core/dom/DOMMatrixReadOnly.h" |
| +#include "core/dom/DOMPoint.h" |
| #include "core/dom/DOMPointInit.h" |
| namespace blink { |
| @@ -31,6 +35,27 @@ DOMPointReadOnly* DOMPointReadOnly::fromPoint(const DOMPointInit& other) { |
| return new DOMPointReadOnly(other.x(), other.y(), other.z(), other.w()); |
| } |
| +DOMPoint* DOMPointReadOnly::matrixTransform(DOMMatrixInit& other, ExceptionState& exceptionState) { |
| + DOMPoint* point = DOMPoint::create(x(), y(), z(), w()); |
|
zino
2016/12/28 16:39:14
This is unnecessary. You don't need to create this
Byoungkwon Ko
2017/01/03 15:54:37
Done.
|
| + DOMMatrixReadOnly* matrix = DOMMatrixReadOnly::fromMatrix(other, exceptionState); |
| + |
| + if (matrix->is2D() && point->z() == 0 && point->w() == 1) { |
| + double x = point->x() * matrix->m11() + point->y() * matrix->m12() + matrix->m41(); |
| + double y = point->x() * matrix->m12() + point->y() * matrix->m22() + matrix->m42(); |
| + return DOMPoint::create(x, y, 0, 1); |
| + } |
| + |
| + double x = point->x() * matrix->m11() + point->y() * matrix->m21() + point->z() * matrix->m31() + |
| + point->w() * matrix->m41(); |
| + double y = point->x() * matrix->m12() + point->y() * matrix->m22() + point->z() * matrix->m32() + |
| + point->w() * matrix->m42(); |
| + double z = point->x() * matrix->m13() + point->y() * matrix->m23() + point->z() * matrix->m33() + |
| + point->w() * matrix->m43(); |
| + double w = point->x() * matrix->m14() + point->y() * matrix->m24() + point->z() * matrix->m34() + |
| + point->w() * matrix->m44(); |
| + return DOMPoint::create(x, y, z, w); |
| +} |
| + |
| DOMPointReadOnly::DOMPointReadOnly(double x, double y, double z, double w) |
| : m_x(x), m_y(y), m_z(z), m_w(w) {} |