Fix for bug 811069 (Make *Element.onerror return EventHandler instead of OnErrorEventHandler). r=bz.

--HG--
extra : rebase_source : a40c6cd2bad3126ee18392b41f4274380b211d10
This commit is contained in:
Peter Van der Beken 2012-11-13 14:37:39 +01:00
parent 907cc9c98c
commit 30532e2297
2 changed files with 28 additions and 54 deletions

View File

@ -1614,24 +1614,18 @@ public:
Note that we include DOCUMENT_ONLY_EVENT events here so that we
can forward all the document stuff to this implementation.
*/
#define EVENT_HELPER(name_, handlerClass_) \
mozilla::dom::handlerClass_* GetOn##name_(); \
void SetOn##name_(mozilla::dom::handlerClass_* listener, \
#define EVENT(name_, id_, type_, struct_) \
mozilla::dom::EventHandlerNonNull* GetOn##name_(); \
void SetOn##name_(mozilla::dom::EventHandlerNonNull* listener, \
mozilla::ErrorResult& error); \
NS_IMETHOD GetOn##name_(JSContext *cx, JS::Value *vp); \
NS_IMETHOD SetOn##name_(JSContext *cx, const JS::Value &v);
#define EVENT(name_, id_, type_, struct_) \
EVENT_HELPER(name_, EventHandlerNonNull)
#define TOUCH_EVENT EVENT
#define DOCUMENT_ONLY_EVENT EVENT
#define ERROR_EVENT(name_, id_, type_, struct_) \
EVENT_HELPER(name_, OnErrorEventHandlerNonNull)
#include "nsEventNameList.h"
#undef ERROR_EVENT
#undef DOCUMENT_ONLY_EVENT
#undef TOUCH_EVENT
#undef EVENT
#undef EVENT_HELPER
protected:
static void Trace(nsINode *tmp, TraceCallback cb, void *closure);

View File

@ -2014,33 +2014,6 @@ nsINode::SizeOfExcludingThis(nsMallocSizeOfFun aMallocSizeOf) const
return n;
}
#define EVENT_HELPER(name_, handlerClass_) \
NS_IMETHODIMP nsINode::GetOn##name_(JSContext *cx, jsval *vp) { \
handlerClass_* h = GetOn##name_(); \
vp->setObjectOrNull(h ? h->Callable() : nullptr); \
return NS_OK; \
} \
NS_IMETHODIMP nsINode::SetOn##name_(JSContext *cx, const jsval &v) { \
JSObject *obj = GetWrapper(); \
if (!obj) { \
/* Just silently do nothing */ \
return NS_OK; \
} \
nsRefPtr<handlerClass_> handler; \
JSObject *callable; \
if (v.isObject() && \
JS_ObjectIsCallable(cx, callable = &v.toObject())) { \
bool ok; \
handler = new handlerClass_(cx, obj, callable, &ok); \
if (!ok) { \
return NS_ERROR_OUT_OF_MEMORY; \
} \
} \
ErrorResult rv; \
SetOn##name_(handler, rv); \
return rv.ErrorCode(); \
}
#define EVENT(name_, id_, type_, struct_) \
EventHandlerNonNull* nsINode::GetOn##name_() { \
nsEventListenerManager *elm = GetListenerManager(false); \
@ -2055,30 +2028,37 @@ nsINode::SizeOfExcludingThis(nsMallocSizeOfFun aMallocSizeOf) const
error.Throw(NS_ERROR_OUT_OF_MEMORY); \
} \
} \
EVENT_HELPER(name_, EventHandlerNonNull)
NS_IMETHODIMP nsINode::GetOn##name_(JSContext *cx, jsval *vp) { \
EventHandlerNonNull* h = GetOn##name_(); \
vp->setObjectOrNull(h ? h->Callable() : nullptr); \
return NS_OK; \
} \
NS_IMETHODIMP nsINode::SetOn##name_(JSContext *cx, const jsval &v) { \
JSObject *obj = GetWrapper(); \
if (!obj) { \
/* Just silently do nothing */ \
return NS_OK; \
} \
nsRefPtr<EventHandlerNonNull> handler; \
JSObject *callable; \
if (v.isObject() && \
JS_ObjectIsCallable(cx, callable = &v.toObject())) { \
bool ok; \
handler = new EventHandlerNonNull(cx, obj, callable, &ok); \
if (!ok) { \
return NS_ERROR_OUT_OF_MEMORY; \
} \
} \
ErrorResult rv; \
SetOn##name_(handler, rv); \
return rv.ErrorCode(); \
}
#define TOUCH_EVENT EVENT
#define DOCUMENT_ONLY_EVENT EVENT
#define ERROR_EVENT(name_, id_, type_, struct_) \
OnErrorEventHandlerNonNull* nsINode::GetOn##name_() { \
nsEventListenerManager *elm = GetListenerManager(false); \
return elm ? elm->GetOnErrorEventHandler() : nullptr; \
} \
void nsINode::SetOn##name_(OnErrorEventHandlerNonNull* handler, \
ErrorResult& error) { \
nsEventListenerManager *elm = GetListenerManager(true); \
if (elm) { \
error = elm->SetEventHandler(handler); \
} else { \
error.Throw(NS_ERROR_OUT_OF_MEMORY); \
} \
} \
EVENT_HELPER(name_, OnErrorEventHandlerNonNull)
#include "nsEventNameList.h"
#undef ERROR_EVENT
#undef DOCUMENT_ONLY_EVENT
#undef TOUCH_EVENT
#undef EVENT
#undef EVENT_HELPER
bool
nsINode::Contains(const nsINode* aOther) const