}          PRBool seenParser = PR_FALSE;   SheetLoadData* data = aLoadData; while (data) {  data->mSheet->SetModified(PR_FALSE); data->mSheet->SetComplete(); if (data->mObserver) { data->mObserver->StyleSheetLoaded(data->mSheet, PR_TRUE);
else if (data->mIsAgent) { if (data->mObserver) { data->mObserver->StyleSheetLoaded(aSheet, PR_FALSE); }
CSSLoaderImpl::SheetComplete(SheetLoadData* aLoadData, PRBool aSucceeded){  LOG(("CSSLoaderImpl::SheetComplete"));  NS_PRECONDITION(aLoadData, "Must have a load data!");  NS_PRECONDITION(aLoadData->mSheet, "Must have a sheet");  LOG(("Load completed: %d", aSucceeded));  // Twiddle the hashtables  if (aLoadData->mURI) {    LOG_URI("  Finished loading: '%s'", aLoadData->mURI);    // Remove the data from the list of loading datas    URLKey key(aLoadData->mURI);    if (aLoadData->mIsLoading) {      #ifdef DEBUG      SheetLoadData* loadingData =#endif        NS_STATIC_CAST(SheetLoadData*, mLoadingDatas.Remove(&key));      NS_ASSERTION(loadingData == aLoadData, "Broken loading table");      aLoadData->mIsLoading = PR_FALSE;    }  }    // This is a mess.  If we have a document.write() that writes out  // two <link> elements pointing to the same url, we will actually  // end up blocking the same parser twice.  This seems very wrong --  // if we blocked it the first time, why is more stuff getting  // written??  In any case, we only want to unblock it once.  // Otherwise we get icky things like crashes in layout...  We need  // to stop blocking the parser.  We really do.  PRBool seenParser = PR_FALSE;  // Go through and deal with the whole linked list.  SheetLoadData* data = aLoadData;  while (data) {    data->mSheet->SetModified(PR_FALSE); // it's clean    data->mSheet->SetComplete();    if (data->mObserver) {      data->mObserver->StyleSheetLoaded(data->mSheet, PR_TRUE);    }                               if (data->mParserToUnblock) {      LOG(("Parser to unblock: %p", data->mParserToUnblock.get()));      if (!seenParser) {        LOG(("Unblocking parser: %p", data->mParserToUnblock.get()));        seenParser = PR_TRUE;        data->mParserToUnblock->ContinueParsing();      }      data->mParserToUnblock = nsnull; // drop the ref, just in case    }    NS_ASSERTION(!data->mParentData ||                 data->mParentData->mPendingChildren != 0,                 "Broken pending child count on our parent");    // If we have a parent, our parent is no longer being parsed, and    // we are the last pending child, then our load completion    // completes the parent too.  Note that the parent _can_ still be    // being parsed (eg if the child (us) failed to open the channel    // or some such).    if (data->mParentData &&        --(data->mParentData->mPendingChildren) == 0 &&        mParsingDatas.IndexOf(data->mParentData) == -1) {      SheetComplete(data->mParentData, aSucceeded);    }        data = data->mNext;  }  // Now that it's marked complete, put the sheet in our cache  if (aSucceeded && aLoadData->mURI) {#ifdef MOZ_XUL    if (IsChromeURI(aLoadData->mURI)) {      nsCOMPtr<nsIXULPrototypeCache> cache(do_GetService("@mozilla.org/xul/xul-prototype-cache;1"));      if (cache) {        PRBool enabled;        cache->GetEnabled(&enabled);        if (enabled) {          nsCOMPtr<nsICSSStyleSheet> sheet;          cache->GetStyleSheet(aLoadData->mURI, getter_AddRefs(sheet));          if (!sheet) {            LOG(("  Putting sheet in XUL prototype cache"));            cache->PutStyleSheet(aLoadData->mSheet);          }        }      }    }    else {#endif      URLKey key(aLoadData->mURI);      mCompleteSheets.Put(&key, aLoadData->mSheet);#ifdef MOZ_XUL    }#endif  }  NS_RELEASE(aLoadData);  // this will release parents and siblings and all that  if (mLoadingDatas.Count() == 0 && mPendingDatas.Count() > 0) {    LOG(("  No more loading sheets; starting alternates"));    mPendingDatas.Enumerate(StartAlternateLoads, this);  }}