Bumping gaia.json for 2 gaia revision(s) a=gaia-bump
[gecko.git] / dom / events / DeviceMotionEvent.h
blobcfa65532c6ad29c3fc8e0a64e8d4819e114299df
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"
12 namespace mozilla {
13 namespace dom {
15 class DeviceRotationRate MOZ_FINAL : public nsWrapperCache
17 public:
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
27 return mOwner;
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; }
39 private:
40 ~DeviceRotationRate();
42 protected:
43 nsRefPtr<DeviceMotionEvent> mOwner;
44 Nullable<double> mAlpha, mBeta, mGamma;
47 class DeviceAcceleration MOZ_FINAL : public nsWrapperCache
49 public:
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,
55 Nullable<double> aZ);
57 DeviceMotionEvent* GetParentObject() const
59 return mOwner;
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; }
71 private:
72 ~DeviceAcceleration();
74 protected:
75 nsRefPtr<DeviceMotionEvent> mOwner;
76 Nullable<double> mX, mY, mZ;
79 class DeviceMotionEvent MOZ_FINAL : public Event
81 public:
83 DeviceMotionEvent(EventTarget* aOwner,
84 nsPresContext* aPresContext,
85 WidgetEvent* aEvent)
86 : Event(aOwner, aPresContext, aEvent)
90 NS_DECL_ISUPPORTS_INHERITED
92 // Forward to Event
93 NS_FORWARD_TO_EVENT
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
119 return mInterval;
122 void InitDeviceMotionEvent(
123 const nsAString& aType,
124 bool aCanBubble,
125 bool aCancelable,
126 const DeviceAccelerationInit& aAcceleration,
127 const DeviceAccelerationInit& aAccelerationIncludingGravity,
128 const DeviceRotationRateInit& aRotationRate,
129 Nullable<double> aInterval,
130 ErrorResult& aRv);
132 static already_AddRefed<DeviceMotionEvent>
133 Constructor(const GlobalObject& aGlobal,
134 const nsAString& aType,
135 const DeviceMotionEventInit& aEventInitDict,
136 ErrorResult& aRv);
138 protected:
139 ~DeviceMotionEvent() {}
141 nsRefPtr<DeviceAcceleration> mAcceleration;
142 nsRefPtr<DeviceAcceleration> mAccelerationIncludingGravity;
143 nsRefPtr<DeviceRotationRate> mRotationRate;
144 Nullable<double> mInterval;
147 } // namespace dom
148 } // namespace mozilla
150 #endif // mozilla_dom_DeviceMotionEvent_h_