Bug 479288 - Move wrapping back into the outerObject hook. r+sr=bent/jst

This commit is contained in:
Blake Kaplan 2009-02-25 17:32:09 -08:00
parent 1a4ca1407d
commit 14658eb0ed
3 changed files with 14 additions and 20 deletions

View File

@ -831,7 +831,8 @@ js_ComputeGlobalThis(JSContext *cx, JSBool lazy, jsval *argv)
thisp = parent;
}
OBJ_TO_OUTER_OBJECT(cx, thisp);
/* Some objects (e.g., With) delegate 'this' to another object. */
thisp = OBJ_THIS_OBJECT(cx, thisp);
if (!thisp)
return NULL;
argv[-1] = OBJECT_TO_JSVAL(thisp);
@ -855,18 +856,11 @@ ComputeThis(JSContext *cx, JSBool lazy, jsval *argv)
return js_ComputeGlobalThis(cx, lazy, argv);
}
OBJ_TO_OUTER_OBJECT(cx, thisp);
/* Some objects (e.g., With) delegate 'this' to another object. */
thisp = OBJ_THIS_OBJECT(cx, thisp);
if (!thisp)
return NULL;
argv[-1] = OBJECT_TO_JSVAL(thisp);
if (thisp->map->ops->thisObject) {
/* Some objects (e.g., With) delegate 'this' to another object. */
thisp = thisp->map->ops->thisObject(cx, thisp);
if (!thisp)
return NULL;
argv[-1] = OBJECT_TO_JSVAL(thisp);
}
}
return thisp;
}
@ -1551,7 +1545,7 @@ js_Execute(JSContext *cx, JSObject *chain, JSScript *script,
cx->fp = &frame;
if (!down) {
OBJ_TO_OUTER_OBJECT(cx, frame.thisp);
frame.thisp = OBJ_THIS_OBJECT(cx, frame.thisp);
if (!frame.thisp) {
ok = JS_FALSE;
goto out2;

View File

@ -169,7 +169,6 @@ obj_getSlot(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
uintN attrs;
JSObject *pobj;
JSClass *clasp;
JSExtendedClass *xclasp;
slot = (uint32) JSVAL_TO_INT(id);
if (id == INT_TO_JSVAL(JSSLOT_PROTO)) {
@ -190,14 +189,11 @@ obj_getSlot(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
if (clasp == &js_CallClass || clasp == &js_BlockClass) {
/* Censor activations and lexical scopes per ECMA-262. */
*vp = JSVAL_NULL;
} else if (clasp->flags & JSCLASS_IS_EXTENDED) {
xclasp = (JSExtendedClass *) clasp;
if (xclasp->outerObject) {
pobj = xclasp->outerObject(cx, pobj);
if (!pobj)
return JS_FALSE;
*vp = OBJECT_TO_JSVAL(pobj);
}
} else if (pobj->map->ops->thisObject) {
pobj = pobj->map->ops->thisObject(cx, pobj);
if (!pobj)
return JS_FALSE;
*vp = OBJECT_TO_JSVAL(pobj);
}
}
return JS_TRUE;

View File

@ -1320,6 +1320,10 @@ XPC_WN_JSOp_ThisObject(JSContext *cx, JSObject *obj)
if(!XPCPerThreadData::IsMainThread(cx))
return obj;
OBJ_TO_OUTER_OBJECT(cx, obj);
if(!obj)
return nsnull;
JSObject *scope = JS_GetScopeChain(cx);
if(!scope)
{