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

Side by Side Diff: third_party/WebKit/Source/core/dom/DOMPointReadOnly.cpp

Issue 2741723005: Move geometry interface files to geometry directory. (Closed)
Patch Set: Rebase Created 3 years, 9 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 unified diff | Download patch
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "core/dom/DOMPointReadOnly.h"
6
7 #include "bindings/core/v8/ExceptionState.h"
8 #include "bindings/core/v8/ScriptValue.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"
13 #include "core/dom/DOMPointInit.h"
14
15 namespace blink {
16
17 DOMPointReadOnly* DOMPointReadOnly::create(double x,
18 double y,
19 double z,
20 double w) {
21 return new DOMPointReadOnly(x, y, z, w);
22 }
23
24 ScriptValue DOMPointReadOnly::toJSONForBinding(
25 ScriptState* scriptState) const {
26 V8ObjectBuilder result(scriptState);
27 result.addNumber("x", x());
28 result.addNumber("y", y());
29 result.addNumber("z", z());
30 result.addNumber("w", w());
31 return result.scriptValue();
32 }
33
34 DOMPointReadOnly* DOMPointReadOnly::fromPoint(const DOMPointInit& other) {
35 return new DOMPointReadOnly(other.x(), other.y(), other.z(), other.w());
36 }
37
38 DOMPoint* DOMPointReadOnly::matrixTransform(DOMMatrixInit& other,
39 ExceptionState& exceptionState) {
40 DOMMatrixReadOnly* matrix =
41 DOMMatrixReadOnly::fromMatrix(other, exceptionState);
42
43 if (matrix->is2D() && z() == 0 && w() == 1) {
44 double transformedX =
45 x() * matrix->m11() + y() * matrix->m12() + matrix->m41();
46 double transformedY =
47 x() * matrix->m12() + y() * matrix->m22() + matrix->m42();
48 return DOMPoint::create(transformedX, transformedY, 0, 1);
49 }
50
51 double transformedX = x() * matrix->m11() + y() * matrix->m21() +
52 z() * matrix->m31() + w() * matrix->m41();
53 double transformedY = x() * matrix->m12() + y() * matrix->m22() +
54 z() * matrix->m32() + w() * matrix->m42();
55 double transformedZ = x() * matrix->m13() + y() * matrix->m23() +
56 z() * matrix->m33() + w() * matrix->m43();
57 double transformedW = x() * matrix->m14() + y() * matrix->m24() +
58 z() * matrix->m34() + w() * matrix->m44();
59 return DOMPoint::create(transformedX, transformedY, transformedZ,
60 transformedW);
61 }
62
63 DOMPointReadOnly::DOMPointReadOnly(double x, double y, double z, double w)
64 : m_x(x), m_y(y), m_z(z), m_w(w) {}
65
66 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/dom/DOMPointReadOnly.h ('k') | third_party/WebKit/Source/core/dom/DOMPointReadOnly.idl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698