if (!mEnabled) return NS_ERROR_NOT_AVAILABLE;
CSSLoaderImpl::LoadAgentSheet(nsIURI* aURL,                               nsICSSStyleSheet*& aSheet,                              PRBool& aCompleted,                              nsICSSLoaderObserver* aObserver){  nsresult result = NS_ERROR_NULL_POINTER;  if (aURL) {    // Get an input stream from the url    nsIInputStream* in;    nsIURI* urlClone;    result = aURL->Clone(&urlClone); // dont give key URL to netlib, it gets munged    if (NS_SUCCEEDED(result)) {      result = NS_OpenURI(&in, urlClone);      NS_RELEASE(urlClone);      if (NS_SUCCEEDED(result)) {        // Translate the input, using our characterset, into unicode        nsCOMPtr<nsIConverterInputStream> uin =          do_CreateInstance("@mozilla.org/intl/converter-input-stream;1",                            &result);        if (NS_SUCCEEDED(result))          result = uin->Init(in, NS_LITERAL_STRING("ISO-8859-1").get(),                             0, PR_TRUE);        if (NS_SUCCEEDED(result)) {          SheetLoadData* data = new SheetLoadData(this, aURL, aObserver);          if (data == nsnull) {            result = NS_ERROR_OUT_OF_MEMORY;          }          else {            NS_ADDREF(data);            URLKey  key(aURL);						if (aObserver == nsnull) {	            mLoadingSheets.Put(&key, data);	            result = ParseSheet(uin, data, aCompleted, aSheet);	          }						else {	      			result = LoadSheet(key, data); // this may steal pending alternates too	      			aCompleted = PR_FALSE;	      		}          }        }        else {          fputs("CSSLoader::LoadAgentSheet - failed to get converter stream\n", stderr);        }        NS_RELEASE(in);      }#ifdef DEBUG      else {        // Dump an error message to the console        PRBool ignoreError = PR_FALSE;        nsCAutoString url;        aURL->GetSpec(url);        // Ignore userChrome.css and userContent.css failures#define USERCHROMECSS "userChrome.css"#define USERCONTENTCSS "userContent.css"        if (url.Length() > sizeof(USERCHROMECSS) &&            Substring(url, url.Length()-sizeof(USERCHROMECSS)+1, sizeof(USERCHROMECSS)).Equals(NS_LITERAL_CSTRING(USERCHROMECSS)))          ignoreError = PR_TRUE;        if (!ignoreError &&            url.Length() > sizeof(USERCONTENTCSS) &&            Substring(url, url.Length()-sizeof(USERCONTENTCSS)+1, sizeof(USERCONTENTCSS)).Equals(NS_LITERAL_CSTRING(USERCONTENTCSS)))          ignoreError = PR_TRUE;        if (!ignoreError) {          nsCAutoString errorMessage(NS_LITERAL_CSTRING("CSSLoaderImpl::LoadAgentSheet: Load of URL '") +                                     url +                                     NS_LITERAL_CSTRING("' failed.  Error code: "));          errorMessage.AppendInt(NS_ERROR_GET_CODE(result));          NS_WARNING(errorMessage.get());        }      }#endif    }  }  return result;}