This commit is contained in:
jst%mozilla.org 2007-12-04 03:53:00 +00:00
Родитель 8a1611b5d4
Коммит 57a8f89c74
1 изменённых файлов: 21 добавлений и 9 удалений

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

@ -4466,19 +4466,31 @@ nsWindowSH::GetProperty(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
// child frame in nsWindowSH::NewResolve() (*vp will tell us if // child frame in nsWindowSH::NewResolve() (*vp will tell us if
// that's the case). If *vp is a window object (i.e. a child // that's the case). If *vp is a window object (i.e. a child
// frame), return without doing a security check. // frame), return without doing a security check.
//
// Calling GetWrappedNativeOfJSObject() is not all that cheap, so
// only do that if the JSClass name is one that is likely to be a
// window object.
nsCOMPtr<nsIXPConnectWrappedNative> vpwrapper; const char *name = JS_GET_CLASS(cx, JSVAL_TO_OBJECT(*vp))->name;
sXPConnect->GetWrappedNativeOfJSObject(cx, JSVAL_TO_OBJECT(*vp),
getter_AddRefs(vpwrapper));
if (vpwrapper) { // The list of Window class names here need to be kept in sync
nsCOMPtr<nsIDOMWindow> window(do_QueryWrappedNative(vpwrapper)); // with the actual class names!
if ((*name == 'W' && strcmp(name, "Window") == 0) ||
(*name == 'C' && strcmp(name, "ChromeWindow") == 0) ||
(*name == 'M' && strcmp(name, "ModalContentWindow") == 0)) {
nsCOMPtr<nsIXPConnectWrappedNative> vpwrapper;
sXPConnect->GetWrappedNativeOfJSObject(cx, JSVAL_TO_OBJECT(*vp),
getter_AddRefs(vpwrapper));
if (window) { if (vpwrapper) {
// Yup, *vp is a window object, return early (*vp is already nsCOMPtr<nsIDOMWindow> window(do_QueryWrappedNative(vpwrapper));
// the window, so no need to wrap it again).
return NS_SUCCESS_I_DID_SOMETHING; if (window) {
// Yup, *vp is a window object, return early (*vp is already
// the window, so no need to wrap it again).
return NS_SUCCESS_I_DID_SOMETHING;
}
} }
} }
} }