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