implement window.scrollbars.visible. bug 58539 r=hyatt,pinkerton

This commit is contained in:
danm%netscape.com 2001-03-27 23:23:09 +00:00
parent 566bcd714d
commit 0daa4060c2
7 changed files with 58 additions and 70 deletions

View File

@ -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);
}

View File

@ -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<nsIXULWindow> 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)) {

View File

@ -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<nsIDOMElement> 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<nsIDOMElement> 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 <window> 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 <window> 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;
}
//*****************************************************************************

View File

@ -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;
}

View File

@ -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;

View File

@ -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<nsIDocShellTreeItem> content;
if (NS_SUCCEEDED(GetPrimaryContentShell(getter_AddRefs(content))) && content) {
nsCOMPtr<nsIScrollable> 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);
}
}
}

View File

@ -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;