if (nsnull != mScriptGlobal) { if (nsnull != mContentViewer && NS_OK == mContentViewer->QueryInterface(kIDocumentViewerIID, (void**)&docViewer)) { nsIPresContext *presContext; if (NS_OK == docViewer->GetPresContext(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);
if (!mProcessedEndDocumentLoad) { mProcessedEndDocumentLoad = PR_TRUE;
nsWebShell::OnEndDocumentLoad(nsIDocumentLoader* loader,                               nsIURL* aURL,                               PRInt32 aStatus){#if 0  const char* spec;  aURL->GetSpec(&spec);  printf("nsWebShell::OnEndDocumentLoad:%p: loader=%p url=%s status=%d\n", this, loader, spec, aStatus);#endif  nsIDocumentViewer* docViewer;  nsresult rv = NS_ERROR_FAILURE;  if (nsnull != mScriptGlobal) {    if (nsnull != mContentViewer &&         NS_OK == mContentViewer->QueryInterface(kIDocumentViewerIID, (void**)&docViewer)) {      nsIPresContext *presContext;      if (NS_OK == docViewer->GetPresContext(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);        NS_RELEASE(presContext);      }      NS_RELEASE(docViewer);    }  }  // Fire the EndLoadURL of the web shell container  if (nsnull != aURL) {     nsAutoString urlString;     const char* spec;     rv = aURL->GetSpec(&spec);     if (NS_SUCCEEDED(rv)) {       urlString = spec;       if (nsnull != mContainer) {          rv = mContainer->EndLoadURL(this, urlString.GetUnicode(), 0);       }       }  }  /*   * Fire the OnEndDocumentLoad of the DocLoaderobserver   */  if ((nsnull != mContainer) && (nsnull != mDocLoaderObserver) && (nsnull != aURL)){     mDocLoaderObserver->OnEndDocumentLoad(mDocLoader, aURL, aStatus);  }    return rv;}