diff --git a/content/events/src/Makefile.in b/content/events/src/Makefile.in index 94dd70ddefcf..2985c672b971 100644 --- a/content/events/src/Makefile.in +++ b/content/events/src/Makefile.in @@ -37,7 +37,6 @@ CPPSRCS = \ nsDOMMutationEvent.cpp \ nsDOMPopupBlockedEvent.cpp \ nsDOMDeviceLightEvent.cpp \ - nsDOMDeviceOrientationEvent.cpp \ nsDOMDeviceMotionEvent.cpp \ nsDOMBeforeUnloadEvent.cpp \ nsDOMXULCommandEvent.cpp \ diff --git a/content/events/src/nsDOMDeviceOrientationEvent.cpp b/content/events/src/nsDOMDeviceOrientationEvent.cpp deleted file mode 100644 index a3ce0ce9ffdd..000000000000 --- a/content/events/src/nsDOMDeviceOrientationEvent.cpp +++ /dev/null @@ -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); -} diff --git a/content/events/src/nsDOMDeviceOrientationEvent.h b/content/events/src/nsDOMDeviceOrientationEvent.h deleted file mode 100644 index d70c51d14b63..000000000000 --- a/content/events/src/nsDOMDeviceOrientationEvent.h +++ /dev/null @@ -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 diff --git a/content/events/test/test_eventctors.html b/content/events/test/test_eventctors.html index 40d888227ace..7f8678cf038f 100644 --- a/content/events/test/test_eventctors.html +++ b/content/events/test/test_eventctors.html @@ -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 diff --git a/dom/base/nsDOMClassInfo.cpp b/dom/base/nsDOMClassInfo.cpp index 913e7962c6a3..36573ee60d65 100644 --- a/dom/base/nsDOMClassInfo.cpp +++ b/dom/base/nsDOMClassInfo.cpp @@ -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 diff --git a/dom/base/nsDOMClassInfoClasses.h b/dom/base/nsDOMClassInfoClasses.h index 4cd9626a1672..97a808d36493 100644 --- a/dom/base/nsDOMClassInfoClasses.h +++ b/dom/base/nsDOMClassInfoClasses.h @@ -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) diff --git a/dom/interfaces/events/nsIDOMDeviceOrientationEvent.idl b/dom/interfaces/events/nsIDOMDeviceOrientationEvent.idl index 8d0740bebb0a..011846a5374f 100644 --- a/dom/interfaces/events/nsIDOMDeviceOrientationEvent.idl +++ b/dom/interfaces/events/nsIDOMDeviceOrientationEvent.idl @@ -41,3 +41,10 @@ interface nsIDOMDeviceOrientationEvent : nsIDOMEvent readonly attribute boolean absolute; }; +dictionary DeviceOrientationEventInit : EventInit +{ + double alpha; + double beta; + double gamma; + boolean absolute; +}; diff --git a/dom/interfaces/events/nsIDOMEvent.idl b/dom/interfaces/events/nsIDOMEvent.idl index 88ffe526af8d..77efdb9c7ad6 100644 --- a/dom/interfaces/events/nsIDOMEvent.idl +++ b/dom/interfaces/events/nsIDOMEvent.idl @@ -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); diff --git a/js/xpconnect/src/event_impl_gen.conf.in b/js/xpconnect/src/event_impl_gen.conf.in index c0345d4646d0..89ec0e6a81a5 100644 --- a/js/xpconnect/src/event_impl_gen.conf.in +++ b/js/xpconnect/src/event_impl_gen.conf.in @@ -15,7 +15,8 @@ simple_events = [ 'PopStateEvent', 'HashChangeEvent', 'CloseEvent', - 'MozContactChangeEvent' + 'MozContactChangeEvent', + 'DeviceOrientationEvent' ] """ include file names """