diff --git a/dom/src/base/nsGlobalWindow.cpp b/dom/src/base/nsGlobalWindow.cpp index 79efc65e9d06..1623c1670699 100644 --- a/dom/src/base/nsGlobalWindow.cpp +++ b/dom/src/base/nsGlobalWindow.cpp @@ -2122,6 +2122,10 @@ GlobalWindowImpl::CalculateChromeFlags(char *aFeatures) { return NS_CHROME_ALL_CHROME; PRBool presenceFlag = PR_FALSE; + + // ((only) titlebars default to "on" if not mentioned) + chromeFlags |= WinHasOption(aFeatures, "titlebar", presenceFlag) ? NS_CHROME_TITLEBAR_ON : 0; + chromeFlags |= WinHasOption(aFeatures, "close", presenceFlag) ? NS_CHROME_WINDOW_CLOSE_ON : 0; chromeFlags |= WinHasOption(aFeatures, "toolbar", presenceFlag) ? NS_CHROME_TOOL_BAR_ON : 0; chromeFlags |= WinHasOption(aFeatures, "location", presenceFlag) ? NS_CHROME_LOCATION_BAR_ON : 0; chromeFlags |= (WinHasOption(aFeatures, "directories", presenceFlag) | WinHasOption(aFeatures, "personalbar", presenceFlag)) @@ -2130,7 +2134,13 @@ GlobalWindowImpl::CalculateChromeFlags(char *aFeatures) { chromeFlags |= WinHasOption(aFeatures, "menubar", presenceFlag) ? NS_CHROME_MENU_BAR_ON : 0; chromeFlags |= WinHasOption(aFeatures, "scrollbars", presenceFlag) ? NS_CHROME_SCROLLBARS_ON : 0; chromeFlags |= WinHasOption(aFeatures, "resizable", presenceFlag) ? NS_CHROME_WINDOW_RESIZE_ON : 0; - chromeFlags |= NS_CHROME_WINDOW_CLOSE_ON; + // default to "on" if titlebar, closebox, or resizable aren't mentioned + if (!PL_strcasestr(aFeatures, "titlebar")) + chromeFlags |= NS_CHROME_TITLEBAR_ON; + if (!PL_strcasestr(aFeatures, "close")) + chromeFlags |= NS_CHROME_WINDOW_CLOSE_ON; + if (!PL_strcasestr(aFeatures, "resizable")) + chromeFlags |= NS_CHROME_WINDOW_RESIZE_ON; // From this point onward, if the above features weren't specified at all, // we will assume that all chrome is present. @@ -2157,9 +2167,6 @@ GlobalWindowImpl::CalculateChromeFlags(char *aFeatures) { if (XP_STRCASESTR(aFeatures,"hotkeys")==NULL) chromeFlags->disable_commands = FALSE; }*/ - /* If titlebar condition not specified, default to shown */ - /*if (XP_STRCASESTR(aFeatures,"titlebar")==0)*/ - chromeFlags |= NS_CHROME_TITLEBAR_ON; /* XXX Add security check on z-ordering, modal, hide title, disable hotkeys */ diff --git a/editor/base/nsEditorShell.cpp b/editor/base/nsEditorShell.cpp index 233dced3e6aa..38dae9ad8e83 100644 --- a/editor/base/nsEditorShell.cpp +++ b/editor/base/nsEditorShell.cpp @@ -834,8 +834,8 @@ nsEditorShell::CreateWindowWithURL(const char* urlStr) if (NS_FAILED(rv) || !url) goto done; - appShell->CreateTopLevelWindow(nsnull, url, PR_TRUE, getter_AddRefs(newWindow), - nsnull, nsnull, 615, 480); + appShell->CreateTopLevelWindow(nsnull, url, PR_TRUE, NS_CHROME_ALL_CHROME, + nsnull, 615, 480, getter_AddRefs(newWindow)); done: /* Release the shell... */ diff --git a/editor/composer/src/nsEditorShell.cpp b/editor/composer/src/nsEditorShell.cpp index 233dced3e6aa..38dae9ad8e83 100644 --- a/editor/composer/src/nsEditorShell.cpp +++ b/editor/composer/src/nsEditorShell.cpp @@ -834,8 +834,8 @@ nsEditorShell::CreateWindowWithURL(const char* urlStr) if (NS_FAILED(rv) || !url) goto done; - appShell->CreateTopLevelWindow(nsnull, url, PR_TRUE, getter_AddRefs(newWindow), - nsnull, nsnull, 615, 480); + appShell->CreateTopLevelWindow(nsnull, url, PR_TRUE, NS_CHROME_ALL_CHROME, + nsnull, 615, 480, getter_AddRefs(newWindow)); done: /* Release the shell... */ diff --git a/profile/pref-migrator/src/nsPMProgressDlg.cpp b/profile/pref-migrator/src/nsPMProgressDlg.cpp index 29df87616ec4..817efd8c0ce3 100644 --- a/profile/pref-migrator/src/nsPMProgressDlg.cpp +++ b/profile/pref-migrator/src/nsPMProgressDlg.cpp @@ -41,6 +41,7 @@ static NS_DEFINE_IID( kNetServiceCID, NS_NETSERVICE_CID ); #include "nsNeckoUtil.h" #endif // NECKO +#include "nsIBrowserWindow.h" #include "nsIWebShell.h" #include "nsIWebShellWindow.h" @@ -182,11 +183,11 @@ nsPrefMigrationProgressDialog::CreateProfileProgressDialog() rv = appShell->CreateTopLevelWindow( nsnull, url, PR_TRUE, - getter_AddRefs(newWindow), - nsnull, + NS_CHROME_ALL_CHROME, this, // callbacks?? 0, - 0 ); + 0, + getter_AddRefs(newWindow)); if ( NS_SUCCEEDED( rv ) ) { diff --git a/widget/src/windows/nsWindow.cpp b/widget/src/windows/nsWindow.cpp index b22e1d8bdf82..b01a1032cfa1 100644 --- a/widget/src/windows/nsWindow.cpp +++ b/widget/src/windows/nsWindow.cpp @@ -671,11 +671,29 @@ nsresult nsWindow::StandardWindowCreate(nsIWidget *aParent, if (mWindowType == eWindowType_dialog) { extendedStyle &= ~WS_EX_CLIENTEDGE; - } else if (mWindowType == eWindowType_popup) { + } else if (mWindowType == eWindowType_popup) { extendedStyle = WS_EX_TOPMOST; style = WS_POPUP; mBorderlessParent = parent; } + + if (aInitData->mBorderStyle != eBorderStyle_all) { + if (aInitData->mBorderStyle == eBorderStyle_none || + !(aInitData->mBorderStyle & eBorderStyle_title)) { + style &= ~WS_DLGFRAME; + style |= WS_POPUP; + } + if (aInitData->mBorderStyle == eBorderStyle_none || + !(aInitData->mBorderStyle & eBorderStyle_close)) { + style &= ~WS_SYSMENU; + } + if (aInitData->mBorderStyle == eBorderStyle_none || + !(aInitData->mBorderStyle & eBorderStyle_resizeh)) { + style &= ~WS_THICKFRAME; + style &= ~WS_MINIMIZEBOX; + style &= ~WS_MAXIMIZEBOX; + } + } } mHas3DBorder = (extendedStyle & WS_EX_CLIENTEDGE) > 0; diff --git a/xpfe/AppCores/src/nsBrowserAppCore.cpp b/xpfe/AppCores/src/nsBrowserAppCore.cpp index 9890cb042dc6..6bc797e71562 100644 --- a/xpfe/AppCores/src/nsBrowserAppCore.cpp +++ b/xpfe/AppCores/src/nsBrowserAppCore.cpp @@ -432,8 +432,9 @@ newWind(char* urlName) if (NS_FAILED(rv)) return rv; nsCOMPtr newWindow; - appShell->CreateTopLevelWindow(nsnull, url, PR_TRUE, getter_AddRefs(newWindow), - nsnull, nsnull, NS_SIZETOCONTENT, NS_SIZETOCONTENT); + appShell->CreateTopLevelWindow(nsnull, url, PR_TRUE, NS_CHROME_ALL_CHROME, + nsnull, NS_SIZETOCONTENT, NS_SIZETOCONTENT, + getter_AddRefs(newWindow)); NS_RELEASE(url); @@ -500,10 +501,12 @@ nsBrowserAppCore::WalletEditor(nsIDOMWindow* aWin) nsCOMPtr parent; DOMWindowToWebShellWindow(aWin, &parent); window = nsnull; - appShell->CreateDialogWindow(parent, urlObj, PR_TRUE, &window, - nsnull, cb, 504, 436); + appShell->CreateTopLevelWindow(parent, urlObj, PR_TRUE, + NS_CHROME_ALL_CHROME | NS_CHROME_OPEN_AS_DIALOG, + cb, 504, 436, &window); if (window != nsnull) { - appShell->RunModalDialog(&window, nsnull, parent, nsnull, cb, 504, 436); + appShell->RunModalDialog(&window, parent, nsnull, NS_CHROME_ALL_CHROME, + cb, 504, 436); NS_RELEASE(window); } nsServiceManager::ReleaseService(kAppShellServiceCID, appShell); @@ -551,10 +554,12 @@ nsBrowserAppCore::SignonViewer(nsIDOMWindow* aWin) nsCOMPtr parent; DOMWindowToWebShellWindow(aWin, &parent); window = nsnull; - appShell->CreateDialogWindow(parent, urlObj, PR_TRUE, &window, - nsnull, cb, 504, 436); + appShell->CreateTopLevelWindow(parent, urlObj, PR_TRUE, + NS_CHROME_ALL_CHROME | NS_CHROME_OPEN_AS_DIALOG, + cb, 504, 436, &window); if (window != nsnull) { - appShell->RunModalDialog(&window, nsnull, parent, nsnull, cb, 504, 436); + appShell->RunModalDialog(&window, parent, nsnull, NS_CHROME_ALL_CHROME, + cb, 504, 436); NS_RELEASE(window); } nsServiceManager::ReleaseService(kAppShellServiceCID, appShell); @@ -601,11 +606,13 @@ nsBrowserAppCore::CookieViewer(nsIDOMWindow* aWin) nsCOMPtr parent; DOMWindowToWebShellWindow(aWin, &parent); window = nsnull; - appShell->CreateDialogWindow(parent, urlObj, PR_TRUE, &window, - nsnull, cb, 504, 436); + appShell->CreateTopLevelWindow(parent, urlObj, PR_TRUE, + NS_CHROME_ALL_CHROME | NS_CHROME_OPEN_AS_DIALOG, + cb, 504, 436, &window); if (window != nsnull) { - appShell->RunModalDialog(&window, nsnull, parent, nsnull, cb, 504, 436); + appShell->RunModalDialog(&window, parent, nsnull, NS_CHROME_ALL_CHROME, + cb, 504, 436); NS_RELEASE(window); } @@ -696,10 +703,12 @@ nsBrowserAppCore::WalletPreview(nsIDOMWindow* aWin, nsIDOMWindow* aForm) nsCOMPtr parent; DOMWindowToWebShellWindow(aWin, &parent); window = nsnull; - appShell->CreateDialogWindow(parent, urlObj, PR_TRUE, &window, - nsnull, cb, 504, 436); + appShell->CreateTopLevelWindow(parent, urlObj, PR_TRUE, + NS_CHROME_ALL_CHROME | NS_CHROME_OPEN_AS_DIALOG, + cb, 504, 436, &window); if (window != nsnull) { - appShell->RunModalDialog(&window, nsnull, parent, nsnull, cb, 504, 436); + appShell->RunModalDialog(&window, parent, nsnull, NS_CHROME_ALL_CHROME, + cb, 504, 436); NS_RELEASE(window); } nsServiceManager::ReleaseService(kAppShellServiceCID, appShell); @@ -1546,8 +1555,9 @@ nsBrowserAppCore::NewWindow() if (NS_FAILED(rv)) return rv; nsCOMPtr newWindow; - appShell->CreateTopLevelWindow(nsnull, url, PR_TRUE, getter_AddRefs(newWindow), - nsnull, nsnull, NS_SIZETOCONTENT, NS_SIZETOCONTENT); + appShell->CreateTopLevelWindow(nsnull, url, PR_TRUE, NS_CHROME_ALL_CHROME, + nsnull, NS_SIZETOCONTENT, NS_SIZETOCONTENT, + getter_AddRefs(newWindow)); NS_RELEASE(url); return NS_OK; @@ -1798,9 +1808,6 @@ nsBrowserAppCore::DoDialog() { // (adapted from nsToolkitCore) nsresult rv; - nsIWebShellWindow *window; - - window = nsnull; nsCOMPtr urlObj; char * urlstr = "resource:/res/samples/Password.html"; @@ -1824,9 +1831,9 @@ nsBrowserAppCore::DoDialog() if (NS_FAILED(rv)) return rv; - rv = appShell->RunModalDialog(&window, urlObj, mWebShellWin, nsnull, nsnull, 300, 200); - if (NS_SUCCEEDED(rv)) - NS_RELEASE(window); + rv = appShell->RunModalDialog(nsnull, mWebShellWin, urlObj, + NS_CHROME_ALL_CHROME | NS_CHROME_OPEN_AS_DIALOG, + nsnull, 300, 200); return rv; } diff --git a/xpfe/AppCores/src/nsToolkitCore.cpp b/xpfe/AppCores/src/nsToolkitCore.cpp index 4c366264c0f5..4d4346e30099 100644 --- a/xpfe/AppCores/src/nsToolkitCore.cpp +++ b/xpfe/AppCores/src/nsToolkitCore.cpp @@ -33,6 +33,7 @@ #include "nsIURL.h" static NS_DEFINE_CID(kIOServiceCID, NS_IOSERVICE_CID); #endif // NECKO +#include "nsIBrowserWindow.h" #include "nsIWebShell.h" #include "nsIWebShellWindow.h" #include "nsIWidget.h" @@ -167,8 +168,9 @@ nsToolkitCore::ShowDialog(const nsString& aUrl, nsIDOMWindow* aParent) { nsCOMPtr parent; DOMWindowToWebShellWindow(aParent, &parent); window = nsnull; - appShell->CreateDialogWindow(parent, urlObj, PR_TRUE, &window, - nsnull, nsnull, 615, 480); + appShell->CreateTopLevelWindow(parent, urlObj, PR_TRUE, + NS_CHROME_ALL_CHROME | NS_CHROME_OPEN_AS_DIALOG, + nsnull, 615, 480, &window); if (window != nsnull) window->Show(PR_TRUE); @@ -201,8 +203,9 @@ nsToolkitCore::ShowWindow(const nsString& aUrl, nsIDOMWindow* aParent) { nsCOMPtr parent; DOMWindowToWebShellWindow(aParent, &parent); nsCOMPtr window; - appShell->CreateTopLevelWindow(parent, urlObj, PR_TRUE, getter_AddRefs(window), - nsnull, nsnull, NS_SIZETOCONTENT, NS_SIZETOCONTENT); + appShell->CreateTopLevelWindow(parent, urlObj, PR_TRUE, NS_CHROME_ALL_CHROME, + nsnull, NS_SIZETOCONTENT, NS_SIZETOCONTENT, + getter_AddRefs(window)); return rv; } @@ -317,8 +320,9 @@ nsToolkitCore::ShowWindowWithArgs(const nsString& aUrl, cb = nsDontQueryInterface( new nsArgCallbacks( aArgs ) ); nsCOMPtr window; - appShell->CreateTopLevelWindow(parent, urlObj, PR_TRUE, getter_AddRefs(window), - nsnull, cb, NS_SIZETOCONTENT, NS_SIZETOCONTENT); + appShell->CreateTopLevelWindow(parent, urlObj, PR_TRUE, NS_CHROME_ALL_CHROME, + cb, NS_SIZETOCONTENT, NS_SIZETOCONTENT, + getter_AddRefs(window)); return rv; } @@ -327,9 +331,6 @@ NS_IMETHODIMP nsToolkitCore::ShowModalDialog(const nsString& aUrl, nsIDOMWindow* aParent) { nsresult rv; - nsIWebShellWindow *window; - - window = nsnull; nsCOMPtr urlObj; #ifndef NECKO @@ -349,9 +350,9 @@ nsToolkitCore::ShowModalDialog(const nsString& aUrl, nsIDOMWindow* aParent) { nsCOMPtr parent; DOMWindowToWebShellWindow(aParent, &parent); - rv = appShell->RunModalDialog(&window, urlObj, parent, nsnull, nsnull, 615, 480); - if (NS_SUCCEEDED(rv)) - NS_RELEASE(window); + rv = appShell->RunModalDialog(nsnull, parent, urlObj, + NS_CHROME_ALL_CHROME | NS_CHROME_OPEN_AS_DIALOG, + nsnull, 615, 480); return rv; } diff --git a/xpfe/appshell/public/nsIAppShellService.idl b/xpfe/appshell/public/nsIAppShellService.idl index 9543ee9cd3ae..0bba2dd0907b 100644 --- a/xpfe/appshell/public/nsIAppShellService.idl +++ b/xpfe/appshell/public/nsIAppShellService.idl @@ -26,7 +26,6 @@ interface nsIWebShellWindow; interface nsIURI; -interface nsIStreamObserver; interface nsIXULWindowCallbacks; interface nsICmdLineService; @@ -47,32 +46,104 @@ class nsIFactory; interface nsIAppShellService : nsISupports { + /** + * Required initialization routine. + * @param aCmdLineService is stored and passed to appshell components as + * they are initialized. + */ void Initialize(in nsICmdLineService aCmdLineService); + + /** + * Runs an application event loop: normally the main event pump which + * defines the lifetime of the application. + */ void Run(); + + /** + * Required exit routine. Stops the event loop and cleanly shuts down + * the appshell components. + */ void Shutdown(); + /** + * Create a window. + * @param aParent the parent window. Can be null. + * @param aUrl the contents of the new window. + * @param aShowWindow the window remains invisible if PR_FALSE. + * @param aChromeMask chrome flags affecting the kind of OS border + * given to the window. see nsIBrowserWindow for + * bit/flag definitions. + * @param aCallbacks interface providing C++ hooks for window initialization + * before the window is made visible. Can be null. + * Deprecated. + * @param aInitialWidth width, in pixels, of the window. Width of window + * at creation. Can be overridden by the "width" + * tag in the XUL. Set to NS_SIZETOCONTENT to force + * the window to wrap to its contents. + * @param aInitialHeight like aInitialWidth, but subtly different. + * @param aResult the newly created window is returned here. + */ void CreateTopLevelWindow(in nsIWebShellWindow aParent, in nsIURI aUrl, in boolean showWindow, - out nsIWebShellWindow aResult, - in nsIStreamObserver anObserver, + in PRUint32 aChromeMask, in nsIXULWindowCallbacks aCallbacks, - in long aInitialWidth, in long aInitialHeight); - void CreateDialogWindow( in nsIWebShellWindow aParent, - in nsIURI aUrl, - in boolean showWindow, - out nsIWebShellWindow aResult, - in nsIStreamObserver anObserver, - in nsIXULWindowCallbacks aCallbacks, - in long aInitialWidth, in long aInitialHeight); - void RunModalDialog( out nsIWebShellWindow aWindow, - in nsIURI aUrl, + in long aInitialWidth, in long aInitialHeight, + out nsIWebShellWindow aResult); + + /** + * Run a window modally. + * @param aWindow the window to run modally. If null or pointing to null, + * a new window is created. If aWindow != null, the window + * is returned from this method, but callers should use it + * carefully: it's been closed, and is therefore partially + * deconstructed. Note that all other parameters are ignored + * if an already created window is passed in. + * @param aParent the parent window. Can be null. + * @param aUrl the contents of the window. + * @param aChromeMask chrome flags affecting the kind of OS border + * given to the window. see nsIBrowserWindow for + * bit/flag definitions. + * @param aCallbacks interface providing C++ hooks for window initialization + * before the window is made visible. Deprecated. + * @param aInitialWidth width, in pixels, of the window. Width of window + * at creation. Can be overridden by the "width" + * tag in the XUL. Set to NS_SIZETOCONTENT to force + * the window to wrap to its contents. + * @param aInitialHeight like aInitialWidth. + */ + void RunModalDialog( inout nsIWebShellWindow aWindow, in nsIWebShellWindow aParent, - in nsIStreamObserver anObserver, + in nsIURI aUrl, + in PRUint32 aChromeMask, in nsIXULWindowCallbacks aCallbacks, in long aInitialWidth, in long aInitialHeight); + + /** + * Close a window. + * @param aWindow a window. + */ void CloseTopLevelWindow(in nsIWebShellWindow aWindow); + + /** + * Return the (singleton) application hidden window, automatically created + * and maintained by this AppShellService. + * @param aResult the hidden window. Do not unhide hidden window. + * Do not taunt hidden window. + */ void GetHiddenWindow(out nsIWebShellWindow aResult); + + /** + * Add a window to the application's registry of windows. These windows + * are generally shown in the Windows taskbar, and the application + * knows it can't quit until it's out of registered windows. + * @param aWindow yes + */ void RegisterTopLevelWindow(in nsIWebShellWindow aWindow); + + /** + * Remove a window from the application's window registry. + * @param aWindow you see the pattern + */ void UnregisterTopLevelWindow(in nsIWebShellWindow aWindow); }; diff --git a/xpfe/appshell/src/nsAppShellService.cpp b/xpfe/appshell/src/nsAppShellService.cpp index 18ff38fd1938..a071272670ec 100644 --- a/xpfe/appshell/src/nsAppShellService.cpp +++ b/xpfe/appshell/src/nsAppShellService.cpp @@ -31,6 +31,7 @@ #include "nsIAppShell.h" #include "nsIWidget.h" +#include "nsIBrowserWindow.h" #include "nsIWebShellWindow.h" #include "nsWebShellWindow.h" @@ -100,22 +101,18 @@ public: NS_IMETHOD Run(void); NS_IMETHOD Shutdown(void); - NS_IMETHOD CreateTopLevelWindow(nsIWebShellWindow * aParent, - nsIURI* aUrl, - PRBool showWindow, - nsIWebShellWindow** aResult, nsIStreamObserver* anObserver, + NS_IMETHOD CreateTopLevelWindow(nsIWebShellWindow *aParent, + nsIURI *aUrl, + PRBool aShowWindow, + PRUint32 aChromeMask, nsIXULWindowCallbacks *aCallbacks, - PRInt32 aInitialWidth, PRInt32 aInitialHeight); - NS_IMETHOD CreateDialogWindow( nsIWebShellWindow * aParent, - nsIURI* aUrl, - PRBool showWindow, - nsIWebShellWindow** aResult, nsIStreamObserver* anObserver, - nsIXULWindowCallbacks *aCallbacks, - PRInt32 aInitialWidth, PRInt32 aInitialHeight); + PRInt32 aInitialWidth, PRInt32 aInitialHeight, + nsIWebShellWindow **aResult); + NS_IMETHOD RunModalDialog( nsIWebShellWindow **aWindow, - nsIURI* aUrl, - nsIWebShellWindow * aParent, - nsIStreamObserver* anObserver, + nsIWebShellWindow *aParent, + nsIURI *aUrl, + PRUint32 aChromeMask, nsIXULWindowCallbacks *aCallbacks, PRInt32 aInitialWidth, PRInt32 aInitialHeight); NS_IMETHOD CloseTopLevelWindow(nsIWebShellWindow* aWindow); @@ -127,13 +124,13 @@ public: protected: virtual ~nsAppShellService(); - NS_IMETHOD JustCreateTopWindow(nsIWebShellWindow * aParent, - nsIURI* aUrl, - PRBool showWindow, - nsIWebShellWindow** aResult, - nsIStreamObserver* anObserver, + NS_IMETHOD JustCreateTopWindow(nsIWebShellWindow *aParent, + nsIURI *aUrl, + PRBool aShowWindow, + PRUint32 aChromeMask, nsIXULWindowCallbacks *aCallbacks, - PRInt32 aInitialWidth, PRInt32 aInitialHeight); + PRInt32 aInitialWidth, PRInt32 aInitialHeight, + nsIWebShellWindow **aResult); void CreateHiddenWindow(); void InitializeComponent( const nsCID &aComponentCID ); void ShutdownComponent( const nsCID &aComponentCID ); @@ -292,11 +289,11 @@ void nsAppShellService::CreateHiddenWindow() #endif if (NS_SUCCEEDED(rv)) { nsCOMPtr newWindow; - rv = JustCreateTopWindow(nsnull, url, PR_FALSE, getter_AddRefs(newWindow), - nsnull, nsnull, NS_SIZETOCONTENT, NS_SIZETOCONTENT); + rv = JustCreateTopWindow(nsnull, url, PR_FALSE, NS_CHROME_ALL_CHROME, + nsnull, 100, 100, getter_AddRefs(newWindow)); if (NS_SUCCEEDED(rv)) { mHiddenWindow = newWindow; - // Mac will want to register now, like CreateTopLevelWindow + // RegisterTopLevelWindow(newWindow); -- Mac only } NS_RELEASE(url); } @@ -504,29 +501,22 @@ nsAppShellService::Shutdown(void) /* * Create a new top level window and display the given URL within it... - * - * @param aParent - parent for the window to be created (generally null; - * included for compatibility with dialogs). - * (currently unused). - * @param aURL - location of XUL window contents description - * @param aShowWindow - whether or not to show the window initially. - * @param anObserver - a stream observer to give to the new window - * @param aConstructionCallbacks - methods which will be called during - * window construction. can be null. - * @param aInitialWidth - width of window, in pixels (currently unused) - * @param aInitialHeight - height of window, in pixels (currently unused) */ NS_IMETHODIMP nsAppShellService::CreateTopLevelWindow(nsIWebShellWindow *aParent, - nsIURI* aUrl, PRBool showWindow, - nsIWebShellWindow** aResult, nsIStreamObserver* anObserver, - nsIXULWindowCallbacks *aCallbacks, - PRInt32 aInitialWidth, PRInt32 aInitialHeight) + nsIURI *aUrl, + PRBool aShowWindow, + PRUint32 aChromeMask, + nsIXULWindowCallbacks *aCallbacks, + PRInt32 aInitialWidth, PRInt32 aInitialHeight, + nsIWebShellWindow **aResult) + { nsresult rv; - rv = JustCreateTopWindow(aParent, aUrl, showWindow, aResult, anObserver, - aCallbacks, aInitialWidth, aInitialHeight); + rv = JustCreateTopWindow(aParent, aUrl, aShowWindow, aChromeMask, + aCallbacks, aInitialWidth, aInitialHeight, + aResult); if (NS_SUCCEEDED(rv)) // the addref resulting from this is the owning addref for this window @@ -541,10 +531,12 @@ nsAppShellService::CreateTopLevelWindow(nsIWebShellWindow *aParent, */ NS_IMETHODIMP nsAppShellService::JustCreateTopWindow(nsIWebShellWindow *aParent, - nsIURI* aUrl, PRBool showWindow, - nsIWebShellWindow** aResult, nsIStreamObserver* anObserver, - nsIXULWindowCallbacks *aCallbacks, - PRInt32 aInitialWidth, PRInt32 aInitialHeight) + nsIURI *aUrl, + PRBool aShowWindow, + PRUint32 aChromeMask, + nsIXULWindowCallbacks *aCallbacks, + PRInt32 aInitialWidth, PRInt32 aInitialHeight, + nsIWebShellWindow **aResult) { nsresult rv; nsWebShellWindow* window; @@ -553,14 +545,25 @@ nsAppShellService::JustCreateTopWindow(nsIWebShellWindow *aParent, *aResult = nsnull; intrinsicallySized = PR_FALSE; window = new nsWebShellWindow(); - if (nsnull == window) { + if (!window) rv = NS_ERROR_OUT_OF_MEMORY; - } else { + else { // temporarily disabling parentage because non-Windows platforms // seem to be interpreting it in unexpected ways. nsWidgetInitData widgetInitData; - widgetInitData.mWindowType = eWindowType_toplevel; - widgetInitData.mBorderStyle = eBorderStyle_all; + + widgetInitData.mWindowType = aChromeMask & NS_CHROME_OPEN_AS_DIALOG ? + eWindowType_dialog : eWindowType_toplevel; + + widgetInitData.mBorderStyle = eBorderStyle_border; + if (aChromeMask & NS_CHROME_TITLEBAR_ON) + widgetInitData.mBorderStyle = NS_STATIC_CAST(enum nsBorderStyle, widgetInitData.mBorderStyle | eBorderStyle_title); + if (aChromeMask & NS_CHROME_WINDOW_CLOSE_ON) + widgetInitData.mBorderStyle = NS_STATIC_CAST(enum nsBorderStyle, widgetInitData.mBorderStyle | eBorderStyle_close); + if (aChromeMask & NS_CHROME_WINDOW_RESIZE_ON) + widgetInitData.mBorderStyle = NS_STATIC_CAST(enum nsBorderStyle, widgetInitData.mBorderStyle | eBorderStyle_resizeh); + if (widgetInitData.mBorderStyle == eBorderStyle_border) // no additions + widgetInitData.mBorderStyle = eBorderStyle_all; if (aInitialWidth == NS_SIZETOCONTENT || aInitialHeight == NS_SIZETOCONTENT) { @@ -571,7 +574,7 @@ nsAppShellService::JustCreateTopWindow(nsIWebShellWindow *aParent, } rv = window->Initialize((nsIWebShellWindow *) nsnull, mAppShell, aUrl, - showWindow, anObserver, aCallbacks, + aShowWindow, nsnull, aCallbacks, aInitialWidth, aInitialHeight, widgetInitData); if (NS_SUCCEEDED(rv)) { @@ -580,7 +583,7 @@ nsAppShellService::JustCreateTopWindow(nsIWebShellWindow *aParent, rv = window->QueryInterface(kIWebShellWindowIID, (void **) aResult); // if intrinsically sized, don't show until we have the size figured out - if (showWindow && !intrinsicallySized) + if (aShowWindow && !intrinsicallySized) window->Show(PR_TRUE); } @@ -608,61 +611,7 @@ nsAppShellService::GetHiddenWindow(nsIWebShellWindow **aWindow) return rv ? NS_OK : NS_ERROR_FAILURE; } -/* - * Like CreateTopLevelWindow, but with dialog window borders. This - * method is necessary because of the current misfortune that the window - * is created before its XUL description has been parsed, so the description - * can't affect attributes like window type. - */ -NS_IMETHODIMP -nsAppShellService::CreateDialogWindow(nsIWebShellWindow * aParent, - nsIURI* aUrl, PRBool showWindow, - nsIWebShellWindow** aResult, nsIStreamObserver* anObserver, - nsIXULWindowCallbacks *aCallbacks, - PRInt32 aInitialWidth, PRInt32 aInitialHeight) -{ - nsresult rv; - nsWebShellWindow* window; - PRBool intrinsicallySized; - - *aResult = nsnull; - intrinsicallySized = PR_FALSE; - window = new nsWebShellWindow(); - if (nsnull == window) { - rv = NS_ERROR_OUT_OF_MEMORY; - } else { - // temporarily disabling parentage because non-Windows platforms - // seem to be interpreting it in unexpected ways. - nsWidgetInitData widgetInitData; - widgetInitData.mWindowType = eWindowType_dialog; - widgetInitData.mBorderStyle = eBorderStyle_default; - - if (aInitialWidth == NS_SIZETOCONTENT || - aInitialHeight == NS_SIZETOCONTENT) { - aInitialWidth = 1; - aInitialHeight = 1; - intrinsicallySized = PR_TRUE; - window->SetIntrinsicallySized(PR_TRUE); - } - - rv = window->Initialize((nsIWebShellWindow *) nsnull, mAppShell, aUrl, - showWindow, anObserver, aCallbacks, - aInitialWidth, aInitialHeight, widgetInitData); - if (NS_SUCCEEDED(rv)) { - rv = window->QueryInterface(kIWebShellWindowIID, (void **) aResult); - RegisterTopLevelWindow(window); - - // if intrinsically sized, don't show until we have the size figured out - if (showWindow && !intrinsicallySized) - window->Show(PR_TRUE); - } - } - - return rv; -} - - -/* CreateDialogWindow, run it modally, and destroy it. To make initial control +/* Create a Window, run it modally, and destroy it. To make initial control settings or get information out of the dialog before dismissal, use event handlers. This wrapper method is desirable because of the complications creeping in to the modal window story: there's a lot of setup. @@ -674,14 +623,14 @@ nsAppShellService::CreateDialogWindow(nsIWebShellWindow * aParent, this function exits, that window has been partially destroyed. We return it anyway, in the hopes that it may be queried for results, somehow. This may be a mistake. It is returned addrefed (by the QueryInterface - to nsIWebShellWindow in CreateDialogWindow). + to nsIWebShellWindow in CreateTopLevelWindow). */ NS_IMETHODIMP nsAppShellService::RunModalDialog( nsIWebShellWindow **aWindow, - nsIURI* aUrl, - nsIWebShellWindow * aParent, - nsIStreamObserver *anObserver, + nsIWebShellWindow *aParent, + nsIURI *aUrl, + PRUint32 aChromeMask, nsIXULWindowCallbacks *aCallbacks, PRInt32 aInitialWidth, PRInt32 aInitialHeight) { @@ -704,8 +653,8 @@ nsAppShellService::RunModalDialog( theWindow = *aWindow; // and rv is already some success indication NS_ADDREF(theWindow); } else - rv = CreateDialogWindow(aParent, aUrl, PR_TRUE, &theWindow, anObserver, - aCallbacks, aInitialWidth, aInitialHeight); + rv = CreateTopLevelWindow(aParent, aUrl, PR_TRUE, aChromeMask, + aCallbacks, aInitialWidth, aInitialHeight, &theWindow); if (NS_SUCCEEDED(rv)) { nsCOMPtr parentWindowWidgetThing; diff --git a/xpfe/appshell/src/nsCommandLineServiceMac.cpp b/xpfe/appshell/src/nsCommandLineServiceMac.cpp index d7413b35dda2..60a2775680b5 100644 --- a/xpfe/appshell/src/nsCommandLineServiceMac.cpp +++ b/xpfe/appshell/src/nsCommandLineServiceMac.cpp @@ -36,6 +36,7 @@ static NS_DEFINE_CID(kIOServiceCID, NS_IOSERVICE_CID); #endif // NECKO #include "nsIDOMToolkitCore.h" +#include "nsIBrowserWindow.h" #include "nsIWebShellWindow.h" #include "nsIWebShell.h" #include "nsIScriptContextOwner.h" @@ -1042,10 +1043,10 @@ nsIWebShellWindow* FindWebShellWindow(nsIXULWindowCallbacks* inCallbacks) nsnull, urlObj, // nsIURI* of chrome PR_TRUE, - &aWindow, - nsnull, + NS_CHROME_ALL_CHROME, inCallbacks, // callbacks - NS_SIZETOCONTENT, NS_SIZETOCONTENT); + NS_SIZETOCONTENT, NS_SIZETOCONTENT, + &aWindow); if (NS_FAILED(rv)) return nsnull; return aWindow; diff --git a/xpfe/appshell/src/nsNetSupportDialog.cpp b/xpfe/appshell/src/nsNetSupportDialog.cpp index 3751ee26fb7e..67bd0dbfdb06 100644 --- a/xpfe/appshell/src/nsNetSupportDialog.cpp +++ b/xpfe/appshell/src/nsNetSupportDialog.cpp @@ -34,6 +34,7 @@ #include "nsNeckoUtil.h" #endif // NECKO #include "nsIDOMHTMLInputElement.h" +#include "nsIBrowserWindow.h" #include "nsIWebShellWindow.h" #include "nsIDOMEventReceiver.h" #include "nsIURL.h" @@ -519,13 +520,15 @@ nsresult nsNetSupportDialog::DoDialog( nsString& inXULURL ) return result; } - result = appShellService->CreateDialogWindow(nsnull, dialogURL, PR_TRUE, - &dialogWindow, nsnull, this, 300, 200); + result = appShellService->CreateTopLevelWindow(nsnull, dialogURL, PR_TRUE, + NS_CHROME_ALL_CHROME | NS_CHROME_OPEN_AS_DIALOG, + this, 300, 200, &dialogWindow); mWebShellWindow = dialogWindow; if (NS_SUCCEEDED(result)) - appShellService->RunModalDialog(&dialogWindow, dialogURL, nsnull, - nsnull, this, 300, 200); + appShellService->RunModalDialog(&dialogWindow, nsnull, dialogURL, + NS_CHROME_ALL_CHROME | NS_CHROME_OPEN_AS_DIALOG, + this, 300, 200); // cleanup if ( mOKButton ) diff --git a/xpfe/appshell/src/nsWebShellWindow.cpp b/xpfe/appshell/src/nsWebShellWindow.cpp index 3f49d21c926d..5f5221021ad0 100644 --- a/xpfe/appshell/src/nsWebShellWindow.cpp +++ b/xpfe/appshell/src/nsWebShellWindow.cpp @@ -1403,19 +1403,15 @@ nsWebShellWindow::NewWebShell(PRUint32 aChromeMask, PRBool aVisible, nsCOMPtr newWindow; - PRBool openAsDialog = ((aChromeMask & NS_CHROME_OPEN_AS_DIALOG) != 0); - // XXX Check modal chrome flag to run a modal dialog! if ((aChromeMask & NS_CHROME_OPEN_AS_CHROME) != 0) { // Just do a nice normal create of a web shell and // return it immediately. - if (openAsDialog) - rv = appShell->CreateDialogWindow(nsnull, nsnull, PR_FALSE, getter_AddRefs(newWindow), - nsnull, nsnull, NS_SIZETOCONTENT, NS_SIZETOCONTENT); - else rv = appShell->CreateTopLevelWindow(nsnull, nsnull, PR_FALSE, getter_AddRefs(newWindow), - nsnull, nsnull, NS_SIZETOCONTENT, NS_SIZETOCONTENT); + rv = appShell->CreateTopLevelWindow(nsnull, nsnull, PR_FALSE, aChromeMask, + nsnull, NS_SIZETOCONTENT, NS_SIZETOCONTENT, + getter_AddRefs(newWindow)); if (NS_SUCCEEDED(rv)) { nsCOMPtr browser(do_QueryInterface(newWindow)); if (browser) @@ -1457,11 +1453,9 @@ nsWebShellWindow::NewWebShell(PRUint32 aChromeMask, PRBool aVisible, #endif // NECKO if (NS_SUCCEEDED(rv)) { - if (openAsDialog) - rv = appShell->CreateDialogWindow(nsnull, urlObj, PR_FALSE, getter_AddRefs(newWindow), - nsnull, nsnull, 615, 480); - else rv = appShell->CreateTopLevelWindow(nsnull, urlObj, PR_FALSE, getter_AddRefs(newWindow), - nsnull, nsnull, 615, 480); + rv = appShell->CreateTopLevelWindow(nsnull, urlObj, PR_FALSE, aChromeMask, + nsnull, 615, 480, + getter_AddRefs(newWindow)); } nsIAppShell *subshell; diff --git a/xpfe/bootstrap/nsAppRunner.cpp b/xpfe/bootstrap/nsAppRunner.cpp index edc65775a265..bfa474554ddb 100644 --- a/xpfe/bootstrap/nsAppRunner.cpp +++ b/xpfe/bootstrap/nsAppRunner.cpp @@ -23,6 +23,7 @@ #include "nsNeckoUtil.h" #endif // NECKO #include "nsIWidget.h" +#include "nsIBrowserWindow.h" #include "nsIWebShellWindow.h" #include "nsIPref.h" #include "plevent.h" @@ -648,9 +649,11 @@ int main(int argc, char* argv[]) goto done; } - nsCOMPtr profWindow; - rv = profAppShell->CreateTopLevelWindow(nsnull, profURL, PR_TRUE, getter_AddRefs(profWindow), - nsnull, nsnull, profWinWidth, profWinHeight); + nsCOMPtr profWindow; + rv = profAppShell->CreateTopLevelWindow(nsnull, profURL, + PR_TRUE, NS_CHROME_ALL_CHROME, + nsnull, profWinWidth, profWinHeight, + getter_AddRefs(profWindow)); NS_RELEASE(profURL); @@ -698,8 +701,10 @@ int main(int argc, char* argv[]) if ( !useArgs ) { nsCOMPtr newWindow; - rv = appShell->CreateTopLevelWindow(nsnull, url, PR_TRUE, getter_AddRefs(newWindow), - nsnull, nsnull, NS_SIZETOCONTENT, NS_SIZETOCONTENT); + rv = appShell->CreateTopLevelWindow(nsnull, url, + PR_TRUE, NS_CHROME_ALL_CHROME, + nsnull, NS_SIZETOCONTENT, NS_SIZETOCONTENT, + getter_AddRefs(newWindow)); } else { nsIDOMToolkitCore* toolkit = nsnull; rv = nsServiceManager::GetService(kToolkitCoreCID, diff --git a/xpfe/browser/samples/Makefile.in b/xpfe/browser/samples/Makefile.in index b17feb6631f1..4da4c4727f0c 100644 --- a/xpfe/browser/samples/Makefile.in +++ b/xpfe/browser/samples/Makefile.in @@ -30,8 +30,10 @@ EXPORT_RESOURCE_SAMPLES = \ $(srcdir)/dexanimdialog.xul \ $(srcdir)/dexparammaster.xul \ $(srcdir)/dexparamdialog.xul \ + $(srcdir)/dexparamdialog.html \ $(srcdir)/dexsimplemaster.xul \ $(srcdir)/dexsimpledialog.xul \ + $(srcdir)/dexopenchrome.xul \ $(srcdir)/tab.xul \ $(srcdir)/xpmenu.xul \ $(NULL) diff --git a/xpfe/browser/samples/dexopenchrome.xul b/xpfe/browser/samples/dexopenchrome.xul new file mode 100644 index 000000000000..b59c06eee5f5 --- /dev/null +++ b/xpfe/browser/samples/dexopenchrome.xul @@ -0,0 +1,64 @@ + + + + + + + + + 0) + features = features + ","; + features = features + featureList[ctr]; + } else { + if (featureList[ctr] == "titlebar" || featureList[ctr] == "close" || + featureList[ctr] == "resizable") { + if (features.length > 0) + features = features + ","; + features = features + featureList[ctr] + "=no"; + } + } + } + dump("******* " + features + "\n"); + window.openDialog("resource://res/samples/dexparamdialog."+extension, + "New", features, {remind:true}); + } + ]]> + + + + close + titlebar + resizable + scrollbars + chrome + dialog + modal + menubar + toolbar + status + location + + + + diff --git a/xpfe/browser/samples/dexparamdialog.html b/xpfe/browser/samples/dexparamdialog.html new file mode 100644 index 000000000000..4f6cad3127b8 --- /dev/null +++ b/xpfe/browser/samples/dexparamdialog.html @@ -0,0 +1,210 @@ + + + + + + + + + + + + + + + + + + + + + + + +
Give me your money
+ + Remind me +
+ +
+ +
+ +
+ +
+ + diff --git a/xpfe/browser/samples/makefile.win b/xpfe/browser/samples/makefile.win index 2b175f4f0104..125a00a175cd 100644 --- a/xpfe/browser/samples/makefile.win +++ b/xpfe/browser/samples/makefile.win @@ -26,8 +26,10 @@ install:: $(DLL) $(MAKE_INSTALL) dexanimdialog.xul $(DIST)\bin\res\samples $(MAKE_INSTALL) dexparammaster.xul $(DIST)\bin\res\samples $(MAKE_INSTALL) dexparamdialog.xul $(DIST)\bin\res\samples + $(MAKE_INSTALL) dexparamdialog.html $(DIST)\bin\res\samples $(MAKE_INSTALL) dexsimplemaster.xul $(DIST)\bin\res\samples $(MAKE_INSTALL) dexsimpledialog.xul $(DIST)\bin\res\samples + $(MAKE_INSTALL) dexopenchrome.xul $(DIST)\bin\res\samples $(MAKE_INSTALL) tab.xul $(DIST)\bin\res\samples $(MAKE_INSTALL) xpmenu.xul $(DIST)\bin\res\samples @@ -36,6 +38,9 @@ clobber:: rm -f $(DIST)\res\samples\dexanimdialog.xul rm -f $(DIST)\res\samples\dexparammaster.xul rm -f $(DIST)\res\samples\dexparamdialog.xul + rm -f $(DIST)\res\samples\dexparamdialog.html rm -f $(DIST)\res\samples\dexsimplemaster.xul rm -f $(DIST)\res\samples\dexsimpledialog.xul + rm -f $(DIST)\res\samples\dexopenchrome.xul rm -f $(DIST)\res\samples\tab.xul + rm -f $(DIST)\res\samples\xpmenu.xul diff --git a/xpfe/components/prefwindow/src/nsPrefWindow.cpp b/xpfe/components/prefwindow/src/nsPrefWindow.cpp index 609d956f16e5..ef2c7bb7cdb2 100644 --- a/xpfe/components/prefwindow/src/nsPrefWindow.cpp +++ b/xpfe/components/prefwindow/src/nsPrefWindow.cpp @@ -182,7 +182,6 @@ NS_IMETHODIMP nsPrefWindow::showWindow( return NS_ERROR_FAILURE; // (code adapted from nsToolkitCore::ShowModal. yeesh.) - nsIWebShellWindow* window = nsnull; nsCOMPtr urlObj; char * urlStr = "chrome://pref/content/"; nsresult rv; @@ -209,13 +208,9 @@ NS_IMETHODIMP nsPrefWindow::showWindow( nsIXULWindowCallbacks *cb = nsnull; nsCOMPtr parent; DOMWindowToWebShellWindow(currentFrontWin, &parent); - appShell->CreateDialogWindow(parent, urlObj, PR_TRUE, &window, - nsnull, cb, 504, 436); - if (window != nsnull) - { - appShell->RunModalDialog(&window, nsnull, parent, nsnull, cb, 504, 436); - NS_RELEASE(window); - } + rv = appShell->RunModalDialog(nsnull, parent, nsnull, + NS_CHROME_ALL_CHROME | NS_CHROME_OPEN_AS_DIALOG, + cb, 504, 436); return rv; } // nsPrefWindow::showWindow() diff --git a/xpfe/components/startup/src/nsCommandLineServiceMac.cpp b/xpfe/components/startup/src/nsCommandLineServiceMac.cpp index d7413b35dda2..60a2775680b5 100644 --- a/xpfe/components/startup/src/nsCommandLineServiceMac.cpp +++ b/xpfe/components/startup/src/nsCommandLineServiceMac.cpp @@ -36,6 +36,7 @@ static NS_DEFINE_CID(kIOServiceCID, NS_IOSERVICE_CID); #endif // NECKO #include "nsIDOMToolkitCore.h" +#include "nsIBrowserWindow.h" #include "nsIWebShellWindow.h" #include "nsIWebShell.h" #include "nsIScriptContextOwner.h" @@ -1042,10 +1043,10 @@ nsIWebShellWindow* FindWebShellWindow(nsIXULWindowCallbacks* inCallbacks) nsnull, urlObj, // nsIURI* of chrome PR_TRUE, - &aWindow, - nsnull, + NS_CHROME_ALL_CHROME, inCallbacks, // callbacks - NS_SIZETOCONTENT, NS_SIZETOCONTENT); + NS_SIZETOCONTENT, NS_SIZETOCONTENT, + &aWindow); if (NS_FAILED(rv)) return nsnull; return aWindow; diff --git a/xpfe/components/xfer/src/nsDownloadProgressDialog.cpp b/xpfe/components/xfer/src/nsDownloadProgressDialog.cpp index a6b8314a215b..4e561b97dbbe 100644 --- a/xpfe/components/xfer/src/nsDownloadProgressDialog.cpp +++ b/xpfe/components/xfer/src/nsDownloadProgressDialog.cpp @@ -19,6 +19,7 @@ #include "nsIAppShellComponentImpl.h" +#include "nsIBrowserWindow.h" #include "nsIServiceManager.h" #include "nsIDocumentViewer.h" #include "nsIContent.h" @@ -141,11 +142,11 @@ nsDownloadProgressDialog::Show() { rv = appShell->CreateTopLevelWindow( nsnull, url, PR_TRUE, - getter_AddRefs(newWindow), - nsnull, + NS_CHROME_ALL_CHROME, this, 0, - 0 ); + 0, + getter_AddRefs(newWindow)); if ( NS_SUCCEEDED( rv ) ) { mWindow = newWindow; } else { diff --git a/xpinstall/src/nsInstallProgressDialog.cpp b/xpinstall/src/nsInstallProgressDialog.cpp index f623cc64c674..b339ed29977f 100644 --- a/xpinstall/src/nsInstallProgressDialog.cpp +++ b/xpinstall/src/nsInstallProgressDialog.cpp @@ -28,6 +28,7 @@ #include "nsIAppShellComponentImpl.h" +#include "nsIBrowserWindow.h" #include "nsIServiceManager.h" #include "nsIDocumentViewer.h" #include "nsIContent.h" @@ -232,11 +233,11 @@ nsInstallProgressDialog::Open() rv = appShell->CreateTopLevelWindow( nsnull, url, PR_TRUE, - getter_AddRefs(mWindow), - nsnull, + NS_CHROME_ALL_CHROME, this, // callbacks?? 0, - 0 ); + 0, + getter_AddRefs(mWindow)); if ( NS_SUCCEEDED( rv ) ) {