зеркало из https://github.com/mozilla/gecko-dev.git
Bug 975688 part.8 Rename nsDOMDeviceMotionEvent, nsDOMDeviceAcceleration and nsDOMDeviceRotationRate to mozilla::dom::DeviceMotionEvent, DeviceAcceleration and DeviceRotationRate r=smaug
--HG-- rename : dom/events/nsDOMDeviceMotionEvent.cpp => dom/events/DeviceMotionEvent.cpp rename : dom/events/nsDOMDeviceMotionEvent.h => dom/events/DeviceMotionEvent.h
This commit is contained in:
Родитель
4a5d85e72b
Коммит
e110ac2771
|
@ -313,17 +313,11 @@ DOMInterfaces = {
|
|||
},
|
||||
|
||||
'DeviceAcceleration': {
|
||||
'nativeType': 'nsDOMDeviceAcceleration',
|
||||
'headerFile': 'nsDOMDeviceMotionEvent.h',
|
||||
},
|
||||
|
||||
'DeviceMotionEvent': {
|
||||
'nativeType': 'nsDOMDeviceMotionEvent',
|
||||
'headerFile': 'mozilla/dom/DeviceMotionEvent.h',
|
||||
},
|
||||
|
||||
'DeviceRotationRate': {
|
||||
'nativeType': 'nsDOMDeviceRotationRate',
|
||||
'headerFile': 'nsDOMDeviceMotionEvent.h',
|
||||
'headerFile': 'mozilla/dom/DeviceMotionEvent.h',
|
||||
},
|
||||
|
||||
'DeviceStorage': {
|
||||
|
|
|
@ -0,0 +1,160 @@
|
|||
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
||||
/* 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/. */
|
||||
|
||||
#include "mozilla/dom/DeviceMotionEvent.h"
|
||||
#include "nsContentUtils.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
||||
/******************************************************************************
|
||||
* DeviceMotionEvent
|
||||
*****************************************************************************/
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTION_INHERITED_3(DeviceMotionEvent, nsDOMEvent,
|
||||
mAcceleration,
|
||||
mAccelerationIncludingGravity,
|
||||
mRotationRate)
|
||||
|
||||
NS_IMPL_ADDREF_INHERITED(DeviceMotionEvent, nsDOMEvent)
|
||||
NS_IMPL_RELEASE_INHERITED(DeviceMotionEvent, nsDOMEvent)
|
||||
|
||||
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED(DeviceMotionEvent)
|
||||
NS_INTERFACE_MAP_END_INHERITING(nsDOMEvent)
|
||||
|
||||
void
|
||||
DeviceMotionEvent::InitDeviceMotionEvent(
|
||||
const nsAString& aType,
|
||||
bool aCanBubble,
|
||||
bool aCancelable,
|
||||
const DeviceAccelerationInit& aAcceleration,
|
||||
const DeviceAccelerationInit& aAccelIncludingGravity,
|
||||
const DeviceRotationRateInit& aRotationRate,
|
||||
Nullable<double> aInterval,
|
||||
ErrorResult& aRv)
|
||||
{
|
||||
aRv = nsDOMEvent::InitEvent(aType, aCanBubble, aCancelable);
|
||||
if (aRv.Failed()) {
|
||||
return;
|
||||
}
|
||||
|
||||
mAcceleration = new DeviceAcceleration(this, aAcceleration.mX,
|
||||
aAcceleration.mY,
|
||||
aAcceleration.mZ);
|
||||
|
||||
mAccelerationIncludingGravity =
|
||||
new DeviceAcceleration(this, aAccelIncludingGravity.mX,
|
||||
aAccelIncludingGravity.mY,
|
||||
aAccelIncludingGravity.mZ);
|
||||
|
||||
mRotationRate = new DeviceRotationRate(this, aRotationRate.mAlpha,
|
||||
aRotationRate.mBeta,
|
||||
aRotationRate.mGamma);
|
||||
mInterval = aInterval;
|
||||
}
|
||||
|
||||
already_AddRefed<DeviceMotionEvent>
|
||||
DeviceMotionEvent::Constructor(const GlobalObject& aGlobal,
|
||||
const nsAString& aType,
|
||||
const DeviceMotionEventInit& aEventInitDict,
|
||||
ErrorResult& aRv)
|
||||
{
|
||||
nsCOMPtr<EventTarget> t = do_QueryInterface(aGlobal.GetAsSupports());
|
||||
nsRefPtr<DeviceMotionEvent> e = new DeviceMotionEvent(t, nullptr, nullptr);
|
||||
aRv = e->InitEvent(aType, aEventInitDict.mBubbles, aEventInitDict.mCancelable);
|
||||
if (aRv.Failed()) {
|
||||
return nullptr;
|
||||
}
|
||||
bool trusted = e->Init(t);
|
||||
|
||||
e->mAcceleration = new DeviceAcceleration(e,
|
||||
aEventInitDict.mAcceleration.mX,
|
||||
aEventInitDict.mAcceleration.mY,
|
||||
aEventInitDict.mAcceleration.mZ);
|
||||
|
||||
e->mAccelerationIncludingGravity = new DeviceAcceleration(e,
|
||||
aEventInitDict.mAccelerationIncludingGravity.mX,
|
||||
aEventInitDict.mAccelerationIncludingGravity.mY,
|
||||
aEventInitDict.mAccelerationIncludingGravity.mZ);
|
||||
|
||||
e->mRotationRate = new DeviceRotationRate(e,
|
||||
aEventInitDict.mRotationRate.mAlpha,
|
||||
aEventInitDict.mRotationRate.mBeta,
|
||||
aEventInitDict.mRotationRate.mGamma);
|
||||
|
||||
e->mInterval = aEventInitDict.mInterval;
|
||||
e->SetTrusted(trusted);
|
||||
|
||||
return e.forget();
|
||||
}
|
||||
|
||||
/******************************************************************************
|
||||
* DeviceAcceleration
|
||||
*****************************************************************************/
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE_1(DeviceAcceleration, mOwner)
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTION_ROOT_NATIVE(DeviceAcceleration, AddRef)
|
||||
NS_IMPL_CYCLE_COLLECTION_UNROOT_NATIVE(DeviceAcceleration, Release)
|
||||
|
||||
DeviceAcceleration::DeviceAcceleration(DeviceMotionEvent* aOwner,
|
||||
Nullable<double> aX,
|
||||
Nullable<double> aY,
|
||||
Nullable<double> aZ)
|
||||
: mOwner(aOwner)
|
||||
, mX(aX)
|
||||
, mY(aY)
|
||||
, mZ(aZ)
|
||||
{
|
||||
SetIsDOMBinding();
|
||||
}
|
||||
|
||||
DeviceAcceleration::~DeviceAcceleration()
|
||||
{
|
||||
}
|
||||
|
||||
/******************************************************************************
|
||||
* DeviceRotationRate
|
||||
*****************************************************************************/
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE_1(DeviceRotationRate, mOwner)
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTION_ROOT_NATIVE(DeviceRotationRate, AddRef)
|
||||
NS_IMPL_CYCLE_COLLECTION_UNROOT_NATIVE(DeviceRotationRate, Release)
|
||||
|
||||
DeviceRotationRate::DeviceRotationRate(DeviceMotionEvent* aOwner,
|
||||
Nullable<double> aAlpha,
|
||||
Nullable<double> aBeta,
|
||||
Nullable<double> aGamma)
|
||||
: mOwner(aOwner)
|
||||
, mAlpha(aAlpha)
|
||||
, mBeta(aBeta)
|
||||
, mGamma(aGamma)
|
||||
{
|
||||
SetIsDOMBinding();
|
||||
}
|
||||
|
||||
DeviceRotationRate::~DeviceRotationRate()
|
||||
{
|
||||
}
|
||||
|
||||
} // namespace dom
|
||||
} // namespace mozilla
|
||||
|
||||
using namespace mozilla;
|
||||
using namespace mozilla::dom;
|
||||
|
||||
nsresult
|
||||
NS_NewDOMDeviceMotionEvent(nsIDOMEvent** aInstancePtrResult,
|
||||
EventTarget* aOwner,
|
||||
nsPresContext* aPresContext,
|
||||
WidgetEvent* aEvent)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aInstancePtrResult);
|
||||
|
||||
DeviceMotionEvent* it = new DeviceMotionEvent(aOwner, aPresContext, aEvent);
|
||||
return CallQueryInterface(it, aInstancePtrResult);
|
||||
}
|
|
@ -0,0 +1,161 @@
|
|||
/* 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 "nsDOMEvent.h"
|
||||
#include "mozilla/Attributes.h"
|
||||
#include "mozilla/dom/DeviceMotionEventBinding.h"
|
||||
|
||||
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);
|
||||
DeviceRotationRate(double aAlpha, double aBeta, double aGamma)
|
||||
{
|
||||
DeviceRotationRate(nullptr, Nullable<double>(aAlpha),
|
||||
Nullable<double>(aBeta), Nullable<double>(aGamma));
|
||||
}
|
||||
|
||||
DeviceMotionEvent* GetParentObject() const
|
||||
{
|
||||
return mOwner;
|
||||
}
|
||||
|
||||
virtual JSObject* WrapObject(JSContext* aCx,
|
||||
JS::Handle<JSObject*> aScope) MOZ_OVERRIDE
|
||||
{
|
||||
return DeviceRotationRateBinding::Wrap(aCx, aScope, this);
|
||||
}
|
||||
|
||||
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);
|
||||
DeviceAcceleration(double aX, double aY, double aZ)
|
||||
{
|
||||
DeviceAcceleration(nullptr, Nullable<double>(aX),
|
||||
Nullable<double>(aY), Nullable<double>(aZ));
|
||||
}
|
||||
|
||||
DeviceMotionEvent* GetParentObject() const
|
||||
{
|
||||
return mOwner;
|
||||
}
|
||||
|
||||
virtual JSObject* WrapObject(JSContext* aCx,
|
||||
JS::Handle<JSObject*> aScope) MOZ_OVERRIDE
|
||||
{
|
||||
return DeviceAccelerationBinding::Wrap(aCx, aScope, this);
|
||||
}
|
||||
|
||||
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;
|
||||
};
|
||||
|
||||
class DeviceMotionEvent MOZ_FINAL : public nsDOMEvent
|
||||
{
|
||||
public:
|
||||
|
||||
DeviceMotionEvent(EventTarget* aOwner,
|
||||
nsPresContext* aPresContext,
|
||||
WidgetEvent* aEvent)
|
||||
: nsDOMEvent(aOwner, aPresContext, aEvent)
|
||||
{
|
||||
}
|
||||
|
||||
NS_DECL_ISUPPORTS_INHERITED
|
||||
|
||||
// Forward to nsDOMEvent
|
||||
NS_FORWARD_TO_NSDOMEVENT
|
||||
|
||||
NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(DeviceMotionEvent, nsDOMEvent)
|
||||
|
||||
virtual JSObject* WrapObject(JSContext* aCx,
|
||||
JS::Handle<JSObject*> aScope) MOZ_OVERRIDE
|
||||
{
|
||||
return DeviceMotionEventBinding::Wrap(aCx, aScope, this);
|
||||
}
|
||||
|
||||
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_
|
|
@ -43,6 +43,7 @@ EXPORTS.mozilla.dom += [
|
|||
'CompositionEvent.h',
|
||||
'DataContainerEvent.h',
|
||||
'DataTransfer.h',
|
||||
'DeviceMotionEvent.h',
|
||||
'EventTarget.h',
|
||||
'PointerEvent.h',
|
||||
'Touch.h',
|
||||
|
@ -60,10 +61,10 @@ UNIFIED_SOURCES += [
|
|||
'CompositionEvent.cpp',
|
||||
'DataContainerEvent.cpp',
|
||||
'DataTransfer.cpp',
|
||||
'DeviceMotionEvent.cpp',
|
||||
'EventTarget.cpp',
|
||||
'nsAsyncDOMEvent.cpp',
|
||||
'nsContentEventHandler.cpp',
|
||||
'nsDOMDeviceMotionEvent.cpp',
|
||||
'nsDOMDragEvent.cpp',
|
||||
'nsDOMEventTargetHelper.cpp',
|
||||
'nsDOMFocusEvent.cpp',
|
||||
|
|
|
@ -1,141 +0,0 @@
|
|||
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
||||
/* 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/. */
|
||||
|
||||
#include "nsDOMDeviceMotionEvent.h"
|
||||
#include "nsContentUtils.h"
|
||||
|
||||
using namespace mozilla;
|
||||
using namespace mozilla::dom;
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTION_INHERITED_3(nsDOMDeviceMotionEvent, nsDOMEvent,
|
||||
mAcceleration,
|
||||
mAccelerationIncludingGravity,
|
||||
mRotationRate)
|
||||
|
||||
NS_IMPL_ADDREF_INHERITED(nsDOMDeviceMotionEvent, nsDOMEvent)
|
||||
NS_IMPL_RELEASE_INHERITED(nsDOMDeviceMotionEvent, nsDOMEvent)
|
||||
|
||||
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED(nsDOMDeviceMotionEvent)
|
||||
NS_INTERFACE_MAP_END_INHERITING(nsDOMEvent)
|
||||
|
||||
void
|
||||
nsDOMDeviceMotionEvent::InitDeviceMotionEvent(const nsAString& aType,
|
||||
bool aCanBubble,
|
||||
bool aCancelable,
|
||||
const DeviceAccelerationInit& aAcceleration,
|
||||
const DeviceAccelerationInit& aAccelerationIncludingGravity,
|
||||
const DeviceRotationRateInit& aRotationRate,
|
||||
Nullable<double> aInterval,
|
||||
ErrorResult& aRv)
|
||||
{
|
||||
aRv = nsDOMEvent::InitEvent(aType, aCanBubble, aCancelable);
|
||||
if (aRv.Failed()) {
|
||||
return;
|
||||
}
|
||||
|
||||
mAcceleration = new nsDOMDeviceAcceleration(this, aAcceleration.mX,
|
||||
aAcceleration.mY,
|
||||
aAcceleration.mZ);
|
||||
|
||||
mAccelerationIncludingGravity =
|
||||
new nsDOMDeviceAcceleration(this, aAccelerationIncludingGravity.mX,
|
||||
aAccelerationIncludingGravity.mY,
|
||||
aAccelerationIncludingGravity.mZ);
|
||||
|
||||
mRotationRate = new nsDOMDeviceRotationRate(this, aRotationRate.mAlpha,
|
||||
aRotationRate.mBeta,
|
||||
aRotationRate.mGamma);
|
||||
mInterval = aInterval;
|
||||
}
|
||||
|
||||
already_AddRefed<nsDOMDeviceMotionEvent>
|
||||
nsDOMDeviceMotionEvent::Constructor(const GlobalObject& aGlobal,
|
||||
const nsAString& aType,
|
||||
const DeviceMotionEventInit& aEventInitDict,
|
||||
ErrorResult& aRv)
|
||||
{
|
||||
nsCOMPtr<mozilla::dom::EventTarget> t =
|
||||
do_QueryInterface(aGlobal.GetAsSupports());
|
||||
nsRefPtr<nsDOMDeviceMotionEvent> e =
|
||||
new nsDOMDeviceMotionEvent(t, nullptr, nullptr);
|
||||
aRv = e->InitEvent(aType, aEventInitDict.mBubbles, aEventInitDict.mCancelable);
|
||||
if (aRv.Failed()) {
|
||||
return nullptr;
|
||||
}
|
||||
bool trusted = e->Init(t);
|
||||
|
||||
e->mAcceleration = new nsDOMDeviceAcceleration(e,
|
||||
aEventInitDict.mAcceleration.mX,
|
||||
aEventInitDict.mAcceleration.mY,
|
||||
aEventInitDict.mAcceleration.mZ);
|
||||
|
||||
e->mAccelerationIncludingGravity = new nsDOMDeviceAcceleration(e,
|
||||
aEventInitDict.mAccelerationIncludingGravity.mX,
|
||||
aEventInitDict.mAccelerationIncludingGravity.mY,
|
||||
aEventInitDict.mAccelerationIncludingGravity.mZ);
|
||||
|
||||
e->mRotationRate = new nsDOMDeviceRotationRate(e,
|
||||
aEventInitDict.mRotationRate.mAlpha,
|
||||
aEventInitDict.mRotationRate.mBeta,
|
||||
aEventInitDict.mRotationRate.mGamma);
|
||||
|
||||
e->mInterval = aEventInitDict.mInterval;
|
||||
e->SetTrusted(trusted);
|
||||
|
||||
return e.forget();
|
||||
}
|
||||
|
||||
|
||||
nsresult
|
||||
NS_NewDOMDeviceMotionEvent(nsIDOMEvent** aInstancePtrResult,
|
||||
mozilla::dom::EventTarget* aOwner,
|
||||
nsPresContext* aPresContext,
|
||||
WidgetEvent* aEvent)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aInstancePtrResult);
|
||||
|
||||
nsDOMDeviceMotionEvent* it =
|
||||
new nsDOMDeviceMotionEvent(aOwner, aPresContext, aEvent);
|
||||
return CallQueryInterface(it, aInstancePtrResult);
|
||||
}
|
||||
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE_1(nsDOMDeviceAcceleration, mOwner)
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTION_ROOT_NATIVE(nsDOMDeviceAcceleration, AddRef)
|
||||
NS_IMPL_CYCLE_COLLECTION_UNROOT_NATIVE(nsDOMDeviceAcceleration, Release)
|
||||
|
||||
nsDOMDeviceAcceleration::nsDOMDeviceAcceleration(nsDOMDeviceMotionEvent* aOwner,
|
||||
Nullable<double> aX,
|
||||
Nullable<double> aY,
|
||||
Nullable<double> aZ)
|
||||
: mOwner(aOwner), mX(aX), mY(aY), mZ(aZ)
|
||||
{
|
||||
SetIsDOMBinding();
|
||||
}
|
||||
|
||||
nsDOMDeviceAcceleration::~nsDOMDeviceAcceleration()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE_1(nsDOMDeviceRotationRate, mOwner)
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTION_ROOT_NATIVE(nsDOMDeviceRotationRate, AddRef)
|
||||
NS_IMPL_CYCLE_COLLECTION_UNROOT_NATIVE(nsDOMDeviceRotationRate, Release)
|
||||
|
||||
nsDOMDeviceRotationRate::nsDOMDeviceRotationRate(nsDOMDeviceMotionEvent* aOwner,
|
||||
Nullable<double> aAlpha,
|
||||
Nullable<double> aBeta,
|
||||
Nullable<double> aGamma)
|
||||
: mOwner(aOwner), mAlpha(aAlpha), mBeta(aBeta), mGamma(aGamma)
|
||||
{
|
||||
SetIsDOMBinding();
|
||||
}
|
||||
|
||||
nsDOMDeviceRotationRate::~nsDOMDeviceRotationRate()
|
||||
{
|
||||
}
|
|
@ -1,156 +0,0 @@
|
|||
/* 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 nsDOMDeviceMotionEvent_h__
|
||||
#define nsDOMDeviceMotionEvent_h__
|
||||
|
||||
#include "nsDOMEvent.h"
|
||||
#include "mozilla/Attributes.h"
|
||||
#include "mozilla/dom/DeviceMotionEventBinding.h"
|
||||
|
||||
class nsDOMDeviceRotationRate MOZ_FINAL : public nsWrapperCache
|
||||
{
|
||||
public:
|
||||
NS_INLINE_DECL_CYCLE_COLLECTING_NATIVE_REFCOUNTING(nsDOMDeviceRotationRate)
|
||||
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_NATIVE_CLASS(nsDOMDeviceRotationRate)
|
||||
|
||||
nsDOMDeviceRotationRate(nsDOMDeviceMotionEvent* aOwner,
|
||||
Nullable<double> aAlpha, Nullable<double> aBeta,
|
||||
Nullable<double> aGamma);
|
||||
nsDOMDeviceRotationRate(double aAlpha, double aBeta, double aGamma)
|
||||
{
|
||||
nsDOMDeviceRotationRate(nullptr, Nullable<double>(aAlpha),
|
||||
Nullable<double>(aBeta), Nullable<double>(aGamma));
|
||||
}
|
||||
|
||||
nsDOMDeviceMotionEvent* GetParentObject() const
|
||||
{
|
||||
return mOwner;
|
||||
}
|
||||
|
||||
virtual JSObject* WrapObject(JSContext* aCx,
|
||||
JS::Handle<JSObject*> aScope) MOZ_OVERRIDE
|
||||
{
|
||||
return mozilla::dom::DeviceRotationRateBinding::Wrap(aCx, aScope, this);
|
||||
}
|
||||
|
||||
Nullable<double> GetAlpha() const { return mAlpha; }
|
||||
Nullable<double> GetBeta() const { return mBeta; }
|
||||
Nullable<double> GetGamma() const { return mGamma; }
|
||||
|
||||
private:
|
||||
~nsDOMDeviceRotationRate();
|
||||
|
||||
protected:
|
||||
nsRefPtr<nsDOMDeviceMotionEvent> mOwner;
|
||||
Nullable<double> mAlpha, mBeta, mGamma;
|
||||
};
|
||||
|
||||
class nsDOMDeviceAcceleration MOZ_FINAL : public nsWrapperCache
|
||||
{
|
||||
public:
|
||||
NS_INLINE_DECL_CYCLE_COLLECTING_NATIVE_REFCOUNTING(nsDOMDeviceAcceleration)
|
||||
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_NATIVE_CLASS(nsDOMDeviceAcceleration)
|
||||
|
||||
nsDOMDeviceAcceleration(nsDOMDeviceMotionEvent* aOwner,
|
||||
Nullable<double> aX, Nullable<double> aY,
|
||||
Nullable<double> aZ);
|
||||
nsDOMDeviceAcceleration(double aX, double aY, double aZ)
|
||||
{
|
||||
nsDOMDeviceAcceleration(nullptr, Nullable<double>(aX),
|
||||
Nullable<double>(aY), Nullable<double>(aZ));
|
||||
}
|
||||
|
||||
nsDOMDeviceMotionEvent* GetParentObject() const
|
||||
{
|
||||
return mOwner;
|
||||
}
|
||||
|
||||
virtual JSObject* WrapObject(JSContext* aCx,
|
||||
JS::Handle<JSObject*> aScope) MOZ_OVERRIDE
|
||||
{
|
||||
return mozilla::dom::DeviceAccelerationBinding::Wrap(aCx, aScope, this);
|
||||
}
|
||||
|
||||
Nullable<double> GetX() const { return mX; }
|
||||
Nullable<double> GetY() const { return mY; }
|
||||
Nullable<double> GetZ() const { return mZ; }
|
||||
|
||||
private:
|
||||
~nsDOMDeviceAcceleration();
|
||||
|
||||
protected:
|
||||
nsRefPtr<nsDOMDeviceMotionEvent> mOwner;
|
||||
Nullable<double> mX, mY, mZ;
|
||||
};
|
||||
|
||||
class nsDOMDeviceMotionEvent MOZ_FINAL : public nsDOMEvent
|
||||
{
|
||||
typedef mozilla::dom::DeviceAccelerationInit DeviceAccelerationInit;
|
||||
typedef mozilla::dom::DeviceRotationRateInit DeviceRotationRateInit;
|
||||
public:
|
||||
|
||||
nsDOMDeviceMotionEvent(mozilla::dom::EventTarget* aOwner,
|
||||
nsPresContext* aPresContext,
|
||||
mozilla::WidgetEvent* aEvent)
|
||||
: nsDOMEvent(aOwner, aPresContext, aEvent)
|
||||
{
|
||||
}
|
||||
|
||||
NS_DECL_ISUPPORTS_INHERITED
|
||||
|
||||
// Forward to nsDOMEvent
|
||||
NS_FORWARD_TO_NSDOMEVENT
|
||||
|
||||
NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(nsDOMDeviceMotionEvent, nsDOMEvent)
|
||||
|
||||
virtual JSObject* WrapObject(JSContext* aCx,
|
||||
JS::Handle<JSObject*> aScope) MOZ_OVERRIDE
|
||||
{
|
||||
return mozilla::dom::DeviceMotionEventBinding::Wrap(aCx, aScope, this);
|
||||
}
|
||||
|
||||
nsDOMDeviceAcceleration* GetAcceleration() const
|
||||
{
|
||||
return mAcceleration;
|
||||
}
|
||||
|
||||
nsDOMDeviceAcceleration* GetAccelerationIncludingGravity() const
|
||||
{
|
||||
return mAccelerationIncludingGravity;
|
||||
}
|
||||
|
||||
nsDOMDeviceRotationRate* 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,
|
||||
mozilla::ErrorResult& aRv);
|
||||
|
||||
static already_AddRefed<nsDOMDeviceMotionEvent>
|
||||
Constructor(const mozilla::dom::GlobalObject& aGlobal,
|
||||
const nsAString& aType,
|
||||
const mozilla::dom::DeviceMotionEventInit& aEventInitDict,
|
||||
mozilla::ErrorResult& aRv);
|
||||
|
||||
protected:
|
||||
nsRefPtr<nsDOMDeviceAcceleration> mAcceleration;
|
||||
nsRefPtr<nsDOMDeviceAcceleration> mAccelerationIncludingGravity;
|
||||
nsRefPtr<nsDOMDeviceRotationRate> mRotationRate;
|
||||
Nullable<double> mInterval;
|
||||
};
|
||||
|
||||
#endif
|
|
@ -392,7 +392,7 @@ nsDeviceSensors::FireDOMMotionEvent(nsIDOMDocument *domdoc,
|
|||
nsCOMPtr<nsIDOMEvent> event;
|
||||
domdoc->CreateEvent(NS_LITERAL_STRING("DeviceMotionEvent"), getter_AddRefs(event));
|
||||
|
||||
nsDOMDeviceMotionEvent* me = static_cast<nsDOMDeviceMotionEvent*>(event.get());
|
||||
DeviceMotionEvent* me = static_cast<DeviceMotionEvent*>(event.get());
|
||||
|
||||
ErrorResult rv;
|
||||
me->InitDeviceMotionEvent(NS_LITERAL_STRING("devicemotion"),
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
#include "nsCOMPtr.h"
|
||||
#include "nsITimer.h"
|
||||
#include "nsIDOMDeviceOrientationEvent.h"
|
||||
#include "nsDOMDeviceMotionEvent.h"
|
||||
#include "mozilla/dom/DeviceMotionEvent.h"
|
||||
#include "mozilla/TimeStamp.h"
|
||||
#include "mozilla/HalSensor.h"
|
||||
#include "nsDataHashtable.h"
|
||||
|
|
Загрузка…
Ссылка в новой задаче