Bug 776966 - Generate DeviceOrientationEvent implementation, r=dougt

This commit is contained in:
Olli Pettay 2012-07-26 00:17:14 +03:00
Родитель 564ccbe7d1
Коммит 2c8046a80a
9 изменённых файлов: 27 добавлений и 131 удалений

Просмотреть файл

@ -37,7 +37,6 @@ CPPSRCS = \
nsDOMMutationEvent.cpp \
nsDOMPopupBlockedEvent.cpp \
nsDOMDeviceLightEvent.cpp \
nsDOMDeviceOrientationEvent.cpp \
nsDOMDeviceMotionEvent.cpp \
nsDOMBeforeUnloadEvent.cpp \
nsDOMXULCommandEvent.cpp \

Просмотреть файл

@ -1,81 +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/. */
#include "nsDOMClassInfoID.h"
#include "nsDOMDeviceOrientationEvent.h"
NS_IMPL_ADDREF_INHERITED(nsDOMDeviceOrientationEvent, nsDOMEvent)
NS_IMPL_RELEASE_INHERITED(nsDOMDeviceOrientationEvent, nsDOMEvent)
DOMCI_DATA(DeviceOrientationEvent, nsDOMDeviceOrientationEvent)
NS_INTERFACE_MAP_BEGIN(nsDOMDeviceOrientationEvent)
NS_INTERFACE_MAP_ENTRY(nsIDOMDeviceOrientationEvent)
NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(DeviceOrientationEvent)
NS_INTERFACE_MAP_END_INHERITING(nsDOMEvent)
NS_IMETHODIMP nsDOMDeviceOrientationEvent::InitDeviceOrientationEvent(const nsAString & aEventTypeArg,
bool aCanBubbleArg,
bool aCancelableArg,
double aAlpha,
double aBeta,
double aGamma,
bool aAbsolute)
{
nsresult rv = nsDOMEvent::InitEvent(aEventTypeArg, aCanBubbleArg, aCancelableArg);
NS_ENSURE_SUCCESS(rv, rv);
mAlpha = aAlpha;
mBeta = aBeta;
mGamma = aGamma;
mAbsolute = aAbsolute;
return NS_OK;
}
NS_IMETHODIMP nsDOMDeviceOrientationEvent::GetAlpha(double *aAlpha)
{
NS_ENSURE_ARG_POINTER(aAlpha);
*aAlpha = mAlpha;
return NS_OK;
}
NS_IMETHODIMP nsDOMDeviceOrientationEvent::GetBeta(double *aBeta)
{
NS_ENSURE_ARG_POINTER(aBeta);
*aBeta = mBeta;
return NS_OK;
}
NS_IMETHODIMP nsDOMDeviceOrientationEvent::GetGamma(double *aGamma)
{
NS_ENSURE_ARG_POINTER(aGamma);
*aGamma = mGamma;
return NS_OK;
}
NS_IMETHODIMP nsDOMDeviceOrientationEvent::GetAbsolute(bool *aAbsolute)
{
NS_ENSURE_ARG_POINTER(aAbsolute);
*aAbsolute = mAbsolute;
return NS_OK;
}
nsresult NS_NewDOMDeviceOrientationEvent(nsIDOMEvent** aInstancePtrResult,
nsPresContext* aPresContext,
nsEvent *aEvent)
{
NS_ENSURE_ARG_POINTER(aInstancePtrResult);
nsDOMDeviceOrientationEvent* it = new nsDOMDeviceOrientationEvent(aPresContext, aEvent);
if (nsnull == it) {
return NS_ERROR_OUT_OF_MEMORY;
}
return CallQueryInterface(it, aInstancePtrResult);
}

Просмотреть файл

@ -1,36 +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 nsDOMDeviceOrientationEvent_h__
#define nsDOMDeviceOrientationEvent_h__
#include "nsIDOMDeviceOrientationEvent.h"
#include "nsDOMEvent.h"
class nsDOMDeviceOrientationEvent : public nsDOMEvent,
public nsIDOMDeviceOrientationEvent
{
public:
nsDOMDeviceOrientationEvent(nsPresContext* aPresContext, nsEvent* aEvent)
: nsDOMEvent(aPresContext, aEvent),
mAlpha(0),
mBeta(0),
mGamma(0),
mAbsolute(true) {}
NS_DECL_ISUPPORTS_INHERITED
// Forward to nsDOMEvent
NS_FORWARD_TO_NSDOMEVENT
// nsIDOMDeviceOrientationEvent Interface
NS_DECL_NSIDOMDEVICEORIENTATIONEVENT
protected:
double mAlpha, mBeta, mGamma;
bool mAbsolute;
};
#endif

Просмотреть файл

