OUTPUT_ERROR();
CSSParserImpl::Parse(nsIUnicharInputStream* aInput,                     nsIURI*                aInputURL,                     nsICSSStyleSheet*&     aResult){  NS_ASSERTION(nsnull != aInputURL, "need base URL");  if (! mSheet) {    NS_NewCSSStyleSheet(&mSheet, aInputURL);    mChildSheetCount = 0;  }  if (! mSheet) {    return NS_ERROR_OUT_OF_MEMORY;  }  PRInt32 errorCode = NS_OK;  nsresult result = InitScanner(aInput, aInputURL);  if (! NS_SUCCEEDED(result)) {    return result;  }  PRInt32 ruleCount = 0;  mSheet->StyleRuleCount(ruleCount);  if (0 < ruleCount) {    nsICSSRule* lastRule = nsnull;    mSheet->GetStyleRuleAt(ruleCount - 1, lastRule);    if (lastRule) {      PRInt32 type;      lastRule->GetType(type);      switch (type) {        case nsICSSRule::CHARSET_RULE:        case nsICSSRule::IMPORT_RULE:               mSection = eCSSSection_Import;              break;        case nsICSSRule::NAMESPACE_RULE:            mSection = eCSSSection_NameSpace;           break;        default:            mSection = eCSSSection_General;           break;      }      NS_RELEASE(lastRule);    }  }  else {    mSection = eCSSSection_Charset; // sheet is empty, any rules are fair  }  nsCSSToken* tk = &mToken;  for (;;) {    // Get next non-whitespace token    if (!GetToken(errorCode, PR_TRUE)) {      break;    }    if (eCSSToken_HTMLComment == tk->mType) {      continue; // legal here only    }    if (eCSSToken_AtKeyword == tk->mType) {      ParseAtRule(errorCode);      continue;    }    UngetToken();    if (ParseRuleSet(errorCode)) {      mSection = eCSSSection_General;    }  }  ReleaseScanner();  aResult = mSheet;  NS_ADDREF(aResult);  return NS_OK;}