2014-02-27 02:51:12 -08:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
|
|
|
|
#ifndef mozilla_dom_DeviceMotionEvent_h_
|
|
|
|
#define mozilla_dom_DeviceMotionEvent_h_
|
|
|
|
|
|
|
|
#include "mozilla/Attributes.h"
|
|
|
|
#include "mozilla/dom/DeviceMotionEventBinding.h"
|
2014-03-04 16:37:43 -08:00
|
|
|
#include "mozilla/dom/Event.h"
|
2014-02-27 02:51:12 -08:00
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
namespace dom {
|
|
|
|
|
|
|
|
class DeviceRotationRate MOZ_FINAL : public nsWrapperCache
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
NS_INLINE_DECL_CYCLE_COLLECTING_NATIVE_REFCOUNTING(DeviceRotationRate)
|
|
|
|
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_NATIVE_CLASS(DeviceRotationRate)
|
|
|
|
|
|
|
|
DeviceRotationRate(DeviceMotionEvent* aOwner,
|
|
|
|
Nullable<double> aAlpha, Nullable<double> aBeta,
|
|
|
|
Nullable<double> aGamma);
|
|
|
|
|
|
|
|
DeviceMotionEvent* GetParentObject() const
|
|
|
|
{
|
|
|
|
return mOwner;
|
|
|
|
}
|
|
|
|
|
2014-04-08 15:27:18 -07:00
|
|
|
virtual JSObject* WrapObject(JSContext* aCx) MOZ_OVERRIDE
|
2014-02-27 02:51:12 -08:00
|
|
|
{
|
Bug 991742 part 6. Remove the "aScope" argument of binding Wrap() methods. r=bholley
This patch was mostly generated with this command:
find . -name "*.h" -o -name "*.cpp" | xargs sed -e 's/Binding::Wrap(aCx, aScope, this/Binding::Wrap(aCx, this/' -e 's/Binding_workers::Wrap(aCx, aScope, this/Binding_workers::Wrap(aCx, this/' -e 's/Binding::Wrap(cx, scope, this/Binding::Wrap(cx, this/' -i ""
plus a few manual fixes to dom/bindings/Codegen.py, js/xpconnect/src/event_impl_gen.py, and a few C++ files that were not caught in the search-and-replace above.
2014-04-08 15:27:17 -07:00
|
|
|
return DeviceRotationRateBinding::Wrap(aCx, this);
|
2014-02-27 02:51:12 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
Nullable<double> GetAlpha() const { return mAlpha; }
|
|
|
|
Nullable<double> GetBeta() const { return mBeta; }
|
|
|
|
Nullable<double> GetGamma() const { return mGamma; }
|
|
|
|
|
|
|
|
private:
|
|
|
|
~DeviceRotationRate();
|
|
|
|
|
|
|
|
protected:
|
|
|
|
nsRefPtr<DeviceMotionEvent> mOwner;
|
|
|
|
Nullable<double> mAlpha, mBeta, mGamma;
|
|
|
|
};
|
|
|
|
|
|
|
|
class DeviceAcceleration MOZ_FINAL : public nsWrapperCache
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
NS_INLINE_DECL_CYCLE_COLLECTING_NATIVE_REFCOUNTING(DeviceAcceleration)
|
|
|
|
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_NATIVE_CLASS(DeviceAcceleration)
|
|
|
|
|
|
|
|
DeviceAcceleration(DeviceMotionEvent* aOwner,
|
|
|
|
Nullable<double> aX, Nullable<double> aY,
|
|
|
|
Nullable<double> aZ);
|
|
|
|
|
|
|
|
DeviceMotionEvent* GetParentObject() const
|
|
|
|
{
|
|
|
|
return mOwner;
|
|
|
|
}
|
|
|
|
|
2014-04-08 15:27:18 -07:00
|
|
|
virtual JSObject* WrapObject(JSContext* aCx) MOZ_OVERRIDE
|
2014-02-27 02:51:12 -08:00
|
|
|
{
|
Bug 991742 part 6. Remove the "aScope" argument of binding Wrap() methods. r=bholley
This patch was mostly generated with this command:
find . -name "*.h" -o -name "*.cpp" | xargs sed -e 's/Binding::Wrap(aCx, aScope, this/Binding::Wrap(aCx, this/' -e 's/Binding_workers::Wrap(aCx, aScope, this/Binding_workers::Wrap(aCx, this/' -e 's/Binding::Wrap(cx, scope, this/Binding::Wrap(cx, this/' -i ""
plus a few manual fixes to dom/bindings/Codegen.py, js/xpconnect/src/event_impl_gen.py, and a few C++ files that were not caught in the search-and-replace above.
2014-04-08 15:27:17 -07:00
|
|
|
return DeviceAccelerationBinding::Wrap(aCx, this);
|
2014-02-27 02:51:12 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
Nullable<double> GetX() const { return mX; }
|
|
|
|
Nullable<double> GetY() const { return mY; }
|
|
|
|
Nullable<double> GetZ() const { return mZ; }
|
|
|
|
|
|
|
|
private:
|
|
|
|
~DeviceAcceleration();
|
|
|
|
|
|
|
|
protected:
|
|
|
|
nsRefPtr<DeviceMotionEvent> mOwner;
|
|
|
|
Nullable<double> mX, mY, mZ;
|
|
|
|
};
|
|
|
|
|
2014-03-04 16:37:43 -08:00
|
|
|
class DeviceMotionEvent MOZ_FINAL : public Event
|
2014-02-27 02:51:12 -08:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
|
|
|
|
DeviceMotionEvent(EventTarget* aOwner,
|
|
|
|
nsPresContext* aPresContext,
|
|
|
|
WidgetEvent* aEvent)
|
2014-03-04 16:37:43 -08:00
|
|
|
: Event(aOwner, aPresContext, aEvent)
|
2014-02-27 02:51:12 -08:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_DECL_ISUPPORTS_INHERITED
|
|
|
|
|
2014-03-04 16:37:43 -08:00
|
|
|
// Forward to Event
|
|
|
|
NS_FORWARD_TO_EVENT
|
2014-02-27 02:51:12 -08:00
|
|
|
|
2014-03-04 16:37:43 -08:00
|
|
|
NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(DeviceMotionEvent, Event)
|
2014-02-27 02:51:12 -08:00
|
|
|
|
2014-04-08 15:27:18 -07:00
|
|
|
virtual JSObject* WrapObject(JSContext* aCx) MOZ_OVERRIDE
|
2014-02-27 02:51:12 -08:00
|
|
|
{
|
Bug 991742 part 6. Remove the "aScope" argument of binding Wrap() methods. r=bholley
This patch was mostly generated with this command:
find . -name "*.h" -o -name "*.cpp" | xargs sed -e 's/Binding::Wrap(aCx, aScope, this/Binding::Wrap(aCx, this/' -e 's/Binding_workers::Wrap(aCx, aScope, this/Binding_workers::Wrap(aCx, this/' -e 's/Binding::Wrap(cx, scope, this/Binding::Wrap(cx, this/' -i ""
plus a few manual fixes to dom/bindings/Codegen.py, js/xpconnect/src/event_impl_gen.py, and a few C++ files that were not caught in the search-and-replace above.
2014-04-08 15:27:17 -07:00
|
|
|
return DeviceMotionEventBinding::Wrap(aCx, this);
|
2014-02-27 02:51:12 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
DeviceAcceleration* GetAcceleration() const
|
|
|
|
{
|
|
|
|
return mAcceleration;
|
|
|
|
}
|
|
|
|
|
|
|
|
DeviceAcceleration* GetAccelerationIncludingGravity() const
|
|
|
|
{
|
|
|
|
return mAccelerationIncludingGravity;
|
|
|
|
}
|
|
|
|
|
|
|
|
DeviceRotationRate* GetRotationRate() const
|
|
|
|
{
|
|
|
|
return mRotationRate;
|
|
|
|
}
|
|
|
|
|
|
|
|
Nullable<double> GetInterval() const
|
|
|
|
{
|
|
|
|
return mInterval;
|
|
|
|
}
|
|
|
|
|
|
|
|
void InitDeviceMotionEvent(
|
|
|
|
const nsAString& aType,
|
|
|
|
bool aCanBubble,
|
|
|
|
bool aCancelable,
|
|
|
|
const DeviceAccelerationInit& aAcceleration,
|
|
|
|
const DeviceAccelerationInit& aAccelerationIncludingGravity,
|
|
|
|
const DeviceRotationRateInit& aRotationRate,
|
|
|
|
Nullable<double> aInterval,
|
|
|
|
ErrorResult& aRv);
|
|
|
|
|
|
|
|
static already_AddRefed<DeviceMotionEvent>
|
|
|
|
Constructor(const GlobalObject& aGlobal,
|
|
|
|
const nsAString& aType,
|
|
|
|
const DeviceMotionEventInit& aEventInitDict,
|
|
|
|
ErrorResult& aRv);
|
|
|
|
|
|
|
|
protected:
|
|
|
|
nsRefPtr<DeviceAcceleration> mAcceleration;
|
|
|
|
nsRefPtr<DeviceAcceleration> mAccelerationIncludingGravity;
|
|
|
|
nsRefPtr<DeviceRotationRate> mRotationRate;
|
|
|
|
Nullable<double> mInterval;
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace dom
|
|
|
|
} // namespace mozilla
|
|
|
|
|
|
|
|
#endif // mozilla_dom_DeviceMotionEvent_h_
|