if (!mEnabled) { LOG_WARN(("  Not enabled")); return NS_ERROR_NOT_AVAILABLE; }  LOG_URI("  Child uri: '%s'", aURL);
if (aURL) { URLKey  key(aURL); PRBool  sheetModified = PR_FALSE;
CSSLoaderImpl::LoadChildSheet(nsICSSStyleSheet* aParentSheet,                              nsIURI* aURL,                               const nsAString& aMedia,                              PRInt32 aDefaultNameSpaceID,                              nsICSSImportRule* aParentRule){  LOG(("CSSLoaderImpl::LoadChildSheet"));  NS_PRECONDITION(aURL, "Must have a URI to load");  if (!mEnabled) {    LOG_WARN(("  Not enabled"));    return NS_ERROR_NOT_AVAILABLE;  }    LOG_URI("  Child uri: '%s'", aURL);  // Check whether we should even load  nsCOMPtr<nsIURI> sheetURI;  nsresult rv = aParentSheet->GetURL(*getter_AddRefs(sheetURI));  if (NS_FAILED(rv) || !sheetURI) return NS_ERROR_FAILURE;  rv = CheckLoadAllowed(sheetURI, aURL, aParentRule);  if (NS_FAILED(rv)) return rv;  LOG(("  Passed load check"));    SheetLoadData* parentData = nsnull;  nsCOMPtr<nsICSSLoaderObserver> observer;  PRInt32 count = mParsingDatas.Count();  if (count > 0) {    LOG(("  Have a parent load"));    parentData = NS_STATIC_CAST(SheetLoadData*,                                mParsingDatas.ElementAt(count - 1));    // Check for cycles    SheetLoadData* data = parentData;    while (data && data->mURI) {      PRBool equal;      if (NS_SUCCEEDED(data->mURI->Equals(aURL, &equal)) && equal) {        // Houston, we have a loop, blow off this child and pretend this never        // happened        LOG_ERROR(("  @import cycle detected, dropping load"));        return NS_OK;      }      data = data->mParentData;    }    NS_ASSERTION(parentData->mSheet = aParentSheet,                 "Unexpected call to LoadChildSheet");  } else {    LOG(("  No parent load; must be CSSOM"));    // No parent load data, so the sheet will need to be notified when    // we finish, if it can be, if we do the load asynchronously.    observer = do_QueryInterface(aParentSheet);  }  // Now that we know it's safe to load this (passes security check and not a  // loop) do so  nsCOMPtr<nsICSSStyleSheet> sheet;  StyleSheetState state;  rv = CreateSheet(aURL, aDefaultNameSpaceID,                   parentData ? parentData->mSyncLoad : PR_FALSE,                   state, getter_AddRefs(sheet));  NS_ENSURE_SUCCESS(rv, rv);  rv = PrepareSheet(sheet, NS_LITERAL_STRING(""), aMedia);  NS_ENSURE_SUCCESS(rv, rv);    rv = InsertChildSheet(sheet, aParentSheet, aParentRule);  NS_ENSURE_SUCCESS(rv, rv);    if (state == eSheetComplete) {    LOG(("  Sheet already complete"));    // We're completely done.  No need to notify, even, since the    // @import rule addition/modification will trigger the right style    // changes automatically.    return NS_OK;  }    SheetLoadData* data = new SheetLoadData(this, aURL, sheet, parentData,                                          observer);  if (!data) {    sheet->SetComplete();    return NS_ERROR_OUT_OF_MEMORY;  }  NS_ADDREF(data);  // Load completion will release the data  return LoadSheet(data, state);  }