Removing IsModal,ShowModal,ExitModalLoop methods from nsIDocShellTreeOwner. General API cleanup. bug 70481 r=ccarlen,hyatt,vidur

This commit is contained in:
danm%netscape.com 2001-03-12 23:08:55 +00:00
Родитель 22ebda3698
Коммит 39f4900fca
5 изменённых файлов: 73 добавлений и 48 удалений

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

@ -38,6 +38,8 @@
#include "nsIDOMWindowInternal.h"
#include "nsAppShellCIDs.h"
#include "nsIAppShellService.h"
#include "nsIDocShellTreeOwner.h"
#include "nsIInterfaceRequestor.h"
static const char* kLoadAsData = "loadAsData";
@ -157,9 +159,8 @@ nsSyncLoader::~nsSyncLoader()
//if (XML_HTTP_REQUEST_SENT == mStatus) {
// Abort();
//}
if (mDocShellTreeOwner) {
mDocShellTreeOwner->ExitModalLoop(NS_OK);
}
if (mChromeWindow)
mChromeWindow->ExitModalEventLoop(NS_OK);
}
NS_IMPL_ISUPPORTS3(nsSyncLoader, nsISyncLoader, nsIDOMLoadListener, nsISupportsWeakReference)
@ -275,9 +276,16 @@ nsSyncLoader::LoadDocument(nsIURI* documentURI, nsIDOMDocument **_retval)
nsCOMPtr<nsIDocShellTreeItem> item = do_QueryInterface(docshell);
if (!item) return NS_ERROR_FAILURE;
rv = item->GetTreeOwner(getter_AddRefs(mDocShellTreeOwner));
nsCOMPtr<nsIDocShellTreeOwner> treeOwner;
rv = item->GetTreeOwner(getter_AddRefs(treeOwner));
if (NS_FAILED(rv)) return NS_ERROR_FAILURE;
nsCOMPtr<nsIInterfaceRequestor> treeRequestor(do_GetInterface(treeOwner));
if (!treeRequestor) return NS_ERROR_FAILURE;
treeRequestor->GetInterface(NS_GET_IID(nsIWebBrowserChrome), getter_AddRefs(mChromeWindow));
if (mChromeWindow) return NS_ERROR_FAILURE;
eventQService = do_GetService(kEventQueueServiceCID);
if(!eventQService ||
NS_FAILED(eventQService->PushThreadEventQueue(getter_AddRefs(modalEventQueue)))) {
@ -308,8 +316,8 @@ nsSyncLoader::LoadDocument(nsIURI* documentURI, nsIDOMDocument **_retval)
}
// Spin an event loop here and wait
if (mDocShellTreeOwner) {
rv = mDocShellTreeOwner->ShowModal();
if (mChromeWindow) {
rv = mChromeWindow->ShowAsModal();
eventQService->PopThreadEventQueue(modalEventQueue);
@ -332,9 +340,9 @@ nsSyncLoader::HandleEvent(nsIDOMEvent* aEvent)
nsresult
nsSyncLoader::Load(nsIDOMEvent* aEvent)
{
if (mDocShellTreeOwner) {
mDocShellTreeOwner->ExitModalLoop(NS_OK);
mDocShellTreeOwner = 0;
if (mChromeWindow) {
mChromeWindow->ExitModalEventLoop(NS_OK);
mChromeWindow = 0;
}
return NS_OK;
@ -349,9 +357,9 @@ nsSyncLoader::Unload(nsIDOMEvent* aEvent)
nsresult
nsSyncLoader::Abort(nsIDOMEvent* aEvent)
{
if (mDocShellTreeOwner) {
mDocShellTreeOwner->ExitModalLoop(NS_OK);
mDocShellTreeOwner = 0;
if (mChromeWindow) {
mChromeWindow->ExitModalEventLoop(NS_OK);
mChromeWindow = 0;
}
return NS_OK;
@ -360,9 +368,9 @@ nsSyncLoader::Abort(nsIDOMEvent* aEvent)
nsresult
nsSyncLoader::Error(nsIDOMEvent* aEvent)
{
if (mDocShellTreeOwner) {
mDocShellTreeOwner->ExitModalLoop(NS_OK);
mDocShellTreeOwner = 0;
if (mChromeWindow) {
mChromeWindow->ExitModalEventLoop(NS_OK);
mChromeWindow = 0;
}
return NS_OK;

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

@ -38,6 +38,8 @@
#include "nsIDOMWindowInternal.h"
#include "nsAppShellCIDs.h"
#include "nsIAppShellService.h"
#include "nsIDocShellTreeOwner.h"
#include "nsIInterfaceRequestor.h"
static const char* kLoadAsData = "loadAsData";
@ -157,9 +159,8 @@ nsSyncLoader::~nsSyncLoader()
//if (XML_HTTP_REQUEST_SENT == mStatus) {
// Abort();
//}
if (mDocShellTreeOwner) {
mDocShellTreeOwner->ExitModalLoop(NS_OK);
}
if (mChromeWindow)
mChromeWindow->ExitModalEventLoop(NS_OK);
}
NS_IMPL_ISUPPORTS3(nsSyncLoader, nsISyncLoader, nsIDOMLoadListener, nsISupportsWeakReference)
@ -275,9 +276,16 @@ nsSyncLoader::LoadDocument(nsIURI* documentURI, nsIDOMDocument **_retval)
nsCOMPtr<nsIDocShellTreeItem> item = do_QueryInterface(docshell);
if (!item) return NS_ERROR_FAILURE;
rv = item->GetTreeOwner(getter_AddRefs(mDocShellTreeOwner));
nsCOMPtr<nsIDocShellTreeOwner> treeOwner;
rv = item->GetTreeOwner(getter_AddRefs(treeOwner));
if (NS_FAILED(rv)) return NS_ERROR_FAILURE;
nsCOMPtr<nsIInterfaceRequestor> treeRequestor(do_GetInterface(treeOwner));
if (!treeRequestor) return NS_ERROR_FAILURE;
treeRequestor->GetInterface(NS_GET_IID(nsIWebBrowserChrome), getter_AddRefs(mChromeWindow));
if (mChromeWindow) return NS_ERROR_FAILURE;
eventQService = do_GetService(kEventQueueServiceCID);
if(!eventQService ||
NS_FAILED(eventQService->PushThreadEventQueue(getter_AddRefs(modalEventQueue)))) {
@ -308,8 +316,8 @@ nsSyncLoader::LoadDocument(nsIURI* documentURI, nsIDOMDocument **_retval)
}
// Spin an event loop here and wait
if (mDocShellTreeOwner) {
rv = mDocShellTreeOwner->ShowModal();
if (mChromeWindow) {
rv = mChromeWindow->ShowAsModal();
eventQService->PopThreadEventQueue(modalEventQueue);
@ -332,9 +340,9 @@ nsSyncLoader::HandleEvent(nsIDOMEvent* aEvent)
nsresult
nsSyncLoader::Load(nsIDOMEvent* aEvent)
{
if (mDocShellTreeOwner) {
mDocShellTreeOwner->ExitModalLoop(NS_OK);
mDocShellTreeOwner = 0;
if (mChromeWindow) {
mChromeWindow->ExitModalEventLoop(NS_OK);
mChromeWindow = 0;
}
return NS_OK;
@ -349,9 +357,9 @@ nsSyncLoader::Unload(nsIDOMEvent* aEvent)
nsresult
nsSyncLoader::Abort(nsIDOMEvent* aEvent)
{
if (mDocShellTreeOwner) {
mDocShellTreeOwner->ExitModalLoop(NS_OK);
mDocShellTreeOwner = 0;
if (mChromeWindow) {
mChromeWindow->ExitModalEventLoop(NS_OK);
mChromeWindow = 0;
}
return NS_OK;
@ -360,9 +368,9 @@ nsSyncLoader::Abort(nsIDOMEvent* aEvent)
nsresult
nsSyncLoader::Error(nsIDOMEvent* aEvent)
{
if (mDocShellTreeOwner) {
mDocShellTreeOwner->ExitModalLoop(NS_OK);
mDocShellTreeOwner = 0;
if (mChromeWindow) {
mChromeWindow->ExitModalEventLoop(NS_OK);
mChromeWindow = 0;
}
return NS_OK;

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

@ -30,7 +30,7 @@
#include "nsString.h"
#include "nsIDOMLoadListener.h"
#include "nsIDocument.h"
#include "nsIDocShellTreeOwner.h"
#include "nsIWebBrowserChrome.h"
#include "nsWeakReference.h"
#include "nsISyncLoader.h"
@ -56,7 +56,7 @@ public:
virtual nsresult Error(nsIDOMEvent* aEvent);
protected:
nsCOMPtr<nsIDocShellTreeOwner> mDocShellTreeOwner;
nsCOMPtr<nsIWebBrowserChrome> mChromeWindow;
};
#endif

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

@ -52,7 +52,9 @@
#include "nsIScriptGlobalObject.h"
#include "nsIDocShell.h"
#include "nsIDocShellTreeItem.h"
#include "nsIDocShellTreeOwner.h"
#include "nsIEventQueueService.h"
#include "nsIInterfaceRequestor.h"
#endif
static const char* kLoadAsData = "loadAsData";
@ -275,8 +277,8 @@ nsXMLHttpRequest::~nsXMLHttpRequest()
Abort();
}
#ifdef IMPLEMENT_SYNC_LOAD
if (mDocShellTreeOwner) {
mDocShellTreeOwner->ExitModalLoop(NS_OK);
if (mChromeWindow) {
mChromeWindow->ExitModalEventLoop(NS_OK);
}
#endif
}
@ -1242,9 +1244,16 @@ nsXMLHttpRequest::Send(nsISupports *body)
nsCOMPtr<nsIDocShellTreeItem> item = do_QueryInterface(docshell);
if (!item) return NS_ERROR_FAILURE;
rv = item->GetTreeOwner(getter_AddRefs(mDocShellTreeOwner));
nsCOMPtr<nsIDocShellTreeOwner> treeOwner;
rv = item->GetTreeOwner(getter_AddRefs(treeOwner));
if (NS_FAILED(rv)) return NS_ERROR_FAILURE;
nsCOMPtr<nsIInterfaceRequestor> treeRequestor(do_GetInterface(treeOwner));
if (!treeRequestor) return NS_ERROR_FAILURE;
treeRequestor->GetInterface(NS_GET_IID(nsIWebBrowserChrome), getter_AddRefs(mChromeWindow));
if (!mChromeWindow) return NS_ERROR_FAILURE;
eventQService = do_GetService(kEventQueueServiceCID);
if(!eventQService ||
NS_FAILED(eventQService->PushThreadEventQueue(getter_AddRefs(modalEventQueue)))) {
@ -1288,8 +1297,8 @@ nsXMLHttpRequest::Send(nsISupports *body)
#ifdef IMPLEMENT_SYNC_LOAD
// If we're synchronous, spin an event loop here and wait
if (!mAsync && mDocShellTreeOwner) {
rv = mDocShellTreeOwner->ShowModal();
if (!mAsync && mChromeWindow) {
rv = mChromeWindow->ShowAsModal();
eventQService->PopThreadEventQueue(modalEventQueue);
@ -1326,9 +1335,9 @@ nsXMLHttpRequest::Load(nsIDOMEvent* aEvent)
{
mStatus = XML_HTTP_REQUEST_COMPLETED;
#ifdef IMPLEMENT_SYNC_LOAD
if (mDocShellTreeOwner) {
mDocShellTreeOwner->ExitModalLoop(NS_OK);
mDocShellTreeOwner = 0;
if (mChromeWindow) {
mChromeWindow->ExitModalEventLoop(NS_OK);
mChromeWindow = 0;
}
#endif
if (mLoadEventListeners) {
@ -1360,9 +1369,9 @@ nsXMLHttpRequest::Abort(nsIDOMEvent* aEvent)
{
mStatus = XML_HTTP_REQUEST_ABORTED;
#ifdef IMPLEMENT_SYNC_LOAD
if (mDocShellTreeOwner) {
mDocShellTreeOwner->ExitModalLoop(NS_OK);
mDocShellTreeOwner = 0;
if (mChromeWindow) {
mChromeWindow->ExitModalEventLoop(NS_OK);
mChromeWindow = 0;
}
#endif
@ -1374,9 +1383,9 @@ nsXMLHttpRequest::Error(nsIDOMEvent* aEvent)
{
mStatus = XML_HTTP_REQUEST_ABORTED;
#ifdef IMPLEMENT_SYNC_LOAD
if (mDocShellTreeOwner) {
mDocShellTreeOwner->ExitModalLoop(NS_OK);
mDocShellTreeOwner = 0;
if (mChromeWindow) {
mChromeWindow->ExitModalEventLoop(NS_OK);
mChromeWindow = 0;
}
#endif
if (mErrorEventListeners) {

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

@ -37,7 +37,7 @@
#include "nsIDocument.h"
#include "nsIStreamListener.h"
#ifdef IMPLEMENT_SYNC_LOAD
#include "nsIDocShellTreeOwner.h"
#include "nsIWebBrowserChrome.h"
#endif
#include "nsWeakReference.h"
#include "nsISupportsArray.h"
@ -101,7 +101,7 @@ protected:
nsCOMPtr<nsIURI> mBaseURI;
nsCOMPtr<nsIDocument> mBaseDocument;
#ifdef IMPLEMENT_SYNC_LOAD
nsCOMPtr<nsIDocShellTreeOwner> mDocShellTreeOwner;
nsCOMPtr<nsIWebBrowserChrome> mChromeWindow;
#endif
nsCOMPtr<nsISupportsArray> mLoadEventListeners;
nsCOMPtr<nsISupportsArray> mErrorEventListeners;