else {  nsCAutoString url; aKey.mURL->GetSpec(url); nsCAutoString errorMessage(NS_LITERAL_CSTRING("CSSLoaderImpl::LoadSheet: Load of URL '") + url + NS_LITERAL_CSTRING("' failed.  Error code: ")); errorMessage.AppendInt(NS_ERROR_GET_CODE(result)); NS_WARNING(errorMessage.get()); }
SheetLoadData* removedData =
CSSLoaderImpl::LoadSheet(URLKey& aKey, SheetLoadData* aData){  nsresult result = NS_OK;  SheetLoadData* loadingData = (SheetLoadData*)mLoadingSheets.Get(&aKey);  if (loadingData) {  // already loading this sheet, glom on to the load    while (loadingData->mNext) {      loadingData = loadingData->mNext;    }    loadingData->mNext = aData;  }  else {  // not loading, go load it    if (aData->mSyncLoad) { // handle agent sheets synchronously      nsIURI* urlClone;      result = aKey.mURL->Clone(&urlClone); // dont give key URL to netlib, it gets munged      if (NS_SUCCEEDED(result)) {        nsIInputStream* in;        result = NS_OpenURI(&in, urlClone);        NS_RELEASE(urlClone);        if (NS_SUCCEEDED(result)) {          // Translate the input using the argument character set id into unicode          nsIUnicharInputStream* uin;          result = NS_NewUTF8ConverterStream(&uin, in, 0);          if (NS_SUCCEEDED(result)) {            mLoadingSheets.Put(&aKey, aData);            PRBool completed;            nsICSSStyleSheet* sheet;            result = ParseSheet(uin, aData, completed, sheet);            NS_ASSERTION(completed, "sync sheet load failed to complete");            NS_IF_RELEASE(sheet);            NS_RELEASE(uin);          }          else {            fputs("CSSLoader::LoadSheet - failed to get converter stream\n", stderr);          }          NS_RELEASE(in);        }#ifdef DEBUG        else {          // Dump an error message to the console          nsCAutoString url;          aKey.mURL->GetSpec(url);          nsCAutoString errorMessage(NS_LITERAL_CSTRING("CSSLoaderImpl::LoadSheet: Load of URL '") +                                     url +                                     NS_LITERAL_CSTRING("' failed.  Error code: "));          errorMessage.AppendInt(NS_ERROR_GET_CODE(result));          NS_WARNING(errorMessage.get());        }#endif      }    }    else if (mDocument || aData->mIsAgent) {  // we're still live, start an async load      nsIUnicharStreamLoader* loader;      nsCOMPtr<nsIURI> urlClone;      result = aKey.mURL->Clone(getter_AddRefs(urlClone)); // dont give key URL to netlib, it gets munged      if (NS_SUCCEEDED(result)) {#ifdef NS_DEBUG        mSyncCallback = PR_TRUE;#endif        nsCOMPtr<nsILoadGroup> loadGroup;        mDocument->GetDocumentLoadGroup(getter_AddRefs(loadGroup));        NS_ASSERTION(loadGroup, "A stylesheet was unable to locate a load group. This means the onload is going to fire too early!");        nsCOMPtr<nsIURI> document_uri;        mDocument->GetDocumentURL(getter_AddRefs(document_uri));#ifdef MOZ_TIMELINE        NS_TIMELINE_MARK_URI("Loading style sheet: %s", urlClone);        NS_TIMELINE_INDENT();#endif        nsCOMPtr<nsIChannel> channel;        result = NS_NewChannel(getter_AddRefs(channel),                               urlClone, nsnull, loadGroup,                               nsnull, nsIChannel::LOAD_NORMAL);        if (NS_SUCCEEDED(result)) {          if (document_uri) {            nsCOMPtr<nsIHttpChannel> httpChannel(do_QueryInterface(channel));            if (httpChannel) {              result = httpChannel->SetReferrer(document_uri,                                                nsIHttpChannel::REFERRER_INLINES);            }          }          if (NS_SUCCEEDED(result)) {            result = NS_NewUnicharStreamLoader(&loader, channel, aData);          }        }#ifdef NS_DEBUG        mSyncCallback = PR_FALSE;#endif        if (NS_SUCCEEDED(result)) {          mLoadingSheets.Put(&aKey, aData);          // grab any pending alternates that have this URL          loadingData = aData;          PRInt32 index = 0;          while (index < mPendingAlternateSheets.Count()) {            SheetLoadData* data = (SheetLoadData*)mPendingAlternateSheets.ElementAt(index);            PRBool equals = PR_FALSE;            result = aKey.mURL->Equals(data->mURL, &equals);            if (NS_SUCCEEDED(result) && equals)            {              mPendingAlternateSheets.RemoveElementAt(index);              NS_IF_RELEASE(loadingData->mNext);              loadingData->mNext = data;              loadingData = data;            }            else {              index++;            }          }        }      }    }    else { // document gone,  no point in starting the load      NS_RELEASE(aData);    }  }  return result;}