diff --git a/mozilla/dom/src/base/nsBarProps.cpp b/mozilla/dom/src/base/nsBarProps.cpp index cad138f8d39..0b30a25af37 100644 --- a/mozilla/dom/src/base/nsBarProps.cpp +++ b/mozilla/dom/src/base/nsBarProps.cpp @@ -238,10 +238,10 @@ ScrollbarsPropImpl::~ScrollbarsPropImpl() NS_IMETHODIMP ScrollbarsPropImpl::GetVisible(PRBool *aVisible) { - return NS_ERROR_FAILURE; + return BarPropImpl::GetVisibleByFlag(aVisible, nsIWebBrowserChrome::CHROME_SCROLLBARS); } NS_IMETHODIMP ScrollbarsPropImpl::SetVisible(PRBool aVisible) { - return NS_ERROR_FAILURE; + return BarPropImpl::SetVisibleByFlag(aVisible, nsIWebBrowserChrome::CHROME_SCROLLBARS); } diff --git a/mozilla/xpfe/appshell/src/nsAppShellService.cpp b/mozilla/xpfe/appshell/src/nsAppShellService.cpp index bbea27424d7..6356965d64e 100644 --- a/mozilla/xpfe/appshell/src/nsAppShellService.cpp +++ b/mozilla/xpfe/appshell/src/nsAppShellService.cpp @@ -566,11 +566,9 @@ nsAppShellService::JustCreateTopWindow(nsIXULWindow *aParent, nsWebShellWindow* window; PRBool intrinsicallySized; PRUint32 zlevel; - PRBool contentScrollbars; *aResult = nsnull; intrinsicallySized = PR_FALSE; - contentScrollbars = PR_FALSE; window = new nsWebShellWindow(); // Bump count to one so it doesn't die on us while doing init. nsCOMPtr tempRef(window); @@ -613,9 +611,6 @@ nsAppShellService::JustCreateTopWindow(nsIXULWindow *aParent, } } - if (aChromeMask & nsIWebBrowserChrome::CHROME_SCROLLBARS) - contentScrollbars = PR_TRUE; - zlevel = nsIXULWindow::normalZ; if (aChromeMask & nsIWebBrowserChrome::CHROME_WINDOW_RAISED) zlevel = nsIXULWindow::raisedZ; @@ -644,8 +639,7 @@ nsAppShellService::JustCreateTopWindow(nsIXULWindow *aParent, } rv = window->Initialize(aParent, mAppShell, aUrl, - aShowWindow, aLoadDefaultPage, - contentScrollbars, zlevel, + aShowWindow, aLoadDefaultPage, zlevel, aInitialWidth, aInitialHeight, widgetInitData); if (NS_SUCCEEDED(rv)) { diff --git a/mozilla/xpfe/appshell/src/nsContentTreeOwner.cpp b/mozilla/xpfe/appshell/src/nsContentTreeOwner.cpp index a5ecbf40d4c..988126209f7 100644 --- a/mozilla/xpfe/appshell/src/nsContentTreeOwner.cpp +++ b/mozilla/xpfe/appshell/src/nsContentTreeOwner.cpp @@ -80,12 +80,9 @@ NS_IMETHODIMP nsContentTreeOwner::GetInterface(const nsIID& aIID, void** aSink) NS_ENSURE_ARG_POINTER(aSink); *aSink = 0; - if(aIID.Equals(NS_GET_IID(nsIWebBrowserChrome))) { - nsIWebBrowserChrome *us = NS_STATIC_CAST(nsIWebBrowserChrome *, this); - NS_ADDREF(us); - *aSink = (void **) us; - return NS_OK; - } + if(aIID.Equals(NS_GET_IID(nsIWebBrowserChrome))) + return mXULWindow->GetInterface(aIID, aSink); + if(aIID.Equals(NS_GET_IID(nsIPrompt))) return mXULWindow->GetInterface(aIID, aSink); @@ -568,52 +565,56 @@ NS_IMETHODIMP nsContentTreeOwner::SetTitle(const PRUnichar* aTitle) NS_IMETHODIMP nsContentTreeOwner::ApplyChromeFlags() { - if(!mXULWindow->mChromeLoaded) - return NS_OK; // We'll do this later when chrome is loaded + if(!mXULWindow->mChromeLoaded) + return NS_OK; // We'll do this later when chrome is loaded - nsCOMPtr window; - mXULWindow->GetWindowDOMElement(getter_AddRefs(window)); - NS_ENSURE_TRUE(window, NS_ERROR_FAILURE); - - mXULWindow->mWindow->ShowMenuBar(mChromeFlags & - nsIWebBrowserChrome::CHROME_MENUBAR ? - PR_TRUE : PR_FALSE); + nsCOMPtr window; + mXULWindow->GetWindowDOMElement(getter_AddRefs(window)); + NS_ENSURE_TRUE(window, NS_ERROR_FAILURE); - // Construct the new value for the 'chromehidden' attribute that - // we'll whack onto the window. We've got style rules in - // navigator.css that trigger visibility based on the - // 'chromehidden' attribute of the tag. - nsAutoString newvalue; + // menubar has its own special treatment + mXULWindow->mWindow->ShowMenuBar(mChromeFlags & + nsIWebBrowserChrome::CHROME_MENUBAR ? + PR_TRUE : PR_FALSE); - if (! (mChromeFlags & nsIWebBrowserChrome::CHROME_MENUBAR)) { - newvalue.AppendWithConversion("menubar "); - } - if (! (mChromeFlags & nsIWebBrowserChrome::CHROME_TOOLBAR)) { - newvalue.AppendWithConversion("toolbar "); - } - if (! (mChromeFlags & nsIWebBrowserChrome::CHROME_LOCATIONBAR)) { - newvalue.AppendWithConversion("location "); - } - if (! (mChromeFlags & nsIWebBrowserChrome::CHROME_PERSONAL_TOOLBAR)) { - newvalue.AppendWithConversion("directories "); - } - if (! (mChromeFlags & nsIWebBrowserChrome::CHROME_STATUSBAR)) { - newvalue.AppendWithConversion("status "); - } - if (! (mChromeFlags & nsIWebBrowserChrome::CHROME_EXTRA)) { - newvalue.AppendWithConversion("extrachrome"); - } + // scrollbars have their own special treatment + mXULWindow->SetContentScrollbarVisibility(mChromeFlags & + nsIWebBrowserChrome::CHROME_SCROLLBARS ? + PR_TRUE : PR_FALSE); - // Get the old value, to avoid useless style reflows if we're just - // setting stuff to the exact same thing. - nsAutoString oldvalue; - window->GetAttribute(NS_ConvertASCIItoUCS2("chromehidden"), oldvalue); + /* the other flags are handled together. we have style rules + in navigator.css that trigger visibility based on + the 'chromehidden' attribute of the tag. */ + nsAutoString newvalue; - if (oldvalue != newvalue) { - window->SetAttribute(NS_ConvertASCIItoUCS2("chromehidden"), newvalue); - } + if (! (mChromeFlags & nsIWebBrowserChrome::CHROME_MENUBAR)) + newvalue.Append(NS_LITERAL_STRING("menubar ")); - return NS_OK; + if (! (mChromeFlags & nsIWebBrowserChrome::CHROME_TOOLBAR)) + newvalue.Append(NS_LITERAL_STRING("toolbar ")); + + if (! (mChromeFlags & nsIWebBrowserChrome::CHROME_LOCATIONBAR)) + newvalue.Append(NS_LITERAL_STRING("location ")); + + if (! (mChromeFlags & nsIWebBrowserChrome::CHROME_PERSONAL_TOOLBAR)) + newvalue.Append(NS_LITERAL_STRING("directories ")); + + if (! (mChromeFlags & nsIWebBrowserChrome::CHROME_STATUSBAR)) + newvalue.Append(NS_LITERAL_STRING("status ")); + + if (! (mChromeFlags & nsIWebBrowserChrome::CHROME_EXTRA)) + newvalue.Append(NS_LITERAL_STRING("extrachrome")); + + + // Get the old value, to avoid useless style reflows if we're just + // setting stuff to the exact same thing. + nsAutoString oldvalue; + window->GetAttribute(NS_LITERAL_STRING("chromehidden"), oldvalue); + + if (oldvalue != newvalue) + window->SetAttribute(NS_LITERAL_STRING("chromehidden"), newvalue); + + return NS_OK; } //***************************************************************************** diff --git a/mozilla/xpfe/appshell/src/nsWebShellWindow.cpp b/mozilla/xpfe/appshell/src/nsWebShellWindow.cpp index 13f92b1d777..f2f4c9d8c27 100644 --- a/mozilla/xpfe/appshell/src/nsWebShellWindow.cpp +++ b/mozilla/xpfe/appshell/src/nsWebShellWindow.cpp @@ -202,7 +202,6 @@ nsWebShellWindow::nsWebShellWindow() : nsXULWindow() mIntrinsicallySized = PR_FALSE; mDebuting = PR_FALSE; mLoadDefaultPage = PR_TRUE; - mKillScrollbarsAfterLoad = PR_FALSE; mSPTimerLock = PR_NewLock(); } @@ -244,7 +243,6 @@ nsresult nsWebShellWindow::Initialize(nsIXULWindow* aParent, nsIAppShell* aShell, nsIURI* aUrl, PRBool aCreatedVisible, PRBool aLoadDefaultPage, - PRBool aContentScrollbars, PRUint32 aZlevel, PRInt32 aInitialWidth, PRInt32 aInitialHeight, nsWidgetInitData& widgetInitData) @@ -254,7 +252,6 @@ nsresult nsWebShellWindow::Initialize(nsIXULWindow* aParent, mShowAfterLoad = aCreatedVisible; mLoadDefaultPage = aLoadDefaultPage; - mKillScrollbarsAfterLoad = !aContentScrollbars; mZlevel = aZlevel; // XXX: need to get the default window size from prefs... @@ -1294,8 +1291,6 @@ nsWebShellWindow::OnStateChange(nsIWebProgress *aProgress, OnChromeLoaded(); LoadContentAreas(); - if (mKillScrollbarsAfterLoad) - KillContentScrollbars(); return NS_OK; } diff --git a/mozilla/xpfe/appshell/src/nsWebShellWindow.h b/mozilla/xpfe/appshell/src/nsWebShellWindow.h index 5a99ed98c17..9f04e8a94bd 100644 --- a/mozilla/xpfe/appshell/src/nsWebShellWindow.h +++ b/mozilla/xpfe/appshell/src/nsWebShellWindow.h @@ -91,7 +91,7 @@ public: // nsWebShellWindow methods... nsresult Initialize(nsIXULWindow * aParent, nsIAppShell* aShell, nsIURI* aUrl, PRBool aCreatedVisible, PRBool aLoadDefaultPage, - PRBool aContentScrollbars, PRUint32 aZlevel, + PRUint32 aZlevel, PRInt32 aInitialWidth, PRInt32 aInitialHeight, nsWidgetInitData& widgetInitData); nsIWidget* GetWidget(void) { return mWindow; } @@ -192,7 +192,6 @@ protected: nsIWebShell* mWebShell; PRBool mLockedUntilChromeLoad; PRBool mLoadDefaultPage; - PRBool mKillScrollbarsAfterLoad; nsVoidArray mMenuDelegates; diff --git a/mozilla/xpfe/appshell/src/nsXULWindow.cpp b/mozilla/xpfe/appshell/src/nsXULWindow.cpp index 061505e6139..4f1fa74017d 100644 --- a/mozilla/xpfe/appshell/src/nsXULWindow.cpp +++ b/mozilla/xpfe/appshell/src/nsXULWindow.cpp @@ -1418,17 +1418,16 @@ PRBool nsXULWindow::ConstrainToZLevel( return altered; } -/* Disable scrollbars in the primary content shell (to open a browser window - without scrollbars, for example) -*/ -void nsXULWindow::KillContentScrollbars() { +void nsXULWindow::SetContentScrollbarVisibility(PRBool aVisible) { nsCOMPtr content; if (NS_SUCCEEDED(GetPrimaryContentShell(getter_AddRefs(content))) && content) { nsCOMPtr shell(do_QueryInterface(content)); - if (shell) - shell->SetDefaultScrollbarPreferences(nsIScrollable::ScrollOrientation_Y, NS_STYLE_OVERFLOW_HIDDEN); - shell->SetDefaultScrollbarPreferences(nsIScrollable::ScrollOrientation_X, NS_STYLE_OVERFLOW_HIDDEN); + if (shell) { + long prefValue = aVisible ? NS_STYLE_OVERFLOW_AUTO : NS_STYLE_OVERFLOW_HIDDEN; + shell->SetDefaultScrollbarPreferences(nsIScrollable::ScrollOrientation_Y, prefValue); + shell->SetDefaultScrollbarPreferences(nsIScrollable::ScrollOrientation_X, prefValue); + } } } diff --git a/mozilla/xpfe/appshell/src/nsXULWindow.h b/mozilla/xpfe/appshell/src/nsXULWindow.h index f5680d83a2b..62b5dfe12fc 100644 --- a/mozilla/xpfe/appshell/src/nsXULWindow.h +++ b/mozilla/xpfe/appshell/src/nsXULWindow.h @@ -94,7 +94,7 @@ protected: void ActivateParent(); PRBool ConstrainToZLevel(PRBool aImmediate, nsWindowZ *aPlacement, nsIWidget *aReqBelow, nsIWidget **aActualBelow); - void KillContentScrollbars(); + void SetContentScrollbarVisibility(PRBool aVisible); nsChromeTreeOwner* mChromeTreeOwner; nsContentTreeOwner* mContentTreeOwner;