mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Missed a cset (33addcc556b8) in backout
This commit is contained in:
parent
59422fe649
commit
ed7ada6b7e
@ -4892,8 +4892,8 @@ nsDOMClassInfo::ShutDown()
|
||||
// Window helper
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsInnerWindowSH::PreCreate(nsISupports *nativeObj, JSContext *cx,
|
||||
JSObject *globalObj, JSObject **parentObj)
|
||||
nsCommonWindowSH::PreCreate(nsISupports *nativeObj, JSContext *cx,
|
||||
JSObject *globalObj, JSObject **parentObj)
|
||||
{
|
||||
// Normally ::PreCreate() is used to give XPConnect the parent
|
||||
// object for the object that's being wrapped, this parent object is
|
||||
@ -4911,30 +4911,25 @@ nsInnerWindowSH::PreCreate(nsISupports *nativeObj, JSContext *cx,
|
||||
NS_ASSERTION(sgo, "nativeObj not a global object!");
|
||||
|
||||
nsGlobalWindow *win = nsGlobalWindow::FromSupports(nativeObj);
|
||||
JSObject *winObj = win->FastGetGlobalJSObject();
|
||||
if (!winObj) {
|
||||
NS_ASSERTION(win->GetOuterWindowInternal()->IsCreatingInnerWindow(),
|
||||
"should have a JS object by this point");
|
||||
return NS_OK;
|
||||
|
||||
if (win->IsOuterWindow()) {
|
||||
win->EnsureInnerWindow();
|
||||
}
|
||||
|
||||
*parentObj = winObj;
|
||||
return NS_OK;
|
||||
}
|
||||
if (sgo) {
|
||||
*parentObj = sgo->GetGlobalJSObject();
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsOuterWindowSH::PreCreate(nsISupports *nativeObj, JSContext *cx,
|
||||
JSObject *globalObj, JSObject **parentObj)
|
||||
{
|
||||
nsCOMPtr<nsIScriptGlobalObject> sgo(do_QueryInterface(nativeObj));
|
||||
NS_ASSERTION(sgo, "nativeObj not a global object!");
|
||||
|
||||
nsGlobalWindow *win = nsGlobalWindow::FromSupports(nativeObj);
|
||||
if (!win->EnsureInnerWindow()) {
|
||||
return NS_ERROR_FAILURE;
|
||||
if (*parentObj) {
|
||||
return win->IsChromeWindow() ? NS_OK : NS_SUCCESS_NEEDS_XOW;
|
||||
}
|
||||
}
|
||||
|
||||
*parentObj = win->GetCurrentInnerWindowInternal()->FastGetGlobalJSObject();
|
||||
// We're most likely being called when the global object is
|
||||
// created, at that point we won't get a nsIScriptContext but we
|
||||
// know we're called on the correct context so we return globalObj
|
||||
|
||||
*parentObj = globalObj;
|
||||
|
||||
return win->IsChromeWindow() ? NS_OK : NS_SUCCESS_NEEDS_XOW;
|
||||
}
|
||||
|
||||
@ -6667,33 +6662,33 @@ nsCommonWindowSH::NewResolve(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
|
||||
my_cx = (JSContext *)my_context->GetNativeContext();
|
||||
}
|
||||
|
||||
JSBool ok = JS_TRUE;
|
||||
jsval exn = JSVAL_VOID;
|
||||
if (win->IsInnerWindow()) {
|
||||
JSBool ok;
|
||||
jsval exn;
|
||||
{
|
||||
JSAutoRequest transfer(my_cx);
|
||||
|
||||
JSObject *realObj;
|
||||
wrapper->GetJSObject(&realObj);
|
||||
|
||||
|
||||
// Don't resolve standard classes on XPCNativeWrapper etc, only
|
||||
// resolve them if we're resolving on the real global object.
|
||||
ok = obj == realObj ?
|
||||
::JS_ResolveStandardClass(my_cx, obj, id, &did_resolve) :
|
||||
JS_TRUE;
|
||||
|
||||
|
||||
if (!ok) {
|
||||
// Trust the JS engine (or the script security manager) to set
|
||||
// the exception in the JS engine.
|
||||
|
||||
|
||||
if (!JS_GetPendingException(my_cx, &exn)) {
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
}
|
||||
|
||||
|
||||
// Return NS_OK to avoid stomping over the exception that was passed
|
||||
// down from the ResolveStandardClass call.
|
||||
// Note that the order of the JS_ClearPendingException and
|
||||
// JS_SetPendingException is important in the case that my_cx == cx.
|
||||
|
||||
|
||||
JS_ClearPendingException(my_cx);
|
||||
}
|
||||
}
|
||||
|
@ -514,6 +514,8 @@ protected:
|
||||
PRBool *did_resolve);
|
||||
|
||||
public:
|
||||
NS_IMETHOD PreCreate(nsISupports *nativeObj, JSContext *cx,
|
||||
JSObject *globalObj, JSObject **parentObj);
|
||||
#ifdef DEBUG
|
||||
NS_IMETHOD PostCreate(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
|
||||
JSObject *obj)
|
||||
@ -576,8 +578,6 @@ protected:
|
||||
static PRBool sResolving;
|
||||
|
||||
public:
|
||||
NS_IMETHOD PreCreate(nsISupports *nativeObj, JSContext *cx,
|
||||
JSObject *globalObj, JSObject **parentObj);
|
||||
NS_IMETHOD AddProperty(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
|
||||
JSObject *obj, jsid id, jsval *vp, PRBool *_retval);
|
||||
NS_IMETHOD NewResolve(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
|
||||
@ -607,8 +607,6 @@ protected:
|
||||
}
|
||||
|
||||
public:
|
||||
NS_IMETHOD PreCreate(nsISupports *nativeObj, JSContext *cx,
|
||||
JSObject *globalObj, JSObject **parentObj);
|
||||
// We WANT_ADDPROPERTY, but are content to inherit it from nsEventReceiverSH.
|
||||
NS_IMETHOD OuterObject(nsIXPConnectWrappedNative *wrapper, JSContext * cx,
|
||||
JSObject * obj, JSObject * *_retval);
|
||||
|
@ -1609,6 +1609,9 @@ nsGlobalWindow::SetNewDocument(nsIDocument* aDocument,
|
||||
if (IsFrozen()) {
|
||||
// This outer is now getting its first inner, thaw the outer now
|
||||
// that it's ready and is getting an inner window.
|
||||
mContext->CreateOuterObject(this, aDocument->NodePrincipal());
|
||||
mContext->DidInitializeContext();
|
||||
mJSObject = (JSObject *)mContext->GetNativeGlobal();
|
||||
|
||||
Thaw();
|
||||
}
|
||||
@ -1815,6 +1818,7 @@ nsGlobalWindow::SetNewDocument(nsIDocument* aDocument,
|
||||
getter_AddRefs(holder));
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv) && newGlobal && holder,
|
||||
"Failed to get script global and holder");
|
||||
newInnerWindow->mJSObject = (JSObject *)newGlobal;
|
||||
|
||||
mCreatingInnerWindow = PR_FALSE;
|
||||
Thaw();
|
||||
@ -1868,20 +1872,6 @@ nsGlobalWindow::SetNewDocument(nsIDocument* aDocument,
|
||||
}
|
||||
|
||||
mInnerWindow = newInnerWindow;
|
||||
|
||||
if (!mJSObject) {
|
||||
mContext->CreateOuterObject(this, newInnerWindow);
|
||||
mContext->DidInitializeContext();
|
||||
mJSObject = (JSObject *)mContext->GetNativeGlobal();
|
||||
} else {
|
||||
// XXX New global object and brain transplant!
|
||||
nsIXPConnect *xpc = nsContentUtils::XPConnect();
|
||||
nsCOMPtr<nsIXPConnectJSObjectHolder> holder;
|
||||
xpc->ReparentWrappedNativeIfFound(cx, currentInner->mJSObject,
|
||||
newInnerWindow->mJSObject,
|
||||
ToSupports(this),
|
||||
getter_AddRefs(holder));
|
||||
}
|
||||
}
|
||||
|
||||
if (!aState && !reUseInnerWindow) {
|
||||
@ -1939,6 +1929,37 @@ nsGlobalWindow::SetNewDocument(nsIDocument* aDocument,
|
||||
// check xpc here.
|
||||
nsIXPConnect *xpc = nsContentUtils::XPConnect();
|
||||
|
||||
nsCOMPtr<nsIXPConnectWrappedNative> wrapper;
|
||||
if (aState) {
|
||||
// Restoring from session history.
|
||||
|
||||
nsCOMPtr<WindowStateHolder> wsh = do_QueryInterface(aState);
|
||||
NS_ASSERTION(wsh, "What kind of weird state are you giving me here?");
|
||||
|
||||
// Restore the prototype for the Window/ChromeWindow class in
|
||||
// the outer window scope.
|
||||
nsCOMPtr<nsIClassInfo> ci =
|
||||
do_QueryInterface((nsIScriptGlobalObject *)this);
|
||||
|
||||
rv = xpc->RestoreWrappedNativePrototype(cx, mJSObject, ci,
|
||||
wsh->GetOuterProto());
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
// Refresh the outer window's prototype to what it was when the
|
||||
// window state was saved. This will make the outer window
|
||||
// object (and wrapper) pick up the prototype it had when the
|
||||
// window state was saved. This means Object.prototype etc from
|
||||
// the old inner will again be on the outer window's prototype
|
||||
// chain.
|
||||
|
||||
rv = xpc->GetWrappedNativeOfJSObject(cx, mJSObject,
|
||||
getter_AddRefs(wrapper));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
rv = wrapper->RefreshPrototype();
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
}
|
||||
|
||||
if (aDocument) {
|
||||
aDocument->SetScriptGlobalObject(newInnerWindow);
|
||||
}
|
||||
@ -2004,10 +2025,11 @@ nsGlobalWindow::SetNewDocument(nsIDocument* aDocument,
|
||||
mContext->GC();
|
||||
mContext->DidInitializeContext();
|
||||
|
||||
nsCOMPtr<nsIXPConnectWrappedNative> wrapper;
|
||||
rv = xpc->GetWrappedNativeOfJSObject(cx, mJSObject,
|
||||
getter_AddRefs(wrapper));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
if (!wrapper) {
|
||||
rv = xpc->GetWrappedNativeOfJSObject(cx, mJSObject,
|
||||
getter_AddRefs(wrapper));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
}
|
||||
|
||||
rv = xpc->UpdateXOWs((JSContext *)GetContextInternal()->GetNativeContext(),
|
||||
wrapper, nsIXPConnect::XPC_XOW_NAVIGATED);
|
||||
|
@ -383,11 +383,6 @@ public:
|
||||
// Make sure this matches the casts we do in QueryInterface().
|
||||
return (nsGlobalWindow *)(nsIScriptGlobalObject *)supports;
|
||||
}
|
||||
static nsISupports *ToSupports(nsGlobalWindow *win)
|
||||
{
|
||||
// Make sure this matches the casts we do in QueryInterface().
|
||||
return (nsISupports *)(nsIScriptGlobalObject *)win;
|
||||
}
|
||||
static nsGlobalWindow *FromWrapper(nsIXPConnectWrappedNative *wrapper)
|
||||
{
|
||||
return FromSupports(wrapper->Native());
|
||||
|
@ -344,11 +344,11 @@ public:
|
||||
* @param aGlobalObject The script global object to use as our global.
|
||||
*/
|
||||
virtual nsresult CreateOuterObject(nsIScriptGlobalObject *aGlobalObject,
|
||||
nsIScriptGlobalObject *aCurrentInner) = 0;
|
||||
nsIPrincipal *aPrincipal) = 0;
|
||||
|
||||
/**
|
||||
* Prepares this context for use with the current inner window for the
|
||||
* context's global object. This must be called after CreateOuterObject.
|
||||
* context's global object. This must be called after InitOuterWindow.
|
||||
*/
|
||||
virtual nsresult InitOuterWindow() = 0;
|
||||
|
||||
|
@ -2582,7 +2582,7 @@ nsJSContext::ConnectToInner(nsIScriptGlobalObject *aNewInner, void *aOuterGlobal
|
||||
{
|
||||
NS_ENSURE_ARG(aNewInner);
|
||||
JSObject *newInnerJSObject = (JSObject *)aNewInner->GetScriptGlobal(JAVASCRIPT);
|
||||
JSObject *outerGlobal = (JSObject *)aOuterGlobal;
|
||||
JSObject *myobject = (JSObject *)aOuterGlobal;
|
||||
|
||||
// Make the inner and outer window both share the same
|
||||
// prototype. The prototype we share is the outer window's
|
||||
@ -2603,18 +2603,12 @@ nsJSContext::ConnectToInner(nsIScriptGlobalObject *aNewInner, void *aOuterGlobal
|
||||
// Object.prototype. This way the outer also gets the benefits
|
||||
// of the global scope polluter, and the inner window's
|
||||
// Object.prototype.
|
||||
JSObject *proto = JS_GetPrototype(mContext, outerGlobal);
|
||||
JSObject *innerProto = JS_GetPrototype(mContext, newInnerJSObject);
|
||||
JSObject *innerProtoProto = JS_GetPrototype(mContext, innerProto);
|
||||
JSObject *proto = ::JS_GetPrototype(mContext, myobject);
|
||||
JSObject *innerProto = ::JS_GetPrototype(mContext, newInnerJSObject);
|
||||
JSObject *innerProtoProto = ::JS_GetPrototype(mContext, innerProto);
|
||||
|
||||
JS_SetPrototype(mContext, newInnerJSObject, proto);
|
||||
JS_SetPrototype(mContext, proto, innerProtoProto);
|
||||
|
||||
// Now that we're connecting the outer global to the inner one,
|
||||
// we must have transplanted it. The JS engine tries to maintain
|
||||
// the global object's compartment as its default compartment,
|
||||
// so update that now since it might have changed.
|
||||
JS_SetGlobalObject(mContext, outerGlobal);
|
||||
::JS_SetPrototype(mContext, newInnerJSObject, proto);
|
||||
::JS_SetPrototype(mContext, proto, innerProtoProto);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@ -2654,8 +2648,11 @@ nsJSContext::InitContext()
|
||||
|
||||
nsresult
|
||||
nsJSContext::CreateOuterObject(nsIScriptGlobalObject *aGlobalObject,
|
||||
nsIScriptGlobalObject *aCurrentInner)
|
||||
nsIPrincipal *aPrincipal)
|
||||
{
|
||||
NS_PRECONDITION(!JS_GetGlobalObject(mContext),
|
||||
"Outer window already initialized");
|
||||
|
||||
nsCOMPtr<nsIDOMChromeWindow> chromeWindow(do_QueryInterface(aGlobalObject));
|
||||
PRUint32 flags = 0;
|
||||
|
||||
@ -2669,21 +2666,18 @@ nsJSContext::CreateOuterObject(nsIScriptGlobalObject *aGlobalObject,
|
||||
// need to preserve the <!-- script hiding hack from JS-in-HTML daze
|
||||
// (introduced in 1995 for graceful script degradation in Netscape 1,
|
||||
// Mosaic, and other pre-JS browsers).
|
||||
JS_SetOptions(mContext, JS_GetOptions(mContext) | JSOPTION_XML);
|
||||
::JS_SetOptions(mContext, ::JS_GetOptions(mContext) | JSOPTION_XML);
|
||||
}
|
||||
|
||||
nsIXPConnect *xpc = nsContentUtils::XPConnect();
|
||||
nsCOMPtr<nsIXPConnectJSObjectHolder> holder;
|
||||
nsresult rv = xpc->WrapNative(mContext, aCurrentInner->GetGlobalJSObject(),
|
||||
aGlobalObject, NS_GET_IID(nsISupports),
|
||||
getter_AddRefs(holder));
|
||||
nsresult rv =
|
||||
xpc->InitClassesWithNewWrappedGlobal(mContext, aGlobalObject,
|
||||
NS_GET_IID(nsISupports),
|
||||
aPrincipal, EmptyCString(),
|
||||
flags, getter_AddRefs(holder));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
// Force our context's global object to be the outer.
|
||||
JSObject *globalObj;
|
||||
holder->GetJSObject(&globalObj);
|
||||
JS_SetGlobalObject(mContext, globalObj);
|
||||
|
||||
// Hold a strong reference to the wrapper for the global to avoid
|
||||
// rooting and unrooting the global object every time its AddRef()
|
||||
// or Release() methods are called
|
||||
@ -2702,9 +2696,14 @@ nsJSContext::InitOuterWindow()
|
||||
// properties will be forwarded to the inner window.
|
||||
JS_ClearScope(mContext, global);
|
||||
|
||||
nsresult rv = NS_OK;
|
||||
// Now that the inner and outer windows are connected, tell XPConnect to
|
||||
// re-initialize the prototypes on the outer window's scope.
|
||||
nsIXPConnect *xpc = nsContentUtils::XPConnect();
|
||||
nsresult rv = xpc->InitClassesForOuterObject(mContext, global);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsCOMPtr<nsIClassInfo> ci(do_QueryInterface(sgo));
|
||||
|
||||
if (ci) {
|
||||
jsval v;
|
||||
|
||||
|
@ -142,7 +142,7 @@ public:
|
||||
void *aOuterGlobal);
|
||||
virtual nsresult InitContext();
|
||||
virtual nsresult CreateOuterObject(nsIScriptGlobalObject *aGlobalObject,
|
||||
nsIScriptGlobalObject *aCurrentInner);
|
||||
nsIPrincipal *aPrincipal);
|
||||
virtual nsresult InitOuterWindow();
|
||||
virtual PRBool IsContextInitialized();
|
||||
virtual void FinalizeContext();
|
||||
|
@ -1728,8 +1728,12 @@ return_wrapper:
|
||||
{
|
||||
XPCWrappedNativeProto* wrapper_proto =
|
||||
isWN ? wrapper->GetProto() : GetSlimWrapperProto(cur);
|
||||
XPCWrappedNativeScope* wrapper_scope =
|
||||
wrapper_proto ? wrapper_proto->GetScope() :
|
||||
wrapper->GetScope();
|
||||
if(proto != wrapper_proto &&
|
||||
(!protoClassInfo || !wrapper_proto ||
|
||||
(proto->GetScope() != wrapper_scope ||
|
||||
!protoClassInfo || !wrapper_proto ||
|
||||
protoClassInfo != wrapper_proto->GetClassInfo()))
|
||||
continue;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user