From b5cc6cd2be24edd46acd544b8dec952055d0dcc1 Mon Sep 17 00:00:00 2001 From: "davidm%netscape.com" Date: Wed, 19 May 1999 03:21:19 +0000 Subject: [PATCH] Add code to post fix string to title and to tell the window mediator about title changes git-svn-id: svn://10.0.0.236/trunk@32244 18797224-902f-48f8-a5cc-f745e15eee43 --- .../xpfe/appshell/src/nsWebShellWindow.cpp | 40 +++++++++++++++++-- mozilla/xpfe/appshell/src/nsWebShellWindow.h | 4 +- 2 files changed, 37 insertions(+), 7 deletions(-) diff --git a/mozilla/xpfe/appshell/src/nsWebShellWindow.cpp b/mozilla/xpfe/appshell/src/nsWebShellWindow.cpp index 6f863055935..c098c42817f 100644 --- a/mozilla/xpfe/appshell/src/nsWebShellWindow.cpp +++ b/mozilla/xpfe/appshell/src/nsWebShellWindow.cpp @@ -87,7 +87,7 @@ #ifdef XP_MAC #include #endif - +#include "nsIWindowMediator.h" /* Define Class IDs */ static NS_DEFINE_IID(kWindowCID, NS_WINDOW_CID); @@ -104,9 +104,14 @@ static NS_DEFINE_IID(kContextMenuCID, NS_CONTEXTMENU_CID); static NS_DEFINE_CID(kPrefCID, NS_PREF_CID); static NS_DEFINE_CID(kEventQueueServiceCID, NS_EVENTQUEUESERVICE_CID); + + +static NS_DEFINE_CID(kWindowMediatorCID, NS_WINDOWMEDIATOR_CID); + static NS_DEFINE_IID(kIDocumentLoaderFactoryIID, NS_IDOCUMENTLOADERFACTORY_IID); static NS_DEFINE_CID(kLayoutDocumentLoaderFactoryCID, NS_LAYOUT_DOCUMENT_LOADER_FACTORY_CID); + /* Define Interface IDs */ static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID); static NS_DEFINE_IID(kIWebShellWindowIID, NS_IWEBSHELL_WINDOW_IID); @@ -134,9 +139,12 @@ static NS_DEFINE_IID(kIXULCommandIID, NS_IXULCOMMAND_IID); static NS_DEFINE_IID(kIContentIID, NS_ICONTENT_IID); static NS_DEFINE_IID(kIEventQueueServiceIID, NS_IEVENTQUEUESERVICE_IID); +static NS_DEFINE_IID(kIWindowMediatorIID,NS_IWINDOWMEDIATOR_IID); + static NS_DEFINE_IID(kIXULPopupListenerIID, NS_IXULPOPUPLISTENER_IID); static NS_DEFINE_CID(kXULPopupListenerCID, NS_XULPOPUPLISTENER_CID); + #ifdef DEBUG_rods #define DEBUG_MENUSDEL 1 #endif @@ -1819,7 +1827,7 @@ void nsWebShellWindow::SetTitleFromXUL() webshellElement = do_QueryInterface(webshellNode); if (webshellElement && windowWidget && NS_SUCCEEDED(webshellElement->GetAttribute("title", windowTitle))) - windowWidget->SetTitle(windowTitle); + SetTitle(windowTitle); } // SetTitleFromXUL @@ -2070,9 +2078,33 @@ NS_IMETHODIMP nsWebShellWindow::GetChrome(PRUint32& aChromeMaskResult) NS_IMETHODIMP nsWebShellWindow::SetTitle(const PRUnichar* aTitle) { nsIWidget *windowWidget = GetWidget(); - + + +// Get window modifier + nsCOMPtr webshellNode = GetDOMNodeFromWebShell(mWebShell); + nsCOMPtr webshellElement; + nsString windowTitleModifier; + + if (webshellNode) + webshellElement = do_QueryInterface(webshellNode); + if (webshellElement ) + webshellElement->GetAttribute("titlemodifier", windowTitleModifier ); + nsString title( aTitle ); + title += windowTitleModifier; + if (windowWidget) - windowWidget->SetTitle(aTitle); + windowWidget->SetTitle(title); + + // Tell the window mediator that a title has changed + #if 1 + { + nsIWindowMediator* service; + if (NS_FAILED(nsServiceManager::GetService(kWindowMediatorCID, kIWindowMediatorIID, (nsISupports**) &service ) ) ) + return NS_OK; + service->UpdateWindowTitle( this, title ); + nsServiceManager::ReleaseService(kWindowMediatorCID, service); + } + #endif // Window Mediation return NS_OK; } diff --git a/mozilla/xpfe/appshell/src/nsWebShellWindow.h b/mozilla/xpfe/appshell/src/nsWebShellWindow.h index c8f77b8b3a4..4ec34bff48a 100644 --- a/mozilla/xpfe/appshell/src/nsWebShellWindow.h +++ b/mozilla/xpfe/appshell/src/nsWebShellWindow.h @@ -114,7 +114,7 @@ public: NS_IMETHOD Close(); NS_IMETHOD GetWebShell(nsIWebShell *& aWebShell); NS_IMETHOD GetWidget(nsIWidget *& aWidget); - + NS_IMETHOD ConvertWebShellToDOMWindow(nsIWebShell* aShell, nsIDOMWindow** aDOMWindow); // nsWebShellWindow methods... nsresult Initialize(nsIWebShellWindow * aParent, nsIAppShell* aShell, nsIURL* aUrl, nsIStreamObserver* anObserver, @@ -225,8 +225,6 @@ public: protected: void ExecuteJavaScriptString(nsString& aJavaScript); - NS_IMETHOD ConvertWebShellToDOMWindow(nsIWebShell* aShell, nsIDOMWindow** aDOMWindow); - PRInt32 GetDocHeight(nsIDocument * aDoc); void LoadMenus(nsIDOMDocument * aDOMDoc, nsIWidget * aParentWindow);