From 0ec3bd25cf5f50b5704531c780d145a43fe49a8f Mon Sep 17 00:00:00 2001 From: Ms2ger Date: Sat, 11 Aug 2012 18:12:54 +0200 Subject: [PATCH] Backout changeset c77acb256aec for failing to work. --- dom/base/nsDOMClassInfo.cpp | 45 ++++++++++++++++++++++++++ dom/base/nsGlobalWindow.cpp | 8 ----- dom/interfaces/base/nsIDOMJSWindow.idl | 5 +-- 3 files changed, 46 insertions(+), 12 deletions(-) diff --git a/dom/base/nsDOMClassInfo.cpp b/dom/base/nsDOMClassInfo.cpp index b04892d2271c..113fe53e82db 100644 --- a/dom/base/nsDOMClassInfo.cpp +++ b/dom/base/nsDOMClassInfo.cpp @@ -1821,6 +1821,7 @@ jsid nsDOMClassInfo::sParent_id = JSID_VOID; jsid nsDOMClassInfo::sScrollbars_id = JSID_VOID; jsid nsDOMClassInfo::sLocation_id = JSID_VOID; jsid nsDOMClassInfo::sConstructor_id = JSID_VOID; +jsid nsDOMClassInfo::s_content_id = JSID_VOID; jsid nsDOMClassInfo::sContent_id = JSID_VOID; jsid nsDOMClassInfo::sMenubar_id = JSID_VOID; jsid nsDOMClassInfo::sToolbar_id = JSID_VOID; @@ -2097,6 +2098,7 @@ nsDOMClassInfo::DefineStaticJSVals(JSContext *cx) SET_JSID_TO_STRING(sScrollbars_id, cx, "scrollbars"); SET_JSID_TO_STRING(sLocation_id, cx, "location"); SET_JSID_TO_STRING(sConstructor_id, cx, "constructor"); + SET_JSID_TO_STRING(s_content_id, cx, "_content"); SET_JSID_TO_STRING(sContent_id, cx, "content"); SET_JSID_TO_STRING(sMenubar_id, cx, "menubar"); SET_JSID_TO_STRING(sToolbar_id, cx, "toolbar"); @@ -5212,6 +5214,7 @@ nsDOMClassInfo::ShutDown() sScrollbars_id = JSID_VOID; sLocation_id = JSID_VOID; sConstructor_id = JSID_VOID; + s_content_id = JSID_VOID; sContent_id = JSID_VOID; sMenubar_id = JSID_VOID; sToolbar_id = JSID_VOID; @@ -6949,6 +6952,18 @@ nsWindowSH::GlobalResolve(nsGlobalWindow *aWin, JSContext *cx, return rv; } +// Native code for window._content getter, this simply maps +// window._content to window.content for backwards compatibility only. +static JSBool +ContentWindowGetter(JSContext *cx, unsigned argc, jsval *vp) +{ + JSObject *obj = JS_THIS_OBJECT(cx, vp); + if (!obj) + return JS_FALSE; + + return ::JS_GetProperty(cx, obj, "content", vp); +} + static JSNewResolveOp sOtherResolveFuncs[] = { mozilla::dom::workers::ResolveWorkerClasses }; @@ -7280,6 +7295,36 @@ nsWindowSH::NewResolve(nsIXPConnectWrappedNative *wrapper, JSContext *cx, } } + if (s_content_id == id) { + // Map window._content to window.content for backwards + // compatibility, this should spit out an message on the JS + // console. + + JSObject *windowObj = win->GetGlobalJSObject(); + + JSAutoRequest ar(cx); + + JSFunction *fun = ::JS_NewFunction(cx, ContentWindowGetter, 0, 0, + windowObj, "_content"); + if (!fun) { + return NS_ERROR_OUT_OF_MEMORY; + } + + JSObject *funObj = ::JS_GetFunctionObject(fun); + + if (!::JS_DefinePropertyById(cx, windowObj, id, JSVAL_VOID, + JS_DATA_TO_FUNC_PTR(JSPropertyOp, funObj), + nullptr, + JSPROP_ENUMERATE | JSPROP_GETTER | + JSPROP_SHARED)) { + return NS_ERROR_FAILURE; + } + + *objp = obj; + + return NS_OK; + } + if (flags & JSRESOLVE_ASSIGNING) { if (IsReadonlyReplaceable(id) || (!(flags & JSRESOLVE_QUALIFIED) && IsWritableReplaceable(id))) { diff --git a/dom/base/nsGlobalWindow.cpp b/dom/base/nsGlobalWindow.cpp index afa07f82656f..a88830f850d9 100644 --- a/dom/base/nsGlobalWindow.cpp +++ b/dom/base/nsGlobalWindow.cpp @@ -3085,14 +3085,6 @@ nsGlobalWindow::GetTopImpl(nsIDOMWindow** aTop, bool aScriptable) return NS_OK; } -// Map window._content to window.content for backwards compatibility, this -// should spit out an message on the JS console. -NS_IMETHODIMP -nsGlobalWindow::GetContentForCompat(nsIDOMWindow** aContent) -{ - return GetContent(aContent); -} - NS_IMETHODIMP nsGlobalWindow::GetContent(nsIDOMWindow** aContent) { diff --git a/dom/interfaces/base/nsIDOMJSWindow.idl b/dom/interfaces/base/nsIDOMJSWindow.idl index d4113cb2fd29..5c5386e38a65 100644 --- a/dom/interfaces/base/nsIDOMJSWindow.idl +++ b/dom/interfaces/base/nsIDOMJSWindow.idl @@ -5,7 +5,7 @@ #include "domstubs.idl" -[scriptable, uuid(1f4da4d4-1d72-4709-8207-3665dbaac4b4)] +[scriptable, uuid(6652c4d2-6b49-424b-aaf9-91f91006fab7)] interface nsIDOMJSWindow : nsISupports { void dump(in DOMString str); @@ -76,7 +76,4 @@ interface nsIDOMJSWindow : nsISupports * This property is "replaceable" in JavaScript. */ readonly attribute nsIDOMWindow frames; - - [binaryname(ContentForCompat)] - readonly attribute nsIDOMWindow _content; };