Bug 916879, remove SetterThrows from eventhandlers, r=emk

This commit is contained in:
Olli Pettay 2013-09-17 14:01:28 +03:00
parent 26adc1f0cf
commit d3863cecc5
62 changed files with 138 additions and 372 deletions

View File

@ -1687,8 +1687,7 @@ public:
*/
#define EVENT(name_, id_, type_, struct_) \
mozilla::dom::EventHandlerNonNull* GetOn##name_(); \
void SetOn##name_(mozilla::dom::EventHandlerNonNull* listener, \
mozilla::ErrorResult& error); \
void SetOn##name_(mozilla::dom::EventHandlerNonNull* listener); \
NS_IMETHOD GetOn##name_(JSContext *cx, JS::Value *vp); \
NS_IMETHOD SetOn##name_(JSContext *cx, const JS::Value &v);
#define TOUCH_EVENT EVENT

View File

@ -2188,14 +2188,11 @@ nsINode::SizeOfExcludingThis(MallocSizeOf aMallocSizeOf) const
return elm ? elm->GetEventHandler(nsGkAtoms::on##name_, EmptyString()) \
: nullptr; \
} \
void nsINode::SetOn##name_(EventHandlerNonNull* handler, \
ErrorResult& error) { \
void nsINode::SetOn##name_(EventHandlerNonNull* handler) \
{ \
nsEventListenerManager *elm = GetListenerManager(true); \
if (elm) { \
error = elm->SetEventHandler(nsGkAtoms::on##name_, \
EmptyString(), handler); \
} else { \
error.Throw(NS_ERROR_OUT_OF_MEMORY); \
elm->SetEventHandler(nsGkAtoms::on##name_, EmptyString(), handler); \
} \
} \
NS_IMETHODIMP nsINode::GetOn##name_(JSContext *cx, JS::Value *vp) { \
@ -2210,9 +2207,8 @@ nsINode::SizeOfExcludingThis(MallocSizeOf aMallocSizeOf) const
JS_ObjectIsCallable(cx, callable = &v.toObject())) { \
handler = new EventHandlerNonNull(callable); \
} \
ErrorResult rv; \
SetOn##name_(handler, rv); \
return rv.ErrorCode(); \
SetOn##name_(handler); \
return NS_OK; \
}
#define TOUCH_EVENT EVENT
#define DOCUMENT_ONLY_EVENT EVENT

View File

@ -74,7 +74,7 @@ protected:
EventHandlerNonNull* GetEventHandler(nsIAtom* aType,
const nsAString& aTypeString);
void SetEventHandler(nsIAtom* aType, const nsAString& aTypeString,
EventHandlerNonNull* aHandler, ErrorResult& rv);
EventHandlerNonNull* aHandler);
};
NS_DEFINE_STATIC_IID_ACCESSOR(EventTarget, NS_EVENTTARGET_IID)

View File

@ -32,25 +32,27 @@ EventTarget::GetEventHandler(nsIAtom* aType, const nsAString& aTypeString)
void
EventTarget::SetEventHandler(const nsAString& aType,
EventHandlerNonNull* aHandler,
ErrorResult& rv)
ErrorResult& aRv)
{
if (!StringBeginsWith(aType, NS_LITERAL_STRING("on"))) {
aRv.Throw(NS_ERROR_INVALID_ARG);
return;
}
if (NS_IsMainThread()) {
nsCOMPtr<nsIAtom> type = do_GetAtom(aType);
return SetEventHandler(type, EmptyString(), aHandler, rv);
SetEventHandler(type, EmptyString(), aHandler);
return;
}
return SetEventHandler(nullptr,
Substring(aType, 2), // Remove "on"
aHandler, rv);
SetEventHandler(nullptr,
Substring(aType, 2), // Remove "on"
aHandler);
}
void
EventTarget::SetEventHandler(nsIAtom* aType, const nsAString& aTypeString,
EventHandlerNonNull* aHandler,
ErrorResult& rv)
EventHandlerNonNull* aHandler)
{
rv = GetListenerManager(true)->SetEventHandler(aType,
aTypeString,
aHandler);
GetListenerManager(true)->SetEventHandler(aType, aTypeString, aHandler);
}
} // namespace dom

View File

@ -276,9 +276,8 @@ nsDOMEventTargetHelper::SetEventHandler(nsIAtom* aType,
JS_ObjectIsCallable(aCx, callable = &aValue.toObject())) {
handler = new EventHandlerNonNull(callable);
}
ErrorResult rv;
SetEventHandler(aType, EmptyString(), handler, rv);
return rv.ErrorCode();
SetEventHandler(aType, EmptyString(), handler);
return NS_OK;
}
void

View File

