nsCOMPtr<nsIXULContentUtils> utils(do_GetService("@mozilla.org/rdf/xul-content-utils;1")); if (utils && utils->UseXULCache()) { nsCOMPtr<nsIXULPrototypeCache> cache(do_GetService("@mozilla.org/rdf/xul-prototype-cache;1")); if (cache) {
nsCOMPtr<nsIXULPrototypeCache> cache(do_GetService("@mozilla.org/xul/xul-prototype-cache;1")); if (cache) { PRBool enabled; cache->GetEnabled(&enabled); if (enabled) {
CSSLoaderImpl::LoadChildSheet(nsICSSStyleSheet* aParentSheet,                              nsIURI* aURL,                               const nsString& aMedia,                              PRInt32 aDefaultNameSpaceID,                              PRInt32 aIndex){  nsresult result = NS_ERROR_NULL_POINTER;  if (aURL) {    URLKey  key(aURL);    PRBool  sheetModified = PR_FALSE;    nsICSSStyleSheet* sheet = (nsICSSStyleSheet*)mLoadedSheets.Get(&key);#ifdef INCLUDE_XUL    if (!sheet && IsChromeURI(aURL)) {      nsCOMPtr<nsIXULContentUtils> utils(do_GetService("@mozilla.org/rdf/xul-content-utils;1"));      if (utils && utils->UseXULCache()) {        nsCOMPtr<nsIXULPrototypeCache> cache(do_GetService("@mozilla.org/rdf/xul-prototype-cache;1"));        if (cache) {          nsCOMPtr<nsICSSStyleSheet> cachedSheet;          cache->GetStyleSheet(aURL, getter_AddRefs(cachedSheet));          if (cachedSheet)            sheet = cachedSheet;        }      }    }#endif    if (sheet && (NS_OK == sheet->IsModified(&sheetModified)) && sheetModified) {  // if dirty, forget it      sheet = nsnull;    }    if (sheet) {  // already have one loaded and unmodified      nsICSSStyleSheet* clone = nsnull;      result = sheet->Clone(clone);      if (NS_SUCCEEDED(result)) {        result = SetMedia(clone, aMedia);        if (NS_SUCCEEDED(result)) {          result = InsertChildSheet(clone, aParentSheet, aIndex);        }        NS_RELEASE(clone);      }    }    else {      SheetLoadData* data = new SheetLoadData(this, aURL, aMedia, aDefaultNameSpaceID,                                              aParentSheet, aIndex);      if (data == nsnull) {        result = NS_ERROR_OUT_OF_MEMORY;      }      else {        NS_ADDREF(data);        PRInt32 count = mParsingData.Count();        if (count) { // still parsing the parent (expected for @import)          // XXX assert that last parsing == parent sheet          SheetLoadData* parentData = (SheetLoadData*)mParsingData.ElementAt(count - 1);          data->mParentData = parentData;          data->mIsAgent = parentData->mIsAgent;          data->mSyncLoad = parentData->mSyncLoad;          // verify that sheet doesn't have new child as a parent           do {            PRBool equals;            result = parentData->mURL->Equals(aURL, &equals);            if (NS_SUCCEEDED(result) && equals) { // houston, we have a loop, blow off this child              data->mParentData = nsnull;              NS_RELEASE(data);              return NS_OK;            }            parentData = parentData->mParentData;          } while (parentData);                  (data->mParentData->mPendingChildren)++;        }        result = LoadSheet(key, data);      }    }  }  return result;}