Bug 585228 - Move forwarding code out of the inner window's resolve hook and don't give it an addProperty hook since it doesn't need it. r=jst

This commit is contained in:
Blake Kaplan 2010-08-06 17:15:55 -07:00
parent 3b8d149022
commit c2aa4c1b09
2 changed files with 28 additions and 48 deletions

View File

@ -5385,34 +5385,15 @@ nsCommonWindowSH::SetProperty(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
}
NS_IMETHODIMP
nsCommonWindowSH::AddProperty(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
JSObject *obj, jsid id, jsval *vp,
PRBool *_retval)
nsOuterWindowSH::AddProperty(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
JSObject *obj, jsid id, jsval *vp,
PRBool *_retval)
{
nsGlobalWindow *win = nsGlobalWindow::FromWrapper(wrapper);
#ifdef DEBUG_SH_FORWARDING
{
nsDependentJSString str(::JS_ValueToString(cx, id));
if (win->IsInnerWindow()) {
#ifdef DEBUG_PRINT_INNER
printf("Property '%s' add on inner window %p\n",
NS_ConvertUTF16toUTF8(str).get(), (void *)win);
#endif
} else {
printf("Property '%s' add on outer window %p\n",
NS_ConvertUTF16toUTF8(str).get(), (void *)win);
}
}
#endif
JSObject *realObj;
wrapper->GetJSObject(&realObj);
if (win->IsOuterWindow() && obj == realObj) {
// XXXjst: Do security checks here when we remove the security
// checks on the inner window.
if (obj == realObj) {
nsGlobalWindow *innerWin = win->GetCurrentInnerWindowInternal();
JSObject *innerObj;
@ -6529,38 +6510,22 @@ ContentWindowGetter(JSContext *cx, JSObject *obj, uintN argc, jsval *argv,
}
PRBool
nsCommonWindowSH::sResolving = PR_FALSE;
nsOuterWindowSH::sResolving = PR_FALSE;
NS_IMETHODIMP
nsCommonWindowSH::NewResolve(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
JSObject *obj, jsid id, PRUint32 flags,
JSObject **objp, PRBool *_retval)
nsOuterWindowSH::NewResolve(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
JSObject *obj, jsid id, PRUint32 flags,
JSObject **objp, PRBool *_retval)
{
nsGlobalWindow *win = nsGlobalWindow::FromWrapper(wrapper);
#ifdef DEBUG_SH_FORWARDING
{
nsDependentJSString str(::JS_ValueToString(cx, id));
if (win->IsInnerWindow()) {
#ifdef DEBUG_PRINT_INNER
printf("Property '%s' resolve on inner window %p\n",
NS_ConvertUTF16toUTF8(str).get(), (void *)win);
#endif
} else {
printf("Property '%s' resolve on outer window %p\n",
NS_ConvertUTF16toUTF8(str).get(), (void *)win);
}
}
#endif
// Note, we won't forward resolve of the location property to the
// inner window, we need to deal with that one for the outer too
// since we've got special security protection code for that
// property. Also note that we want to enter this block even for
// native wrappers, so that we'll ensure an inner window to wrap
// against for the result of whatever we're getting.
if (win->IsOuterWindow() && id != sLocation_id) {
if (id != sLocation_id) {
// XXXjst: Do security checks here when we remove the security
// checks on the inner window.
@ -6641,6 +6606,17 @@ nsCommonWindowSH::NewResolve(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
}
}
return nsCommonWindowSH::NewResolve(wrapper, cx, obj, id, flags, objp,
_retval);
}
NS_IMETHODIMP
nsCommonWindowSH::NewResolve(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
JSObject *obj, jsid id, PRUint32 flags,
JSObject **objp, PRBool *_retval)
{
nsGlobalWindow *win = nsGlobalWindow::FromWrapper(wrapper);
if (!JSID_IS_STRING(id)) {
if (JSID_IS_INT(id) && !(flags & JSRESOLVE_ASSIGNING)) {
// If we're resolving a numeric property, treat that as if

View File

@ -513,8 +513,6 @@ protected:
JSObject *obj, JSString *str,
PRBool *did_resolve);
static PRBool sResolving;
public:
NS_IMETHOD PreCreate(nsISupports *nativeObj, JSContext *cx,
JSObject *globalObj, JSObject **parentObj);
@ -544,8 +542,6 @@ public:
JSObject *obj, jsid id, jsval *vp, PRBool *_retval);
NS_IMETHOD SetProperty(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
JSObject *obj, jsid id, jsval *vp, PRBool *_retval);
NS_IMETHOD AddProperty(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
JSObject *obj, jsid id, jsval *vp, PRBool *_retval);
NS_IMETHOD DelProperty(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
JSObject *obj, jsid id, jsval *vp, PRBool *_retval);
NS_IMETHOD NewResolve(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
@ -579,7 +575,14 @@ protected:
{
}
static PRBool sResolving;
public:
NS_IMETHOD AddProperty(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
JSObject *obj, jsid id, jsval *vp, PRBool *_retval);
NS_IMETHOD NewResolve(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
JSObject *obj, jsid id, PRUint32 flags,
JSObject **objp, PRBool *_retval);
NS_IMETHOD NewEnumerate(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
JSObject *obj, PRUint32 enum_op, jsval *statep,
jsid *idp, PRBool *_retval);
@ -604,6 +607,7 @@ protected:
}
public:
// We WANT_ADDPROPERTY, but are content to inherit it from nsEventReceiverSH.
NS_IMETHOD OuterObject(nsIXPConnectWrappedNative *wrapper, JSContext * cx,
JSObject * obj, JSObject * *_retval);