mLoader->mDocument->GetDocumentCharacterSet(aCharset);
mLoader->mDocument->GetDocumentCharacterSet(charset);
SheetLoadData::OnDetermineCharset(nsIUnicharStreamLoader* aLoader,                                  nsISupports* aContext,                                  const char* aData,                                  PRUint32 aDataLength,                                  nsACString& aCharset){  nsCOMPtr<nsIChannel> channel;  nsresult result = aLoader->GetChannel(getter_AddRefs(channel));  if (NS_FAILED(result))    channel = nsnull;  aCharset.Truncate();  /*   * First determine the charset (if one is indicated)   * 1)  Check nsIChannel::contentCharset   * 2)  Check @charset rules in the data   * 3)  Check "charset" attribute of the <LINK> or <?xml-stylesheet?>   *   * If all these fail to give us a charset, fall back on our   * default (document charset or ISO-8859-1 if we have no document   * charset)   */  if (channel) {    channel->GetContentCharset(aCharset);  }  result = NS_ERROR_NOT_AVAILABLE;#ifdef DEBUG_bzbarsky  if (! aCharset.IsEmpty()) {    fprintf(stderr, "Setting from HTTP to: %s\n",            PromiseFlatCString(aCharset).get());  }#endif  if (aCharset.IsEmpty()) {    //  We have no charset    //  Try @charset rule and BOM    result = GetCharsetFromData((const unsigned char*)aData,                                aDataLength, aCharset);#ifdef DEBUG_bzbarsky    if (NS_SUCCEEDED(result)) {      fprintf(stderr, "Setting from @charset rule or BOM: %s\n",              PromiseFlatCString(aCharset).get());    }#endif  }  if (aCharset.IsEmpty()) {    // Now try the charset on the <link> or processing instruction    // that loaded us    if (mOwningElement) {      nsAutoString elementCharset;      mOwningElement->GetCharset(elementCharset);      CopyUCS2toASCII(elementCharset, aCharset);#ifdef DEBUG_bzbarsky      if (! aCharset.IsEmpty()) {        fprintf(stderr, "Setting from property on element: %s\n",                PromiseFlatCString(aCharset).get());      }#endif    }  }  if (aCharset.IsEmpty() && mLoader->mDocument) {    // no useful data on charset.  Try the document charset.    // That needs no resolution, since it's already fully resolved    mLoader->mDocument->GetDocumentCharacterSet(aCharset);#ifdef DEBUG_bzbarsky    fprintf(stderr, "Set from document: %s\n",            PromiseFlatCString(aCharset).get());#endif  }        if (aCharset.IsEmpty()) {    NS_WARNING("Unable to determine charset for sheet, using ISO-8859-1!");    aCharset = NS_LITERAL_CSTRING("ISO-8859-1");  }    return NS_OK;}