diff --git a/mozilla/xpfe/appshell/public/nsIAppShellService.idl b/mozilla/xpfe/appshell/public/nsIAppShellService.idl index 07f99d4e0de..9ad3bad2f0a 100644 --- a/mozilla/xpfe/appshell/public/nsIAppShellService.idl +++ b/mozilla/xpfe/appshell/public/nsIAppShellService.idl @@ -72,17 +72,6 @@ interface nsIAppShellService : nsISupports */ void Shutdown(); - /** - * Push a new event queue onto the stack of queues and begin processing - * messages from it. - */ - void PushThreadEventQueue(); - - /** - * Pop the last pushed event queue and stop processing messages from it. - */ - void PopThreadEventQueue(); - /** * Create a window. * @param aParent the parent window. Can be null. diff --git a/mozilla/xpfe/appshell/src/nsAppShellService.cpp b/mozilla/xpfe/appshell/src/nsAppShellService.cpp index ca8062b94f3..84b979827e9 100644 --- a/mozilla/xpfe/appshell/src/nsAppShellService.cpp +++ b/mozilla/xpfe/appshell/src/nsAppShellService.cpp @@ -509,16 +509,6 @@ nsAppShellService::Shutdown(void) return NS_OK; } -NS_IMETHODIMP -nsAppShellService::PushThreadEventQueue() { - return mAppShell->PushThreadEventQueue(); -} - -NS_IMETHODIMP -nsAppShellService::PopThreadEventQueue() { - return mAppShell->PopThreadEventQueue(); -} - /* * Create a new top level window and display the given URL within it... */ @@ -714,16 +704,19 @@ nsAppShellService::RunModalDialog( { nsresult rv; nsIWebShellWindow *theWindow; - PRBool pushedQueue; + nsIEventQueue *pushedQueue; - pushedQueue = PR_FALSE; + NS_WITH_SERVICE(nsIEventQueueService, eventQService, kEventQueueServiceCID, &rv); + if (NS_FAILED(rv)) + return rv; + + pushedQueue = NULL; if (aWindow && *aWindow) { - theWindow = *aWindow; // and rv is already some success indication + theWindow = *aWindow; NS_ADDREF(theWindow); rv = NS_OK; } else { - pushedQueue = PR_TRUE; - PushThreadEventQueue(); + eventQService->PushThreadEventQueue(&pushedQueue); rv = CreateTopLevelWindow(aParent, aUrl, PR_TRUE, PR_TRUE, aChromeMask, aCallbacks, aInitialWidth, aInitialHeight, &theWindow); } @@ -751,7 +744,7 @@ nsAppShellService::RunModalDialog( } if (pushedQueue) - PopThreadEventQueue(); + eventQService->PopThreadEventQueue(pushedQueue); return rv; } diff --git a/mozilla/xpfe/appshell/src/nsWebShellWindow.cpp b/mozilla/xpfe/appshell/src/nsWebShellWindow.cpp index d89eea84362..74c4465afcc 100644 --- a/mozilla/xpfe/appshell/src/nsWebShellWindow.cpp +++ b/mozilla/xpfe/appshell/src/nsWebShellWindow.cpp @@ -211,6 +211,39 @@ struct nsWebShellInfo { } }; +// a little utility object to push an event queue and pop it when it +// goes out of scope. should probably be in a file of utility functions. +class stEventQueueStack { +public: + stEventQueueStack(); + ~stEventQueueStack(); + nsresult Success() const { return mPushedStack; } +private: + nsIEventQueueService *mService; + nsIEventQueue *mQueue; + nsresult mGotService, + mPushedStack; +}; +stEventQueueStack::stEventQueueStack() { + + // ick! this makes bad assumptions about the structure of the service, but + // the service manager seems to need to work this way... + mGotService = nsServiceManager::GetService(kEventQueueServiceCID, + nsIEventQueueService::GetIID(), + (nsISupports **) &mService); + mPushedStack = mGotService; + if (NS_SUCCEEDED(mGotService)) + mService->PushThreadEventQueue(&mQueue); +} +stEventQueueStack::~stEventQueueStack() { + if (NS_SUCCEEDED(mPushedStack)) + mService->PopThreadEventQueue(mQueue); + // more ick! + if (NS_SUCCEEDED(mGotService)) + nsServiceManager::ReleaseService(kEventQueueServiceCID, + NS_STATIC_CAST(nsISupports *, mService)); +} + nsWebShellWindow::nsWebShellWindow() { NS_INIT_REFCNT(); @@ -294,11 +327,6 @@ nsWebShellWindow::QueryInterface(REFNSIID aIID, void** aInstancePtr) NS_ADDREF_THIS(); return NS_OK; } - if (aIID.Equals(nsIModalWindowSupport::GetIID())) { - *aInstancePtr = (void*)NS_STATIC_CAST(nsIModalWindowSupport*, this); - NS_ADDREF_THIS(); - return NS_OK; - } if (aIID.Equals(nsISupportsWeakReference::GetIID())) { *aInstancePtr = (void*)NS_STATIC_CAST(nsISupportsWeakReference *, this); NS_ADDREF_THIS(); @@ -1551,7 +1579,9 @@ nsWebShellWindow::NewWebShell(PRUint32 aChromeMask, PRBool aVisible, // First push a nested event queue for event processing from netlib // onto our UI thread queue stack. - appShell->PushThreadEventQueue(); + stEventQueueStack queuePusher; + rv = queuePusher.Success(); + if (NS_FAILED(rv)) return rv; nsCOMPtr urlObj; char * urlStr = "chrome://navigator/content/"; @@ -1606,9 +1636,6 @@ nsWebShellWindow::NewWebShell(PRUint32 aChromeMask, PRBool aVisible, newWindow->GetLockedState(locked); } - // Get rid of the nested UI thread queue used for netlib - appShell->PopThreadEventQueue(); - subshell->Spindown(); NS_RELEASE(subshell); } @@ -1789,14 +1816,16 @@ NS_IMETHODIMP nsWebShellWindow::ShowModally(PRBool aPrepare) { nsresult rv; + nsIEventQueue *eventQ; nsCOMPtr parentWidget; - NS_WITH_SERVICE(nsIAppShellService, appShell, kAppShellServiceCID, &rv); + NS_WITH_SERVICE(nsIEventQueueService, eventQService, kEventQueueServiceCID, &rv); if (NS_FAILED(rv)) return rv; - if (aPrepare && NS_FAILED(appShell->PushThreadEventQueue())) - aPrepare = PR_FALSE; + eventQ = NULL; + if (aPrepare) + eventQService->PushThreadEventQueue(&eventQ); parentWidget = do_QueryReferent(mParentWindow); if (parentWidget) @@ -1805,8 +1834,8 @@ nsWebShellWindow::ShowModally(PRBool aPrepare) if (parentWidget) parentWidget->Enable(PR_TRUE); - if (aPrepare) - appShell->PopThreadEventQueue(); + if (eventQ) + eventQService->PopThreadEventQueue(eventQ); return rv; } @@ -3049,22 +3078,3 @@ NS_IMETHODIMP nsWebShellWindow::ConfirmCheckYN(const PRUnichar *text, const PRUn return NS_ERROR_NOT_IMPLEMENTED; } -// nsIModalWindowSupport interface -nsresult nsWebShellWindow::PrepareModality() -{ - nsresult rv; - NS_WITH_SERVICE(nsIAppShellService, appShell, kAppShellServiceCID, &rv); - if (NS_FAILED(rv)) - return rv; - return appShell->PushThreadEventQueue(); -} - -nsresult nsWebShellWindow::FinishModality() -{ - nsresult rv; - NS_WITH_SERVICE(nsIAppShellService, appShell, kAppShellServiceCID, &rv); - if (NS_FAILED(rv)) - return rv; - return appShell->PopThreadEventQueue(); -} - diff --git a/mozilla/xpfe/appshell/src/nsWebShellWindow.h b/mozilla/xpfe/appshell/src/nsWebShellWindow.h index 8f48b3ce026..5821e9e266e 100644 --- a/mozilla/xpfe/appshell/src/nsWebShellWindow.h +++ b/mozilla/xpfe/appshell/src/nsWebShellWindow.h @@ -23,7 +23,6 @@ #include "nsISupports.h" #include "nsIWebShellWindow.h" #include "nsIBrowserWindow.h" -#include "nsIModalWindowSupport.h" #include "nsGUIEvent.h" #include "nsIWebShell.h" #include "nsIDocumentLoaderObserver.h" @@ -65,7 +64,6 @@ class nsWebShellWindow : public nsIWebShellWindow, public nsIDocumentObserver, public nsIUrlDispatcher, public nsIPrompt, - public nsIModalWindowSupport, public nsSupportsWeakReference { @@ -268,10 +266,6 @@ public: // nsIPrompt NS_DECL_NSIPROMPT - // nsIModalWindowSupport - NS_IMETHOD PrepareModality(); - NS_IMETHOD FinishModality(); - protected: PRInt32 GetDocHeight(nsIDocument * aDoc);