Changed nsPIDOMWindow::GetPrivateParent() to be implemented using it's own mChromeElement so it doesn't have to rely on the nsIWebShell::GetParentEvenIfChrome(). r=hyatt.

This commit is contained in:
tbogard%aol.net 1999-11-17 00:43:19 +00:00
parent 4979550535
commit 50ecb4c11b

View File

@ -624,24 +624,23 @@ GlobalWindowImpl::SetOpener(nsIDOMWindow* aOpener)
NS_IMETHODIMP NS_IMETHODIMP
GlobalWindowImpl::GetParent(nsIDOMWindow** aParent) GlobalWindowImpl::GetParent(nsIDOMWindow** aParent)
{ {
nsresult ret = NS_OK; NS_ENSURE_ARG_POINTER(aParent);
*aParent = nsnull;
if(!mWebShell)
return NS_OK;
*aParent = nsnull; nsCOMPtr<nsIWebShell> parentWebShell;
if (nsnull != mWebShell) { mWebShell->GetParent(*getter_AddRefs(parentWebShell));
nsIWebShell *parentWebShell;
mWebShell->GetParent(parentWebShell);
if (nsnull != parentWebShell) { if(parentWebShell)
ret = WebShellToDOMWindow(parentWebShell, aParent); NS_ENSURE_SUCCESS(WebShellToDOMWindow(parentWebShell, aParent),
NS_RELEASE(parentWebShell); NS_ERROR_FAILURE);
} else
else { {
*aParent = this; *aParent = NS_STATIC_CAST(nsIDOMWindow*, this);
NS_ADDREF(this); NS_ADDREF(*aParent);
} }
} return NS_OK;
return ret;
} }
NS_IMETHODIMP NS_IMETHODIMP
@ -3460,24 +3459,36 @@ GlobalWindowImpl::GetControllers(nsIControllers** aResult)
NS_IMETHODIMP NS_IMETHODIMP
GlobalWindowImpl::GetPrivateParent(nsPIDOMWindow** aParent) GlobalWindowImpl::GetPrivateParent(nsPIDOMWindow** aParent)
{ {
nsresult ret = NS_OK; nsCOMPtr<nsIDOMWindow> parent;
GetParent(getter_AddRefs(parent));
*aParent = nsnull; if(NS_STATIC_CAST(nsIDOMWindow*, this) == parent)
if (nsnull != mWebShell) { {
nsIWebShell *parentWebShell; if(mChromeElement)
mWebShell->GetParentEvenIfChrome(parentWebShell); {
nsCOMPtr<nsIDocument> doc;
NS_ENSURE_SUCCESS(mChromeElement->GetDocument(*getter_AddRefs(doc)),
NS_ERROR_FAILURE);
if (nsnull != parentWebShell) { nsCOMPtr<nsIScriptContextOwner> contextOwner =
nsCOMPtr<nsIDOMWindow> domWindow; dont_QueryInterface(doc->GetScriptContextOwner());
ret = WebShellToDOMWindow(parentWebShell, getter_AddRefs(domWindow)); NS_ENSURE_TRUE(contextOwner, NS_ERROR_FAILURE);
domWindow->QueryInterface(nsPIDOMWindow::GetIID(),(void**)aParent);
NS_RELEASE(parentWebShell); nsCOMPtr<nsIScriptGlobalObject> globalObject;
} contextOwner->GetScriptGlobalObject(getter_AddRefs(globalObject));
else { NS_ENSURE_TRUE(globalObject, NS_ERROR_FAILURE);
parent = do_QueryInterface(globalObject);
}
else
parent = nsnull;
}
if(parent)
NS_ENSURE_SUCCESS(CallQueryInterface(parent, aParent), NS_ERROR_FAILURE);
else
*aParent = nsnull; *aParent = nsnull;
}
}
return ret; return NS_OK;
} }