michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #ifndef mozilla_dom_DeviceMotionEvent_h_ michael@0: #define mozilla_dom_DeviceMotionEvent_h_ michael@0: michael@0: #include "mozilla/Attributes.h" michael@0: #include "mozilla/dom/DeviceMotionEventBinding.h" michael@0: #include "mozilla/dom/Event.h" michael@0: michael@0: namespace mozilla { michael@0: namespace dom { michael@0: michael@0: class DeviceRotationRate MOZ_FINAL : public nsWrapperCache michael@0: { michael@0: public: michael@0: NS_INLINE_DECL_CYCLE_COLLECTING_NATIVE_REFCOUNTING(DeviceRotationRate) michael@0: NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_NATIVE_CLASS(DeviceRotationRate) michael@0: michael@0: DeviceRotationRate(DeviceMotionEvent* aOwner, michael@0: Nullable aAlpha, Nullable aBeta, michael@0: Nullable aGamma); michael@0: michael@0: DeviceMotionEvent* GetParentObject() const michael@0: { michael@0: return mOwner; michael@0: } michael@0: michael@0: virtual JSObject* WrapObject(JSContext* aCx) MOZ_OVERRIDE michael@0: { michael@0: return DeviceRotationRateBinding::Wrap(aCx, this); michael@0: } michael@0: michael@0: Nullable GetAlpha() const { return mAlpha; } michael@0: Nullable GetBeta() const { return mBeta; } michael@0: Nullable GetGamma() const { return mGamma; } michael@0: michael@0: private: michael@0: ~DeviceRotationRate(); michael@0: michael@0: protected: michael@0: nsRefPtr mOwner; michael@0: Nullable mAlpha, mBeta, mGamma; michael@0: }; michael@0: michael@0: class DeviceAcceleration MOZ_FINAL : public nsWrapperCache michael@0: { michael@0: public: michael@0: NS_INLINE_DECL_CYCLE_COLLECTING_NATIVE_REFCOUNTING(DeviceAcceleration) michael@0: NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_NATIVE_CLASS(DeviceAcceleration) michael@0: michael@0: DeviceAcceleration(DeviceMotionEvent* aOwner, michael@0: Nullable aX, Nullable aY, michael@0: Nullable aZ); michael@0: michael@0: DeviceMotionEvent* GetParentObject() const michael@0: { michael@0: return mOwner; michael@0: } michael@0: michael@0: virtual JSObject* WrapObject(JSContext* aCx) MOZ_OVERRIDE michael@0: { michael@0: return DeviceAccelerationBinding::Wrap(aCx, this); michael@0: } michael@0: michael@0: Nullable GetX() const { return mX; } michael@0: Nullable GetY() const { return mY; } michael@0: Nullable GetZ() const { return mZ; } michael@0: michael@0: private: michael@0: ~DeviceAcceleration(); michael@0: michael@0: protected: michael@0: nsRefPtr mOwner; michael@0: Nullable mX, mY, mZ; michael@0: }; michael@0: michael@0: class DeviceMotionEvent MOZ_FINAL : public Event michael@0: { michael@0: public: michael@0: michael@0: DeviceMotionEvent(EventTarget* aOwner, michael@0: nsPresContext* aPresContext, michael@0: WidgetEvent* aEvent) michael@0: : Event(aOwner, aPresContext, aEvent) michael@0: { michael@0: } michael@0: michael@0: NS_DECL_ISUPPORTS_INHERITED michael@0: michael@0: // Forward to Event michael@0: NS_FORWARD_TO_EVENT michael@0: michael@0: NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(DeviceMotionEvent, Event) michael@0: michael@0: virtual JSObject* WrapObject(JSContext* aCx) MOZ_OVERRIDE michael@0: { michael@0: return DeviceMotionEventBinding::Wrap(aCx, this); michael@0: } michael@0: michael@0: DeviceAcceleration* GetAcceleration() const michael@0: { michael@0: return mAcceleration; michael@0: } michael@0: michael@0: DeviceAcceleration* GetAccelerationIncludingGravity() const michael@0: { michael@0: return mAccelerationIncludingGravity; michael@0: } michael@0: michael@0: DeviceRotationRate* GetRotationRate() const michael@0: { michael@0: return mRotationRate; michael@0: } michael@0: michael@0: Nullable GetInterval() const michael@0: { michael@0: return mInterval; michael@0: } michael@0: michael@0: void InitDeviceMotionEvent( michael@0: const nsAString& aType, michael@0: bool aCanBubble, michael@0: bool aCancelable, michael@0: const DeviceAccelerationInit& aAcceleration, michael@0: const DeviceAccelerationInit& aAccelerationIncludingGravity, michael@0: const DeviceRotationRateInit& aRotationRate, michael@0: Nullable aInterval, michael@0: ErrorResult& aRv); michael@0: michael@0: static already_AddRefed michael@0: Constructor(const GlobalObject& aGlobal, michael@0: const nsAString& aType, michael@0: const DeviceMotionEventInit& aEventInitDict, michael@0: ErrorResult& aRv); michael@0: michael@0: protected: michael@0: nsRefPtr mAcceleration; michael@0: nsRefPtr mAccelerationIncludingGravity; michael@0: nsRefPtr mRotationRate; michael@0: Nullable mInterval; michael@0: }; michael@0: michael@0: } // namespace dom michael@0: } // namespace mozilla michael@0: michael@0: #endif // mozilla_dom_DeviceMotionEvent_h_