1 /* This Source Code Form is subject to the terms of the Mozilla Public
2 * License, v. 2.0. If a copy of the MPL was not distributed with this
3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
5 #ifndef mozilla_dom_DeviceMotionEvent_h_
6 #define mozilla_dom_DeviceMotionEvent_h_
8 #include "mozilla/Attributes.h"
9 #include "mozilla/dom/DeviceMotionEventBinding.h"
10 #include "mozilla/dom/Event.h"
15 class DeviceRotationRate MOZ_FINAL
: public nsWrapperCache
18 NS_INLINE_DECL_CYCLE_COLLECTING_NATIVE_REFCOUNTING(DeviceRotationRate
)
19 NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_NATIVE_CLASS(DeviceRotationRate
)
21 DeviceRotationRate(DeviceMotionEvent
* aOwner
,
22 Nullable
<double> aAlpha
, Nullable
<double> aBeta
,
23 Nullable
<double> aGamma
);
25 DeviceMotionEvent
* GetParentObject() const
30 virtual JSObject
* WrapObject(JSContext
* aCx
) MOZ_OVERRIDE
32 return DeviceRotationRateBinding::Wrap(aCx
, this);
35 Nullable
<double> GetAlpha() const { return mAlpha
; }
36 Nullable
<double> GetBeta() const { return mBeta
; }
37 Nullable
<double> GetGamma() const { return mGamma
; }
40 ~DeviceRotationRate();
43 nsRefPtr
<DeviceMotionEvent
> mOwner
;
44 Nullable
<double> mAlpha
, mBeta
, mGamma
;
47 class DeviceAcceleration MOZ_FINAL
: public nsWrapperCache
50 NS_INLINE_DECL_CYCLE_COLLECTING_NATIVE_REFCOUNTING(DeviceAcceleration
)
51 NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_NATIVE_CLASS(DeviceAcceleration
)
53 DeviceAcceleration(DeviceMotionEvent
* aOwner
,
54 Nullable
<double> aX
, Nullable
<double> aY
,
57 DeviceMotionEvent
* GetParentObject() const
62 virtual JSObject
* WrapObject(JSContext
* aCx
) MOZ_OVERRIDE
64 return DeviceAccelerationBinding::Wrap(aCx
, this);
67 Nullable
<double> GetX() const { return mX
; }
68 Nullable
<double> GetY() const { return mY
; }
69 Nullable
<double> GetZ() const { return mZ
; }
72 ~DeviceAcceleration();
75 nsRefPtr
<DeviceMotionEvent
> mOwner
;
76 Nullable
<double> mX
, mY
, mZ
;
79 class DeviceMotionEvent MOZ_FINAL
: public Event
83 DeviceMotionEvent(EventTarget
* aOwner
,
84 nsPresContext
* aPresContext
,
86 : Event(aOwner
, aPresContext
, aEvent
)
90 NS_DECL_ISUPPORTS_INHERITED
95 NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(DeviceMotionEvent
, Event
)
97 virtual JSObject
* WrapObject(JSContext
* aCx
) MOZ_OVERRIDE
99 return DeviceMotionEventBinding::Wrap(aCx
, this);
102 DeviceAcceleration
* GetAcceleration() const
104 return mAcceleration
;
107 DeviceAcceleration
* GetAccelerationIncludingGravity() const
109 return mAccelerationIncludingGravity
;
112 DeviceRotationRate
* GetRotationRate() const
114 return mRotationRate
;
117 Nullable
<double> GetInterval() const
122 void InitDeviceMotionEvent(
123 const nsAString
& aType
,
126 const DeviceAccelerationInit
& aAcceleration
,
127 const DeviceAccelerationInit
& aAccelerationIncludingGravity
,
128 const DeviceRotationRateInit
& aRotationRate
,
129 Nullable
<double> aInterval
,
132 static already_AddRefed
<DeviceMotionEvent
>
133 Constructor(const GlobalObject
& aGlobal
,
134 const nsAString
& aType
,
135 const DeviceMotionEventInit
& aEventInitDict
,
139 ~DeviceMotionEvent() {}
141 nsRefPtr
<DeviceAcceleration
> mAcceleration
;
142 nsRefPtr
<DeviceAcceleration
> mAccelerationIncludingGravity
;
143 nsRefPtr
<DeviceRotationRate
> mRotationRate
;
144 Nullable
<double> mInterval
;
148 } // namespace mozilla
150 #endif // mozilla_dom_DeviceMotionEvent_h_