mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-12-25 17:43:44 +00:00
Bug 783416 - Stop saving the prototype in WindowStateHolder (r=mrbkap)
This commit is contained in:
parent
2c43c45c0c
commit
7ea7c080cb
@ -1602,24 +1602,16 @@ public:
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
WindowStateHolder(nsGlobalWindow *aWindow,
|
||||
nsIXPConnectJSObjectHolder *aHolder,
|
||||
nsIXPConnectJSObjectHolder *aOuterProto,
|
||||
nsIXPConnectJSObjectHolder *aOuterRealProto);
|
||||
nsIXPConnectJSObjectHolder *aHolder);
|
||||
|
||||
nsGlobalWindow* GetInnerWindow() { return mInnerWindow; }
|
||||
nsIXPConnectJSObjectHolder *GetInnerWindowHolder()
|
||||
{ return mInnerWindowHolder; }
|
||||
|
||||
nsIXPConnectJSObjectHolder* GetOuterProto() { return mOuterProto; }
|
||||
nsIXPConnectJSObjectHolder* GetOuterRealProto() { return mOuterRealProto; }
|
||||
|
||||
void DidRestoreWindow()
|
||||
{
|
||||
mInnerWindow = nullptr;
|
||||
|
||||
mInnerWindowHolder = nullptr;
|
||||
mOuterProto = nullptr;
|
||||
mOuterRealProto = nullptr;
|
||||
}
|
||||
|
||||
protected:
|
||||
@ -1629,19 +1621,13 @@ protected:
|
||||
// We hold onto this to make sure the inner window doesn't go away. The outer
|
||||
// window ends up recalculating it anyway.
|
||||
nsCOMPtr<nsIXPConnectJSObjectHolder> mInnerWindowHolder;
|
||||
nsCOMPtr<nsIXPConnectJSObjectHolder> mOuterProto;
|
||||
nsCOMPtr<nsIXPConnectJSObjectHolder> mOuterRealProto;
|
||||
};
|
||||
|
||||
NS_DEFINE_STATIC_IID_ACCESSOR(WindowStateHolder, WINDOWSTATEHOLDER_IID)
|
||||
|
||||
WindowStateHolder::WindowStateHolder(nsGlobalWindow *aWindow,
|
||||
nsIXPConnectJSObjectHolder *aHolder,
|
||||
nsIXPConnectJSObjectHolder *aOuterProto,
|
||||
nsIXPConnectJSObjectHolder *aOuterRealProto)
|
||||
: mInnerWindow(aWindow),
|
||||
mOuterProto(aOuterProto),
|
||||
mOuterRealProto(aOuterRealProto)
|
||||
nsIXPConnectJSObjectHolder *aHolder)
|
||||
: mInnerWindow(aWindow)
|
||||
{
|
||||
NS_PRECONDITION(aWindow, "null window");
|
||||
NS_PRECONDITION(aWindow->IsInnerWindow(), "Saving an outer window");
|
||||
@ -2047,20 +2033,7 @@ nsGlobalWindow::SetNewDocument(nsIDocument* aDocument,
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
}
|
||||
|
||||
// XXX Not sure if this is needed.
|
||||
if (aState) {
|
||||
JSObject *proto;
|
||||
if (nsIXPConnectJSObjectHolder *holder = wsh->GetOuterRealProto()) {
|
||||
holder->GetJSObject(&proto);
|
||||
} else {
|
||||
proto = nullptr;
|
||||
}
|
||||
|
||||
if (!JS_SetPrototype(cx, mJSObject, xpc_UnmarkGrayObject(proto))) {
|
||||
NS_ERROR("can't set prototype");
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
} else {
|
||||
if (!aState) {
|
||||
if (!JS_DefineProperty(cx, newInnerWindow->mJSObject, "window",
|
||||
OBJECT_TO_JSVAL(mJSObject),
|
||||
JS_PropertyStub, JS_StrictPropertyStub,
|
||||
@ -10361,38 +10334,10 @@ nsGlobalWindow::SaveWindowState(nsISupports **aState)
|
||||
// to the page.
|
||||
inner->Freeze();
|
||||
|
||||
// Remember the outer window's prototype.
|
||||
JSContext *cx = mContext->GetNativeContext();
|
||||
JSAutoRequest req(cx);
|
||||
|
||||
nsIXPConnect *xpc = nsContentUtils::XPConnect();
|
||||
|
||||
nsCOMPtr<nsIClassInfo> ci =
|
||||
do_QueryInterface((nsIScriptGlobalObject *)this);
|
||||
nsCOMPtr<nsIXPConnectJSObjectHolder> proto;
|
||||
nsresult rv = xpc->GetWrappedNativePrototype(cx, mJSObject, ci,
|
||||
getter_AddRefs(proto));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
JSObject *realProto = JS_GetPrototype(mJSObject);
|
||||
nsCOMPtr<nsIXPConnectJSObjectHolder> realProtoHolder;
|
||||
if (realProto) {
|
||||
rv = xpc->HoldObject(cx, realProto, getter_AddRefs(realProtoHolder));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
}
|
||||
|
||||
nsCOMPtr<nsISupports> state = new WindowStateHolder(inner,
|
||||
mInnerWindowHolder,
|
||||
proto,
|
||||
realProtoHolder);
|
||||
mInnerWindowHolder);
|
||||
NS_ENSURE_TRUE(state, NS_ERROR_OUT_OF_MEMORY);
|
||||
|
||||
JSObject *wnProto;
|
||||
proto->GetJSObject(&wnProto);
|
||||
if (!JS_SetPrototype(cx, mJSObject, wnProto)) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
#ifdef DEBUG_PAGE_CACHE
|
||||
printf("saving window state, state = %p\n", (void*)state);
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user