}
DocumentViewerImpl::LoadComplete(nsresult aStatus){  nsresult rv = NS_OK;  NS_ENSURE_TRUE(mDocument, NS_ERROR_NOT_AVAILABLE);  nsCOMPtr<nsIScriptGlobalObject> global;  // First, get the script global object from the document...  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;  mLoaded = PR_TRUE;  /* We need to protect ourself against auto-destruction in case the window is closed     while processing the OnLoad event.     See bug http://bugzilla.mozilla.org/show_bug.cgi?id=78445 for more explanation.  */  NS_ADDREF_THIS();  // 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);#ifdef MOZ_TIMELINE    // if navigator.xul's load is complete, the main nav window is visible    // mark that point.    if (mDocument) {      //printf("DEBUG: getting uri from document (%p)\n", mDocument.get());      nsCOMPtr<nsIURI> uri;      mDocument->GetDocumentURL(getter_AddRefs(uri));      if (uri.get() != nsnull) {        //printf("DEBUG: getting spec fro uri (%p)\n", uri.get());        nsCAutoString spec;        uri->GetSpec(spec);        if (!strcmp(spec.get(), "chrome://navigator/content/navigator.xul")) {          NS_TIMELINE_MARK("Navigator Window visible now");        }      }    }#endif /* MOZ_TIMELINE */  } else {    // XXX: Should fire error event to the document...  }    // Now that the document has loaded, we can tell the presshell  // to unsuppress painting.  if (mPresShell && !mStopped)    mPresShell->UnsuppressPainting();  NS_RELEASE_THIS();  return rv;}