mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1088228 part 3. Use the new nsJSUtils API for event handlers. r=peterv
This commit is contained in:
parent
321060bfa7
commit
f90685062b
@ -863,18 +863,6 @@ EventListenerManager::CompileEventHandlerInternal(Listener* aListener,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
JS::AutoObjectVector scopeChain(cx);
|
|
||||||
{ // scope for curScope
|
|
||||||
// We append all the non-globals on our desired scope chain.
|
|
||||||
JS::Rooted<JSObject*> curScope(cx, &v.toObject());
|
|
||||||
while (curScope && !JS_IsGlobalObject(curScope)) {
|
|
||||||
if (!scopeChain.append(curScope)) {
|
|
||||||
return NS_ERROR_OUT_OF_MEMORY;
|
|
||||||
}
|
|
||||||
curScope = JS_GetParent(curScope);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (addonId) {
|
if (addonId) {
|
||||||
JS::Rooted<JSObject*> vObj(cx, &v.toObject());
|
JS::Rooted<JSObject*> vObj(cx, &v.toObject());
|
||||||
JS::Rooted<JSObject*> addonScope(cx, xpc::GetAddonScope(cx, vObj, addonId));
|
JS::Rooted<JSObject*> addonScope(cx, xpc::GetAddonScope(cx, vObj, addonId));
|
||||||
@ -882,14 +870,9 @@ EventListenerManager::CompileEventHandlerInternal(Listener* aListener,
|
|||||||
return NS_ERROR_FAILURE;
|
return NS_ERROR_FAILURE;
|
||||||
}
|
}
|
||||||
JSAutoCompartment ac(cx, addonScope);
|
JSAutoCompartment ac(cx, addonScope);
|
||||||
for (size_t i = 0; i < scopeChain.length(); ++i) {
|
|
||||||
if (!JS_WrapObject(cx, scopeChain[i])) {
|
|
||||||
return NS_ERROR_FAILURE;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// And wrap v as well, since scopeChain might be empty so we can't
|
// Wrap our event target into the addon scope, since that's where we want to
|
||||||
// reliably use it to enter a compartment.
|
// do all our work.
|
||||||
if (!JS_WrapValue(cx, &v)) {
|
if (!JS_WrapValue(cx, &v)) {
|
||||||
return NS_ERROR_FAILURE;
|
return NS_ERROR_FAILURE;
|
||||||
}
|
}
|
||||||
@ -897,6 +880,16 @@ EventListenerManager::CompileEventHandlerInternal(Listener* aListener,
|
|||||||
JS::Rooted<JSObject*> target(cx, &v.toObject());
|
JS::Rooted<JSObject*> target(cx, &v.toObject());
|
||||||
JSAutoCompartment ac(cx, target);
|
JSAutoCompartment ac(cx, target);
|
||||||
|
|
||||||
|
// Now that we've entered the compartment we actually care about, create our
|
||||||
|
// scope chain. Note that we start with |element|, not aElement, because
|
||||||
|
// mTarget is different from aElement in the <body> case, where mTarget is a
|
||||||
|
// Window, and in that case we do not want the scope chain to include the body
|
||||||
|
// or the document.
|
||||||
|
JS::AutoObjectVector scopeChain(cx);
|
||||||
|
if (!nsJSUtils::GetScopeChainForElement(cx, element, scopeChain)) {
|
||||||
|
return NS_ERROR_OUT_OF_MEMORY;
|
||||||
|
}
|
||||||
|
|
||||||
nsDependentAtomString str(attrName);
|
nsDependentAtomString str(attrName);
|
||||||
// Most of our names are short enough that we don't even have to malloc
|
// Most of our names are short enough that we don't even have to malloc
|
||||||
// the JS string stuff, so don't worry about playing games with
|
// the JS string stuff, so don't worry about playing games with
|
||||||
|
Loading…
Reference in New Issue
Block a user