Fixes window.title property so that the frame window's titlebar is changed when the property changes. b=50682, r=mscott, a=mscott

git-svn-id: svn://10.0.0.236/trunk@80259 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
locka%iol.ie
2000-10-03 13:35:30 +00:00
parent 349bdbc894
commit 437fcbc26d
2 changed files with 8 additions and 35 deletions

View File

@@ -1056,54 +1056,26 @@ GlobalWindowImpl::SetLocation(jsval aLocation)
NS_IMETHODIMP
GlobalWindowImpl::GetTitle(nsAWritableString& aTitle)
{
aTitle.Truncate();
nsCOMPtr<nsIDocShellTreeItem> docShellAsItem(do_QueryInterface(mDocShell));
if (docShellAsItem) {
// See if we're a chrome shell.
PRInt32 type;
docShellAsItem->GetItemType(&type);
if(type == nsIDocShellTreeItem::typeChrome) {
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);
}
}
}
}
aTitle = mTitle;
return NS_OK;
}
NS_IMETHODIMP
GlobalWindowImpl::SetTitle(const nsAReadableString& aTitle)
{
nsCOMPtr<nsIDocShellTreeItem> docShellAsItem(do_QueryInterface(mDocShell));
if(docShellAsItem) {
mTitle = aTitle;
if(mDocShell) {
// See if we're a chrome shell.
PRInt32 type;
nsCOMPtr<nsIDocShellTreeItem> docShellAsItem(do_QueryInterface(mDocShell));
docShellAsItem->GetItemType(&type);
if(type == nsIDocShellTreeItem::typeChrome) {
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).get());
}
nsCOMPtr<nsIBaseWindow> docShellAsWin(do_QueryInterface(mDocShell));
if(docShellAsWin) {
docShellAsWin->SetTitle(nsPromiseFlatString(mTitle));
}
}
}
return NS_OK;
}

View File

@@ -248,6 +248,7 @@ protected:
PRBool mFirstDocumentLoad;
nsString mStatus;
nsString mDefaultStatus;
nsString mTitle;
nsIScriptGlobalObjectOwner* mGlobalObjectOwner; // Weak Reference
nsIDocShell* mDocShell; // Weak Reference