teach RunModalDialog to use extant windows; use one in NetSupportDialog (fixes bug 7858). remove AppShellService interface references

This commit is contained in:
danm%netscape.com 1999-06-24 03:29:22 +00:00
Родитель dbf66fa37f
Коммит 582ad47b3f
22 изменённых файлов: 136 добавлений и 152 удалений

Просмотреть файл

@ -761,7 +761,7 @@ nsEditorShell::CreateWindowWithURL(const char* urlStr)
if (NS_FAILED(rv) || !url) if (NS_FAILED(rv) || !url)
goto done; goto done;
appShell->CreateTopLevelWindow(nsnull, url, PR_TRUE, *getter_AddRefs(newWindow), appShell->CreateTopLevelWindow(nsnull, url, PR_TRUE, getter_AddRefs(newWindow),
nsnull, nsnull, 615, 480); nsnull, nsnull, 615, 480);
done: done:

Просмотреть файл

@ -761,7 +761,7 @@ nsEditorShell::CreateWindowWithURL(const char* urlStr)
if (NS_FAILED(rv) || !url) if (NS_FAILED(rv) || !url)
goto done; goto done;
appShell->CreateTopLevelWindow(nsnull, url, PR_TRUE, *getter_AddRefs(newWindow), appShell->CreateTopLevelWindow(nsnull, url, PR_TRUE, getter_AddRefs(newWindow),
nsnull, nsnull, 615, 480); nsnull, nsnull, 615, 480);
done: done:

Просмотреть файл

@ -278,7 +278,7 @@ nsMessenger::Open3PaneWindow()
appShell->CreateTopLevelWindow(nsnull, // parent appShell->CreateTopLevelWindow(nsnull, // parent
url, url,
PR_TRUE, PR_TRUE,
*getter_AddRefs(newWindow), // result widget getter_AddRefs(newWindow), // result widget
nsnull, // observer nsnull, // observer
nsnull, // callbacks nsnull, // callbacks
200, // width 200, // width

Просмотреть файл

@ -202,7 +202,7 @@ int main(int argc, char *argv[])
kIAppShellServiceIID, kIAppShellServiceIID,
(nsISupports**)&appShell); (nsISupports**)&appShell);
if (NS_SUCCEEDED(rv)) 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); nsnull, nsnull, 200, 200);
// Create the Event Queue for this thread... // Create the Event Queue for this thread...

Просмотреть файл

@ -137,7 +137,7 @@ int main(int argc, char *argv[])
kIAppShellServiceIID, kIAppShellServiceIID,
(nsISupports**)&appShell); (nsISupports**)&appShell);
if (NS_SUCCEEDED(rv)) 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); nsnull, nsnull, 200, 200);
// Create the Event Queue for this thread... // Create the Event Queue for this thread...

Просмотреть файл

