mObserver,
nsWebShell::DoLoadURL(nsIURI * aUri,                      const char* aCommand,                      nsIInputStream* aPostDataStream,                      nsLoadFlags aType,                      const PRUint32 aLocalIP,                      const PRUnichar* aReferrer){  if (!aUri)    return NS_ERROR_NULL_POINTER;  // Ugh. It sucks that we have to hack webshell like this. Forgive me, Father.  do {    nsresult rv;    NS_WITH_SERVICE(nsIGlobalHistory, history, "component://netscape/browser/global-history", &rv);    if (NS_FAILED(rv)) break;    rv = history->AddPage(nsCAutoString(mURL), nsnull /* referrer */, PR_Now());    if (NS_FAILED(rv)) break;  } while (0);  nsXPIDLCString urlSpec;  nsresult rv = NS_OK;  rv = aUri->GetSpec(getter_Copies(urlSpec));  if (NS_FAILED(rv)) return rv;  mURL = urlSpec;  mReferrer = aReferrer;  // If it's a normal reload that uses the cache, look at the destination anchor  // and see if it's an element within the current document  // We don't have a reload loadtype yet in necko. So, check for just history  // loadtype  if ((aType == LOAD_HISTORY || aType == nsIChannel::LOAD_NORMAL) && (nsnull != mContentViewer) &&      (nsnull == aPostDataStream))  {    nsCOMPtr<nsIDocumentViewer> docViewer;    if (NS_SUCCEEDED(mContentViewer->QueryInterface(kIDocumentViewerIID,                                                    getter_AddRefs(docViewer)))) {      // Get the document object      nsCOMPtr<nsIDocument> doc;      docViewer->GetDocument(*getter_AddRefs(doc));      // Get the URL for the document      nsCOMPtr<nsIURI>  docURL = nsDontAddRef<nsIURI>(doc->GetDocumentURL());      if (aUri && docURL && EqualBaseURLs(docURL, aUri)) {        // See if there's a destination anchor        nsXPIDLCString ref;        nsCOMPtr<nsIURL> aUrl = do_QueryInterface(aUri);        if (aUrl)          rv = aUrl->GetRef(getter_Copies(ref));        nsCOMPtr<nsIPresShell> presShell;        rv = docViewer->GetPresShell(*getter_AddRefs(presShell));        if (NS_SUCCEEDED(rv) && presShell) {          if (nsnull != (const char *) ref) {            // Go to the anchor in the current document            rv = presShell->GoToAnchor(nsAutoString(ref));            // Pass notifications to BrowserAppCore just to be consistent with            // regular page loads thro' necko            nsCOMPtr<nsIChannel> dummyChannel;            rv = NS_OpenURI(getter_AddRefs(dummyChannel), aUri, nsnull);            if (NS_FAILED(rv)) return rv;            mProcessedEndDocumentLoad = PR_FALSE;            rv = OnEndDocumentLoad(mDocLoader, dummyChannel, 0, this);            return rv;          }          else if (aType == LOAD_HISTORY)          {            // Go to the top of the current document            nsCOMPtr<nsIViewManager> viewMgr;            rv = presShell->GetViewManager(getter_AddRefs(viewMgr));            if (NS_SUCCEEDED(rv) && viewMgr) {              nsIScrollableView* view;              rv = viewMgr->GetRootScrollableView(&view);              if (NS_SUCCEEDED(rv) && view)                rv = view->ScrollTo(0, 0, NS_VMREFRESH_IMMEDIATE);              // Pass notifications to BrowserAppCore just to be consistent with              // regular necko loads.              nsCOMPtr<nsIChannel> dummyChannel;              rv = NS_OpenURI(getter_AddRefs(dummyChannel), aUri, nsnull);              if (NS_FAILED(rv)) return rv;              mProcessedEndDocumentLoad = PR_FALSE;              rv = OnEndDocumentLoad(mDocLoader, dummyChannel, 0, this);            }            return rv;          }        }      } // EqualBaseURLs(docURL, url)    }  }  // Stop loading the current document (if any...).  This call may result in  // firing an EndLoadURL notification for the old document...  StopBeforeRequestingURL();  // Tell web-shell-container we are loading a new url  if (nsnull != mContainer) {    nsAutoString uniSpec (urlSpec);    rv = mContainer->BeginLoadURL(this, uniSpec.GetUnicode());    if (NS_FAILED(rv)) {      return rv;    }  }  mProcessedEndDocumentLoad = PR_FALSE;#ifdef RAPTOR_PERF_METRICS  {     char* url;     nsresult rv = NS_OK;     rv = aUri->GetSpec(&url);     if (NS_SUCCEEDED(rv)) {       RAPTOR_STOPWATCH_TRACE(("*** Timing layout processes on url: '%s'\n", url));       delete [] url;     }  }  NS_RESET_AND_START_STOPWATCH(mTotalTime)#endif /* WebShell was primarily passing the buck when it came to streamObserver.  * So, pass on the observer which is already a streamObserver to DocLoder.  *  - Radha  */  return mDocLoader->LoadDocument(aUri,        // URL string                                  aCommand,        // Command                                  this,            // Container                                  aPostDataStream, // Post Data                                  nsnull,          // Extra Info...                                  mObserver,       // Observer                                  aType,           // reload type                                  aLocalIP,        // load attributes.                                  aReferrer);      // referrer}