Moved the firing of the OnLoad event from WebShell into DocumentViewer...

This commit is contained in:
rpotts%netscape.com 2000-09-06 09:11:38 +00:00
Родитель 1f3563e514
Коммит 49552edbbe
4 изменённых файлов: 113 добавлений и 22 удалений

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

@ -633,10 +633,44 @@ DocumentViewerImpl::Init(nsIWidget* aParentWidget,
return rv; return rv;
} }
//
// LoadComplete(aStatus)
//
// aStatus - The status returned from loading the document.
//
// This method is called by the container when the document has been
// completely loaded.
//
NS_IMETHODIMP NS_IMETHODIMP
DocumentViewerImpl::LoadComplete(nsresult aStatus) DocumentViewerImpl::LoadComplete(nsresult aStatus)
{ {
return NS_ERROR_FAILURE; nsresult rv;
nsCOMPtr<nsIScriptGlobalObject> global;
// First, get the script global object from the document...
if (mDocument) {
rv = mDocument->GetScriptGlobalObject(getter_AddRefs(global));
}
// Fail if no ScriptGlobalObject is available...
NS_ASSERTION(global, "nsIScriptGlobalObject not set for document!");
if (!global) return NS_ERROR_NULL_POINTER;
// Now, fire either an OnLoad or OnError event to the document...
if(NS_SUCCEEDED(aStatus)) {
nsEventStatus status = nsEventStatus_eIgnore;
nsEvent event;
event.eventStructType = NS_EVENT;
event.message = NS_PAGE_LOAD;
rv = global->HandleDOMEvent(mPresContext, &event, nsnull,
NS_EVENT_FLAG_INIT, &status);
} else {
// XXX: Should fire error event to the document...
}
return rv;
} }
NS_IMETHODIMP NS_IMETHODIMP

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

@ -957,30 +957,19 @@ nsWebShell::OnEndDocumentLoad(nsIDocumentLoader* loader,
else else
mCharsetReloadState = eCharsetReloadInit; mCharsetReloadState = eCharsetReloadInit;
// Clear the LSHE reference in docshell to indicate document loading
// is done one way or another.
LSHE = nsnull;
/* one of many safeguards that prevent death and destruction if /* one of many safeguards that prevent death and destruction if
someone is so very very rude as to bring this window down someone is so very very rude as to bring this window down
during this load handler. */ during this load handler. */
nsCOMPtr<nsIWebShell> kungFuDeathGrip(this); nsCOMPtr<nsIWebShell> kungFuDeathGrip(this);
// Clear the LSHE reference in docshell to indicate document loading // Notify the ContentViewer that the Document has finished loading...
// is done one way or another. if (!mEODForCurrentDocument && mContentViewer) {
LSHE = nsnull; mContentViewer->LoadComplete(aStatus);
if(mScriptGlobal && !mEODForCurrentDocument && NS_SUCCEEDED(aStatus)) }
{
if(mContentViewer)
{
nsCOMPtr<nsIPresContext> presContext;
GetPresContext(getter_AddRefs(presContext));
if(presContext)
{
nsEventStatus status = nsEventStatus_eIgnore;
nsMouseEvent event;
event.eventStructType = NS_EVENT;
event.message = NS_PAGE_LOAD;
rv = mScriptGlobal->HandleDOMEvent(presContext, &event, nsnull, NS_EVENT_FLAG_INIT, &status);
}
}
}
mEODForCurrentDocument = PR_TRUE; mEODForCurrentDocument = PR_TRUE;
nsCOMPtr<nsIDocumentLoaderObserver> dlObserver; nsCOMPtr<nsIDocumentLoaderObserver> dlObserver;

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

@ -633,10 +633,44 @@ DocumentViewerImpl::Init(nsIWidget* aParentWidget,
return rv; return rv;
} }
//
// LoadComplete(aStatus)
//
// aStatus - The status returned from loading the document.
//
// This method is called by the container when the document has been
// completely loaded.
//
NS_IMETHODIMP NS_IMETHODIMP
DocumentViewerImpl::LoadComplete(nsresult aStatus) DocumentViewerImpl::LoadComplete(nsresult aStatus)
{ {
return NS_ERROR_FAILURE; nsresult rv;
nsCOMPtr<nsIScriptGlobalObject> global;
// First, get the script global object from the document...
if (mDocument) {
rv = mDocument->GetScriptGlobalObject(getter_AddRefs(global));
}
// Fail if no ScriptGlobalObject is available...
NS_ASSERTION(global, "nsIScriptGlobalObject not set for document!");
if (!global) return NS_ERROR_NULL_POINTER;
// Now, fire either an OnLoad or OnError event to the document...
if(NS_SUCCEEDED(aStatus)) {
nsEventStatus status = nsEventStatus_eIgnore;
nsEvent event;
event.eventStructType = NS_EVENT;
event.message = NS_PAGE_LOAD;
rv = global->HandleDOMEvent(mPresContext, &event, nsnull,
NS_EVENT_FLAG_INIT, &status);
} else {
// XXX: Should fire error event to the document...
}
return rv;
} }
NS_IMETHODIMP NS_IMETHODIMP

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

@ -633,10 +633,44 @@ DocumentViewerImpl::Init(nsIWidget* aParentWidget,
return rv; return rv;
} }
//
// LoadComplete(aStatus)
//
// aStatus - The status returned from loading the document.
//
// This method is called by the container when the document has been
// completely loaded.
//
NS_IMETHODIMP NS_IMETHODIMP
DocumentViewerImpl::LoadComplete(nsresult aStatus) DocumentViewerImpl::LoadComplete(nsresult aStatus)
{ {
return NS_ERROR_FAILURE; nsresult rv;
nsCOMPtr<nsIScriptGlobalObject> global;
// First, get the script global object from the document...
if (mDocument) {
rv = mDocument->GetScriptGlobalObject(getter_AddRefs(global));
}
// Fail if no ScriptGlobalObject is available...
NS_ASSERTION(global, "nsIScriptGlobalObject not set for document!");
if (!global) return NS_ERROR_NULL_POINTER;
// Now, fire either an OnLoad or OnError event to the document...
if(NS_SUCCEEDED(aStatus)) {
nsEventStatus status = nsEventStatus_eIgnore;
nsEvent event;
event.eventStructType = NS_EVENT;
event.message = NS_PAGE_LOAD;
rv = global->HandleDOMEvent(mPresContext, &event, nsnull,
NS_EVENT_FLAG_INIT, &status);
} else {
// XXX: Should fire error event to the document...
}
return rv;
} }
NS_IMETHODIMP NS_IMETHODIMP