From ce860be60f1e2d2de758f50a9ad680557dc9f5a7 Mon Sep 17 00:00:00 2001 From: "danm%netscape.com" Date: Thu, 10 Jun 1999 01:27:47 +0000 Subject: [PATCH] adding show/hide support for interior chrome and menubars --- dom/src/base/nsBarProps.cpp | 49 +++++++++++++++++++++----- dom/src/base/nsBarProps.h | 4 +-- xpfe/appshell/src/nsWebShellWindow.cpp | 24 ++++++++----- 3 files changed, 58 insertions(+), 19 deletions(-) diff --git a/dom/src/base/nsBarProps.cpp b/dom/src/base/nsBarProps.cpp index cb19773872b9..e4e4ab1e30ac 100644 --- a/dom/src/base/nsBarProps.cpp +++ b/dom/src/base/nsBarProps.cpp @@ -92,6 +92,31 @@ BarPropImpl::SetBrowserWindow(nsIBrowserWindow *aBrowser) { mBrowser = aBrowser; } +NS_IMETHODIMP +BarPropImpl::GetVisible(PRBool *aVisible, PRUint32 aChromeFlag) { + PRUint32 chromeFlags; + *aVisible = PR_FALSE; + if (mBrowser && NS_SUCCEEDED(mBrowser->GetChrome(chromeFlags))) { + if (chromeFlags & aChromeFlag) + *aVisible = PR_TRUE; + return NS_OK; + } + return NS_ERROR_FAILURE; +} + +NS_IMETHODIMP +BarPropImpl::SetVisible(PRBool aVisible, PRUint32 aChromeFlag) { + PRUint32 chromeFlags; + if (mBrowser && NS_SUCCEEDED(mBrowser->GetChrome(chromeFlags))) { + if (aVisible) + chromeFlags |= aChromeFlag; + else + chromeFlags &= ~aChromeFlag; + return mBrowser->SetChrome(chromeFlags); + } + return NS_ERROR_FAILURE; +} + // // MenubarProp class implementation // @@ -104,16 +129,24 @@ MenubarPropImpl::~MenubarPropImpl() { NS_IMETHODIMP MenubarPropImpl::GetVisible(PRBool *aVisible) { +#if 1 + return BarPropImpl::GetVisible(aVisible, NS_CHROME_MENU_BAR_ON); +#else if (mBrowser) return mBrowser->IsMenuBarVisible(aVisible); return NS_ERROR_FAILURE; +#endif } NS_IMETHODIMP MenubarPropImpl::SetVisible(PRBool aVisible) { +#if 1 + return BarPropImpl::SetVisible(aVisible, NS_CHROME_MENU_BAR_ON); +#else if (mBrowser) return mBrowser->ShowMenuBar(aVisible); return NS_ERROR_FAILURE; +#endif } // @@ -128,12 +161,12 @@ ToolbarPropImpl::~ToolbarPropImpl() { NS_IMETHODIMP ToolbarPropImpl::GetVisible(PRBool *aVisible) { - return NS_ERROR_FAILURE; + return BarPropImpl::GetVisible(aVisible, NS_CHROME_TOOL_BAR_ON); } NS_IMETHODIMP ToolbarPropImpl::SetVisible(PRBool aVisible) { - return NS_ERROR_FAILURE; + return BarPropImpl::SetVisible(aVisible, NS_CHROME_TOOL_BAR_ON); } // @@ -148,12 +181,12 @@ LocationbarPropImpl::~LocationbarPropImpl() { NS_IMETHODIMP LocationbarPropImpl::GetVisible(PRBool *aVisible) { - return NS_ERROR_FAILURE; + return BarPropImpl::GetVisible(aVisible, NS_CHROME_LOCATION_BAR_ON); } NS_IMETHODIMP LocationbarPropImpl::SetVisible(PRBool aVisible) { - return NS_ERROR_FAILURE; + return BarPropImpl::SetVisible(aVisible, NS_CHROME_LOCATION_BAR_ON); } // @@ -168,12 +201,12 @@ PersonalbarPropImpl::~PersonalbarPropImpl() { NS_IMETHODIMP PersonalbarPropImpl::GetVisible(PRBool *aVisible) { - return NS_ERROR_FAILURE; + return BarPropImpl::GetVisible(aVisible, NS_CHROME_PERSONAL_TOOLBAR_ON); } NS_IMETHODIMP PersonalbarPropImpl::SetVisible(PRBool aVisible) { - return NS_ERROR_FAILURE; + return BarPropImpl::SetVisible(aVisible, NS_CHROME_PERSONAL_TOOLBAR_ON); } // @@ -188,12 +221,12 @@ StatusbarPropImpl::~StatusbarPropImpl() { NS_IMETHODIMP StatusbarPropImpl::GetVisible(PRBool *aVisible) { - return NS_ERROR_FAILURE; + return BarPropImpl::GetVisible(aVisible, NS_CHROME_STATUS_BAR_ON); } NS_IMETHODIMP StatusbarPropImpl::SetVisible(PRBool aVisible) { - return NS_ERROR_FAILURE; + return BarPropImpl::SetVisible(aVisible, NS_CHROME_STATUS_BAR_ON); } // diff --git a/dom/src/base/nsBarProps.h b/dom/src/base/nsBarProps.h index 2b83f32138bb..9fbead1a8d2c 100644 --- a/dom/src/base/nsBarProps.h +++ b/dom/src/base/nsBarProps.h @@ -45,8 +45,8 @@ public: NS_IMETHOD_(void) SetBrowserWindow(nsIBrowserWindow *aBrowser); - NS_IMETHOD GetVisible(PRBool *aVisible) = 0; - NS_IMETHOD SetVisible(PRBool aVisible) = 0; + NS_IMETHOD GetVisible(PRBool *aVisible, PRUint32 aChromeFlag); + NS_IMETHOD SetVisible(PRBool aVisible, PRUint32 aChromeFlag); protected: nsIBrowserWindow* mBrowser; diff --git a/xpfe/appshell/src/nsWebShellWindow.cpp b/xpfe/appshell/src/nsWebShellWindow.cpp index d7ff717879d2..a61ea25bee9c 100644 --- a/xpfe/appshell/src/nsWebShellWindow.cpp +++ b/xpfe/appshell/src/nsWebShellWindow.cpp @@ -1969,6 +1969,9 @@ void nsWebShellWindow::ShowAppropriateChrome() if (NS_FAILED(chromeDoc->GetDocumentElement(getter_AddRefs(rootElement))) || !rootElement) return; + // special treatment for the menubar + ShowMenuBar(mChromeMask & NS_CHROME_MENU_BAR_ON ? PR_TRUE : PR_FALSE); + // get a list of this document's elements with the chromeclass attribute specified xulRoot = do_QueryInterface(rootElement); if (xulRoot) { // todo (maybe) the longer, straight DOM (not RDF) version? @@ -1989,25 +1992,24 @@ void nsWebShellWindow::ShowAppropriateChrome() // show or hide the element according to its chromeclass and the chromemask domElement->GetAttribute("chromeclass", chromeClass); makeChange = PR_FALSE; - if (chromeClass == "menubar") { - if (!(mChromeMask & NS_CHROME_MENU_BAR_ON)) - mWindow->ShowMenuBar(PR_FALSE); + if (chromeClass == "toolbar") { + makeChange = PR_TRUE; + flag = mChromeMask & NS_CHROME_TOOL_BAR_ON; } else if (chromeClass == "location") { makeChange = PR_TRUE; flag = mChromeMask & NS_CHROME_LOCATION_BAR_ON; + } else if (chromeClass == "directories") { + makeChange = PR_TRUE; + flag = mChromeMask & NS_CHROME_PERSONAL_TOOLBAR_ON; } else if (chromeClass == "status") { makeChange = PR_TRUE; flag = mChromeMask & NS_CHROME_STATUS_BAR_ON; - } else if (chromeClass == "toolbar") { - makeChange = PR_TRUE; - flag = mChromeMask & NS_CHROME_TOOL_BAR_ON; } - if (makeChange) { + if (makeChange) if (flag) domElement->RemoveAttribute("chromehidden"); else - domElement->SetAttribute("chromehidden", ""); - } + domElement->SetAttribute("chromehidden", "T"); } } } @@ -2423,6 +2425,10 @@ NS_IMETHODIMP nsWebShellWindow::SetProgress(PRInt32 aProgress, PRInt32 aProgress NS_IMETHODIMP nsWebShellWindow::ShowMenuBar(PRBool aShow) { + if (aShow) + mChromeMask |= NS_CHROME_MENU_BAR_ON; + else + mChromeMask &= ~NS_CHROME_MENU_BAR_ON; return mWindow->ShowMenuBar(aShow); }