Attach nsGlobalWindow's title property to the primary content document's title property. b=41984, r=jst

This commit is contained in:
locka%iol.ie 2000-09-01 13:31:21 +00:00
parent 3bf37c3125
commit 1f402e7d0a

View File

@ -979,39 +979,52 @@ NS_IMETHODIMP
GlobalWindowImpl::GetTitle(nsAWritableString& aTitle)
{
aTitle.Truncate();
if (mDocShell) {
nsCOMPtr<nsIDocShellTreeItem> docShellAsItem(do_QueryInterface(mDocShell));
if (docShellAsItem) {
// See if we're a chrome shell.
PRInt32 type;
nsCOMPtr<nsIDocShellTreeItem> docShellAsItem(do_QueryInterface(mDocShell));
docShellAsItem->GetItemType(&type);
if(type == nsIDocShellTreeItem::typeChrome) {
nsCOMPtr<nsIBaseWindow> docShellAsWin(do_QueryInterface(mDocShell));
if(docShellAsWin) {
nsCOMPtr<nsIDocShellTreeOwner> treeOwner;
GetTreeOwner(getter_AddRefs(treeOwner));
if (treeOwner) {
nsCOMPtr<nsIDocShellTreeItem> primaryContent;
treeOwner->GetPrimaryContentShell(getter_AddRefs(primaryContent));
nsCOMPtr<nsIBaseWindow> docShellAsWin(do_QueryInterface(primaryContent));
if (docShellAsWin) {
nsXPIDLString title;
docShellAsWin->GetTitle(getter_Copies(title));
aTitle.Assign(title);
}
}
}
}
return NS_OK;
}
NS_IMETHODIMP
GlobalWindowImpl::SetTitle(const nsAReadableString& aTitle)
{
if(mDocShell) {
nsCOMPtr<nsIDocShellTreeItem> docShellAsItem(do_QueryInterface(mDocShell));
if(docShellAsItem) {
// See if we're a chrome shell.
PRInt32 type;
nsCOMPtr<nsIDocShellTreeItem> docShellAsItem(do_QueryInterface(mDocShell));
docShellAsItem->GetItemType(&type);
if(type == nsIDocShellTreeItem::typeChrome) {
nsCOMPtr<nsIBaseWindow> docShellAsWin(do_QueryInterface(mDocShell));
if(docShellAsWin) {
nsCOMPtr<nsIDocShellTreeOwner> treeOwner;
GetTreeOwner(getter_AddRefs(treeOwner));
if (treeOwner) {
nsCOMPtr<nsIDocShellTreeItem> primaryContent;
treeOwner->GetPrimaryContentShell(getter_AddRefs(primaryContent));
nsCOMPtr<nsIBaseWindow> docShellAsWin(do_QueryInterface(primaryContent));
if (docShellAsWin) {
docShellAsWin->SetTitle(nsPromiseFlatString(aTitle));
}
}
}
}
return NS_OK;
}