FIx for 215440, add support for a titledefault attribute that can be used when a document has no title.

This commit is contained in:
hyatt%mozilla.org 2003-08-07 21:05:58 +00:00
parent d1ef21e542
commit b3f8e51529
2 changed files with 24 additions and 28 deletions

View File

@ -597,36 +597,30 @@ NS_IMETHODIMP nsContentTreeOwner::GetTitle(PRUnichar** aTitle)
NS_IMETHODIMP nsContentTreeOwner::SetTitle(const PRUnichar* aTitle)
{
// We only allow the title to be set from the primary content shell
if(!mPrimary || !mContentTitleSetting)
return NS_OK;
if(!mPrimary || !mContentTitleSetting)
return NS_OK;
nsAutoString title;
nsAutoString docTitle(aTitle);
nsAutoString title;
nsAutoString docTitle(aTitle);
if (docTitle.IsEmpty())
docTitle.Assign(mTitleDefault);
if (!mTitlePreface.IsEmpty()) {
// Title will be: "Preface: Doc Title - Mozilla"
title.Assign(mTitlePreface);
title.Append(docTitle);
}
else {
// Title will be: "Doc Title - Mozilla"
title = docTitle;
}
title += mTitleSeparator + mWindowTitleModifier;
if(!docTitle.IsEmpty())
{
if(!mTitlePreface.IsEmpty())
{
// Title will be: "Preface: Doc Title - Mozilla"
title.Assign(mTitlePreface);
title.Append(docTitle);
}
else
{
// Title will be: "Doc Title - Mozilla"
title = docTitle;
}
title += mTitleSeparator + mWindowTitleModifier;
}
else
{
// Title will just be plain: Mozilla
title.Assign(mWindowTitleModifier);
}
// XXX Don't need to fully qualify this once I remove nsWebShellWindow::SetTitle
// return mXULWindow->SetTitle(title.get());
return mXULWindow->nsXULWindow::SetTitle(title.get());
// XXX Don't need to fully qualify this once I remove nsWebShellWindow::SetTitle
// return mXULWindow->SetTitle(title.get());
return mXULWindow->nsXULWindow::SetTitle(title.get());
}
//*****************************************************************************
@ -715,6 +709,7 @@ void nsContentTreeOwner::XULWindow(nsXULWindow* aXULWindow)
docShellElement->GetAttribute(NS_LITERAL_STRING("titlemodifier"), mWindowTitleModifier);
docShellElement->GetAttribute(NS_LITERAL_STRING("titlemenuseparator"), mTitleSeparator);
docShellElement->GetAttribute(NS_LITERAL_STRING("titlepreface"), mTitlePreface);
docShellElement->GetAttribute(NS_LITERAL_STRING("titledefault"), mTitleDefault);
}
}
else

View File

@ -70,6 +70,7 @@ protected:
nsString mWindowTitleModifier;
nsString mTitleSeparator;
nsString mTitlePreface;
nsString mTitleDefault;
private:
PRUint32 mChromeFlags; // don't use directly! use GetChromeFlags()