@ -173,7 +173,7 @@ nsPrefMigrationProgressDialog::CreateProfileProgressDialog()
rv = appShell->CreateTopLevelWindow( nsnull, rv = appShell->CreateTopLevelWindow( nsnull,
url, url,
PR_TRUE, PR_TRUE,
*getter_AddRefs(newWindow), getter_AddRefs(newWindow),
nsnull, nsnull,
this, // callbacks?? this, // callbacks??
0, 0,

Просмотреть файл

@ -411,7 +411,7 @@ newWind(char* urlName)
if (NS_FAILED(rv)) return rv; if (NS_FAILED(rv)) return rv;
nsCOMPtr<nsIWebShellWindow> newWindow; nsCOMPtr<nsIWebShellWindow> newWindow;
appShell->CreateTopLevelWindow(nsnull, url, PR_TRUE, *getter_AddRefs(newWindow), appShell->CreateTopLevelWindow(nsnull, url, PR_TRUE, getter_AddRefs(newWindow),
nsnull, nsnull, 615, 480); nsnull, nsnull, 615, 480);
NS_RELEASE(url); NS_RELEASE(url);
@ -478,23 +478,15 @@ nsBrowserAppCore::WalletEditor(nsIDOMWindow* aWin)
nsCOMPtr<nsIWebShellWindow> parent; nsCOMPtr<nsIWebShellWindow> parent;
DOMWindowToWebShellWindow(aWin, &parent); DOMWindowToWebShellWindow(aWin, &parent);
appShell->CreateDialogWindow(parent, urlObj, PR_TRUE, window, window = nsnull;
appShell->CreateDialogWindow(parent, urlObj, PR_TRUE, &window,
nsnull, cb, 504, 436); nsnull, cb, 504, 436);
if (window != nsnull) {
appShell->RunModalDialog(&window, nsnull, parent, nsnull, cb, 504, 436);
NS_RELEASE(window);
}
nsServiceManager::ReleaseService(kAppShellServiceCID, appShell); nsServiceManager::ReleaseService(kAppShellServiceCID, appShell);
if (window != nsnull) {
nsCOMPtr<nsIWidget> 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; return rv;
} }
@ -537,23 +529,14 @@ nsBrowserAppCore::SignonViewer(nsIDOMWindow* aWin)
nsCOMPtr<nsIWebShellWindow> parent; nsCOMPtr<nsIWebShellWindow> parent;
DOMWindowToWebShellWindow(aWin, &parent); DOMWindowToWebShellWindow(aWin, &parent);
appShell->CreateDialogWindow(parent, urlObj, PR_TRUE, window, window = nsnull;
appShell->CreateDialogWindow(parent, urlObj, PR_TRUE, &window,
nsnull, cb, 504, 436); nsnull, cb, 504, 436);
nsServiceManager::ReleaseService(kAppShellServiceCID, appShell);
if (window != nsnull) { if (window != nsnull) {
nsCOMPtr<nsIWidget> parentWindowWidgetThing; appShell->RunModalDialog(&window, nsnull, parent, nsnull, cb, 504, 436);
nsresult gotParent; NS_RELEASE(window);
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);
} }
nsServiceManager::ReleaseService(kAppShellServiceCID, appShell);
return rv; return rv;
} }
@ -596,23 +579,16 @@ nsBrowserAppCore::CookieViewer(nsIDOMWindow* aWin)
nsCOMPtr<nsIWebShellWindow> parent; nsCOMPtr<nsIWebShellWindow> parent;
DOMWindowToWebShellWindow(aWin, &parent); DOMWindowToWebShellWindow(aWin, &parent);
appShell->CreateDialogWindow(parent, urlObj, PR_TRUE, window, window = nsnull;
appShell->CreateDialogWindow(parent, urlObj, PR_TRUE, &window,
nsnull, cb, 504, 436); nsnull, cb, 504, 436);
nsServiceManager::ReleaseService(kAppShellServiceCID, appShell);
if (window != nsnull) { if (window != nsnull) {
nsCOMPtr<nsIWidget> parentWindowWidgetThing; appShell->RunModalDialog(&window, nsnull, parent, nsnull, cb, 504, 436);
nsresult gotParent; NS_RELEASE(window);
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);
} }
nsServiceManager::ReleaseService(kAppShellServiceCID, appShell);
return rv; return rv;
} }
@ -698,23 +674,15 @@ nsBrowserAppCore::WalletPreview(nsIDOMWindow* aWin, nsIDOMWindow* aForm)
nsCOMPtr<nsIWebShellWindow> parent; nsCOMPtr<nsIWebShellWindow> parent;
DOMWindowToWebShellWindow(aWin, &parent); DOMWindowToWebShellWindow(aWin, &parent);
appShell->CreateDialogWindow(parent, urlObj, PR_TRUE, window, window = nsnull;
appShell->CreateDialogWindow(parent, urlObj, PR_TRUE, &window,
nsnull, cb, 504, 436); nsnull, cb, 504, 436);
if (window != nsnull) {
appShell->RunModalDialog(&window, nsnull, parent, nsnull, cb, 504, 436);
NS_RELEASE(window);
}
nsServiceManager::ReleaseService(kAppShellServiceCID, appShell); nsServiceManager::ReleaseService(kAppShellServiceCID, appShell);
if (window != nsnull) {
nsCOMPtr<nsIWidget> 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; return rv;
} }
@ -1462,7 +1430,7 @@ nsBrowserAppCore::NewWindow()
if (NS_FAILED(rv)) return rv; if (NS_FAILED(rv)) return rv;
nsCOMPtr<nsIWebShellWindow> newWindow; nsCOMPtr<nsIWebShellWindow> newWindow;
appShell->CreateTopLevelWindow(nsnull, url, PR_TRUE, *getter_AddRefs(newWindow), appShell->CreateTopLevelWindow(nsnull, url, PR_TRUE, getter_AddRefs(newWindow),
nsnull, nsnull, 615, 480); nsnull, nsnull, 615, 480);
NS_RELEASE(url); NS_RELEASE(url);
@ -1731,7 +1699,7 @@ nsBrowserAppCore::DoDialog()
if (NS_FAILED(rv)) if (NS_FAILED(rv))
return 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)) if (NS_SUCCEEDED(rv))
NS_RELEASE(window); NS_RELEASE(window);
return rv; return rv;

