nsCOMPtr<nsIWebBrowserChrome> browserChrome(do_GetInterface(mTreeOwner)); nsresult rv = NS_ERROR_FAILURE;
if (!mOverURL.Equals(aURLSpec) || !mOverTarget.Equals(aTargetSpec)) { #ifdef NOISY_LINKS fputs("Was '", stdout); fputs(mOverURL, stdout); fputs("' '", stdout); fputs(mOverTarget, stdout); fputs("'\n", stdout); fputs("Over link '", stdout); fputs(aURLSpec, stdout); fputs("' '", stdout); fputs(aTargetSpec, stdout); fputs("'\n", stdout); #endif
nsWebShell::OnOverLink(nsIContent* aContent,                       const PRUnichar* aURLSpec,                       const PRUnichar* aTargetSpec){    nsCOMPtr<nsIWebBrowserChrome> browserChrome(do_GetInterface(mTreeOwner));  nsresult rv = NS_ERROR_FAILURE;  if(browserChrome)  {    nsCOMPtr<nsITextToSubURI> textToSubURI = do_GetService(NS_ITEXTTOSUBURI_CONTRACTID, &rv);    if (NS_FAILED(rv)) return rv;    PRUnichar *uStr;    nsString aSpec(aURLSpec);    PRInt32 pos = aSpec.FindChar(':');    nsAutoString scheme;    static const char kMailToURI[] = "mailto";    // If the scheme is mailtourl then should not convert from a document charset    if ((pos == (PRInt32)(sizeof kMailToURI - 1)) && (aSpec.Left(scheme, pos) != -1) &&         scheme.EqualsIgnoreCase(kMailToURI)) {      // use UTF-8 instead and apply URL escape.      rv = textToSubURI->UnEscapeAndConvert("UTF-8",NS_ConvertUCS2toUTF8(aURLSpec).get(), &uStr);    }    else  {      // use doc charset instead and apply URL escape.      nsCOMPtr<nsIPresShell> presShell;      nsCOMPtr<nsIDocument> doc;      nsDocShell::GetPresShell(getter_AddRefs(presShell));      NS_ENSURE_TRUE(presShell, NS_ERROR_FAILURE);      presShell->GetDocument(getter_AddRefs(doc));      NS_ENSURE_TRUE(doc, NS_ERROR_FAILURE);      nsAutoString charset;      NS_ENSURE_SUCCESS(doc->GetDocumentCharacterSet(charset), NS_ERROR_FAILURE);      rv = textToSubURI->UnEscapeAndConvert(NS_ConvertUCS2toUTF8(charset.get()).get(),             NS_ConvertUCS2toUTF8(aURLSpec).get(), &uStr);        }    if (NS_SUCCEEDED(rv))   {      rv = browserChrome->SetStatus(nsIWebBrowserChrome::STATUS_LINK, uStr);      nsMemory::Free(uStr);    }  }  return rv;}