Compare(contentType, NS_LITERAL_CSTRING("text/css"), nsCaseInsensitiveCStringComparator()) == 0 ||
contentType.Equals(NS_LITERAL_CSTRING("text/css"), nsCaseInsensitiveCStringComparator()) ||
SheetLoadData::OnStreamComplete(nsIStreamLoader* aLoader,                                nsISupports* aContext,                                nsresult aStatus,                                PRUint32 aStringLen,                                const char* aString){  NS_TIMELINE_OUTDENT();  NS_TIMELINE_MARK_LOADER("SheetLoadData::OnStreamComplete(%s)", aLoader);  nsresult result = NS_OK;  nsString *strUnicodeBuffer = nsnull;  if (aString && aStringLen>0) {    nsCOMPtr<nsIRequest> request;    aLoader->GetRequest(getter_AddRefs(request));    nsXPIDLCString contentType;    if (! (mLoader->mNavQuirkMode)) {      nsCOMPtr<nsIChannel> channel(do_QueryInterface(request));      if (channel) {        channel->GetContentType(getter_Copies(contentType));      }    }    if (mLoader->mNavQuirkMode ||        Compare(contentType,                NS_LITERAL_CSTRING("text/css"),                nsCaseInsensitiveCStringComparator()) == 0 ||        contentType.IsEmpty()) {      /*       * First determine the charset (if one is indicated)       * 1)  Check HTTP charset       * 2)  Check @charset rules       * 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)       */      nsAutoString strHTTPCharset;      nsCOMPtr<nsIHttpChannel> httpChannel = do_QueryInterface(request);      if (httpChannel) {        nsXPIDLCString httpCharset;        httpChannel->GetCharset(getter_Copies(httpCharset));        CopyASCIItoUCS2(httpCharset, strHTTPCharset);      }      result = NS_ERROR_NOT_AVAILABLE;      if (! strHTTPCharset.IsEmpty()) {        result = mLoader->SetCharset(strHTTPCharset);      }      if (NS_FAILED(result)) {        //  We have no charset or the HTTP charset is not recognized.        //  Try @charset rules        result = mLoader->SetCharset(aString, aStringLen);      }      if (NS_FAILED(result)) {        // Now try the charset on the <link> or processing instruction        // that loaded us        nsCOMPtr<nsIStyleSheetLinkingElement>          element(do_QueryInterface(mOwningElement));        if (element) {          nsAutoString linkCharset;          element->GetCharset(linkCharset);          if (! linkCharset.IsEmpty()) {            result = mLoader->SetCharset(linkCharset);          }        }      }      if (NS_FAILED(result)) {        // no useful data on charset.  Just set to empty string, and let        // SetCharset pick a sane default        mLoader->SetCharset(NS_LITERAL_STRING(""));      }            {        // now get the decoder        nsCOMPtr<nsICharsetConverterManager> ccm =           do_GetService(kCharsetConverterManagerCID, &result);        if (NS_SUCCEEDED(result) && ccm) {          nsString charset;          mLoader->GetCharset(charset);          nsIUnicodeDecoder *decoder = nsnull;          ccm->GetUnicodeDecoder(&charset,&decoder);          if (decoder) {            PRInt32 unicodeLength=0;            if (NS_SUCCEEDED(decoder->GetMaxLength(aString,aStringLen,&unicodeLength))) {              PRUnichar *unicodeString = nsnull;              strUnicodeBuffer = new nsString;              if (nsnull == strUnicodeBuffer) {                result = NS_ERROR_OUT_OF_MEMORY;              } else {                // make space for the decoding                strUnicodeBuffer->SetCapacity(unicodeLength);                unicodeString = (PRUnichar *) strUnicodeBuffer->get();                result = decoder->Convert(aString, (PRInt32 *) &aStringLen, unicodeString, &unicodeLength);                if (NS_SUCCEEDED(result)) {                  strUnicodeBuffer->SetLength(unicodeLength);                } else {#ifdef DEBUG                  /*                   * We currently fail often because of XML documents                   * which are in UTF-8 importing stylesheets which                   * use an ISO-8859-1 char, especially in comments in                   * the sheet.  See http://bugzilla.mozilla.org/show_bug.cgi?id=106843                   *                   * This assertion should at least make it possible                   * to catch such errors in chrome, pending this bug                   * being fixed                   */                                     nsXPIDLCString uriStr;                  mURL->GetSpec(getter_Copies(uriStr));                  nsCAutoString errorMessage;                  errorMessage = NS_LITERAL_CSTRING("Decoding sheet from ") +                                 uriStr +                                 NS_LITERAL_CSTRING(" failed");                  NS_ASSERTION(PR_FALSE, errorMessage.get());#endif // DEBUG                  strUnicodeBuffer->SetLength(0);                }              }            }            NS_RELEASE(decoder);          }        }      }    }  }  mLoader->DidLoadStyle(aLoader, strUnicodeBuffer, this, aStatus);  // NOTE: passed ownership of strUnicodeBuffer to mLoader in the call,   //       so nulling it out for clarity / safety  strUnicodeBuffer = nsnull;  // We added a reference when the loader was created. This  // release should destroy it.  NS_RELEASE(aLoader);  return result;}