зеркало из https://github.com/mozilla/pjs.git
Moved the firing of the OnLoad event from WebShell into DocumentViewer...
This commit is contained in:
Родитель
1f3563e514
Коммит
49552edbbe
|
@ -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<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
|
||||
|
|
|
@ -957,29 +957,18 @@ 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<nsIWebShell> 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<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);
|
||||
}
|
||||
}
|
||||
// Notify the ContentViewer that the Document has finished loading...
|
||||
if (!mEODForCurrentDocument && mContentViewer) {
|
||||
mContentViewer->LoadComplete(aStatus);
|
||||
}
|
||||
|
||||
mEODForCurrentDocument = PR_TRUE;
|
||||
|
|
|
@ -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<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
|
||||
|
|
|
@ -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<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
|
||||
|
|
Загрузка…
Ссылка в новой задаче