зеркало из https://github.com/mozilla/pjs.git
Re-landing fix related to regression bug 147811. Make declaring on* functions trigger the event listener registration code so that event handlers get registerd by simply declaring a global (or whatever the scope) function with the name of a event handler. r=caillon@aillon.org, sr=brendan@mozilla.org.
This commit is contained in:
Родитель
aa19a080f5
Коммит
a743394ec7
|
@ -697,7 +697,7 @@ nsEventListenerManager::AddEventListener(nsIDOMEventListener *aListener,
|
|||
//method to verify equality.
|
||||
nsCOMPtr<nsIScriptEventListener> regSel = do_QueryInterface(ls->mListener, &rv);
|
||||
if (NS_SUCCEEDED(rv) && regSel) {
|
||||
PRBool equal;
|
||||
PRBool equal;
|
||||
if (NS_SUCCEEDED(regSel->CheckIfEqual(sel, &equal)) && equal) {
|
||||
if (ls->mFlags & aFlags && ls->mSubType & aSubType) {
|
||||
found = PR_TRUE;
|
||||
|
@ -1214,10 +1214,10 @@ nsEventListenerManager::RegisterScriptEventListener(nsIScriptContext *aContext,
|
|||
nsCOMPtr<nsIJSContextStack> stack =
|
||||
do_GetService("@mozilla.org/js/xpc/ContextStack;1", &rv);
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
return rv;
|
||||
JSContext *cx;
|
||||
if (NS_FAILED(stack->Peek(&cx)))
|
||||
return nsnull;
|
||||
if (NS_FAILED(rv = stack->Peek(&cx)))
|
||||
return rv;
|
||||
|
||||
JSContext *current_cx = (JSContext *)aContext->GetNativeContext();
|
||||
|
||||
|
@ -1235,18 +1235,18 @@ nsEventListenerManager::RegisterScriptEventListener(nsIScriptContext *aContext,
|
|||
|
||||
nsCOMPtr<nsIClassInfo> classInfo = do_QueryInterface(aObject);
|
||||
|
||||
if (sAddListenerID == JSVAL_VOID) {
|
||||
if (sAddListenerID == JSVAL_VOID && cx) {
|
||||
sAddListenerID = STRING_TO_JSVAL(::JS_InternString(cx, "addEventListener"));
|
||||
}
|
||||
|
||||
rv = nsContentUtils::GetSecurityManager()->
|
||||
CheckPropertyAccess(cx, jsobj,
|
||||
"EventTarget",
|
||||
sAddListenerID,
|
||||
nsIXPCSecurityManager::ACCESS_SET_PROPERTY);
|
||||
if (NS_FAILED(rv)) {
|
||||
rv = nsContentUtils::GetSecurityManager()->
|
||||
CheckPropertyAccess(cx, jsobj,
|
||||
"EventTarget",
|
||||
sAddListenerID,
|
||||
nsIXPCSecurityManager::ACCESS_SET_PROPERTY);
|
||||
if (NS_FAILED(rv)) {
|
||||
// XXX set pending exception on the native call context?
|
||||
return rv;
|
||||
return rv;
|
||||
}
|
||||
}
|
||||
|
||||
return SetJSEventListener(aContext, aObject, aName, PR_FALSE);
|
||||
|
|
|
@ -3214,9 +3214,11 @@ nsWindowSH::AddProperty(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
|
|||
// exception, we must make sure that exception is propagated.
|
||||
|
||||
*_retval = PR_FALSE;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
return nsEventReceiverSH::AddProperty(wrapper, cx, obj, id, vp, _retval);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
|
@ -4502,7 +4504,7 @@ nsNodeSH::AddProperty(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
|
|||
doc->AddReference(content, wrapper);
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
return nsEventReceiverSH::AddProperty(wrapper, cx, obj, id, vp, _retval);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
|
@ -4615,7 +4617,9 @@ nsEventReceiverSH::NewResolve(nsIXPConnectWrappedNative *wrapper,
|
|||
JSContext *cx, JSObject *obj, jsval id,
|
||||
PRUint32 flags, JSObject **objp, PRBool *_retval)
|
||||
{
|
||||
if (!JSVAL_IS_STRING(id)) {
|
||||
// If we're assigning to an on* property, we'll register the handler
|
||||
// in our ::SetProperty() hook, so no need to do it here too.
|
||||
if (!JSVAL_IS_STRING(id) || (flags & JSRESOLVE_ASSIGNING)) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -4647,6 +4651,14 @@ nsEventReceiverSH::SetProperty(nsIXPConnectWrappedNative *wrapper,
|
|||
return RegisterCompileHandler(wrapper, cx, obj, id, PR_FALSE, &did_compile);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsEventReceiverSH::AddProperty(nsIXPConnectWrappedNative *wrapper,
|
||||
JSContext *cx, JSObject *obj, jsval id,
|
||||
jsval *vp, PRBool *_retval)
|
||||
{
|
||||
return nsEventReceiverSH::SetProperty(wrapper, cx, obj, id, vp, _retval);
|
||||
}
|
||||
|
||||
/*
|
||||
NS_IMETHODIMP
|
||||
nsEventReceiverSH::OnFinalize(...)
|
||||
|
@ -5292,7 +5304,7 @@ nsHTMLDocumentSH::DocumentOpen(JSContext *cx, JSObject *obj, uintN argc,
|
|||
nsresult rv =
|
||||
sXPConnect->GetWrappedNativeOfJSObject(cx, obj, getter_AddRefs(wrapper));
|
||||
if (NS_FAILED(rv)) {
|
||||
ThrowJSException(cx, rv);
|
||||
nsDOMClassInfo::ThrowJSException(cx, rv);
|
||||
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
|
|
@ -310,6 +310,8 @@ public:
|
|||
NS_IMETHOD SetProperty(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
|
||||
JSObject *obj, jsval id, jsval *vp,
|
||||
PRBool *_retval);
|
||||
NS_IMETHOD AddProperty(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
|
||||
JSObject *obj, jsval id, jsval *vp, PRBool *_retval);
|
||||
};
|
||||
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче