зеркало из https://github.com/mozilla/pjs.git
Avoid calling nsXPConnect::GetWrapperFor in the common case of wrapping a global object in its own scope. r=jst
This commit is contained in:
Родитель
0d2ffef49a
Коммит
507771115c
|
@ -406,8 +406,10 @@ WrapObject(JSContext *cx, JSObject *parent, jsval *vp, XPCWrappedNative* wn)
|
|||
}
|
||||
}
|
||||
|
||||
XPCWrappedNativeScope *parentScope =
|
||||
XPCWrappedNativeScope::FindInJSObjectScope(cx, parent, nsnull, rt);
|
||||
XPCWrappedNative *parentwn =
|
||||
XPCWrappedNative::GetWrappedNativeOfJSObject(cx, parent);
|
||||
NS_ASSERTION(parentwn, "parent must be a wrapped native");
|
||||
XPCWrappedNativeScope *parentScope = parentwn->GetScope();
|
||||
|
||||
#ifdef DEBUG_mrbkap_off
|
||||
printf("Wrapping object at %p (%s) [%p]\n",
|
||||
|
|
|
@ -1507,6 +1507,27 @@ XPC_WN_JSOp_ThisObject(JSContext *cx, JSObject *obj)
|
|||
AutoPopJSContext popper(threadData->GetJSContextStack());
|
||||
popper.PushIfNotTop(cx);
|
||||
|
||||
JSObject* outerscope = scope;
|
||||
OBJ_TO_OUTER_OBJECT(cx, outerscope);
|
||||
if(!outerscope)
|
||||
return nsnull;
|
||||
|
||||
if(obj == outerscope)
|
||||
{
|
||||
// Fast-path for the common case: a window being wrapped in its own
|
||||
// scope. Check to see if the object actually needs a XOW, and then
|
||||
// give it one in its own scope.
|
||||
|
||||
if(!XPCCrossOriginWrapper::ClassNeedsXOW(obj->getClass()->name))
|
||||
return obj;
|
||||
|
||||
js::AutoValueRooter tvr(cx, OBJECT_TO_JSVAL(obj));
|
||||
if(!XPCCrossOriginWrapper::WrapObject(cx, scope, tvr.addr()))
|
||||
return nsnull;
|
||||
|
||||
return JSVAL_TO_OBJECT(tvr.value());
|
||||
}
|
||||
|
||||
nsIScriptSecurityManager* secMan = XPCWrapper::GetSecurityManager();
|
||||
if(!secMan)
|
||||
{
|
||||
|
|
Загрузка…
Ссылка в новой задаче