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) { | |
39 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.
| |
40 DOMMatrixReadOnly* matrix = DOMMatrixReadOnly::fromMatrix(other, exceptionStat e); | |
41 | |
42 if (matrix->is2D() && point->z() == 0 && point->w() == 1) { | |
43 double x = point->x() * matrix->m11() + point->y() * matrix->m12() + matrix- >m41(); | |
44 double y = point->x() * matrix->m12() + point->y() * matrix->m22() + matrix- >m42(); | |
45 return DOMPoint::create(x, y, 0, 1); | |
46 } | |
47 | |
48 double x = point->x() * matrix->m11() + point->y() * matrix->m21() + point->z( ) * matrix->m31() + | |
49 point->w() * matrix->m41(); | |
50 double y = point->x() * matrix->m12() + point->y() * matrix->m22() + point->z( ) * matrix->m32() + | |
51 point->w() * matrix->m42(); | |
52 double z = point->x() * matrix->m13() + point->y() * matrix->m23() + point->z( ) * matrix->m33() + | |
53 point->w() * matrix->m43(); | |
54 double w = point->x() * matrix->m14() + point->y() * matrix->m24() + point->z( ) * matrix->m34() + | |
55 point->w() * matrix->m44(); | |
56 return DOMPoint::create(x, y, z, w); | |
57 } | |
58 | |
34 DOMPointReadOnly::DOMPointReadOnly(double x, double y, double z, double w) | 59 DOMPointReadOnly::DOMPointReadOnly(double x, double y, double z, double w) |
35 : m_x(x), m_y(y), m_z(z), m_w(w) {} | 60 : m_x(x), m_y(y), m_z(z), m_w(w) {} |
36 | 61 |
37 } // namespace blink | 62 } // namespace blink |
OLD | NEW |