Просмотреть файл

@ -469,7 +469,7 @@ nsDOMPropsCore::ShowProperties(const nsString& aUrl, nsIDOMWindow* aParent, nsID
nsCOMPtr<nsIWebShellWindow> parent = DOMWindowToWebShellWindow(aParent); nsCOMPtr<nsIWebShellWindow> parent = DOMWindowToWebShellWindow(aParent);
nsCOMPtr<nsIWebShellWindow> newWindow; nsCOMPtr<nsIWebShellWindow> 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); nsnull, dialog, 450, 240);
nsServiceManager::ReleaseService(kAppShellServiceCID, appShell); nsServiceManager::ReleaseService(kAppShellServiceCID, appShell);

Просмотреть файл

@ -172,7 +172,8 @@ nsToolkitCore::ShowDialog(const nsString& aUrl, nsIDOMWindow* aParent) {
nsCOMPtr<nsIWebShellWindow> parent; nsCOMPtr<nsIWebShellWindow> parent;
DOMWindowToWebShellWindow(aParent, &parent); DOMWindowToWebShellWindow(aParent, &parent);
appShell->CreateDialogWindow(parent, urlObj, PR_TRUE, window, window = nsnull;
appShell->CreateDialogWindow(parent, urlObj, PR_TRUE, &window,
nsnull, nsnull, 615, 480); nsnull, nsnull, 615, 480);
if (window != nsnull) if (window != nsnull)
@ -212,7 +213,7 @@ nsToolkitCore::ShowWindow(const nsString& aUrl, nsIDOMWindow* aParent) {
nsCOMPtr<nsIWebShellWindow> parent; nsCOMPtr<nsIWebShellWindow> parent;
DOMWindowToWebShellWindow(aParent, &parent); DOMWindowToWebShellWindow(aParent, &parent);
nsCOMPtr<nsIWebShellWindow> window; nsCOMPtr<nsIWebShellWindow> window;
appShell->CreateTopLevelWindow(parent, urlObj, PR_TRUE, *getter_AddRefs(window), appShell->CreateTopLevelWindow(parent, urlObj, PR_TRUE, getter_AddRefs(window),
nsnull, nsnull, 615, 480); nsnull, nsnull, 615, 480);
if (window) if (window)
@ -337,7 +338,7 @@ nsToolkitCore::ShowWindowWithArgs(const nsString& aUrl,
cb = nsDontQueryInterface<nsArgCallbacks>( new nsArgCallbacks( aArgs ) ); cb = nsDontQueryInterface<nsArgCallbacks>( new nsArgCallbacks( aArgs ) );
nsCOMPtr<nsIWebShellWindow> window; nsCOMPtr<nsIWebShellWindow> window;
appShell->CreateTopLevelWindow(parent, urlObj, PR_TRUE, *getter_AddRefs(window), appShell->CreateTopLevelWindow(parent, urlObj, PR_TRUE, getter_AddRefs(window),
nsnull, cb, 615, 650); nsnull, cb, 615, 650);
if (window) if (window)
@ -378,7 +379,7 @@ nsToolkitCore::ShowModalDialog(const nsString& aUrl, nsIDOMWindow* aParent) {
nsCOMPtr<nsIWebShellWindow> parent; nsCOMPtr<nsIWebShellWindow> parent;
DOMWindowToWebShellWindow(aParent, &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)) if (NS_SUCCEEDED(rv))
NS_RELEASE(window); NS_RELEASE(window);
return rv; return rv;

Просмотреть файл

@ -52,18 +52,19 @@ public:
NS_IMETHOD CreateTopLevelWindow(nsIWebShellWindow * aParent, NS_IMETHOD CreateTopLevelWindow(nsIWebShellWindow * aParent,
nsIURI* aUrl, nsIURI* aUrl,
PRBool showWindow, PRBool showWindow,
nsIWebShellWindow*& aResult, nsIStreamObserver* anObserver, nsIWebShellWindow** aResult, nsIStreamObserver* anObserver,
nsIXULWindowCallbacks *aCallbacks, nsIXULWindowCallbacks *aCallbacks,
PRInt32 aInitialWidth, PRInt32 aInitialHeight) = 0; PRInt32 aInitialWidth, PRInt32 aInitialHeight) = 0;
NS_IMETHOD CreateDialogWindow( nsIWebShellWindow * aParent, NS_IMETHOD CreateDialogWindow( nsIWebShellWindow * aParent,
nsIURI* aUrl, nsIURI* aUrl,
PRBool showWindow, PRBool showWindow,
nsIWebShellWindow*& aResult, nsIStreamObserver* anObserver, nsIWebShellWindow** aResult, nsIStreamObserver* anObserver,
nsIXULWindowCallbacks *aCallbacks, nsIXULWindowCallbacks *aCallbacks,
PRInt32 aInitialWidth, PRInt32 aInitialHeight) = 0; PRInt32 aInitialWidth, PRInt32 aInitialHeight) = 0;
NS_IMETHOD RunModalDialog( nsIWebShellWindow * aParent, NS_IMETHOD RunModalDialog( nsIWebShellWindow **aWindow,
nsIURI* aUrl, nsIURI* aUrl,
nsIWebShellWindow*& aResult, nsIStreamObserver* anObserver, nsIWebShellWindow * aParent,
nsIStreamObserver* anObserver,
nsIXULWindowCallbacks *aCallbacks, nsIXULWindowCallbacks *aCallbacks,
PRInt32 aInitialWidth, PRInt32 aInitialHeight) = 0; PRInt32 aInitialWidth, PRInt32 aInitialHeight) = 0;
NS_IMETHOD CloseTopLevelWindow(nsIWebShellWindow* aWindow) = 0; NS_IMETHOD CloseTopLevelWindow(nsIWebShellWindow* aWindow) = 0;

Просмотреть файл

@ -100,18 +100,19 @@ public:
NS_IMETHOD CreateTopLevelWindow(nsIWebShellWindow * aParent, NS_IMETHOD CreateTopLevelWindow(nsIWebShellWindow * aParent,
nsIURI* aUrl, nsIURI* aUrl,
PRBool showWindow, PRBool showWindow,
nsIWebShellWindow*& aResult, nsIStreamObserver* anObserver, nsIWebShellWindow** aResult, nsIStreamObserver* anObserver,
nsIXULWindowCallbacks *aCallbacks, nsIXULWindowCallbacks *aCallbacks,
PRInt32 aInitialWidth, PRInt32 aInitialHeight); PRInt32 aInitialWidth, PRInt32 aInitialHeight);
NS_IMETHOD CreateDialogWindow( nsIWebShellWindow * aParent, NS_IMETHOD CreateDialogWindow( nsIWebShellWindow * aParent,
nsIURI* aUrl, nsIURI* aUrl,
PRBool showWindow, PRBool showWindow,
nsIWebShellWindow*& aResult, nsIStreamObserver* anObserver, nsIWebShellWindow** aResult, nsIStreamObserver* anObserver,
nsIXULWindowCallbacks *aCallbacks, nsIXULWindowCallbacks *aCallbacks,
PRInt32 aInitialWidth, PRInt32 aInitialHeight); PRInt32 aInitialWidth, PRInt32 aInitialHeight);
NS_IMETHOD RunModalDialog( nsIWebShellWindow * aParent, NS_IMETHOD RunModalDialog( nsIWebShellWindow **aWindow,
nsIURI* aUrl, nsIURI* aUrl,
nsIWebShellWindow*& aResult, nsIStreamObserver* anObserver, nsIWebShellWindow * aParent,
nsIStreamObserver* anObserver,
nsIXULWindowCallbacks *aCallbacks, nsIXULWindowCallbacks *aCallbacks,
PRInt32 aInitialWidth, PRInt32 aInitialHeight); PRInt32 aInitialWidth, PRInt32 aInitialHeight);
NS_IMETHOD CloseTopLevelWindow(nsIWebShellWindow* aWindow); NS_IMETHOD CloseTopLevelWindow(nsIWebShellWindow* aWindow);
@ -478,14 +479,14 @@ nsAppShellService::Shutdown(void)
NS_IMETHODIMP NS_IMETHODIMP
nsAppShellService::CreateTopLevelWindow(nsIWebShellWindow *aParent, nsAppShellService::CreateTopLevelWindow(nsIWebShellWindow *aParent,
nsIURI* aUrl, PRBool showWindow, nsIURI* aUrl, PRBool showWindow,
nsIWebShellWindow*& aResult, nsIStreamObserver* anObserver, nsIWebShellWindow** aResult, nsIStreamObserver* anObserver,
nsIXULWindowCallbacks *aCallbacks, nsIXULWindowCallbacks *aCallbacks,
PRInt32 aInitialWidth, PRInt32 aInitialHeight) PRInt32 aInitialWidth, PRInt32 aInitialHeight)
{ {
nsresult rv; nsresult rv;
nsWebShellWindow* window; nsWebShellWindow* window;
aResult = nsnull; *aResult = nsnull;
window = new nsWebShellWindow(); window = new nsWebShellWindow();
if (nsnull == window) { if (nsnull == window) {
rv = NS_ERROR_OUT_OF_MEMORY; rv = NS_ERROR_OUT_OF_MEMORY;
@ -498,7 +499,7 @@ nsAppShellService::CreateTopLevelWindow(nsIWebShellWindow *aParent,
if (NS_SUCCEEDED(rv)) if (NS_SUCCEEDED(rv))
{ {
// this does the AddRef of the return value // 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 // the addref resulting from this is the owning addref for this window
RegisterTopLevelWindow(window); RegisterTopLevelWindow(window);
@ -526,14 +527,14 @@ nsAppShellService::CloseTopLevelWindow(nsIWebShellWindow* aWindow)
NS_IMETHODIMP NS_IMETHODIMP
nsAppShellService::CreateDialogWindow(nsIWebShellWindow * aParent, nsAppShellService::CreateDialogWindow(nsIWebShellWindow * aParent,
nsIURI* aUrl, PRBool showWindow, nsIURI* aUrl, PRBool showWindow,
nsIWebShellWindow*& aResult, nsIStreamObserver* anObserver, nsIWebShellWindow** aResult, nsIStreamObserver* anObserver,
nsIXULWindowCallbacks *aCallbacks, nsIXULWindowCallbacks *aCallbacks,
PRInt32 aInitialWidth, PRInt32 aInitialHeight) PRInt32 aInitialWidth, PRInt32 aInitialHeight)
{ {
nsresult rv; nsresult rv;
nsWebShellWindow* window; nsWebShellWindow* window;
aResult = nsnull; *aResult = nsnull;
window = new nsWebShellWindow(); window = new nsWebShellWindow();
if (nsnull == window) { if (nsnull == window) {
rv = NS_ERROR_OUT_OF_MEMORY; rv = NS_ERROR_OUT_OF_MEMORY;
@ -544,7 +545,7 @@ nsAppShellService::CreateDialogWindow(nsIWebShellWindow * aParent,
anObserver, aCallbacks, anObserver, aCallbacks,
aInitialWidth, aInitialHeight); aInitialWidth, aInitialHeight);
if (NS_SUCCEEDED(rv)) { if (NS_SUCCEEDED(rv)) {
rv = window->QueryInterface(kIWebShellWindowIID, (void **) &aResult); rv = window->QueryInterface(kIWebShellWindowIID, (void **) aResult);
RegisterTopLevelWindow(window); RegisterTopLevelWindow(window);
if (showWindow) if (showWindow)
window->Show(PR_TRUE); 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. complications creeping in to the modal window story: there's a lot of setup.
See the code.. See the code..
Note that the window created is returned in aResult. By the time this function If a window is passed in via the first parameter, that window will be
exits, that window has been partially destroyed. We return it anyway, in the the one displayed modally. If no window is passed in (if *aWindow is null)
hopes that it may be queried for results, somehow. This may be a mistake. the window created will be returned in *aWindow. Note that by the time
It is returned addrefed (by the QueryInterface to nsIWebShellWindow in this function exits, that window has been partially destroyed. We return it
CreateDialogWindow). 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 NS_IMETHODIMP
nsAppShellService::RunModalDialog( nsAppShellService::RunModalDialog(
nsIWebShellWindow *aParent, nsIURI* aUrl, nsIWebShellWindow **aWindow,
nsIWebShellWindow*& aResult, nsIStreamObserver *anObserver, nsIURI* aUrl,
nsIWebShellWindow * aParent,
nsIStreamObserver *anObserver,
nsIXULWindowCallbacks *aCallbacks, nsIXULWindowCallbacks *aCallbacks,
PRInt32 aInitialWidth, PRInt32 aInitialHeight) PRInt32 aInitialWidth, PRInt32 aInitialHeight)
{ {
nsresult rv;
nsresult rv; nsIWebShellWindow *theWindow;
#ifdef XP_PC // XXX: Won't work with any other platforms yet. #ifdef XP_PC // XXX: Won't work with any other platforms yet.
// First push a nested event queue for event processing from netlib // First push a nested event queue for event processing from netlib
@ -590,8 +594,12 @@ nsAppShellService::RunModalDialog(
eQueueService->PushThreadEventQueue(); eQueueService->PushThreadEventQueue();
#endif #endif
rv = CreateDialogWindow(aParent, aUrl, PR_TRUE, aResult, anObserver, aCallbacks, if (aWindow && *aWindow) {
aInitialWidth, aInitialHeight); 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)) { if (NS_SUCCEEDED(rv)) {
nsCOMPtr<nsIWidget> parentWindowWidgetThing; nsCOMPtr<nsIWidget> parentWindowWidgetThing;
@ -601,9 +609,18 @@ nsAppShellService::RunModalDialog(
// Windows OS wants the parent disabled for modality // Windows OS wants the parent disabled for modality
if (NS_SUCCEEDED(gotParent)) if (NS_SUCCEEDED(gotParent))
parentWindowWidgetThing->Enable(PR_FALSE); parentWindowWidgetThing->Enable(PR_FALSE);
aResult->ShowModal(); theWindow->ShowModal();
if (NS_SUCCEEDED(gotParent)) if (NS_SUCCEEDED(gotParent))
parentWindowWidgetThing->Enable(PR_TRUE); 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 // Release the event queue

Просмотреть файл

@ -1006,7 +1006,7 @@ nsIWebShellWindow* FindWebShellWindow(nsIXULWindowCallbacks* inCallbacks)
nsnull, nsnull,
urlObj, // nsIURI* of chrome urlObj, // nsIURI* of chrome
PR_TRUE, PR_TRUE,
aWindow, *aWindow,
nsnull, nsnull,
inCallbacks, // callbacks inCallbacks, // callbacks
windowWidth, windowHeight); windowWidth, windowHeight);

Просмотреть файл

@ -302,6 +302,9 @@ nsNetSupportDialog::nsNetSupportDialog()
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( mWebShell );
NS_IF_RELEASE( mWebShellWindow ); NS_IF_RELEASE( mWebShellWindow );
NS_IF_RELEASE( mOKButton ); NS_IF_RELEASE( mOKButton );
@ -428,50 +431,53 @@ nsresult nsNetSupportDialog::ConstructAfterJavaScript(nsIWebShell *aWebShell)
nsresult nsNetSupportDialog::DoDialog( nsString& inXULURL ) nsresult nsNetSupportDialog::DoDialog( nsString& inXULURL )
{ {
nsresult result; nsresult result;
nsIWebShellWindow *dialogWindow;
// Create the Application Shell instance... // Create the Application Shell instance...
NS_WITH_SERVICE(nsIAppShellService, appShellService, kAppShellServiceCID, &result); NS_WITH_SERVICE(nsIAppShellService, appShellService, kAppShellServiceCID, &result);
if ( !NS_SUCCEEDED ( result ) ) if ( !NS_SUCCEEDED ( result ) )
return result; return result;
nsIURI* dialogURL; nsIURI* dialogURL;
#ifndef NECKO #ifndef NECKO
result = NS_NewURL(&dialogURL, inXULURL ); result = NS_NewURL(&dialogURL, inXULURL );
#else #else
NS_WITH_SERVICE(nsIIOService, service, kIOServiceCID, &result); NS_WITH_SERVICE(nsIIOService, service, kIOServiceCID, &result);
if (NS_FAILED(result)) return result; if (NS_FAILED(result)) return result;
nsIURI *uri = nsnull; nsIURI *uri = nsnull;
const char *uriStr = inXULURL.GetBuffer(); const char *uriStr = inXULURL.GetBuffer();
result = service->NewURI(uriStr, nsnull, &uri); result = service->NewURI(uriStr, nsnull, &uri);
if (NS_FAILED(result)) return result; if (NS_FAILED(result)) return result;
result = uri->QueryInterface(nsIURI::GetIID(), (void**)&dialogURL); result = uri->QueryInterface(nsIURI::GetIID(), (void**)&dialogURL);
NS_RELEASE(uri); NS_RELEASE(uri);
#endif // NECKO #endif // NECKO
if (!NS_SUCCEEDED (result) ) if (!NS_SUCCEEDED (result) )
{ {
appShellService->Release(); appShellService->Release();
return result; return result;
} }
NS_IF_RELEASE( mWebShellWindow ); result = appShellService->CreateDialogWindow(nsnull, dialogURL, PR_TRUE,
appShellService->RunModalDialog( nsnull, dialogURL, mWebShellWindow, nsnull, this, 300, 200); &dialogWindow, nsnull, this, 300, 200);
mWebShellWindow = dialogWindow;
// cleanup if (NS_SUCCEEDED(result))
if ( mOKButton ) appShellService->RunModalDialog(&dialogWindow, dialogURL, nsnull,
RemoveEventListener( mOKButton ); nsnull, this, 300, 200);
if ( mCancelButton )
RemoveEventListener( mCancelButton );
dialogURL->Release();
// save pointer to window for later access, just in case. note this is dangerous, since // cleanup
// the window has been closed and partially destroyed at this point. but here we are. if ( mOKButton )
// it seems necessary to first release any old window we may be holding, since this is RemoveEventListener( mOKButton );
// a service, and can therefore remain active between actual invocations. if ( mCancelButton )
RemoveEventListener( mCancelButton );
dialogURL->Release();
NS_RELEASE( mWebShellWindow );
return NS_OK; return NS_OK;
} }
// Event Handlers which should be called using XPConnect eventually // Event Handlers which should be called using XPConnect eventually

Просмотреть файл

@ -1124,7 +1124,7 @@ nsWebShellWindow::CreatePopup(nsIDOMElement* aElement, nsIDOMElement* aPopupCont
return rv; return rv;
nsCOMPtr<nsIWebShellWindow> newWindow; nsCOMPtr<nsIWebShellWindow> newWindow;
appShell->CreateTopLevelWindow(nsnull, nsnull, PR_FALSE, *getter_AddRefs(newWindow), appShell->CreateTopLevelWindow(nsnull, nsnull, PR_FALSE, getter_AddRefs(newWindow),
nsnull, nsnull, 200, 300); nsnull, nsnull, 200, 300);
// Move the window to aXPos and aYPos // Move the window to aXPos and aYPos
nsCOMPtr<nsIBrowserWindow> browserWindow = do_QueryInterface(newWindow); nsCOMPtr<nsIBrowserWindow> browserWindow = do_QueryInterface(newWindow);
@ -1251,7 +1251,7 @@ nsWebShellWindow::NewWebShell(PRUint32 aChromeMask, PRBool aVisible,
if ((aChromeMask & NS_CHROME_OPEN_AS_CHROME) != 0) { if ((aChromeMask & NS_CHROME_OPEN_AS_CHROME) != 0) {
// Just do a nice normal create of a web shell and // Just do a nice normal create of a web shell and
// return it immediately. // 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); nsnull, nsnull, 615, 480);
if (NS_SUCCEEDED(rv)) { if (NS_SUCCEEDED(rv)) {
nsCOMPtr<nsIBrowserWindow> browser(do_QueryInterface(newWindow)); nsCOMPtr<nsIBrowserWindow> browser(do_QueryInterface(newWindow));
@ -1294,7 +1294,7 @@ nsWebShellWindow::NewWebShell(PRUint32 aChromeMask, PRBool aVisible,
#endif // NECKO #endif // NECKO
if (NS_SUCCEEDED(rv)) 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); nsnull, nsnull, 615, 480);
nsIAppShell *subshell; nsIAppShell *subshell;

Просмотреть файл

@ -627,7 +627,7 @@ int main(int argc, char* argv[])
} }
nsCOMPtr<nsIWebShellWindow> profWindow; nsCOMPtr<nsIWebShellWindow> 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); nsnull, nsnull, profWinWidth, profWinHeight);
NS_RELEASE(profURL); NS_RELEASE(profURL);
@ -656,7 +656,7 @@ int main(int argc, char* argv[])
if ( !useArgs ) { if ( !useArgs ) {
nsCOMPtr<nsIWebShellWindow> newWindow; nsCOMPtr<nsIWebShellWindow> 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); nsnull, nsnull, widthVal, heightVal);
} else { } else {
nsIDOMToolkitCore* toolkit = nsnull; nsIDOMToolkitCore* toolkit = nsnull;

Просмотреть файл

@ -660,7 +660,7 @@ nsFindComponent::Find(nsISupports *aContext, PRBool *aDidFind)
rv = mAppShell->CreateTopLevelWindow( nsnull, rv = mAppShell->CreateTopLevelWindow( nsnull,
url, url,
PR_TRUE, PR_TRUE,
*getter_AddRefs(newWindow), getter_AddRefs(newWindow),
nsnull, nsnull,
dialog, dialog,
0, 0,

Просмотреть файл

@ -210,21 +210,12 @@ NS_IMETHODIMP nsPrefWindow::showWindow(
nsIXULWindowCallbacks *cb = nsnull; nsIXULWindowCallbacks *cb = nsnull;
nsCOMPtr<nsIWebShellWindow> parent; nsCOMPtr<nsIWebShellWindow> parent;
DOMWindowToWebShellWindow(currentFrontWin, &parent); DOMWindowToWebShellWindow(currentFrontWin, &parent);
appShell->CreateDialogWindow(parent, urlObj, PR_TRUE, window, appShell->CreateDialogWindow(parent, urlObj, PR_TRUE, &window,
nsnull, cb, 504, 436); nsnull, cb, 504, 436);
if (window) if (window != nsnull)
{ {
nsCOMPtr<nsIWidget> parentWindowWidgetThing; appShell->RunModalDialog(&window, nsnull, parent, nsnull, cb, 504, 436);
nsresult gotParent NS_RELEASE(window);
= 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; return rv;
} // nsPrefWindow::showWindow() } // nsPrefWindow::showWindow()

Просмотреть файл

@ -1006,7 +1006,7 @@ nsIWebShellWindow* FindWebShellWindow(nsIXULWindowCallbacks* inCallbacks)
nsnull, nsnull,
urlObj, // nsIURI* of chrome urlObj, // nsIURI* of chrome
PR_TRUE, PR_TRUE,
aWindow, *aWindow,
nsnull, nsnull,
inCallbacks, // callbacks inCallbacks, // callbacks
windowWidth, windowHeight); windowWidth, windowHeight);

Просмотреть файл

@ -228,7 +228,7 @@ nsUnknownContentTypeHandler::HandleUnknownContentType( nsIURI *aURL,
rv = mAppShell->CreateTopLevelWindow( nsnull, rv = mAppShell->CreateTopLevelWindow( nsnull,
url, url,
PR_TRUE, PR_TRUE,
*getter_AddRefs(newWindow), getter_AddRefs(newWindow),
nsnull, nsnull,
dialog, dialog,
0, 0 ); 0, 0 );

Просмотреть файл

@ -169,7 +169,7 @@ nsDownloadProgressDialog::Show() {
rv = appShell->CreateTopLevelWindow( nsnull, rv = appShell->CreateTopLevelWindow( nsnull,
url, url,
PR_TRUE, PR_TRUE,
*getter_AddRefs(newWindow), getter_AddRefs(newWindow),
nsnull, nsnull,
this, this,
0, 0,

Просмотреть файл

@ -237,7 +237,7 @@ nsInstallProgressDialog::Open()
rv = appShell->CreateTopLevelWindow( nsnull, rv = appShell->CreateTopLevelWindow( nsnull,
url, url,
PR_TRUE, PR_TRUE,
*getter_AddRefs(mWindow), getter_AddRefs(newWindow),
nsnull, nsnull,
this, // callbacks?? this, // callbacks??
0, 0,

Просмотреть файл

@ -369,7 +369,7 @@ nsXPInstallManager::BeforeJavascriptEvaluation()
rv = appShell->CreateTopLevelWindow( nsnull, rv = appShell->CreateTopLevelWindow( nsnull,
url, url,
PR_TRUE, PR_TRUE,
*getter_AddRefs(newWindow), getter_AddRefs(newWindow),
nsnull, nsnull,
this, // callbacks?? this, // callbacks??
0, 0,