OLD | NEW |
---|---|
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "core/dom/DOMPointReadOnly.h" | 5 #include "core/dom/DOMPointReadOnly.h" |
6 | 6 |
7 #include "bindings/core/v8/ExceptionState.h" | |
7 #include "bindings/core/v8/ScriptValue.h" | 8 #include "bindings/core/v8/ScriptValue.h" |
8 #include "bindings/core/v8/V8ObjectBuilder.h" | 9 #include "bindings/core/v8/V8ObjectBuilder.h" |
10 #include "core/dom/DOMMatrixInit.h" | |
11 #include "core/dom/DOMMatrixReadOnly.h" | |
12 #include "core/dom/DOMPoint.h" | |
9 #include "core/dom/DOMPointInit.h" | 13 #include "core/dom/DOMPointInit.h" |
10 | 14 |
11 namespace blink { | 15 namespace blink { |
12 | 16 |
13 DOMPointReadOnly* DOMPointReadOnly::create(double x, | 17 DOMPointReadOnly* DOMPointReadOnly::create(double x, |
14 double y, | 18 double y, |
15 double z, | 19 double z, |
16 double w) { | 20 double w) { |
17 return new DOMPointReadOnly(x, y, z, w); | 21 return new DOMPointReadOnly(x, y, z, w); |
18 } | 22 } |
19 | 23 |
20 ScriptValue DOMPointReadOnly::toJSONForBinding( | 24 ScriptValue DOMPointReadOnly::toJSONForBinding( |
21 ScriptState* scriptState) const { | 25 ScriptState* scriptState) const { |
22 V8ObjectBuilder result(scriptState); | 26 V8ObjectBuilder result(scriptState); |
23 result.addNumber("x", x()); | 27 result.addNumber("x", x()); |
24 result.addNumber("y", y()); | 28 result.addNumber("y", y()); |
25 result.addNumber("z", z()); | 29 result.addNumber("z", z()); |
26 result.addNumber("w", w()); | 30 result.addNumber("w", w()); |
27 return result.scriptValue(); | 31 return result.scriptValue(); |
28 } | 32 } |
29 | 33 |
30 DOMPointReadOnly* DOMPointReadOnly::fromPoint(const DOMPointInit& other) { | 34 DOMPointReadOnly* DOMPointReadOnly::fromPoint(const DOMPointInit& other) { |
31 return new DOMPointReadOnly(other.x(), other.y(), other.z(), other.w()); | 35 return new DOMPointReadOnly(other.x(), other.y(), other.z(), other.w()); |
32 } | 36 } |
33 | 37 |
38 DOMPoint* DOMPointReadOnly::matrixTransform(DOMMatrixInit& other, ExceptionState & exceptionState) { | |
zino
2017/01/03 16:16:55
nit: This line(and other lines) probably should be
Byoungkwon Ko
2017/01/03 16:35:39
Done.
| |
39 DOMMatrixReadOnly* matrix = DOMMatrixReadOnly::fromMatrix(other, exceptionStat e); | |
40 | |
41 if (matrix->is2D() && z() == 0 && w() == 1) { | |
42 double transformedX = x() * matrix->m11() + y() * matrix->m12() + matrix->m4 1(); | |
43 double transformedY = x() * matrix->m12() + y() * matrix->m22() + matrix->m4 2(); | |
44 return DOMPoint::create(transformedX, transformedY, 0, 1); | |
45 } | |
46 | |
47 double transformedX = x() * matrix->m11() + y() * matrix->m21() + z() * matrix ->m31() + | |
48 w() * matrix->m41(); | |
49 double transformedY = x() * matrix->m12() + y() * matrix->m22() + z() * matrix ->m32() + | |
50 w() * matrix->m42(); | |
51 double transformedZ = x() * matrix->m13() + y() * matrix->m23() + z() * matrix ->m33() + | |
52 w() * matrix->m43(); | |
53 double transformedW = x() * matrix->m14() + y() * matrix->m24() + z() * matrix ->m34() + | |
54 w() * matrix->m44(); | |
55 return DOMPoint::create(transformedX, transformedY, transformedZ, transformedW ); | |
56 } | |
57 | |
34 DOMPointReadOnly::DOMPointReadOnly(double x, double y, double z, double w) | 58 DOMPointReadOnly::DOMPointReadOnly(double x, double y, double z, double w) |
35 : m_x(x), m_y(y), m_z(z), m_w(w) {} | 59 : m_x(x), m_y(y), m_z(z), m_w(w) {} |
36 | 60 |
37 } // namespace blink | 61 } // namespace blink |
OLD | NEW |