diff --git a/editor/base/nsEditorShell.cpp b/editor/base/nsEditorShell.cpp index 0e26e0e239e0..6d23eb0b12d3 100644 --- a/editor/base/nsEditorShell.cpp +++ b/editor/base/nsEditorShell.cpp @@ -761,7 +761,7 @@ nsEditorShell::CreateWindowWithURL(const char* urlStr) if (NS_FAILED(rv) || !url) goto done; - appShell->CreateTopLevelWindow(nsnull, url, PR_TRUE, *getter_AddRefs(newWindow), + appShell->CreateTopLevelWindow(nsnull, url, PR_TRUE, getter_AddRefs(newWindow), nsnull, nsnull, 615, 480); done: diff --git a/editor/composer/src/nsEditorShell.cpp b/editor/composer/src/nsEditorShell.cpp index 0e26e0e239e0..6d23eb0b12d3 100644 --- a/editor/composer/src/nsEditorShell.cpp +++ b/editor/composer/src/nsEditorShell.cpp @@ -761,7 +761,7 @@ nsEditorShell::CreateWindowWithURL(const char* urlStr) if (NS_FAILED(rv) || !url) goto done; - appShell->CreateTopLevelWindow(nsnull, url, PR_TRUE, *getter_AddRefs(newWindow), + appShell->CreateTopLevelWindow(nsnull, url, PR_TRUE, getter_AddRefs(newWindow), nsnull, nsnull, 615, 480); done: diff --git a/mailnews/base/src/nsMessenger.cpp b/mailnews/base/src/nsMessenger.cpp index 2d16945f8a42..6527697eaebf 100644 --- a/mailnews/base/src/nsMessenger.cpp +++ b/mailnews/base/src/nsMessenger.cpp @@ -278,7 +278,7 @@ nsMessenger::Open3PaneWindow() appShell->CreateTopLevelWindow(nsnull, // parent url, PR_TRUE, - *getter_AddRefs(newWindow), // result widget + getter_AddRefs(newWindow), // result widget nsnull, // observer nsnull, // callbacks 200, // width diff --git a/mailnews/compose/tests/compose/test.cpp b/mailnews/compose/tests/compose/test.cpp index 03521c3bd747..a309976735bf 100644 --- a/mailnews/compose/tests/compose/test.cpp +++ b/mailnews/compose/tests/compose/test.cpp @@ -202,7 +202,7 @@ int main(int argc, char *argv[]) kIAppShellServiceIID, (nsISupports**)&appShell); if (NS_SUCCEEDED(rv)) - appShell->CreateTopLevelWindow(nsnull, nsnull, PR_TRUE, *getter_AddRefs(newWindow), + appShell->CreateTopLevelWindow(nsnull, nsnull, PR_TRUE, getter_AddRefs(newWindow), nsnull, nsnull, 200, 200); // Create the Event Queue for this thread... diff --git a/mailnews/compose/tests/sendlater/test.cpp b/mailnews/compose/tests/sendlater/test.cpp index 5d588cb11db8..0a0af685c47f 100644 --- a/mailnews/compose/tests/sendlater/test.cpp +++ b/mailnews/compose/tests/sendlater/test.cpp @@ -137,7 +137,7 @@ int main(int argc, char *argv[]) kIAppShellServiceIID, (nsISupports**)&appShell); if (NS_SUCCEEDED(rv)) - appShell->CreateTopLevelWindow(nsnull, nsnull, PR_TRUE, *getter_AddRefs(newWindow), + appShell->CreateTopLevelWindow(nsnull, nsnull, PR_TRUE, getter_AddRefs(newWindow), nsnull, nsnull, 200, 200); // Create the Event Queue for this thread... diff --git a/profile/pref-migrator/src/nsPMProgressDlg.cpp b/profile/pref-migrator/src/nsPMProgressDlg.cpp index f96052ac1281..263e4076d4bf 100644 --- a/profile/pref-migrator/src/nsPMProgressDlg.cpp +++ b/profile/pref-migrator/src/nsPMProgressDlg.cpp @@ -173,7 +173,7 @@ nsPrefMigrationProgressDialog::CreateProfileProgressDialog() rv = appShell->CreateTopLevelWindow( nsnull, url, PR_TRUE, - *getter_AddRefs(newWindow), + getter_AddRefs(newWindow), nsnull, this, // callbacks?? 0, diff --git a/xpfe/AppCores/src/nsBrowserAppCore.cpp b/xpfe/AppCores/src/nsBrowserAppCore.cpp index d0476914e6e0..80dd628504e8 100644 --- a/xpfe/AppCores/src/nsBrowserAppCore.cpp +++ b/xpfe/AppCores/src/nsBrowserAppCore.cpp @@ -411,7 +411,7 @@ newWind(char* urlName) if (NS_FAILED(rv)) return rv; nsCOMPtr newWindow; - appShell->CreateTopLevelWindow(nsnull, url, PR_TRUE, *getter_AddRefs(newWindow), + appShell->CreateTopLevelWindow(nsnull, url, PR_TRUE, getter_AddRefs(newWindow), nsnull, nsnull, 615, 480); NS_RELEASE(url); @@ -478,23 +478,15 @@ nsBrowserAppCore::WalletEditor(nsIDOMWindow* aWin) nsCOMPtr parent; DOMWindowToWebShellWindow(aWin, &parent); - appShell->CreateDialogWindow(parent, urlObj, PR_TRUE, window, + window = nsnull; + 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); + } nsServiceManager::ReleaseService(kAppShellServiceCID, appShell); - if (window != nsnull) { - nsCOMPtr parentWindowWidgetThing; - nsresult gotParent; - gotParent = parent ? parent->GetWidget(*getter_AddRefs(parentWindowWidgetThing)) : - NS_ERROR_FAILURE; - // Windows OS is the only one that needs the parent disabled, or cares - // arguably this should be done by the new window, within ShowModal... - if (NS_SUCCEEDED(gotParent)) - parentWindowWidgetThing->Enable(PR_FALSE); - window->ShowModal(); - if (NS_SUCCEEDED(gotParent)) - parentWindowWidgetThing->Enable(PR_TRUE); - } return rv; } @@ -537,23 +529,14 @@ nsBrowserAppCore::SignonViewer(nsIDOMWindow* aWin) nsCOMPtr parent; DOMWindowToWebShellWindow(aWin, &parent); - appShell->CreateDialogWindow(parent, urlObj, PR_TRUE, window, + window = nsnull; + appShell->CreateDialogWindow(parent, urlObj, PR_TRUE, &window, nsnull, cb, 504, 436); - nsServiceManager::ReleaseService(kAppShellServiceCID, appShell); - if (window != nsnull) { - nsCOMPtr parentWindowWidgetThing; - nsresult gotParent; - gotParent = parent ? parent->GetWidget(*getter_AddRefs(parentWindowWidgetThing)) : - NS_ERROR_FAILURE; - // Windows OS is the only one that needs the parent disabled, or cares - // arguably this should be done by the new window, within ShowModal... - if (NS_SUCCEEDED(gotParent)) - parentWindowWidgetThing->Enable(PR_FALSE); - window->ShowModal(); - if (NS_SUCCEEDED(gotParent)) - parentWindowWidgetThing->Enable(PR_TRUE); + appShell->RunModalDialog(&window, nsnull, parent, nsnull, cb, 504, 436); + NS_RELEASE(window); } + nsServiceManager::ReleaseService(kAppShellServiceCID, appShell); return rv; } @@ -596,23 +579,16 @@ nsBrowserAppCore::CookieViewer(nsIDOMWindow* aWin) nsCOMPtr parent; DOMWindowToWebShellWindow(aWin, &parent); - appShell->CreateDialogWindow(parent, urlObj, PR_TRUE, window, + window = nsnull; + appShell->CreateDialogWindow(parent, urlObj, PR_TRUE, &window, nsnull, cb, 504, 436); - nsServiceManager::ReleaseService(kAppShellServiceCID, appShell); if (window != nsnull) { - nsCOMPtr parentWindowWidgetThing; - nsresult gotParent; - gotParent = parent ? parent->GetWidget(*getter_AddRefs(parentWindowWidgetThing)) : - NS_ERROR_FAILURE; - // Windows OS is the only one that needs the parent disabled, or cares - // arguably this should be done by the new window, within ShowModal... - if (NS_SUCCEEDED(gotParent)) - parentWindowWidgetThing->Enable(PR_FALSE); - window->ShowModal(); - if (NS_SUCCEEDED(gotParent)) - parentWindowWidgetThing->Enable(PR_TRUE); + appShell->RunModalDialog(&window, nsnull, parent, nsnull, cb, 504, 436); + NS_RELEASE(window); } + + nsServiceManager::ReleaseService(kAppShellServiceCID, appShell); return rv; } @@ -698,23 +674,15 @@ nsBrowserAppCore::WalletPreview(nsIDOMWindow* aWin, nsIDOMWindow* aForm) nsCOMPtr parent; DOMWindowToWebShellWindow(aWin, &parent); - appShell->CreateDialogWindow(parent, urlObj, PR_TRUE, window, + window = nsnull; + 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); + } nsServiceManager::ReleaseService(kAppShellServiceCID, appShell); - if (window != nsnull) { - nsCOMPtr parentWindowWidgetThing; - nsresult gotParent; - gotParent = parent ? parent->GetWidget(*getter_AddRefs(parentWindowWidgetThing)) : - NS_ERROR_FAILURE; - // Windows OS is the only one that needs the parent disabled, or cares - // arguably this should be done by the new window, within ShowModal... - if (NS_SUCCEEDED(gotParent)) - parentWindowWidgetThing->Enable(PR_FALSE); - window->ShowModal(); - if (NS_SUCCEEDED(gotParent)) - parentWindowWidgetThing->Enable(PR_TRUE); - } return rv; } @@ -1462,7 +1430,7 @@ nsBrowserAppCore::NewWindow() if (NS_FAILED(rv)) return rv; nsCOMPtr newWindow; - appShell->CreateTopLevelWindow(nsnull, url, PR_TRUE, *getter_AddRefs(newWindow), + appShell->CreateTopLevelWindow(nsnull, url, PR_TRUE, getter_AddRefs(newWindow), nsnull, nsnull, 615, 480); NS_RELEASE(url); @@ -1731,7 +1699,7 @@ nsBrowserAppCore::DoDialog() if (NS_FAILED(rv)) return rv; - rv = appShell->RunModalDialog(mWebShellWin, urlObj, window, nsnull, nsnull, 300, 200); + rv = appShell->RunModalDialog(&window, urlObj, mWebShellWin, nsnull, nsnull, 300, 200); if (NS_SUCCEEDED(rv)) NS_RELEASE(window); return rv; diff --git a/xpfe/AppCores/src/nsDOMPropsCore.cpp b/xpfe/AppCores/src/nsDOMPropsCore.cpp index 858f34256d50..a5545fd1c789 100644 --- a/xpfe/AppCores/src/nsDOMPropsCore.cpp +++ b/xpfe/AppCores/src/nsDOMPropsCore.cpp @@ -469,7 +469,7 @@ nsDOMPropsCore::ShowProperties(const nsString& aUrl, nsIDOMWindow* aParent, nsID nsCOMPtr parent = DOMWindowToWebShellWindow(aParent); nsCOMPtr newWindow; - rv = appShell->CreateTopLevelWindow(parent, urlObj, PR_TRUE, *getter_AddRefs(newWindow), + rv = appShell->CreateTopLevelWindow(parent, urlObj, PR_TRUE, getter_AddRefs(newWindow), nsnull, dialog, 450, 240); nsServiceManager::ReleaseService(kAppShellServiceCID, appShell); diff --git a/xpfe/AppCores/src/nsToolkitCore.cpp b/xpfe/AppCores/src/nsToolkitCore.cpp index 88deea9eda35..bb4416e4cd66 100644 --- a/xpfe/AppCores/src/nsToolkitCore.cpp +++ b/xpfe/AppCores/src/nsToolkitCore.cpp @@ -172,7 +172,8 @@ nsToolkitCore::ShowDialog(const nsString& aUrl, nsIDOMWindow* aParent) { nsCOMPtr parent; DOMWindowToWebShellWindow(aParent, &parent); - appShell->CreateDialogWindow(parent, urlObj, PR_TRUE, window, + window = nsnull; + appShell->CreateDialogWindow(parent, urlObj, PR_TRUE, &window, nsnull, nsnull, 615, 480); if (window != nsnull) @@ -212,7 +213,7 @@ nsToolkitCore::ShowWindow(const nsString& aUrl, nsIDOMWindow* aParent) { nsCOMPtr parent; DOMWindowToWebShellWindow(aParent, &parent); nsCOMPtr window; - appShell->CreateTopLevelWindow(parent, urlObj, PR_TRUE, *getter_AddRefs(window), + appShell->CreateTopLevelWindow(parent, urlObj, PR_TRUE, getter_AddRefs(window), nsnull, nsnull, 615, 480); if (window) @@ -337,7 +338,7 @@ nsToolkitCore::ShowWindowWithArgs(const nsString& aUrl, cb = nsDontQueryInterface( new nsArgCallbacks( aArgs ) ); nsCOMPtr window; - appShell->CreateTopLevelWindow(parent, urlObj, PR_TRUE, *getter_AddRefs(window), + appShell->CreateTopLevelWindow(parent, urlObj, PR_TRUE, getter_AddRefs(window), nsnull, cb, 615, 650); if (window) @@ -378,7 +379,7 @@ nsToolkitCore::ShowModalDialog(const nsString& aUrl, nsIDOMWindow* aParent) { nsCOMPtr parent; DOMWindowToWebShellWindow(aParent, &parent); - rv = appShell->RunModalDialog(parent, urlObj, window, nsnull, nsnull, 615, 480); + rv = appShell->RunModalDialog(&window, urlObj, parent, nsnull, nsnull, 615, 480); if (NS_SUCCEEDED(rv)) NS_RELEASE(window); return rv; diff --git a/xpfe/appshell/public/nsIAppShellService.h b/xpfe/appshell/public/nsIAppShellService.h index c9cc51aacce4..a41264c8cfb3 100644 --- a/xpfe/appshell/public/nsIAppShellService.h +++ b/xpfe/appshell/public/nsIAppShellService.h @@ -52,18 +52,19 @@ public: NS_IMETHOD CreateTopLevelWindow(nsIWebShellWindow * aParent, nsIURI* aUrl, PRBool showWindow, - nsIWebShellWindow*& aResult, nsIStreamObserver* anObserver, + nsIWebShellWindow** aResult, nsIStreamObserver* anObserver, nsIXULWindowCallbacks *aCallbacks, PRInt32 aInitialWidth, PRInt32 aInitialHeight) = 0; NS_IMETHOD CreateDialogWindow( nsIWebShellWindow * aParent, nsIURI* aUrl, PRBool showWindow, - nsIWebShellWindow*& aResult, nsIStreamObserver* anObserver, + nsIWebShellWindow** aResult, nsIStreamObserver* anObserver, nsIXULWindowCallbacks *aCallbacks, PRInt32 aInitialWidth, PRInt32 aInitialHeight) = 0; - NS_IMETHOD RunModalDialog( nsIWebShellWindow * aParent, + NS_IMETHOD RunModalDialog( nsIWebShellWindow **aWindow, nsIURI* aUrl, - nsIWebShellWindow*& aResult, nsIStreamObserver* anObserver, + nsIWebShellWindow * aParent, + nsIStreamObserver* anObserver, nsIXULWindowCallbacks *aCallbacks, PRInt32 aInitialWidth, PRInt32 aInitialHeight) = 0; NS_IMETHOD CloseTopLevelWindow(nsIWebShellWindow* aWindow) = 0; diff --git a/xpfe/appshell/src/nsAppShellService.cpp b/xpfe/appshell/src/nsAppShellService.cpp index 711268b44162..3f553a6f03df 100644 --- a/xpfe/appshell/src/nsAppShellService.cpp +++ b/xpfe/appshell/src/nsAppShellService.cpp @@ -100,18 +100,19 @@ public: NS_IMETHOD CreateTopLevelWindow(nsIWebShellWindow * aParent, nsIURI* aUrl, PRBool showWindow, - nsIWebShellWindow*& aResult, nsIStreamObserver* anObserver, + nsIWebShellWindow** aResult, nsIStreamObserver* anObserver, nsIXULWindowCallbacks *aCallbacks, PRInt32 aInitialWidth, PRInt32 aInitialHeight); NS_IMETHOD CreateDialogWindow( nsIWebShellWindow * aParent, nsIURI* aUrl, PRBool showWindow, - nsIWebShellWindow*& aResult, nsIStreamObserver* anObserver, + nsIWebShellWindow** aResult, nsIStreamObserver* anObserver, nsIXULWindowCallbacks *aCallbacks, PRInt32 aInitialWidth, PRInt32 aInitialHeight); - NS_IMETHOD RunModalDialog( nsIWebShellWindow * aParent, + NS_IMETHOD RunModalDialog( nsIWebShellWindow **aWindow, nsIURI* aUrl, - nsIWebShellWindow*& aResult, nsIStreamObserver* anObserver, + nsIWebShellWindow * aParent, + nsIStreamObserver* anObserver, nsIXULWindowCallbacks *aCallbacks, PRInt32 aInitialWidth, PRInt32 aInitialHeight); NS_IMETHOD CloseTopLevelWindow(nsIWebShellWindow* aWindow); @@ -478,14 +479,14 @@ nsAppShellService::Shutdown(void) NS_IMETHODIMP nsAppShellService::CreateTopLevelWindow(nsIWebShellWindow *aParent, nsIURI* aUrl, PRBool showWindow, - nsIWebShellWindow*& aResult, nsIStreamObserver* anObserver, + nsIWebShellWindow** aResult, nsIStreamObserver* anObserver, nsIXULWindowCallbacks *aCallbacks, PRInt32 aInitialWidth, PRInt32 aInitialHeight) { nsresult rv; nsWebShellWindow* window; - aResult = nsnull; + *aResult = nsnull; window = new nsWebShellWindow(); if (nsnull == window) { rv = NS_ERROR_OUT_OF_MEMORY; @@ -498,7 +499,7 @@ nsAppShellService::CreateTopLevelWindow(nsIWebShellWindow *aParent, if (NS_SUCCEEDED(rv)) { // this does the AddRef of the return value - rv = window->QueryInterface(kIWebShellWindowIID, (void **) &aResult); + rv = window->QueryInterface(kIWebShellWindowIID, (void **) aResult); // the addref resulting from this is the owning addref for this window RegisterTopLevelWindow(window); @@ -526,14 +527,14 @@ nsAppShellService::CloseTopLevelWindow(nsIWebShellWindow* aWindow) NS_IMETHODIMP nsAppShellService::CreateDialogWindow(nsIWebShellWindow * aParent, nsIURI* aUrl, PRBool showWindow, - nsIWebShellWindow*& aResult, nsIStreamObserver* anObserver, + nsIWebShellWindow** aResult, nsIStreamObserver* anObserver, nsIXULWindowCallbacks *aCallbacks, PRInt32 aInitialWidth, PRInt32 aInitialHeight) { nsresult rv; nsWebShellWindow* window; - aResult = nsnull; + *aResult = nsnull; window = new nsWebShellWindow(); if (nsnull == window) { rv = NS_ERROR_OUT_OF_MEMORY; @@ -544,7 +545,7 @@ nsAppShellService::CreateDialogWindow(nsIWebShellWindow * aParent, anObserver, aCallbacks, aInitialWidth, aInitialHeight); if (NS_SUCCEEDED(rv)) { - rv = window->QueryInterface(kIWebShellWindowIID, (void **) &aResult); + rv = window->QueryInterface(kIWebShellWindowIID, (void **) aResult); RegisterTopLevelWindow(window); if (showWindow) window->Show(PR_TRUE); @@ -561,22 +562,25 @@ nsAppShellService::CreateDialogWindow(nsIWebShellWindow * aParent, complications creeping in to the modal window story: there's a lot of setup. See the code.. - Note that the window created is returned in aResult. By the time 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). + If a window is passed in via the first parameter, that window will be + the one displayed modally. If no window is passed in (if *aWindow is null) + the window created will be returned in *aWindow. Note that by the time + 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). */ NS_IMETHODIMP nsAppShellService::RunModalDialog( - nsIWebShellWindow *aParent, nsIURI* aUrl, - nsIWebShellWindow*& aResult, nsIStreamObserver *anObserver, + nsIWebShellWindow **aWindow, + nsIURI* aUrl, + nsIWebShellWindow * aParent, + nsIStreamObserver *anObserver, nsIXULWindowCallbacks *aCallbacks, PRInt32 aInitialWidth, PRInt32 aInitialHeight) { - - nsresult rv; - + nsresult rv; + nsIWebShellWindow *theWindow; #ifdef XP_PC // XXX: Won't work with any other platforms yet. // First push a nested event queue for event processing from netlib @@ -590,8 +594,12 @@ nsAppShellService::RunModalDialog( eQueueService->PushThreadEventQueue(); #endif - rv = CreateDialogWindow(aParent, aUrl, PR_TRUE, aResult, anObserver, aCallbacks, - aInitialWidth, aInitialHeight); + if (aWindow && *aWindow) { + theWindow = *aWindow; // and rv is already some success indication + NS_ADDREF(theWindow); + } else + rv = CreateDialogWindow(aParent, aUrl, PR_TRUE, &theWindow, anObserver, + aCallbacks, aInitialWidth, aInitialHeight); if (NS_SUCCEEDED(rv)) { nsCOMPtr parentWindowWidgetThing; @@ -601,9 +609,18 @@ nsAppShellService::RunModalDialog( // Windows OS wants the parent disabled for modality if (NS_SUCCEEDED(gotParent)) parentWindowWidgetThing->Enable(PR_FALSE); - aResult->ShowModal(); + theWindow->ShowModal(); if (NS_SUCCEEDED(gotParent)) parentWindowWidgetThing->Enable(PR_TRUE); + + // return the used window if possible, or otherwise get rid of it + if (aWindow) + if (*aWindow) + NS_RELEASE(theWindow); // we borrowed it, now let it go + else + *aWindow = theWindow; // and it's addrefed from Create... + else + NS_RELEASE(theWindow); // can't return it; let it go } // Release the event queue diff --git a/xpfe/appshell/src/nsCommandLineServiceMac.cpp b/xpfe/appshell/src/nsCommandLineServiceMac.cpp index 115def205a53..de437acba58b 100644 --- a/xpfe/appshell/src/nsCommandLineServiceMac.cpp +++ b/xpfe/appshell/src/nsCommandLineServiceMac.cpp @@ -1006,7 +1006,7 @@ nsIWebShellWindow* FindWebShellWindow(nsIXULWindowCallbacks* inCallbacks) nsnull, urlObj, // nsIURI* of chrome PR_TRUE, - aWindow, + *aWindow, nsnull, inCallbacks, // callbacks windowWidth, windowHeight); diff --git a/xpfe/appshell/src/nsNetSupportDialog.cpp b/xpfe/appshell/src/nsNetSupportDialog.cpp index bd49e3bb6eb5..75179e0b99b4 100644 --- a/xpfe/appshell/src/nsNetSupportDialog.cpp +++ b/xpfe/appshell/src/nsNetSupportDialog.cpp @@ -302,6 +302,9 @@ nsNetSupportDialog::nsNetSupportDialog() nsNetSupportDialog::~nsNetSupportDialog() { + // just making sure I understand what I'm doing... + NS_ASSERTION( !mWebShellWindow, "webshell window still exists in ~nsNetSupportDialog" ); + NS_IF_RELEASE( mWebShell ); NS_IF_RELEASE( mWebShellWindow ); NS_IF_RELEASE( mOKButton ); @@ -428,50 +431,53 @@ nsresult nsNetSupportDialog::ConstructAfterJavaScript(nsIWebShell *aWebShell) nsresult nsNetSupportDialog::DoDialog( nsString& inXULURL ) { - nsresult result; + nsresult result; + nsIWebShellWindow *dialogWindow; + // Create the Application Shell instance... NS_WITH_SERVICE(nsIAppShellService, appShellService, kAppShellServiceCID, &result); - if ( !NS_SUCCEEDED ( result ) ) - return result; + if ( !NS_SUCCEEDED ( result ) ) + return result; - nsIURI* dialogURL; + nsIURI* dialogURL; #ifndef NECKO - result = NS_NewURL(&dialogURL, inXULURL ); + result = NS_NewURL(&dialogURL, inXULURL ); #else - NS_WITH_SERVICE(nsIIOService, service, kIOServiceCID, &result); - if (NS_FAILED(result)) return result; + NS_WITH_SERVICE(nsIIOService, service, kIOServiceCID, &result); + if (NS_FAILED(result)) return result; - nsIURI *uri = nsnull; - const char *uriStr = inXULURL.GetBuffer(); - result = service->NewURI(uriStr, nsnull, &uri); - if (NS_FAILED(result)) return result; + nsIURI *uri = nsnull; + const char *uriStr = inXULURL.GetBuffer(); + result = service->NewURI(uriStr, nsnull, &uri); + if (NS_FAILED(result)) return result; - result = uri->QueryInterface(nsIURI::GetIID(), (void**)&dialogURL); - NS_RELEASE(uri); + result = uri->QueryInterface(nsIURI::GetIID(), (void**)&dialogURL); + NS_RELEASE(uri); #endif // NECKO - if (!NS_SUCCEEDED (result) ) - { - appShellService->Release(); - return result; - } + if (!NS_SUCCEEDED (result) ) + { + appShellService->Release(); + return result; + } - NS_IF_RELEASE( mWebShellWindow ); - appShellService->RunModalDialog( nsnull, dialogURL, mWebShellWindow, nsnull, this, 300, 200); + result = appShellService->CreateDialogWindow(nsnull, dialogURL, PR_TRUE, + &dialogWindow, nsnull, this, 300, 200); + mWebShellWindow = dialogWindow; - // cleanup - if ( mOKButton ) - RemoveEventListener( mOKButton ); - if ( mCancelButton ) - RemoveEventListener( mCancelButton ); - dialogURL->Release(); + if (NS_SUCCEEDED(result)) + appShellService->RunModalDialog(&dialogWindow, dialogURL, nsnull, + nsnull, this, 300, 200); - // save pointer to window for later access, just in case. note this is dangerous, since - // the window has been closed and partially destroyed at this point. but here we are. - // it seems necessary to first release any old window we may be holding, since this is - // a service, and can therefore remain active between actual invocations. + // cleanup + if ( mOKButton ) + RemoveEventListener( mOKButton ); + if ( mCancelButton ) + RemoveEventListener( mCancelButton ); + dialogURL->Release(); + NS_RELEASE( mWebShellWindow ); - return NS_OK; + return NS_OK; } // Event Handlers which should be called using XPConnect eventually diff --git a/xpfe/appshell/src/nsWebShellWindow.cpp b/xpfe/appshell/src/nsWebShellWindow.cpp index 3507a9b07afd..0d51bcc11a78 100644 --- a/xpfe/appshell/src/nsWebShellWindow.cpp +++ b/xpfe/appshell/src/nsWebShellWindow.cpp @@ -1124,7 +1124,7 @@ nsWebShellWindow::CreatePopup(nsIDOMElement* aElement, nsIDOMElement* aPopupCont return rv; nsCOMPtr newWindow; - appShell->CreateTopLevelWindow(nsnull, nsnull, PR_FALSE, *getter_AddRefs(newWindow), + appShell->CreateTopLevelWindow(nsnull, nsnull, PR_FALSE, getter_AddRefs(newWindow), nsnull, nsnull, 200, 300); // Move the window to aXPos and aYPos nsCOMPtr browserWindow = do_QueryInterface(newWindow); @@ -1251,7 +1251,7 @@ nsWebShellWindow::NewWebShell(PRUint32 aChromeMask, PRBool aVisible, if ((aChromeMask & NS_CHROME_OPEN_AS_CHROME) != 0) { // Just do a nice normal create of a web shell and // return it immediately. - rv = appShell->CreateTopLevelWindow(nsnull, nsnull, PR_FALSE, *getter_AddRefs(newWindow), + rv = appShell->CreateTopLevelWindow(nsnull, nsnull, PR_FALSE, getter_AddRefs(newWindow), nsnull, nsnull, 615, 480); if (NS_SUCCEEDED(rv)) { nsCOMPtr browser(do_QueryInterface(newWindow)); @@ -1294,7 +1294,7 @@ nsWebShellWindow::NewWebShell(PRUint32 aChromeMask, PRBool aVisible, #endif // NECKO if (NS_SUCCEEDED(rv)) - rv = appShell->CreateTopLevelWindow(nsnull, urlObj, PR_FALSE, *getter_AddRefs(newWindow), + rv = appShell->CreateTopLevelWindow(nsnull, urlObj, PR_FALSE, getter_AddRefs(newWindow), nsnull, nsnull, 615, 480); nsIAppShell *subshell; diff --git a/xpfe/bootstrap/nsAppRunner.cpp b/xpfe/bootstrap/nsAppRunner.cpp index 47c03cbfed89..ebf2669e81fb 100644 --- a/xpfe/bootstrap/nsAppRunner.cpp +++ b/xpfe/bootstrap/nsAppRunner.cpp @@ -627,7 +627,7 @@ int main(int argc, char* argv[]) } nsCOMPtr profWindow; - rv = profAppShell->CreateTopLevelWindow(nsnull, profURL, PR_TRUE, *getter_AddRefs(profWindow), + rv = profAppShell->CreateTopLevelWindow(nsnull, profURL, PR_TRUE, getter_AddRefs(profWindow), nsnull, nsnull, profWinWidth, profWinHeight); NS_RELEASE(profURL); @@ -656,7 +656,7 @@ int main(int argc, char* argv[]) if ( !useArgs ) { nsCOMPtr newWindow; - rv = appShell->CreateTopLevelWindow(nsnull, url, PR_TRUE, *getter_AddRefs(newWindow), + rv = appShell->CreateTopLevelWindow(nsnull, url, PR_TRUE, getter_AddRefs(newWindow), nsnull, nsnull, widthVal, heightVal); } else { nsIDOMToolkitCore* toolkit = nsnull; diff --git a/xpfe/components/find/src/nsFindComponent.cpp b/xpfe/components/find/src/nsFindComponent.cpp index 042460dfd10c..5f85fb103fc6 100644 --- a/xpfe/components/find/src/nsFindComponent.cpp +++ b/xpfe/components/find/src/nsFindComponent.cpp @@ -660,7 +660,7 @@ nsFindComponent::Find(nsISupports *aContext, PRBool *aDidFind) rv = mAppShell->CreateTopLevelWindow( nsnull, url, PR_TRUE, - *getter_AddRefs(newWindow), + getter_AddRefs(newWindow), nsnull, dialog, 0, diff --git a/xpfe/components/prefwindow/src/nsPrefWindow.cpp b/xpfe/components/prefwindow/src/nsPrefWindow.cpp index 31c312c1a69d..426e21fe2d7a 100644 --- a/xpfe/components/prefwindow/src/nsPrefWindow.cpp +++ b/xpfe/components/prefwindow/src/nsPrefWindow.cpp @@ -210,21 +210,12 @@ NS_IMETHODIMP nsPrefWindow::showWindow( nsIXULWindowCallbacks *cb = nsnull; nsCOMPtr parent; DOMWindowToWebShellWindow(currentFrontWin, &parent); - appShell->CreateDialogWindow(parent, urlObj, PR_TRUE, window, + appShell->CreateDialogWindow(parent, urlObj, PR_TRUE, &window, nsnull, cb, 504, 436); - if (window) + if (window != nsnull) { - nsCOMPtr parentWindowWidgetThing; - nsresult gotParent - = parent ? parent->GetWidget(*getter_AddRefs(parentWindowWidgetThing)) : - NS_ERROR_FAILURE; - // Windows OS is the only one that needs the parent disabled, or cares - // arguably this should be done by the new window, within ShowModal... - if (NS_SUCCEEDED(gotParent)) - parentWindowWidgetThing->Enable(PR_FALSE); - window->ShowModal(); - if (NS_SUCCEEDED(gotParent)) - parentWindowWidgetThing->Enable(PR_TRUE); + appShell->RunModalDialog(&window, nsnull, parent, nsnull, cb, 504, 436); + NS_RELEASE(window); } return rv; } // nsPrefWindow::showWindow() diff --git a/xpfe/components/startup/src/nsCommandLineServiceMac.cpp b/xpfe/components/startup/src/nsCommandLineServiceMac.cpp index 115def205a53..de437acba58b 100644 --- a/xpfe/components/startup/src/nsCommandLineServiceMac.cpp +++ b/xpfe/components/startup/src/nsCommandLineServiceMac.cpp @@ -1006,7 +1006,7 @@ nsIWebShellWindow* FindWebShellWindow(nsIXULWindowCallbacks* inCallbacks) nsnull, urlObj, // nsIURI* of chrome PR_TRUE, - aWindow, + *aWindow, nsnull, inCallbacks, // callbacks windowWidth, windowHeight); diff --git a/xpfe/components/ucth/src/nsUnknownContentTypeHandler.cpp b/xpfe/components/ucth/src/nsUnknownContentTypeHandler.cpp index ec900533cee1..be0e359e8346 100644 --- a/xpfe/components/ucth/src/nsUnknownContentTypeHandler.cpp +++ b/xpfe/components/ucth/src/nsUnknownContentTypeHandler.cpp @@ -228,7 +228,7 @@ nsUnknownContentTypeHandler::HandleUnknownContentType( nsIURI *aURL, rv = mAppShell->CreateTopLevelWindow( nsnull, url, PR_TRUE, - *getter_AddRefs(newWindow), + getter_AddRefs(newWindow), nsnull, dialog, 0, 0 ); diff --git a/xpfe/components/xfer/src/nsDownloadProgressDialog.cpp b/xpfe/components/xfer/src/nsDownloadProgressDialog.cpp index cbd8446a7633..a6ad3c4e17d9 100644 --- a/xpfe/components/xfer/src/nsDownloadProgressDialog.cpp +++ b/xpfe/components/xfer/src/nsDownloadProgressDialog.cpp @@ -169,7 +169,7 @@ nsDownloadProgressDialog::Show() { rv = appShell->CreateTopLevelWindow( nsnull, url, PR_TRUE, - *getter_AddRefs(newWindow), + getter_AddRefs(newWindow), nsnull, this, 0, diff --git a/xpinstall/src/nsInstallProgressDialog.cpp b/xpinstall/src/nsInstallProgressDialog.cpp index 30b5fc50b0d4..7050f9ce47bf 100644 --- a/xpinstall/src/nsInstallProgressDialog.cpp +++ b/xpinstall/src/nsInstallProgressDialog.cpp @@ -237,7 +237,7 @@ nsInstallProgressDialog::Open() rv = appShell->CreateTopLevelWindow( nsnull, url, PR_TRUE, - *getter_AddRefs(mWindow), + getter_AddRefs(newWindow), nsnull, this, // callbacks?? 0, diff --git a/xpinstall/src/nsXPInstallManager.cpp b/xpinstall/src/nsXPInstallManager.cpp index 411b6696e8be..10cb176bd9f1 100644 --- a/xpinstall/src/nsXPInstallManager.cpp +++ b/xpinstall/src/nsXPInstallManager.cpp @@ -369,7 +369,7 @@ nsXPInstallManager::BeforeJavascriptEvaluation() rv = appShell->CreateTopLevelWindow( nsnull, url, PR_TRUE, - *getter_AddRefs(newWindow), + getter_AddRefs(newWindow), nsnull, this, // callbacks?? 0,