1 | /* |
2 | * Copyright (C) 2014 Adobe Systems Incorporated. All rights reserved. |
3 | * Copyright (C) 2016 Apple Inc. All Rights Reserved. |
4 | * |
5 | * Redistribution and use in source and binary forms, with or without |
6 | * modification, are permitted provided that the following conditions |
7 | * are met: |
8 | * |
9 | * 1. Redistributions of source code must retain the above |
10 | * copyright notice, this list of conditions and the following |
11 | * disclaimer. |
12 | * 2. Redistributions in binary form must reproduce the above |
13 | * copyright notice, this list of conditions and the following |
14 | * disclaimer in the documentation and/or other materials |
15 | * provided with the distribution. |
16 | * |
17 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
18 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
19 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS |
20 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE |
21 | * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, |
22 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
23 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR |
24 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
25 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, |
26 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
27 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED |
28 | * OF THE POSSIBILITY OF SUCH DAMAGE. |
29 | */ |
30 | |
31 | #pragma once |
32 | |
33 | #include "DOMPointInit.h" |
34 | #include "ExceptionOr.h" |
35 | #include "ScriptWrappable.h" |
36 | #include <wtf/RefCounted.h> |
37 | |
38 | namespace WebCore { |
39 | |
40 | struct DOMMatrixInit; |
41 | class DOMPoint; |
42 | |
43 | class DOMPointReadOnly : public ScriptWrappable, public RefCounted<DOMPointReadOnly> { |
44 | WTF_MAKE_ISO_ALLOCATED(DOMPointReadOnly); |
45 | public: |
46 | static Ref<DOMPointReadOnly> create(double x, double y, double z, double w) { return adoptRef(*new DOMPointReadOnly(x, y, z, w)); } |
47 | static Ref<DOMPointReadOnly> create(const DOMPointInit& init) { return create(init.x, init.y, init.z, init.w); } |
48 | static Ref<DOMPointReadOnly> fromPoint(const DOMPointInit& init) { return create(init.x, init.y, init.z, init.w); } |
49 | |
50 | double x() const { return m_x; } |
51 | double y() const { return m_y; } |
52 | double z() const { return m_z; } |
53 | double w() const { return m_w; } |
54 | |
55 | ExceptionOr<Ref<DOMPoint>> matrixTransform(DOMMatrixInit&&) const; |
56 | |
57 | protected: |
58 | DOMPointReadOnly(double x, double y, double z, double w) |
59 | : m_x(x) |
60 | , m_y(y) |
61 | , m_z(z) |
62 | , m_w(w) |
63 | { |
64 | } |
65 | |
66 | // Any of these can be NaN or Inf. |
67 | double m_x; |
68 | double m_y; |
69 | double m_z; |
70 | double m_w; |
71 | }; |
72 | |
73 | } // namespace WebCore |
74 | |
75 | |