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

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

Issue 2771683005: Revert of Move geometry interface files to geometry directory. (Closed)
Patch Set: 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/geometry/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/geometry/DOMMatrixInit.h"
11 #include "core/geometry/DOMMatrixReadOnly.h"
12 #include "core/geometry/DOMPoint.h"
13 #include "core/geometry/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(ScriptState* scriptState) const {
25 V8ObjectBuilder result(scriptState);
26 result.addNumber("x", x());
27 result.addNumber("y", y());
28 result.addNumber("z", z());
29 result.addNumber("w", w());
30 return result.scriptValue();
31 }
32
33 DOMPointReadOnly* DOMPointReadOnly::fromPoint(const DOMPointInit& other) {
34 return new DOMPointReadOnly(other.x(), other.y(), other.z(), other.w());
35 }
36
37 DOMPoint* DOMPointReadOnly::matrixTransform(DOMMatrixInit& other,
38 ExceptionState& exceptionState) {
39 DOMMatrixReadOnly* matrix =
40 DOMMatrixReadOnly::fromMatrix(other, exceptionState);
41
42 if (matrix->is2D() && z() == 0 && w() == 1) {
43 double transformedX =
44 x() * matrix->m11() + y() * matrix->m12() + matrix->m41();
45 double transformedY =
46 x() * matrix->m12() + y() * matrix->m22() + matrix->m42();
47 return DOMPoint::create(transformedX, transformedY, 0, 1);
48 }
49
50 double transformedX = x() * matrix->m11() + y() * matrix->m21() +
51 z() * matrix->m31() + w() * matrix->m41();
52 double transformedY = x() * matrix->m12() + y() * matrix->m22() +
53 z() * matrix->m32() + w() * matrix->m42();
54 double transformedZ = x() * matrix->m13() + y() * matrix->m23() +
55 z() * matrix->m33() + w() * matrix->m43();
56 double transformedW = x() * matrix->m14() + y() * matrix->m24() +
57 z() * matrix->m34() + w() * matrix->m44();
58 return DOMPoint::create(transformedX, transformedY, transformedZ,
59 transformedW);
60 }
61
62 DOMPointReadOnly::DOMPointReadOnly(double x, double y, double z, double w)
63 : m_x(x), m_y(y), m_z(z), m_w(w) {}
64
65 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698