|
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ |
|
2 /* This Source Code Form is subject to the terms of the Mozilla Public |
|
3 * License, v. 2.0. If a copy of the MPL was not distributed with this |
|
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
|
5 |
|
6 #ifndef MOZILLA_DOMPOINT_H_ |
|
7 #define MOZILLA_DOMPOINT_H_ |
|
8 |
|
9 #include "nsWrapperCache.h" |
|
10 #include "nsISupports.h" |
|
11 #include "nsCycleCollectionParticipant.h" |
|
12 #include "mozilla/Attributes.h" |
|
13 #include "mozilla/ErrorResult.h" |
|
14 #include "nsCOMPtr.h" |
|
15 #include "mozilla/dom/BindingDeclarations.h" |
|
16 |
|
17 namespace mozilla { |
|
18 namespace dom { |
|
19 |
|
20 class GlobalObject; |
|
21 class DOMPointInit; |
|
22 |
|
23 class DOMPointReadOnly : public nsWrapperCache |
|
24 { |
|
25 public: |
|
26 DOMPointReadOnly(nsISupports* aParent, double aX, double aY, |
|
27 double aZ, double aW) |
|
28 : mParent(aParent) |
|
29 , mX(aX) |
|
30 , mY(aY) |
|
31 , mZ(aZ) |
|
32 , mW(aW) |
|
33 { |
|
34 SetIsDOMBinding(); |
|
35 } |
|
36 |
|
37 double X() const { return mX; } |
|
38 double Y() const { return mY; } |
|
39 double Z() const { return mZ; } |
|
40 double W() const { return mW; } |
|
41 |
|
42 protected: |
|
43 nsCOMPtr<nsISupports> mParent; |
|
44 double mX, mY, mZ, mW; |
|
45 }; |
|
46 |
|
47 class DOMPoint MOZ_FINAL : public DOMPointReadOnly |
|
48 { |
|
49 public: |
|
50 DOMPoint(nsISupports* aParent, double aX = 0.0, double aY = 0.0, |
|
51 double aZ = 0.0, double aW = 1.0) |
|
52 : DOMPointReadOnly(aParent, aX, aY, aZ, aW) |
|
53 {} |
|
54 |
|
55 NS_INLINE_DECL_CYCLE_COLLECTING_NATIVE_REFCOUNTING(DOMPoint) |
|
56 NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_NATIVE_CLASS(DOMPoint) |
|
57 |
|
58 static already_AddRefed<DOMPoint> |
|
59 Constructor(const GlobalObject& aGlobal, const DOMPointInit& aParams, |
|
60 ErrorResult& aRV); |
|
61 static already_AddRefed<DOMPoint> |
|
62 Constructor(const GlobalObject& aGlobal, double aX, double aY, |
|
63 double aZ, double aW, ErrorResult& aRV); |
|
64 |
|
65 nsISupports* GetParentObject() const { return mParent; } |
|
66 virtual JSObject* WrapObject(JSContext* aCx) MOZ_OVERRIDE; |
|
67 |
|
68 void SetX(double aX) { mX = aX; } |
|
69 void SetY(double aY) { mY = aY; } |
|
70 void SetZ(double aZ) { mZ = aZ; } |
|
71 void SetW(double aW) { mW = aW; } |
|
72 }; |
|
73 |
|
74 } |
|
75 } |
|
76 |
|
77 #endif /*MOZILLA_DOMPOINT_H_*/ |