@ -425,6 +425,24 @@ is(e.value, 1, "value should be 1");
document.dispatchEvent(e);
is(receivedEvent, e, "Wrong event!");
// DeviceOrientationEvent
e = new DeviceOrientationEvent("hello");
ok(e.type, "hello", "Wrong event type!");
ok(!e.isTrusted, "Event should not be trusted");
is(e.alpha, 0);
is(e.beta, 0);
is(e.gamma, 0);
is(e.absolute, false);
e = new DeviceOrientationEvent("hello", { alpha: 1, beta: 2, gamma: 3, absolute: true } );
ok(e.type, "hello", "Wrong event type!");
ok(!e.isTrusted, "Event should not be trusted");
is(e.alpha, 1);
is(e.beta, 2);
is(e.gamma, 3);
is(e.absolute, true);
document.dispatchEvent(e);
is(receivedEvent, e, "Wrong event!");
// MouseEvent

Просмотреть файл

@ -299,7 +299,6 @@
#include "GeneratedEvents.h"
#undef MOZ_GENERATED_EVENTS_INCLUDES
#include "nsIDOMDeviceLightEvent.h"
#include "nsIDOMDeviceOrientationEvent.h"
#include "nsIDOMDeviceMotionEvent.h"
#include "nsIDOMRange.h"
#include "nsIDOMNodeIterator.h"
@ -826,9 +825,6 @@ static nsDOMClassInfoData sClassInfoData[] = {
#include "GeneratedEvents.h"
#undef MOZ_GENERATED_EVENT_LIST
// Device Orientation
NS_DEFINE_CLASSINFO_DATA(DeviceOrientationEvent, nsDOMGenericSH,
DOM_DEFAULT_SCRIPTABLE_FLAGS)
NS_DEFINE_CLASSINFO_DATA(DeviceMotionEvent, nsDOMGenericSH,
DOM_DEFAULT_SCRIPTABLE_FLAGS)
NS_DEFINE_CLASSINFO_DATA(DeviceAcceleration, nsDOMGenericSH,
@ -2614,11 +2610,6 @@ nsDOMClassInfo::Init()
#include "GeneratedEvents.h"
#undef MOZ_GENERATED_EVENT_LIST
DOM_CLASSINFO_MAP_BEGIN(DeviceOrientationEvent, nsIDOMDeviceOrientationEvent)
DOM_CLASSINFO_MAP_ENTRY(nsIDOMDeviceOrientationEvent)
DOM_CLASSINFO_EVENT_MAP_ENTRIES
DOM_CLASSINFO_MAP_END
DOM_CLASSINFO_MAP_BEGIN(DeviceMotionEvent, nsIDOMDeviceMotionEvent)
DOM_CLASSINFO_MAP_ENTRY(nsIDOMDeviceMotionEvent)
DOM_CLASSINFO_EVENT_MAP_ENTRIES

Просмотреть файл

@ -48,7 +48,6 @@ DOMCI_CLASS(DeviceLightEvent)
#define MOZ_GENERATED_EVENT(_event_interface) DOMCI_CLASS(_event_interface)
#include "GeneratedEvents.h"
#undef MOZ_GENERATED_EVENT_LIST
DOMCI_CLASS(DeviceOrientationEvent)
DOMCI_CLASS(DeviceMotionEvent)
DOMCI_CLASS(DeviceAcceleration)
DOMCI_CLASS(DeviceRotationRate)

Просмотреть файл

@ -41,3 +41,10 @@ interface nsIDOMDeviceOrientationEvent : nsIDOMEvent
readonly attribute boolean absolute;
};
dictionary DeviceOrientationEventInit : EventInit
{
double alpha;
double beta;
double gamma;
boolean absolute;
};

Просмотреть файл

@ -204,8 +204,6 @@ NS_NewDOMMutationEvent(nsIDOMEvent** aResult, nsPresContext* aPresContext, class
nsresult
NS_NewDOMPopupBlockedEvent(nsIDOMEvent** aResult, nsPresContext* aPresContext, nsEvent* aEvent);
nsresult
NS_NewDOMDeviceOrientationEvent(nsIDOMEvent** aResult, nsPresContext* aPresContext, nsEvent* aEvent);
nsresult
NS_NewDOMDeviceLightEvent(nsIDOMEvent** aResult, nsPresContext* aPresContext, nsEvent* aEvent);
nsresult
NS_NewDOMDeviceMotionEvent(nsIDOMEvent** aResult, nsPresContext* aPresContext, nsEvent* aEvent);

Просмотреть файл

@ -15,7 +15,8 @@ simple_events = [
'PopStateEvent',
'HashChangeEvent',
'CloseEvent',
'MozContactChangeEvent'
'MozContactChangeEvent',
'DeviceOrientationEvent'
]
""" include file names """