Stop();
StopBeforeRequestingURL();
nsWebShell::DoLoadURL(const nsString& aUrlSpec,                      const char* aCommand,                      nsIPostData* aPostData,#ifdef NECKO                      nsLoadFlags aType,#else                      nsURLReloadType aType,#endif                      const PRUint32 aLocalIP){  // 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#ifdef NECKO  if ((aType == nsIChannel::LOAD_NORMAL) && (nsnull != mContentViewer))#else  if ((aType == nsURLReload) && (nsnull != mContentViewer))#endif  {    nsCOMPtr<nsIDocumentViewer> docViewer;    nsresult rv;    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());      // See if they're the same      nsCOMPtr<nsIURI>  url;#ifndef NECKO      NS_NewURL(getter_AddRefs(url), aUrlSpec);#else            NS_WITH_SERVICE(nsIIOService, service, kIOServiceCID, &rv);      if (NS_FAILED(rv)) return rv;      nsIURI *uri = nsnull;      char *uriSpec = aUrlSpec.ToNewCString();      rv = service->NewURI(uriSpec, nsnull, &uri);      nsCRT::free(uriSpec);      if (NS_FAILED(rv)) return rv;      rv = uri->QueryInterface(nsIURI::GetIID(), (void**)&url);      NS_RELEASE(uri);      if (NS_FAILED(rv)) return rv;#endif // NECKO      if (EqualBaseURLs(docURL, url))      {      // See if there's a destination anchor#ifdef NECKO        char* ref = nsnull;        nsCOMPtr<nsIURL> url2 = do_QueryInterface(url);        if (url2) {          rv = url2->GetRef(&ref);        }#else        const char* ref;        url->GetRef(&ref);#endif        nsCOMPtr<nsIPresShell> presShell;        rv = docViewer->GetPresShell(*getter_AddRefs(presShell));        if (NS_SUCCEEDED(rv) && presShell) {          if (nsnull != ref) {            // Go to the anchor in the current document                                presShell->GoToAnchor(nsAutoString(ref));                    }          else {            // 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) {                                view->ScrollTo(0, 0, NS_VMREFRESH_IMMEDIATE);              }            }          }        }        return NS_OK;      } // EqualBaseURLs(docURL, url)    }  }  // Stop loading the current document (if any...).  This call may result in  // firing an EndLoadURL notification for the old document...  Stop();  // Tell web-shell-container we are loading a new url  if (nsnull != mContainer) {    nsresult rv = mContainer->BeginLoadURL(this, aUrlSpec.GetUnicode());    if (NS_FAILED(rv)) {      return rv;    }  }  mProcessedEndDocumentLoad = PR_FALSE; /* 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(aUrlSpec,       // URL string                                  aCommand,       // Command                                  this,           // Container                                  aPostData,      // Post Data                                  nsnull,         // Extra Info...                                  mObserver,      // Observer                                  aType,          // reload type                                  aLocalIP);      // load attributes.}