NS_RELEASE(defaultNameSpace);
void CSSParserImpl::ParseTypeOrUniversalSelector(PRInt32&  aDataMask,                                      nsCSSSelector& aSelector,                                      PRInt32& aParsingStatus,                                      PRInt32& aErrorCode,                                      PRBool aIsNegated){  nsAutoString buffer;  if (mToken.IsSymbol('*')) {  // universal element selector, or universal namespace    if (ExpectSymbol(aErrorCode, '|', PR_FALSE)) {  // was namespace      aDataMask |= SEL_MASK_NSPACE;      aSelector.SetNameSpace(kNameSpaceID_Unknown); // namespace wildcard      if (! GetToken(aErrorCode, PR_FALSE)) {        REPORT_UNEXPECTED_EOF(NS_LITERAL_STRING("element type"));        aParsingStatus = SELECTOR_PARSING_STOPPED_ERROR;        return;      }      if (eCSSToken_Ident == mToken.mType) {  // element name        aDataMask |= SEL_MASK_ELEM;        if (mCaseSensitive) {          aSelector.SetTag(mToken.mIdent);        }        else {          ToLowerCase(mToken.mIdent, buffer);          aSelector.SetTag(buffer);        }      }      else if (mToken.IsSymbol('*')) {  // universal selector        aDataMask |= SEL_MASK_ELEM;        // don't set tag      }      else {        REPORT_UNEXPECTED_TOKEN(          NS_LITERAL_STRING("Expected element name or '*' but found"));        UngetToken();        aParsingStatus = SELECTOR_PARSING_STOPPED_ERROR;        return;      }    }    else {  // was universal element selector      aSelector.SetNameSpace(kNameSpaceID_Unknown); // wildcard      if (mNameSpace) { // look for default namespace        nsINameSpace* defaultNameSpace = nsnull;        mNameSpace->FindNameSpace(nsnull, defaultNameSpace);        if (defaultNameSpace) {          PRInt32 defaultID;          defaultNameSpace->GetNameSpaceID(defaultID);          aSelector.SetNameSpace(defaultID);          NS_RELEASE(defaultNameSpace);        }      }      aDataMask |= SEL_MASK_ELEM;      // don't set any tag in the selector    }    if (! GetToken(aErrorCode, PR_FALSE)) {   // premature eof is ok (here!)      aParsingStatus = SELECTOR_PARSING_STOPPED_OK;      return;    }  }  else if (eCSSToken_Ident == mToken.mType) {    // element name or namespace name    buffer = mToken.mIdent; // hang on to ident    if (ExpectSymbol(aErrorCode, '|', PR_FALSE)) {  // was namespace      aDataMask |= SEL_MASK_NSPACE;      PRInt32 nameSpaceID = kNameSpaceID_Unknown;      if (mNameSpace) {        ToLowerCase(buffer); // always case insensitive, since stays within CSS        nsCOMPtr<nsIAtom> prefix = do_GetAtom(buffer);        mNameSpace->FindNameSpaceID(prefix, nameSpaceID);      } // else, no declared namespaces      if (kNameSpaceID_Unknown == nameSpaceID) {  // unknown prefix, dump it        REPORT_UNEXPECTED(NS_LITERAL_STRING("Unknown namespace prefix '") +                          buffer + NS_LITERAL_STRING("'."));        aParsingStatus = SELECTOR_PARSING_STOPPED_ERROR;        return;      }      aSelector.SetNameSpace(nameSpaceID);      if (! GetToken(aErrorCode, PR_FALSE)) {        REPORT_UNEXPECTED_EOF(NS_LITERAL_STRING("element type"));        aParsingStatus = SELECTOR_PARSING_STOPPED_ERROR;        return;      }      if (eCSSToken_Ident == mToken.mType) {  // element name        aDataMask |= SEL_MASK_ELEM;        if (mCaseSensitive) {          aSelector.SetTag(mToken.mIdent);        }        else {          ToLowerCase(mToken.mIdent, buffer);          aSelector.SetTag(buffer);        }      }      else if (mToken.IsSymbol('*')) {  // universal selector        aDataMask |= SEL_MASK_ELEM;        // don't set tag      }      else {        REPORT_UNEXPECTED_TOKEN(            NS_LITERAL_STRING("Expected element name or '*' but found"));        UngetToken();        aParsingStatus = SELECTOR_PARSING_STOPPED_ERROR;        return;      }    }    else {  // was element name      aSelector.SetNameSpace(kNameSpaceID_Unknown); // wildcard      if (mNameSpace) { // look for default namespace        nsINameSpace* defaultNameSpace = nsnull;        mNameSpace->FindNameSpace(nsnull, defaultNameSpace);        if (defaultNameSpace) {          PRInt32 defaultID;          defaultNameSpace->GetNameSpaceID(defaultID);          aSelector.SetNameSpace(defaultID);          NS_RELEASE(defaultNameSpace);        }      }      if (mCaseSensitive) {        aSelector.SetTag(buffer);      }      else {        ToLowerCase(buffer);        aSelector.SetTag(buffer);      }      aDataMask |= SEL_MASK_ELEM;    }    if (! GetToken(aErrorCode, PR_FALSE)) {   // premature eof is ok (here!)      aParsingStatus = SELECTOR_PARSING_STOPPED_OK;      return;    }  }  else if (mToken.IsSymbol('|')) {  // No namespace    aDataMask |= SEL_MASK_NSPACE;    aSelector.SetNameSpace(kNameSpaceID_None);  // explicit NO namespace    // get mandatory tag    if (! GetToken(aErrorCode, PR_FALSE)) {      REPORT_UNEXPECTED_EOF(NS_LITERAL_STRING("element type"));      aParsingStatus = SELECTOR_PARSING_STOPPED_ERROR;      return;    }    if (eCSSToken_Ident == mToken.mType) {  // element name      aDataMask |= SEL_MASK_ELEM;      if (mCaseSensitive) {        aSelector.SetTag(mToken.mIdent);      }      else {        ToLowerCase(mToken.mIdent, buffer);        aSelector.SetTag(buffer);      }    }    else if (mToken.IsSymbol('*')) {  // universal selector      aDataMask |= SEL_MASK_ELEM;      // don't set tag    }    else {      REPORT_UNEXPECTED_TOKEN(        NS_LITERAL_STRING("Expected element name or '*' but found"));      UngetToken();      aParsingStatus = SELECTOR_PARSING_STOPPED_ERROR;      return;    }    if (! GetToken(aErrorCode, PR_FALSE)) {   // premature eof is ok (here!)      aParsingStatus = SELECTOR_PARSING_STOPPED_OK;      return;    }  }  else {    // no tag or namespace: implied universal selector    // set namespace to unknown since it is not specified    aSelector.SetNameSpace(kNameSpaceID_Unknown); // wildcard    if (mNameSpace) { // look for default namespace      nsINameSpace* defaultNameSpace = nsnull;      mNameSpace->FindNameSpace(nsnull, defaultNameSpace);      if (defaultNameSpace) {        PRInt32 defaultID;        defaultNameSpace->GetNameSpaceID(defaultID);        aSelector.SetNameSpace(defaultID);        NS_RELEASE(defaultNameSpace);      }    }  }  aParsingStatus = SELECTOR_PARSING_ENDED_OK;  if (aIsNegated) {    // restore last token read in case of a negated type selector    UngetToken();  }}