HTMLContentSink::ScrollToRef()
HTMLContentSink::ScrollToRef(PRBool aReallyScroll)
HTMLContentSink::ScrollToRef(){  // XXX Duplicate code in nsXMLContentSink.  // XXX Be sure to change both places if you make changes here.  if (mRef.IsEmpty()) {    return;  }  char* tmpstr = ToNewCString(mRef);  if (!tmpstr) {    return;  }  nsUnescape(tmpstr);  nsCAutoString unescapedRef;  unescapedRef.Assign(tmpstr);  nsMemory::Free(tmpstr);  nsresult rv = NS_ERROR_FAILURE;  // We assume that the bytes are in UTF-8, as it says in the spec:  // http://www.w3.org/TR/html4/appendix/notes.html#h-B.2.1  nsAutoString ref = NS_ConvertUTF8toUCS2(unescapedRef);  PRInt32 i, ns = mDocument->GetNumberOfShells();  for (i = 0; i < ns; i++) {    nsCOMPtr<nsIPresShell> shell;    mDocument->GetShellAt(i, getter_AddRefs(shell));    if (shell) {      // Scroll to the anchor      shell->FlushPendingNotifications(PR_FALSE);      // Check an empty string which might be caused by the UTF-8 conversion      if (!ref.IsEmpty()) {        rv = shell->GoToAnchor(ref, PR_TRUE);      } else {        rv = NS_ERROR_FAILURE;      }      // If UTF-8 URL failed then try to assume the string as a      // document's charset.      if (NS_FAILED(rv)) {        nsAutoString docCharset;        rv = mDocument->GetDocumentCharacterSet(docCharset);        if (NS_SUCCEEDED(rv)) {          rv = CharsetConvRef(docCharset, unescapedRef, ref);          if (NS_SUCCEEDED(rv) && !ref.IsEmpty())            rv = shell->GoToAnchor(ref, PR_TRUE);        }      }      if (NS_SUCCEEDED(rv)) {        mScrolledToRefAlready = PR_TRUE;      }    }  }}