SheetLoadData* loadingData = (SheetLoadData*)mLoadingSheets.Get(&aKey); if (loadingData) { while (loadingData->mNext) { loadingData = loadingData->mNext;
LOG_URI("  Load from: '%s'", aLoadData->mURI);  nsresult rv = NS_OK;  if (!mDocument && !aLoadData->mIsAgent) {  LOG_WARN(("  No document and not agent sheet; pre-dropping load")); SheetComplete(aLoadData, PR_FALSE); return NS_OK; }  if (aLoadData->mSyncLoad) { LOG(("  Synchronous load")); NS_ASSERTION(aSheetState == eSheetNeedsParser, "Sync loads can't reuse existing async loads");   nsCOMPtr<nsIInputStream> stream; rv = NS_OpenURI(getter_AddRefs(stream), aLoadData->mURI); if (NS_FAILED(rv)) { LOG_ERROR(("  Failed to open URI synchronously")); SheetComplete(aLoadData, PR_FALSE); return rv;
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    nsIUnicharStreamLoader* loader;    nsIURL* urlClone = CloneURL(aKey.mURL); // don't give the key to netlib, it munges it    if (urlClone) {      result = NS_NewUnicharStreamLoader(&loader, urlClone, DoneLoadingStyle, aData);      NS_RELEASE(urlClone);      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);          if (aKey.mURL->Equals(data->mURL)) {            mPendingAlternateSheets.RemoveElementAt(index);            loadingData->mNext = data;            loadingData = data;          }          else {            index++;          }        }      }    }  }  return result;}