Bug 1137578. Remove JS_GetParent usage from mozJSSubscriptLoader. r=bholley

This commit is contained in:
Boris Zbarsky 2015-03-03 07:12:01 -05:00
Родитель d9cb8e8309
Коммит a5316a236e
1 изменённых файлов: 4 добавлений и 18 удалений

Просмотреть файл

@ -108,22 +108,6 @@ ReportError(JSContext *cx, const char *origMsg, nsIURI* uri)
return ReportError(cx, msg.get());
}
// There probably aren't actually any consumers that rely on having the full
// scope chain up the parent chain of "obj" (instead of just having obj and then
// the global), but we do this for now to preserve backwards compat.
static bool
BuildScopeChainForObject(JSContext *cx, HandleObject obj,
AutoObjectVector &scopeChain)
{
RootedObject cur(cx, obj);
for ( ; cur && !JS_IsGlobalObject(cur); cur = JS_GetParent(cur)) {
if (!scopeChain.append(cur)) {
return false;
}
}
return true;
}
nsresult
mozJSSubScriptLoader::ReadScript(nsIURI *uri, JSContext *cx, JSObject *targetObjArg,
const nsAString &charset, const char *uriStr,
@ -196,7 +180,8 @@ mozJSSubScriptLoader::ReadScript(nsIURI *uri, JSContext *cx, JSObject *targetObj
JS::Compile(cx, target_obj, options, srcBuf, script);
} else {
AutoObjectVector scopeChain(cx);
if (!BuildScopeChainForObject(cx, target_obj, scopeChain)) {
if (!JS_IsGlobalObject(target_obj) &&
!scopeChain.append(target_obj)) {
return NS_ERROR_OUT_OF_MEMORY;
}
// XXXbz do we really not care if the compile fails???
@ -211,7 +196,8 @@ mozJSSubScriptLoader::ReadScript(nsIURI *uri, JSContext *cx, JSObject *targetObj
JS::Compile(cx, target_obj, options, buf.get(), len, script);
} else {
AutoObjectVector scopeChain(cx);
if (!BuildScopeChainForObject(cx, target_obj, scopeChain)) {
if (!JS_IsGlobalObject(target_obj) &&
!scopeChain.append(target_obj)) {
return NS_ERROR_OUT_OF_MEMORY;
}
// XXXbz do we really not care if the compile fails???