@ -174,15 +174,12 @@ NS_DEFINE_STATIC_IID_ACCESSOR(nsDOMEventTargetHelper,
} \
return GetEventHandler(nullptr, NS_LITERAL_STRING(#_event)); \
} \
inline void SetOn##_event(mozilla::dom::EventHandlerNonNull* aCallback, \
mozilla::ErrorResult& aRv) \
inline void SetOn##_event(mozilla::dom::EventHandlerNonNull* aCallback) \
{ \
if (NS_IsMainThread()) { \
SetEventHandler(nsGkAtoms::on##_event, EmptyString(), \
aCallback, aRv); \
SetEventHandler(nsGkAtoms::on##_event, EmptyString(), aCallback); \
} else { \
SetEventHandler(nullptr, NS_LITERAL_STRING(#_event), \
aCallback, aRv); \
SetEventHandler(nullptr, NS_LITERAL_STRING(#_event), aCallback); \
} \
}

View File

@ -573,19 +573,18 @@ nsEventListenerManager::FindEventHandler(uint32_t aEventType,
return nullptr;
}
nsresult
nsListenerStruct*
nsEventListenerManager::SetEventHandlerInternal(nsIScriptContext *aContext,
JS::Handle<JSObject*> aScopeObject,
nsIAtom* aName,
const nsAString& aTypeString,
const nsEventHandler& aHandler,
bool aPermitUntrustedEvents,
nsListenerStruct **aListenerStruct)
bool aPermitUntrustedEvents)
{
NS_ASSERTION((aContext && aScopeObject) || aHandler.HasEventHandler(),
"Must have one or the other!");
MOZ_ASSERT((aContext && aScopeObject) || aHandler.HasEventHandler(),
"Must have one or the other!");
MOZ_ASSERT(aName || !aTypeString.IsEmpty());
nsresult rv = NS_OK;
uint32_t eventType = nsContentUtils::GetEventId(aName);
nsListenerStruct* ls = FindEventHandler(eventType, aName, aTypeString);
@ -596,16 +595,14 @@ nsEventListenerManager::SetEventHandlerInternal(nsIScriptContext *aContext,
flags.mListenerIsJSListener = true;
nsCOMPtr<nsIJSEventListener> scriptListener;
rv = NS_NewJSEventListener(aContext, aScopeObject, mTarget, aName,
aHandler, getter_AddRefs(scriptListener));
NS_NewJSEventListener(aContext, aScopeObject, mTarget, aName,
aHandler, getter_AddRefs(scriptListener));
if (NS_SUCCEEDED(rv)) {
EventListenerHolder holder(scriptListener);
AddEventListenerInternal(holder, eventType, aName, aTypeString, flags,
true);
EventListenerHolder holder(scriptListener);
AddEventListenerInternal(holder, eventType, aName, aTypeString, flags,
true);
ls = FindEventHandler(eventType, aName, aTypeString);
}
ls = FindEventHandler(eventType, aName, aTypeString);
} else {
nsIJSEventListener* scriptListener = ls->GetJSListener();
MOZ_ASSERT(scriptListener,
@ -620,19 +617,13 @@ nsEventListenerManager::SetEventHandlerInternal(nsIScriptContext *aContext,
}
}
if (NS_SUCCEEDED(rv) && ls) {
// Set flag to indicate possible need for compilation later
ls->mHandlerIsString = !aHandler.HasEventHandler();
if (aPermitUntrustedEvents) {
ls->mFlags.mAllowUntrustedEvents = true;
}
*aListenerStruct = ls;
} else {
*aListenerStruct = nullptr;
// Set flag to indicate possible need for compilation later
ls->mHandlerIsString = !aHandler.HasEventHandler();
if (aPermitUntrustedEvents) {
ls->mFlags.mAllowUntrustedEvents = true;
}
return rv;
return ls;
}
nsresult
@ -758,10 +749,10 @@ nsEventListenerManager::SetEventHandler(nsIAtom *aName,
JS::Rooted<JSObject*> scope(context->GetNativeContext(),
global->GetGlobalJSObject());
nsListenerStruct *ls;
rv = SetEventHandlerInternal(context, scope, aName, EmptyString(),
nsEventHandler(), aPermitUntrustedEvents, &ls);
NS_ENSURE_SUCCESS(rv, rv);
nsListenerStruct* ls = SetEventHandlerInternal(context, scope, aName,
EmptyString(),
nsEventHandler(),
aPermitUntrustedEvents);
if (!aDeferCompilation) {
return CompileEventHandlerInternal(ls, true, &aBody);
@ -1229,60 +1220,54 @@ nsEventListenerManager::HasUnloadListeners()
return false;
}
nsresult
void
nsEventListenerManager::SetEventHandler(nsIAtom* aEventName,
const nsAString& aTypeString,
EventHandlerNonNull* aHandler)
{
if (!aHandler) {
RemoveEventHandler(aEventName, aTypeString);
return NS_OK;
return;
}
// Untrusted events are always permitted for non-chrome script
// handlers.
nsListenerStruct *ignored;
return SetEventHandlerInternal(nullptr, JS::NullPtr(), aEventName,
aTypeString, nsEventHandler(aHandler),
!mIsMainThreadELM ||
!nsContentUtils::IsCallerChrome(),
&ignored);
SetEventHandlerInternal(nullptr, JS::NullPtr(), aEventName,
aTypeString, nsEventHandler(aHandler),
!mIsMainThreadELM ||
!nsContentUtils::IsCallerChrome());
}
nsresult
void
nsEventListenerManager::SetEventHandler(OnErrorEventHandlerNonNull* aHandler)
{
if (!aHandler) {
RemoveEventHandler(nsGkAtoms::onerror, EmptyString());
return NS_OK;
return;
}
// Untrusted events are always permitted for non-chrome script
// handlers.
nsListenerStruct *ignored;
return SetEventHandlerInternal(nullptr, JS::NullPtr(), nsGkAtoms::onerror,
EmptyString(), nsEventHandler(aHandler),
!mIsMainThreadELM ||
!nsContentUtils::IsCallerChrome(),
&ignored);
SetEventHandlerInternal(nullptr, JS::NullPtr(), nsGkAtoms::onerror,
EmptyString(), nsEventHandler(aHandler),
!mIsMainThreadELM ||
!nsContentUtils::IsCallerChrome());
}
nsresult
void
nsEventListenerManager::SetEventHandler(BeforeUnloadEventHandlerNonNull* aHandler)
{
if (!aHandler) {
RemoveEventHandler(nsGkAtoms::onbeforeunload, EmptyString());
return NS_OK;
return;
}
// Untrusted events are always permitted for non-chrome script
// handlers.
nsListenerStruct *ignored;
return SetEventHandlerInternal(nullptr, JS::NullPtr(), nsGkAtoms::onbeforeunload,
EmptyString(), nsEventHandler(aHandler),
!mIsMainThreadELM ||
!nsContentUtils::IsCallerChrome(),
&ignored);
SetEventHandlerInternal(nullptr, JS::NullPtr(), nsGkAtoms::onbeforeunload,
EmptyString(), nsEventHandler(aHandler),
!mIsMainThreadELM ||
!nsContentUtils::IsCallerChrome());
}
const nsEventHandler*

View File

@ -440,13 +440,12 @@ protected:
* allowed to be null. The nsListenerStruct that results, if any, is returned
* in aListenerStruct.
*/
nsresult SetEventHandlerInternal(nsIScriptContext *aContext,
JS::Handle<JSObject*> aScopeGlobal,
nsIAtom* aName,
const nsAString& aTypeString,
const nsEventHandler& aHandler,
bool aPermitUntrustedEvents,
nsListenerStruct **aListenerStruct);
nsListenerStruct* SetEventHandlerInternal(nsIScriptContext *aContext,
JS::Handle<JSObject*> aScopeGlobal,
nsIAtom* aName,
const nsAString& aTypeString,
const nsEventHandler& aHandler,
bool aPermitUntrustedEvents);
bool IsDeviceType(uint32_t aType);
void EnableDevice(uint32_t aType);
@ -457,11 +456,11 @@ public:
* Set the "inline" event listener for aEventName to aHandler. If
* aHandler is null, this will actually remove the event listener
*/
nsresult SetEventHandler(nsIAtom* aEventName,
const nsAString& aTypeString,
mozilla::dom::EventHandlerNonNull* aHandler);
nsresult SetEventHandler(mozilla::dom::OnErrorEventHandlerNonNull* aHandler);
nsresult SetEventHandler(mozilla::dom::BeforeUnloadEventHandlerNonNull* aHandler);
void SetEventHandler(nsIAtom* aEventName,
const nsAString& aTypeString,
mozilla::dom::EventHandlerNonNull* aHandler);
void SetEventHandler(mozilla::dom::OnErrorEventHandlerNonNull* aHandler);
void SetEventHandler(mozilla::dom::BeforeUnloadEventHandlerNonNull* aHandler);
/**
* Get the value of the "inline" event listener for aEventName.

View File

@ -502,9 +502,8 @@ HTMLBodyElement::IsEventAttributeName(nsIAtom *aName)
JS_ObjectIsCallable(cx, callable = &v.toObject())) { \
handler = new type_(callable); \
} \
ErrorResult rv; \
forwardto_::SetOn##name_(handler, rv); \
return rv.ErrorCode(); \
forwardto_::SetOn##name_(handler); \
return NS_OK; \
}
#define FORWARDED_EVENT(name_, id_, type_, struct_) \
FORWARDED_EVENT_HELPER(name_, nsGenericHTMLElement, EventHandlerNonNull, \
@ -525,7 +524,7 @@ HTMLBodyElement::IsEventAttributeName(nsIAtom *aName)
return nullptr; \
} \
void \
HTMLBodyElement::SetOn##name_(type_* handler, ErrorResult& error) \
HTMLBodyElement::SetOn##name_(type_* handler) \
{ \
nsPIDOMWindow* win = OwnerDoc()->GetInnerWindow(); \
if (!win) { \
@ -534,7 +533,7 @@ HTMLBodyElement::IsEventAttributeName(nsIAtom *aName)
\
nsCOMPtr<nsISupports> supports = do_QueryInterface(win); \
nsGlobalWindow* globalWin = nsGlobalWindow::FromSupports(supports); \
return globalWin->SetOn##name_(handler, error); \
return globalWin->SetOn##name_(handler); \
} \
FORWARDED_EVENT_HELPER(name_, HTMLBodyElement, type_, type_*)
#define WINDOW_EVENT(name_, id_, type_, struct_) \

View File

@ -60,7 +60,7 @@ public:
NS_IMETHOD SetOn##name_(JSContext *cx, const JS::Value &v);
#define WINDOW_EVENT_HELPER(name_, type_) \
type_* GetOn##name_(); \
void SetOn##name_(type_* handler, ErrorResult& error);
void SetOn##name_(type_* handler);
#define WINDOW_EVENT(name_, id_, type_, struct_) \
WINDOW_EVENT_HELPER(name_, EventHandlerNonNull)
#define BEFOREUNLOAD_EVENT(name_, id_, type_, struct_) \

View File

@ -361,9 +361,8 @@ HTMLFrameSetElement::IsEventAttributeName(nsIAtom *aName)
JS_ObjectIsCallable(cx, callable = &v.toObject())) { \
handler = new type_(callable); \
} \
ErrorResult rv; \
forwardto_::SetOn##name_(handler, rv); \
return rv.ErrorCode(); \
forwardto_::SetOn##name_(handler); \
return NS_OK; \
}
#define FORWARDED_EVENT(name_, id_, type_, struct_) \
FORWARDED_EVENT_HELPER(name_, nsGenericHTMLElement, EventHandlerNonNull, \
@ -384,7 +383,7 @@ HTMLFrameSetElement::IsEventAttributeName(nsIAtom *aName)
return nullptr; \
} \
void \
HTMLFrameSetElement::SetOn##name_(type_* handler, ErrorResult& error) \
HTMLFrameSetElement::SetOn##name_(type_* handler) \
{ \
nsPIDOMWindow* win = OwnerDoc()->GetInnerWindow(); \
if (!win) { \
@ -393,7 +392,7 @@ HTMLFrameSetElement::IsEventAttributeName(nsIAtom *aName)
\
nsCOMPtr<nsISupports> supports = do_QueryInterface(win); \
nsGlobalWindow* globalWin = nsGlobalWindow::FromSupports(supports); \
return globalWin->SetOn##name_(handler, error); \
return globalWin->SetOn##name_(handler); \
} \
FORWARDED_EVENT_HELPER(name_, HTMLFrameSetElement, type_, type_*)
#define WINDOW_EVENT(name_, id_, type_, struct_) \

View File

@ -90,7 +90,7 @@ public:
NS_IMETHOD SetOn##name_(JSContext *cx, const JS::Value &v);
#define WINDOW_EVENT_HELPER(name_, type_) \
type_* GetOn##name_(); \
void SetOn##name_(type_* handler, ErrorResult& error);
void SetOn##name_(type_* handler);
#define WINDOW_EVENT(name_, id_, type_, struct_) \
WINDOW_EVENT_HELPER(name_, EventHandlerNonNull)
#define BEFOREUNLOAD_EVENT(name_, id_, type_, struct_) \

View File

@ -868,8 +868,7 @@ nsGenericHTMLElement::GetOn##name_() \
return nsINode::GetOn##name_(); \
} \
void \
nsGenericHTMLElement::SetOn##name_(EventHandlerNonNull* handler, \
ErrorResult& error) \
nsGenericHTMLElement::SetOn##name_(EventHandlerNonNull* handler) \
{ \
if (Tag() == nsGkAtoms::body || Tag() == nsGkAtoms::frameset) { \
nsPIDOMWindow* win = OwnerDoc()->GetInnerWindow(); \
@ -879,10 +878,10 @@ nsGenericHTMLElement::SetOn##name_(EventHandlerNonNull* handler, \
\
nsCOMPtr<nsISupports> supports = do_QueryInterface(win); \
nsGlobalWindow* globalWin = nsGlobalWindow::FromSupports(supports); \
return globalWin->SetOn##name_(handler, error); \
return globalWin->SetOn##name_(handler); \
} \
\
return nsINode::SetOn##name_(handler, error); \
return nsINode::SetOn##name_(handler); \
}
#define ERROR_EVENT(name_, id_, type_, struct_) \
already_AddRefed<EventHandlerNonNull> \
@ -908,8 +907,7 @@ nsGenericHTMLElement::GetOn##name_() \
return handler.forget(); \
} \
void \
nsGenericHTMLElement::SetOn##name_(EventHandlerNonNull* handler, \
ErrorResult& error) \
nsGenericHTMLElement::SetOn##name_(EventHandlerNonNull* handler) \
{ \
if (Tag() == nsGkAtoms::body || Tag() == nsGkAtoms::frameset) { \
nsPIDOMWindow* win = OwnerDoc()->GetInnerWindow(); \
@ -923,10 +921,10 @@ nsGenericHTMLElement::SetOn##name_(EventHandlerNonNull* handler, \
if (handler) { \
errorHandler = new OnErrorEventHandlerNonNull(handler); \
} \
return globalWin->SetOn##name_(errorHandler, error); \
return globalWin->SetOn##name_(errorHandler); \
} \
\
return nsINode::SetOn##name_(handler, error); \
return nsINode::SetOn##name_(handler); \
}
#include "nsEventNameList.h" // IWYU pragma: keep
#undef ERROR_EVENT

View File

@ -239,14 +239,12 @@ public:
using nsINode::GetOn##name_; \
using nsINode::SetOn##name_; \
mozilla::dom::EventHandlerNonNull* GetOn##name_(); \
void SetOn##name_(mozilla::dom::EventHandlerNonNull* handler, \
mozilla::ErrorResult& error);
void SetOn##name_(mozilla::dom::EventHandlerNonNull* handler);
#define ERROR_EVENT(name_, id_, type_, struct_) \
using nsINode::GetOn##name_; \
using nsINode::SetOn##name_; \
already_AddRefed<mozilla::dom::EventHandlerNonNull> GetOn##name_(); \
void SetOn##name_(mozilla::dom::EventHandlerNonNull* handler, \
mozilla::ErrorResult& error);
void SetOn##name_(mozilla::dom::EventHandlerNonNull* handler);
#include "nsEventNameList.h" // IWYU pragma: keep
#undef ERROR_EVENT
#undef FORWARDED_EVENT

View File

@ -432,12 +432,12 @@ MessagePort::GetOnmessage()
}
void
MessagePort::SetOnmessage(EventHandlerNonNull* aCallback, ErrorResult& aRv)
MessagePort::SetOnmessage(EventHandlerNonNull* aCallback)
{
if (NS_IsMainThread()) {
SetEventHandler(nsGkAtoms::onmessage, EmptyString(), aCallback, aRv);
SetEventHandler(nsGkAtoms::onmessage, EmptyString(), aCallback);
} else {
SetEventHandler(nullptr, NS_LITERAL_STRING("message"), aCallback, aRv);
SetEventHandler(nullptr, NS_LITERAL_STRING("message"), aCallback);
}
// When using onmessage, the call to start() is implied.

View File

@ -52,7 +52,7 @@ public:
GetOnmessage();
void
SetOnmessage(EventHandlerNonNull* aCallback, ErrorResult& aRv);
SetOnmessage(EventHandlerNonNull* aCallback);
// Non WebIDL methods

View File

@ -12056,9 +12056,8 @@ nsGlobalWindow::DisableNetworkEvent(uint32_t aType)
JS_ObjectIsCallable(cx, callable = &v.toObject())) { \
handler = new EventHandlerNonNull(callable); \
} \
ErrorResult rv; \
SetOn##name_(handler, rv); \
return rv.ErrorCode(); \
SetOn##name_(handler); \
return NS_OK; \
}
#define ERROR_EVENT(name_, id_, type_, struct_) \
NS_IMETHODIMP nsGlobalWindow::GetOn##name_(JSContext *cx, \
@ -12087,7 +12086,8 @@ nsGlobalWindow::DisableNetworkEvent(uint32_t aType)
JS_ObjectIsCallable(cx, callable = &v.toObject())) { \
handler = new OnErrorEventHandlerNonNull(callable); \
} \
return elm->SetEventHandler(handler); \
elm->SetEventHandler(handler); \
return NS_OK; \
}
#define BEFOREUNLOAD_EVENT(name_, id_, type_, struct_) \
NS_IMETHODIMP nsGlobalWindow::GetOn##name_(JSContext *cx, \
@ -12117,7 +12117,8 @@ nsGlobalWindow::DisableNetworkEvent(uint32_t aType)
JS_ObjectIsCallable(cx, callable = &v.toObject())) { \
handler = new BeforeUnloadEventHandlerNonNull(callable); \
} \
return elm->SetEventHandler(handler); \
elm->SetEventHandler(handler); \
return NS_OK; \
}
#define WINDOW_ONLY_EVENT EVENT
#define TOUCH_EVENT EVENT

View File

@ -707,15 +707,11 @@ public:
return elm ? elm->GetEventHandler(nsGkAtoms::on##name_, EmptyString()) \
: nullptr; \
} \
void SetOn##name_(mozilla::dom::EventHandlerNonNull* handler, \
mozilla::ErrorResult& error) \
void SetOn##name_(mozilla::dom::EventHandlerNonNull* handler) \
{ \
nsEventListenerManager *elm = GetListenerManager(true); \
if (elm) { \
error = elm->SetEventHandler(nsGkAtoms::on##name_, EmptyString(), \
handler); \
} else { \
error.Throw(NS_ERROR_OUT_OF_MEMORY); \
elm->SetEventHandler(nsGkAtoms::on##name_, EmptyString(), handler); \
} \
}
#define ERROR_EVENT(name_, id_, type_, struct_) \
@ -724,14 +720,11 @@ public:
nsEventListenerManager *elm = GetListenerManager(false); \
return elm ? elm->GetOnErrorEventHandler() : nullptr; \
} \
void SetOn##name_(mozilla::dom::OnErrorEventHandlerNonNull* handler, \
mozilla::ErrorResult& error) \
void SetOn##name_(mozilla::dom::OnErrorEventHandlerNonNull* handler) \
{ \
nsEventListenerManager *elm = GetListenerManager(true); \
if (elm) { \
error = elm->SetEventHandler(handler); \
} else { \
error.Throw(NS_ERROR_OUT_OF_MEMORY); \
elm->SetEventHandler(handler); \
} \
}
#define BEFOREUNLOAD_EVENT(name_, id_, type_, struct_) \
@ -740,14 +733,11 @@ public:
nsEventListenerManager *elm = GetListenerManager(false); \
return elm ? elm->GetOnBeforeUnloadEventHandler() : nullptr; \
} \
void SetOn##name_(mozilla::dom::BeforeUnloadEventHandlerNonNull* handler, \
mozilla::ErrorResult& error) \
void SetOn##name_(mozilla::dom::BeforeUnloadEventHandlerNonNull* handler) \
{ \
nsEventListenerManager *elm = GetListenerManager(true); \
if (elm) { \
error = elm->SetEventHandler(handler); \
} else { \
error.Throw(NS_ERROR_OUT_OF_MEMORY); \
elm->SetEventHandler(handler); \
} \
}
#define WINDOW_ONLY_EVENT EVENT

View File

@ -27,7 +27,6 @@ interface AudioBufferSourceNode : AudioNode {
[Throws]
void stop(optional double when = 0);
[SetterThrows]
attribute EventHandler onended;
};

View File

@ -22,7 +22,6 @@ interface AudioChannelManager : EventTarget {
* speakers (or vice versa). This allows you to, for example, pause your
* window's audio when the headphones are unplugged.
*/
[SetterThrows]
attribute EventHandler onheadphoneschange;
/**

View File

@ -16,12 +16,8 @@ interface BatteryManager : EventTarget {
readonly attribute unrestricted double dischargingTime;
readonly attribute double level;
[SetterThrows]
attribute EventHandler onchargingchange;
[SetterThrows]
attribute EventHandler onchargingtimechange;
[SetterThrows]
attribute EventHandler ondischargingtimechange;
[SetterThrows]
attribute EventHandler onlevelchange;
};

View File

@ -48,27 +48,21 @@ interface BluetoothAdapter : EventTarget {
[GetterThrows]
readonly attribute any uuids;
[SetterThrows]
attribute EventHandler ondevicefound;
// Fired when pairing process is completed
[SetterThrows]
attribute EventHandler onpairedstatuschanged;
// Fired when a2dp connection status changed
[SetterThrows]
attribute EventHandler ona2dpstatuschanged;
// Fired when handsfree connection status changed
[SetterThrows]
attribute EventHandler onhfpstatuschanged;
// Fired when sco connection status changed
[SetterThrows]
attribute EventHandler onscostatuschanged;
// Fired when remote devices query current media play status
[SetterThrows]
attribute EventHandler onrequestmediaplaystatus;
[Creator, Throws]

View File

@ -7,11 +7,8 @@ interface BluetoothManager : EventTarget {
[Throws]
readonly attribute boolean enabled;
[SetterThrows]
attribute EventHandler onenabled;
[SetterThrows]
attribute EventHandler ondisabled;
[SetterThrows]
attribute EventHandler onadapteradded;
[Throws]

View File

@ -14,8 +14,6 @@ interface DOMRequest : EventTarget {
readonly attribute any result;
readonly attribute nsISupports? error;
[SetterThrows]
attribute EventHandler onsuccess;
[SetterThrows]
attribute EventHandler onerror;
};

View File

@ -21,14 +21,10 @@ interface DataChannel : EventTarget
readonly attribute boolean reliable;
readonly attribute RTCDataChannelState readyState;
readonly attribute unsigned long bufferedAmount;
[SetterThrows]
attribute EventHandler onopen;
[SetterThrows]
attribute EventHandler onerror;
[SetterThrows]
attribute EventHandler onclose;
void close();
[SetterThrows]
attribute EventHandler onmessage;
attribute RTCDataChannelType binaryType;
[Throws]

View File

@ -20,9 +20,7 @@ interface DesktopNotification : EventTarget
[Throws]
void show();
[SetterThrows]
attribute EventHandler onclick;
[SetterThrows]
attribute EventHandler onclose;
};

View File

@ -8,7 +8,6 @@ dictionary DeviceStorageEnumerationParameters {
};
interface DeviceStorage : EventTarget {
[SetterThrows]
attribute EventHandler onchange;
[Throws]

View File

@ -136,17 +136,17 @@ partial interface Document {
//(Not implemented)readonly attribute HTMLCollection commands;
// special event handler IDL attributes that only apply to Document objects
[LenientThis, SetterThrows] attribute EventHandler onreadystatechange;
[LenientThis] attribute EventHandler onreadystatechange;
// Gecko extensions?
[LenientThis, SetterThrows] attribute EventHandler onmouseenter;
[LenientThis, SetterThrows] attribute EventHandler onmouseleave;
[SetterThrows] attribute EventHandler onwheel;
[SetterThrows] attribute EventHandler oncopy;
[SetterThrows] attribute EventHandler oncut;
[SetterThrows] attribute EventHandler onpaste;
[SetterThrows] attribute EventHandler onbeforescriptexecute;
[SetterThrows] attribute EventHandler onafterscriptexecute;
[LenientThis] attribute EventHandler onmouseenter;
[LenientThis] attribute EventHandler onmouseleave;
attribute EventHandler onwheel;
attribute EventHandler oncopy;
attribute EventHandler oncut;
attribute EventHandler onpaste;
attribute EventHandler onbeforescriptexecute;
attribute EventHandler onafterscriptexecute;
/**
* True if this document is synthetic : stand alone image, video, audio file,
* etc.

View File

@ -71,11 +71,10 @@ interface Element : Node {
// Mozilla specific stuff
[SetterThrows,LenientThis]
[LenientThis]
attribute EventHandler onmouseenter;
[SetterThrows,LenientThis]
[LenientThis]
attribute EventHandler onmouseleave;
[SetterThrows]
attribute EventHandler onwheel;
// Selectors API

View File

@ -24,143 +24,85 @@ typedef OnErrorEventHandlerNonNull? OnErrorEventHandler;
[NoInterfaceObject]
interface GlobalEventHandlers {
[SetterThrows]
attribute EventHandler onabort;
//(Not implemented)[SetterThrows]
//(Not implemented)attribute EventHandler oncancel;
[SetterThrows]
attribute EventHandler oncanplay;
[SetterThrows]
attribute EventHandler oncanplaythrough;
[SetterThrows]
attribute EventHandler onchange;
[SetterThrows]
attribute EventHandler onclick;
//(Not implemented)[SetterThrows]
//(Not implemented)attribute EventHandler onclose;
[SetterThrows]
attribute EventHandler oncontextmenu;
//(Not implemented)[SetterThrows]
//(Not implemented)attribute EventHandler oncuechange;
[SetterThrows]
attribute EventHandler ondblclick;
[SetterThrows]
attribute EventHandler ondrag;
[SetterThrows]
attribute EventHandler ondragend;
[SetterThrows]
attribute EventHandler ondragenter;
[SetterThrows]
attribute EventHandler ondragleave;
[SetterThrows]
attribute EventHandler ondragover;
[SetterThrows]
attribute EventHandler ondragstart;
[SetterThrows]
attribute EventHandler ondrop;
[SetterThrows]
attribute EventHandler ondurationchange;
[SetterThrows]
attribute EventHandler onemptied;
[SetterThrows]
attribute EventHandler onended;
[SetterThrows]
attribute EventHandler oninput;
[SetterThrows]
attribute EventHandler oninvalid;
[SetterThrows]
attribute EventHandler onkeydown;
[SetterThrows]
attribute EventHandler onkeypress;
[SetterThrows]
attribute EventHandler onkeyup;
[SetterThrows]
attribute EventHandler onloadeddata;
[SetterThrows]
attribute EventHandler onloadedmetadata;
[SetterThrows]
attribute EventHandler onloadstart;
[SetterThrows]
attribute EventHandler onmousedown;
[SetterThrows]
attribute EventHandler onmousemove;
[SetterThrows]
attribute EventHandler onmouseout;
[SetterThrows]
attribute EventHandler onmouseover;
[SetterThrows]
attribute EventHandler onmouseup;
//(Not implemented)[SetterThrows]
//(Not implemented)attribute EventHandler onmousewheel;
[SetterThrows]
attribute EventHandler onpause;
[SetterThrows]
attribute EventHandler onplay;
[SetterThrows]
attribute EventHandler onplaying;
[SetterThrows]
attribute EventHandler onprogress;
[SetterThrows]
attribute EventHandler onratechange;
[SetterThrows]
attribute EventHandler onreset;
[SetterThrows]
attribute EventHandler onseeked;
[SetterThrows]
attribute EventHandler onseeking;
[SetterThrows]
attribute EventHandler onselect;
[SetterThrows]
attribute EventHandler onshow;
//(Not implemented)[SetterThrows]
//(Not implemented)attribute EventHandler onsort;
[SetterThrows]
attribute EventHandler onstalled;
[SetterThrows]
attribute EventHandler onsubmit;
[SetterThrows]
attribute EventHandler onsuspend;
[SetterThrows]
attribute EventHandler ontimeupdate;
[SetterThrows]
attribute EventHandler onvolumechange;
[SetterThrows]
attribute EventHandler onwaiting;
// Mozilla-specific handlers
[SetterThrows]
attribute EventHandler onmozfullscreenchange;
[SetterThrows]
attribute EventHandler onmozfullscreenerror;
[SetterThrows]
attribute EventHandler onmozpointerlockchange;
[SetterThrows]
attribute EventHandler onmozpointerlockerror;
};
[NoInterfaceObject]
interface NodeEventHandlers {
[SetterThrows]
attribute EventHandler onblur;
// We think the spec is wrong here.
// attribute OnErrorEventHandler onerror;
[SetterThrows]
attribute EventHandler onerror;
[SetterThrows]
attribute EventHandler onfocus;
[SetterThrows]
attribute EventHandler onload;
[SetterThrows]
attribute EventHandler onscroll;
};
[NoInterfaceObject]
interface WindowEventHandlers {
[SetterThrows]
attribute EventHandler onafterprint;
[SetterThrows]
attribute EventHandler onbeforeprint;
[SetterThrows]
attribute BeforeUnloadEventHandler onbeforeunload;
// For now, onerror comes from NodeEventHandlers
// When we convert Window to WebIDL this may need to change.
@ -170,24 +112,15 @@ interface WindowEventHandlers {
//(Not implemented)attribute EventHandler onfullscreenchange;
//(Not implemented)[SetterThrows]
//(Not implemented)attribute EventHandler onfullscreenerror;
[SetterThrows]
attribute EventHandler onhashchange;
[SetterThrows]
attribute EventHandler onmessage;
[SetterThrows]
attribute EventHandler onoffline;
[SetterThrows]
attribute EventHandler ononline;
[SetterThrows]
attribute EventHandler onpagehide;
[SetterThrows]
attribute EventHandler onpageshow;
[SetterThrows]
attribute EventHandler onpopstate;
[SetterThrows]
attribute EventHandler onresize;
//(Not implemented)[SetterThrows]
//(Not implemented)attribute EventHandler onstorage;
[SetterThrows]
attribute EventHandler onunload;
};

View File

@ -25,12 +25,9 @@ interface EventSource : EventTarget {
readonly attribute unsigned short readyState;
// networking
[SetterThrows]
attribute EventHandler onopen;
[SetterThrows]
attribute EventHandler onmessage;
[SetterThrows]
attribute EventHandler onerror;
attribute EventHandler onopen;
attribute EventHandler onmessage;
attribute EventHandler onerror;
void close();
};

View File

@ -32,22 +32,18 @@ interface FMRadio : EventTarget {
readonly attribute double channelWidth;
/* Fired when the FM radio is enabled. */
[SetterThrows]
attribute EventHandler onenabled;
/* Fired when the FM radio is disabled. */
[SetterThrows]
attribute EventHandler ondisabled;
/**
* Fired when the antenna becomes available or unavailable, i.e., fired when
* the antennaAvailable attribute changes.
*/
[SetterThrows]
attribute EventHandler onantennaavailablechange;
/* Fired when the FM radio's frequency is changed. */
[SetterThrows]
attribute EventHandler onfrequencychange;
/**

View File

@ -15,8 +15,6 @@ interface FileHandle : EventTarget {
[Throws]
DOMRequest getFile();
[SetterThrows]
attribute EventHandler onabort;
[SetterThrows]
attribute EventHandler onerror;
};

View File

@ -39,17 +39,11 @@ interface FileReader : EventTarget {
readonly attribute DOMError? error;
// event handler attributes
[SetterThrows]
attribute EventHandler onloadstart;
[SetterThrows]
attribute EventHandler onprogress;
[SetterThrows]
attribute EventHandler onload;
[SetterThrows]
attribute EventHandler onabort;
[SetterThrows]
attribute EventHandler onerror;
[SetterThrows]
attribute EventHandler onloadend;
};

View File

@ -9,6 +9,5 @@ interface LockedFile;
interface FileRequest : DOMRequest {
readonly attribute LockedFile? lockedFile;
[SetterThrows]
attribute EventHandler onprogress;
};

View File

@ -79,11 +79,8 @@ interface HTMLElement : Element {
// FIXME Bug 810677 Move className from HTMLElement to Element
attribute DOMString className;
[SetterThrows]
attribute EventHandler oncopy;
[SetterThrows]
attribute EventHandler oncut;
[SetterThrows]
attribute EventHandler onpaste;
};
@ -99,17 +96,17 @@ partial interface HTMLElement {
[NoInterfaceObject]
interface TouchEventHandlers {
[SetterThrows,Func="nsGenericHTMLElement::TouchEventsEnabled"]
[Func="nsGenericHTMLElement::TouchEventsEnabled"]
attribute EventHandler ontouchstart;
[SetterThrows,Func="nsGenericHTMLElement::TouchEventsEnabled"]
[Func="nsGenericHTMLElement::TouchEventsEnabled"]
attribute EventHandler ontouchend;
[SetterThrows,Func="nsGenericHTMLElement::TouchEventsEnabled"]
[Func="nsGenericHTMLElement::TouchEventsEnabled"]
attribute EventHandler ontouchmove;
[SetterThrows,Func="nsGenericHTMLElement::TouchEventsEnabled"]
[Func="nsGenericHTMLElement::TouchEventsEnabled"]
attribute EventHandler ontouchenter;
[SetterThrows,Func="nsGenericHTMLElement::TouchEventsEnabled"]
[Func="nsGenericHTMLElement::TouchEventsEnabled"]
attribute EventHandler ontouchleave;
[SetterThrows,Func="nsGenericHTMLElement::TouchEventsEnabled"]
[Func="nsGenericHTMLElement::TouchEventsEnabled"]
attribute EventHandler ontouchcancel;
};

View File

@ -35,11 +35,8 @@ interface IDBDatabase : EventTarget {
void close ();
[SetterThrows]
attribute EventHandler onabort;
[SetterThrows]
attribute EventHandler onerror;
[SetterThrows]
attribute EventHandler onversionchange;
};

View File

@ -8,9 +8,7 @@
*/
interface IDBOpenDBRequest : IDBRequest {
[SetterThrows]
attribute EventHandler onblocked;
[SetterThrows]
attribute EventHandler onupgradeneeded;
};

View File

@ -24,9 +24,7 @@ interface IDBRequest : EventTarget {
readonly attribute IDBTransaction? transaction;
readonly attribute IDBRequestReadyState readyState;
[SetterThrows]
attribute EventHandler onsuccess;
[SetterThrows]
attribute EventHandler onerror;
};

View File

@ -28,11 +28,8 @@ interface IDBTransaction : EventTarget {
[Throws]
void abort();
[SetterThrows]
attribute EventHandler onabort;
[SetterThrows]
attribute EventHandler oncomplete;
[SetterThrows]
attribute EventHandler onerror;
};

View File

@ -21,16 +21,12 @@ interface MediaRecorder : EventTarget {
readonly attribute DOMString mimeType;
[SetterThrows]
attribute EventHandler ondataavailable;
[SetterThrows]
attribute EventHandler onerror;
[SetterThrows]
attribute EventHandler onstop;
[SetterThrows]
attribute EventHandler onwarning;
[Throws]

View File

@ -17,7 +17,6 @@ interface MessagePort : EventTarget {
void close();
// event handlers
[SetterThrows]
attribute EventHandler onmessage;
attribute EventHandler onmessage;
};
// MessagePort implements Transferable;

View File

@ -13,6 +13,5 @@ interface MozCellBroadcast : EventTarget
/**
* Cell Broadcast messages received.
*/
[SetterThrows]
attribute EventHandler onreceived;
};

View File

@ -31,6 +31,5 @@ interface MozVoicemail : EventTarget
/**
* The current voicemail status has changed
*/
[SetterThrows]
attribute EventHandler onstatuschanged;
};

View File

@ -19,16 +19,12 @@ interface Notification : EventTarget {
[Throws]
static void requestPermission(optional NotificationPermissionCallback permissionCallback);
[SetterThrows]
attribute EventHandler onclick;
[SetterThrows]
attribute EventHandler onshow;
[SetterThrows]
attribute EventHandler onerror;
[SetterThrows]
attribute EventHandler onclose;
[Constant]

View File

@ -18,7 +18,6 @@ interface OfflineAudioContext : AudioContext {
void startRendering();
[SetterThrows]
attribute EventHandler oncomplete;
};

View File

@ -42,21 +42,13 @@ interface OfflineResourceList : EventTarget {
void swapCache();
/* Events */
[SetterThrows]
attribute EventHandler onchecking;
[SetterThrows]
attribute EventHandler onerror;
[SetterThrows]
attribute EventHandler onnoupdate;
[SetterThrows]
attribute EventHandler ondownloading;
[SetterThrows]
attribute EventHandler onprogress;
[SetterThrows]
attribute EventHandler onupdateready;
[SetterThrows]
attribute EventHandler oncached;
[SetterThrows]
attribute EventHandler onobsolete;
};

View File

@ -36,7 +36,6 @@ interface OscillatorNode : AudioNode {
void stop(double when);
void setPeriodicWave(PeriodicWave periodicWave);
[SetterThrows]
attribute EventHandler onended;
};

View File

@ -31,11 +31,8 @@ interface SVGElement : Element {
readonly attribute SVGSVGElement? ownerSVGElement;
readonly attribute SVGElement? viewportElement;
[SetterThrows]
attribute EventHandler oncopy;
[SetterThrows]
attribute EventHandler oncut;
[SetterThrows]
attribute EventHandler onpaste;
};

View File

@ -35,7 +35,6 @@ interface Screen : EventTarget {
*/
readonly attribute DOMString mozOrientation;
[SetterThrows]
attribute EventHandler onmozorientationchange;
/**

View File

@ -13,7 +13,6 @@
[PrefControlled]
interface ScriptProcessorNode : AudioNode {
[SetterThrows]
attribute EventHandler onaudioprocess;
readonly attribute long bufferSize;

View File

@ -33,26 +33,15 @@ interface SpeechRecognition : EventTarget {
void abort();
// event methods
[SetterThrows]
attribute EventHandler onaudiostart;
[SetterThrows]
attribute EventHandler onsoundstart;
[SetterThrows]
attribute EventHandler onspeechstart;
[SetterThrows]
attribute EventHandler onspeechend;
[SetterThrows]
attribute EventHandler onsoundend;
[SetterThrows]
attribute EventHandler onaudioend;
[SetterThrows]
attribute EventHandler onresult;
[SetterThrows]
attribute EventHandler onnomatch;
[SetterThrows]
attribute EventHandler onerror;
[SetterThrows]
attribute EventHandler onstart;
[SetterThrows]
attribute EventHandler onend;
};

View File

@ -21,18 +21,11 @@ interface SpeechSynthesisUtterance : EventTarget {
attribute float rate;
attribute float pitch;
[SetterThrows]
attribute EventHandler onstart;
[SetterThrows]
attribute EventHandler onend;
[SetterThrows]
attribute EventHandler onerror;
[SetterThrows]
attribute EventHandler onpause;
[SetterThrows]
attribute EventHandler onresume;
[SetterThrows]
attribute EventHandler onmark;
[SetterThrows]
attribute EventHandler onboundary;
};

View File

@ -27,12 +27,8 @@ interface Telephony : EventTarget {
[Throws]
void stopTone();
[SetterThrows]
attribute EventHandler onincoming;
[SetterThrows]
attribute EventHandler oncallschanged;
[SetterThrows]
attribute EventHandler onremoteheld;
[SetterThrows]
attribute EventHandler onremoteresumed;
};

View File

@ -32,30 +32,18 @@ interface TelephonyCall : EventTarget {
[Throws]
void resume();
[SetterThrows]
attribute EventHandler onstatechange;
[SetterThrows]
attribute EventHandler ondialing;
[SetterThrows]
attribute EventHandler onalerting;
[SetterThrows]
attribute EventHandler onconnecting;
[SetterThrows]
attribute EventHandler onconnected;
[SetterThrows]
attribute EventHandler ondisconnecting;
[SetterThrows]
attribute EventHandler ondisconnected;
[SetterThrows]
attribute EventHandler onholding;
[SetterThrows]
attribute EventHandler onheld;
[SetterThrows]
attribute EventHandler onresuming;
[SetterThrows]
attribute EventHandler onerror;
// Fired whenever the group attribute changes.
[SetterThrows]
attribute EventHandler ongroupchange;
};

View File

@ -25,16 +25,10 @@ interface TelephonyCallGroup : EventTarget {
readonly attribute DOMString state;
[SetterThrows]
attribute EventHandler onstatechange;
[SetterThrows]
attribute EventHandler onconnected;
[SetterThrows]
attribute EventHandler onholding;
[SetterThrows]
attribute EventHandler onheld;
[SetterThrows]
attribute EventHandler onresuming;
[SetterThrows]
attribute EventHandler oncallschanged;
};

View File

@ -39,7 +39,6 @@ interface TextTrack : EventTarget {
void addCue(VTTCue cue);
void removeCue(VTTCue cue);
[SetterThrows]
attribute EventHandler oncuechange;
[Throws]
void removeRegion(TextTrackRegion region);

View File

@ -13,8 +13,6 @@ interface TextTrackList : EventTarget {
getter TextTrack (unsigned long index);
TextTrack? getTrackById(DOMString id);
[SetterThrows]
attribute EventHandler onaddtrack;
[SetterThrows]
attribute EventHandler onremovetrack;
};

View File

@ -41,9 +41,7 @@ interface VTTCue : EventTarget {
attribute DOMString text;
DocumentFragment getCueAsHTML();
[SetterThrows]
attribute EventHandler onenter;
attribute EventHandler onenter;
[SetterThrows]
attribute EventHandler onexit;
attribute EventHandler onexit;
};

View File

@ -32,13 +32,10 @@ interface WebSocket : EventTarget {
// networking
[SetterThrows]
attribute EventHandler onopen;
[SetterThrows]
attribute EventHandler onerror;
[SetterThrows]
attribute EventHandler onclose;
readonly attribute DOMString extensions;
@ -50,7 +47,6 @@ interface WebSocket : EventTarget {
// messaging
[SetterThrows]
attribute EventHandler onmessage;
attribute BinaryType binaryType;

View File

@ -57,7 +57,7 @@ dictionary MozXMLHttpRequestParameters
Constructor(DOMString ignored)]
interface XMLHttpRequest : XMLHttpRequestEventTarget {
// event handler
[SetterThrows, GetterThrows=Workers]
[SetterThrows=Workers, GetterThrows=Workers]
attribute EventHandler onreadystatechange;
// states

View File

@ -13,24 +13,24 @@
[NoInterfaceObject]
interface XMLHttpRequestEventTarget : EventTarget {
// event handlers
[SetterThrows, GetterThrows=Workers]
[SetterThrows=Workers, GetterThrows=Workers]
attribute EventHandler onloadstart;
[SetterThrows, GetterThrows=Workers]
[SetterThrows=Workers, GetterThrows=Workers]
attribute EventHandler onprogress;
[SetterThrows, GetterThrows=Workers]
[SetterThrows=Workers, GetterThrows=Workers]
attribute EventHandler onabort;
[SetterThrows, GetterThrows=Workers]
[SetterThrows=Workers, GetterThrows=Workers]
attribute EventHandler onerror;
[SetterThrows, GetterThrows=Workers]
[SetterThrows=Workers, GetterThrows=Workers]
attribute EventHandler onload;
[SetterThrows, GetterThrows=Workers]
[SetterThrows=Workers, GetterThrows=Workers]
attribute EventHandler ontimeout;
[SetterThrows, GetterThrows=Workers]
[SetterThrows=Workers, GetterThrows=Workers]
attribute EventHandler onloadend;
};