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
Родитель 3bf37c3125
Коммит 1f402e7d0a
1 изменённых файлов: 27 добавлений и 14 удалений

Просмотреть файл

@ -978,37 +978,50 @@ GlobalWindowImpl::SetLocation(jsval aLocation)
NS_IMETHODIMP
GlobalWindowImpl::GetTitle(nsAWritableString& aTitle)
{
aTitle.Truncate();
if (mDocShell) {
aTitle.Truncate();
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) {
nsXPIDLString title;
docShellAsWin->GetTitle(getter_Copies(title));
aTitle.Assign(title);
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) {
docShellAsWin->SetTitle(nsPromiseFlatString(aTitle));
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));
}
}
}
}