diff --git a/mozilla/content/base/src/nsDocumentViewer.cpp b/mozilla/content/base/src/nsDocumentViewer.cpp index bc60c201ddb..478ec12ffef 100644 --- a/mozilla/content/base/src/nsDocumentViewer.cpp +++ b/mozilla/content/base/src/nsDocumentViewer.cpp @@ -633,10 +633,44 @@ DocumentViewerImpl::Init(nsIWidget* aParentWidget, 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 DocumentViewerImpl::LoadComplete(nsresult aStatus) { - return NS_ERROR_FAILURE; + nsresult rv; + + nsCOMPtr 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 diff --git a/mozilla/docshell/base/nsWebShell.cpp b/mozilla/docshell/base/nsWebShell.cpp index 6e4d5e50862..6f6c61c5baf 100644 --- a/mozilla/docshell/base/nsWebShell.cpp +++ b/mozilla/docshell/base/nsWebShell.cpp @@ -957,30 +957,19 @@ nsWebShell::OnEndDocumentLoad(nsIDocumentLoader* loader, else 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 someone is so very very rude as to bring this window down during this load handler. */ nsCOMPtr kungFuDeathGrip(this); - // Clear the LSHE reference in docshell to indicate document loading - // is done one way or another. - LSHE = nsnull; - if(mScriptGlobal && !mEODForCurrentDocument && NS_SUCCEEDED(aStatus)) - { - if(mContentViewer) - { - nsCOMPtr 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); - } - } - } + // Notify the ContentViewer that the Document has finished loading... + if (!mEODForCurrentDocument && mContentViewer) { + mContentViewer->LoadComplete(aStatus); + } mEODForCurrentDocument = PR_TRUE; nsCOMPtr dlObserver; diff --git a/mozilla/layout/base/nsDocumentViewer.cpp b/mozilla/layout/base/nsDocumentViewer.cpp index bc60c201ddb..478ec12ffef 100644 --- a/mozilla/layout/base/nsDocumentViewer.cpp +++ b/mozilla/layout/base/nsDocumentViewer.cpp @@ -633,10 +633,44 @@ DocumentViewerImpl::Init(nsIWidget* aParentWidget, 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 DocumentViewerImpl::LoadComplete(nsresult aStatus) { - return NS_ERROR_FAILURE; + nsresult rv; + + nsCOMPtr 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 diff --git a/mozilla/layout/base/src/nsDocumentViewer.cpp b/mozilla/layout/base/src/nsDocumentViewer.cpp index bc60c201ddb..478ec12ffef 100644 --- a/mozilla/layout/base/src/nsDocumentViewer.cpp +++ b/mozilla/layout/base/src/nsDocumentViewer.cpp @@ -633,10 +633,44 @@ DocumentViewerImpl::Init(nsIWidget* aParentWidget, 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 DocumentViewerImpl::LoadComplete(nsresult aStatus) { - return NS_ERROR_FAILURE; + nsresult rv; + + nsCOMPtr 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