dom/events/DeviceMotionEvent.h

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

michael@0 1 /* This Source Code Form is subject to the terms of the Mozilla Public
michael@0 2 * License, v. 2.0. If a copy of the MPL was not distributed with this
michael@0 3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
michael@0 4
michael@0 5 #ifndef mozilla_dom_DeviceMotionEvent_h_
michael@0 6 #define mozilla_dom_DeviceMotionEvent_h_
michael@0 7
michael@0 8 #include "mozilla/Attributes.h"
michael@0 9 #include "mozilla/dom/DeviceMotionEventBinding.h"
michael@0 10 #include "mozilla/dom/Event.h"
michael@0 11
michael@0 12 namespace mozilla {
michael@0 13 namespace dom {
michael@0 14
michael@0 15 class DeviceRotationRate MOZ_FINAL : public nsWrapperCache
michael@0 16 {
michael@0 17 public:
michael@0 18 NS_INLINE_DECL_CYCLE_COLLECTING_NATIVE_REFCOUNTING(DeviceRotationRate)
michael@0 19 NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_NATIVE_CLASS(DeviceRotationRate)
michael@0 20
michael@0 21 DeviceRotationRate(DeviceMotionEvent* aOwner,
michael@0 22 Nullable<double> aAlpha, Nullable<double> aBeta,
michael@0 23 Nullable<double> aGamma);
michael@0 24
michael@0 25 DeviceMotionEvent* GetParentObject() const
michael@0 26 {
michael@0 27 return mOwner;
michael@0 28 }
michael@0 29
michael@0 30 virtual JSObject* WrapObject(JSContext* aCx) MOZ_OVERRIDE
michael@0 31 {
michael@0 32 return DeviceRotationRateBinding::Wrap(aCx, this);
michael@0 33 }
michael@0 34
michael@0 35 Nullable<double> GetAlpha() const { return mAlpha; }
michael@0 36 Nullable<double> GetBeta() const { return mBeta; }
michael@0 37 Nullable<double> GetGamma() const { return mGamma; }
michael@0 38
michael@0 39 private:
michael@0 40 ~DeviceRotationRate();
michael@0 41
michael@0 42 protected:
michael@0 43 nsRefPtr<DeviceMotionEvent> mOwner;
michael@0 44 Nullable<double> mAlpha, mBeta, mGamma;
michael@0 45 };
michael@0 46
michael@0 47 class DeviceAcceleration MOZ_FINAL : public nsWrapperCache
michael@0 48 {
michael@0 49 public:
michael@0 50 NS_INLINE_DECL_CYCLE_COLLECTING_NATIVE_REFCOUNTING(DeviceAcceleration)
michael@0 51 NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_NATIVE_CLASS(DeviceAcceleration)
michael@0 52
michael@0 53 DeviceAcceleration(DeviceMotionEvent* aOwner,
michael@0 54 Nullable<double> aX, Nullable<double> aY,
michael@0 55 Nullable<double> aZ);
michael@0 56
michael@0 57 DeviceMotionEvent* GetParentObject() const
michael@0 58 {
michael@0 59 return mOwner;
michael@0 60 }
michael@0 61
michael@0 62 virtual JSObject* WrapObject(JSContext* aCx) MOZ_OVERRIDE
michael@0 63 {
michael@0 64 return DeviceAccelerationBinding::Wrap(aCx, this);
michael@0 65 }
michael@0 66
michael@0 67 Nullable<double> GetX() const { return mX; }
michael@0 68 Nullable<double> GetY() const { return mY; }
michael@0 69 Nullable<double> GetZ() const { return mZ; }
michael@0 70
michael@0 71 private:
michael@0 72 ~DeviceAcceleration();
michael@0 73
michael@0 74 protected:
michael@0 75 nsRefPtr<DeviceMotionEvent> mOwner;
michael@0 76 Nullable<double> mX, mY, mZ;
michael@0 77 };
michael@0 78
michael@0 79 class DeviceMotionEvent MOZ_FINAL : public Event
michael@0 80 {
michael@0 81 public:
michael@0 82
michael@0 83 DeviceMotionEvent(EventTarget* aOwner,
michael@0 84 nsPresContext* aPresContext,
michael@0 85 WidgetEvent* aEvent)
michael@0 86 : Event(aOwner, aPresContext, aEvent)
michael@0 87 {
michael@0 88 }
michael@0 89
michael@0 90 NS_DECL_ISUPPORTS_INHERITED
michael@0 91
michael@0 92 // Forward to Event
michael@0 93 NS_FORWARD_TO_EVENT
michael@0 94
michael@0 95 NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(DeviceMotionEvent, Event)
michael@0 96
michael@0 97 virtual JSObject* WrapObject(JSContext* aCx) MOZ_OVERRIDE
michael@0 98 {
michael@0 99 return DeviceMotionEventBinding::Wrap(aCx, this);
michael@0 100 }
michael@0 101
michael@0 102 DeviceAcceleration* GetAcceleration() const
michael@0 103 {
michael@0 104 return mAcceleration;
michael@0 105 }
michael@0 106
michael@0 107 DeviceAcceleration* GetAccelerationIncludingGravity() const
michael@0 108 {
michael@0 109 return mAccelerationIncludingGravity;
michael@0 110 }
michael@0 111
michael@0 112 DeviceRotationRate* GetRotationRate() const
michael@0 113 {
michael@0 114 return mRotationRate;
michael@0 115 }
michael@0 116
michael@0 117 Nullable<double> GetInterval() const
michael@0 118 {
michael@0 119 return mInterval;
michael@0 120 }
michael@0 121
michael@0 122 void InitDeviceMotionEvent(
michael@0 123 const nsAString& aType,
michael@0 124 bool aCanBubble,
michael@0 125 bool aCancelable,
michael@0 126 const DeviceAccelerationInit& aAcceleration,
michael@0 127 const DeviceAccelerationInit& aAccelerationIncludingGravity,
michael@0 128 const DeviceRotationRateInit& aRotationRate,
michael@0 129 Nullable<double> aInterval,
michael@0 130 ErrorResult& aRv);
michael@0 131
michael@0 132 static already_AddRefed<DeviceMotionEvent>
michael@0 133 Constructor(const GlobalObject& aGlobal,
michael@0 134 const nsAString& aType,
michael@0 135 const DeviceMotionEventInit& aEventInitDict,
michael@0 136 ErrorResult& aRv);
michael@0 137
michael@0 138 protected:
michael@0 139 nsRefPtr<DeviceAcceleration> mAcceleration;
michael@0 140 nsRefPtr<DeviceAcceleration> mAccelerationIncludingGravity;
michael@0 141 nsRefPtr<DeviceRotationRate> mRotationRate;
michael@0 142 Nullable<double> mInterval;
michael@0 143 };
michael@0 144
michael@0 145 } // namespace dom
michael@0 146 } // namespace mozilla
michael@0 147
michael@0 148 #endif // mozilla_dom_DeviceMotionEvent_h_

mercurial