LOG(("CSSLoaderImpl::SheetComplete")); NS_PRECONDITION(aLoadData, "Must have a load data!"); NS_PRECONDITION(aLoadData->mSheet, "Must have a sheet");  LOG(("Load completed: %d", aSucceeded));   if (aLoadData->mURI) { LOG_URI("  Finished loading: '%s'", aLoadData->mURI);  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;
CSSLoaderImpl::SheetComplete(nsICSSStyleSheet* aSheet, SheetLoadData* aLoadData){#ifdef INCLUDE_XUL  if (IsChromeURI(aLoadData->mURL)) {    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->mURL, getter_AddRefs(sheet));        if (!sheet) {          cache->PutStyleSheet(aSheet);          aSheet->SetModified(PR_FALSE); // We're clean.        }      }    }  }#endif  nsresult result = NS_OK;  URLKey  key(aLoadData->mURL);  if (! aLoadData->mIsInline) { // don't remember inline sheets     NS_ADDREF(aSheet);  // add ref for table    nsICSSStyleSheet* oldSheet = (nsICSSStyleSheet*)mLoadedSheets.Put(&key, aSheet);    NS_IF_RELEASE(oldSheet);  // relase predecessor (was dirty)  }  SheetLoadData* data = aLoadData;  do {  // add to parent sheet, parent doc or pending doc sheet list    PrepareSheet(aSheet, data->mTitle, data->mMedia);    if (data->mParentSheet) { // is child sheet      InsertChildSheet(aSheet, data->mParentSheet, data->mSheetIndex);      if (data->mParentRule) { // we have the @import rule that loaded this sheet        data->mParentRule->SetSheet(aSheet);        if (!data->mParentData) {          // No parent load data; this must be an @import rule being          // inserted via the DOM.  Let the parent sheet know that          // it's done.          nsCOMPtr<nsICSSLoaderObserver> loaderObserver(do_QueryInterface(data->mParentSheet));          if (loaderObserver) {            loaderObserver->StyleSheetLoaded(aSheet, PR_TRUE);          }        }      }    }    else if (data->mIsAgent) {  // is agent sheet      if (data->mObserver) {        data->mObserver->StyleSheetLoaded(aSheet, PR_FALSE);      }    }    else {  // doc sheet      if (data->mParserToUnblock) { // if blocking, insert it immediately        InsertSheetInDoc(aSheet, data->mSheetIndex, data->mOwningElement, PR_TRUE, data->mObserver);      }      else { // otherwise wait until all are loaded (even inlines)        AddPendingSheet(aSheet, data->mSheetIndex, data->mOwningElement, data->mObserver);      }    }    data = data->mNext;    if (data) { // clone sheet for next insertion      nsICSSStyleSheet* clone = nsnull;      result = aSheet->Clone(clone);      NS_RELEASE(aSheet);      if (NS_SUCCEEDED(result)) {        aSheet = clone;      }    }    else {      NS_RELEASE(aSheet);    }  } while (data && aSheet);  Cleanup(key, aLoadData);  return result;}