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/. */
6 #ifndef MOZILLA_DOMPOINT_H_
7 #define MOZILLA_DOMPOINT_H_
9 #include "nsWrapperCache.h"
10 #include "nsISupports.h"
11 #include "nsCycleCollectionParticipant.h"
12 #include "mozilla/Attributes.h"
13 #include "mozilla/ErrorResult.h"
15 #include "mozilla/dom/BindingDeclarations.h"
23 class DOMPointReadOnly
: public nsWrapperCache
26 DOMPointReadOnly(nsISupports
* aParent
, double aX
, double aY
,
36 double X() const { return mX
; }
37 double Y() const { return mY
; }
38 double Z() const { return mZ
; }
39 double W() const { return mW
; }
42 nsCOMPtr
<nsISupports
> mParent
;
43 double mX
, mY
, mZ
, mW
;
46 class DOMPoint MOZ_FINAL
: public DOMPointReadOnly
51 explicit DOMPoint(nsISupports
* aParent
, double aX
= 0.0, double aY
= 0.0,
52 double aZ
= 0.0, double aW
= 1.0)
53 : DOMPointReadOnly(aParent
, aX
, aY
, aZ
, aW
)
56 NS_INLINE_DECL_CYCLE_COLLECTING_NATIVE_REFCOUNTING(DOMPoint
)
57 NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_NATIVE_CLASS(DOMPoint
)
59 static already_AddRefed
<DOMPoint
>
60 Constructor(const GlobalObject
& aGlobal
, const DOMPointInit
& aParams
,
62 static already_AddRefed
<DOMPoint
>
63 Constructor(const GlobalObject
& aGlobal
, double aX
, double aY
,
64 double aZ
, double aW
, ErrorResult
& aRV
);
66 nsISupports
* GetParentObject() const { return mParent
; }
67 virtual JSObject
* WrapObject(JSContext
* aCx
) MOZ_OVERRIDE
;
69 void SetX(double aX
) { mX
= aX
; }
70 void SetY(double aY
) { mY
= aY
; }
71 void SetZ(double aZ
) { mZ
= aZ
; }
72 void SetW(double aW
) { mW
= aW
; }
78 #endif /*MOZILLA_DOMPOINT_H_*/