Bug 780146 - Part a: Move window._content into IDL; r=jst

This commit is contained in:
Ms2ger 2012-08-09 09:16:09 +02:00
parent 316662d3d8
commit 198f4a2ae7
3 changed files with 13 additions and 47 deletions

View File

@ -1800,7 +1800,6 @@ 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;
@ -2077,7 +2076,6 @@ 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");
@ -5204,7 +5202,6 @@ 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;
@ -6962,18 +6959,6 @@ 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
};
@ -7306,36 +7291,6 @@ 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))) {

View File

@ -3070,6 +3070,14 @@ 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)
{
@ -3114,7 +3122,7 @@ nsGlobalWindow::GetContent(nsIDOMWindow** aContent)
}
nsCOMPtr<nsIDOMWindow> domWindow(do_GetInterface(primaryContent));
NS_IF_ADDREF(*aContent = domWindow);
domWindow.forget(aContent);
return NS_OK;
}

View File

@ -5,7 +5,7 @@
#include "domstubs.idl"
[scriptable, uuid(6652c4d2-6b49-424b-aaf9-91f91006fab7)]
[scriptable, uuid(1f4da4d4-1d72-4709-8207-3665dbaac4b4)]
interface nsIDOMJSWindow : nsISupports
{
void dump(in DOMString str);
@ -76,4 +76,7 @@ interface nsIDOMJSWindow : nsISupports
* This property is "replaceable" in JavaScript.
*/
readonly attribute nsIDOMWindow frames;
[binaryname(ContentForCompat)]
readonly attribute nsIDOMWindow _content;
};