if (NS_SUCCEEDED(result)) { aSheet->SetModified(PR_FALSE); failed = PR_FALSE; if (0 == aLoadData->mPendingChildren) { if (aLoadData->mIsInline) { aLoadData->mDidBlockParser = PR_FALSE; } SheetComplete(aSheet, aLoadData); } else { aCompleted = PR_FALSE; } } RecycleParser(parser);
nsresult rv = aLoadData->mSheet->Init(aSheetURI); NS_ASSERTION(NS_SUCCEEDED(rv), "If this is failing, something has gone terribly wrong");  nsCOMPtr<nsICSSParser> parser; rv = GetParserFor(aLoadData->mSheet, getter_AddRefs(parser)); if (NS_FAILED(rv)) { LOG_ERROR(("  Failed to get CSS parser")); SheetComplete(aLoadData, PR_FALSE); return rv; }    nsCOMPtr<nsICSSStyleSheet> dummySheet;  mParsingDatas.AppendElement(aLoadData); rv = parser->Parse(aStream, aSheetURI, *getter_AddRefs(dummySheet)); mParsingDatas.RemoveElementAt(mParsingDatas.Count() - 1); RecycleParser(parser);  NS_ASSERTION(aLoadData->mPendingChildren == 0 || !aLoadData->mSyncLoad, "Sync load has leftover pending children!");  if (aLoadData->mPendingChildren == 0) { LOG(("  No pending kids from parse")); aCompleted = PR_TRUE; if (!aLoadData->mURI) {   LOG(("  Inline sheet with no pending kids; nulling out parser")); aLoadData->mParserToUnblock = nsnull;
CSSLoaderImpl::ParseSheet(nsIUnicharInputStream* aIn,                          SheetLoadData* aLoadData,                          PRBool& aCompleted,                          nsICSSStyleSheet*& aSheet){  nsresult result;  PRBool  failed = PR_TRUE;  aCompleted = PR_TRUE;  aSheet = nsnull;  result = NS_NewCSSStyleSheet(&aSheet, aLoadData->mURL);  if (NS_SUCCEEDED(result)) {    nsCOMPtr<nsICSSParser> parser;    result = GetParserFor(aSheet, getter_AddRefs(parser));    if (NS_SUCCEEDED(result)) {      mParsingData.AppendElement(aLoadData);      if (kNameSpaceID_Unknown != aLoadData->mDefaultNameSpaceID) {        aSheet->SetDefaultNameSpaceID(aLoadData->mDefaultNameSpaceID);      }      result = parser->Parse(aIn, aLoadData->mURL, aSheet);  // this may result in re-entrant load child sheet calls      mParsingData.RemoveElementAt(mParsingData.Count() - 1);      if (NS_SUCCEEDED(result)) {        aSheet->SetModified(PR_FALSE);  // make it clean from the load        failed = PR_FALSE;        if (0 == aLoadData->mPendingChildren) { // sheet isn't still loading children          if (aLoadData->mIsInline) {            aLoadData->mDidBlockParser = PR_FALSE;  // don't need to unblock, we're done and won't block          }          SheetComplete(aSheet, aLoadData);        }        else {  // else sheet is still waiting for children to load, last child will complete it          aCompleted = PR_FALSE;        }      }      RecycleParser(parser);    }  }  if (failed) {    URLKey  key(aLoadData->mURL);    Cleanup(key, aLoadData);  }  return result;}