mNameSpace->FindNameSpaceID(prefix, nameSpaceID);
mNameSpace->FindNameSpaceID(prefix, &nameSpaceID);
void CSSParserImpl::ParseAttributeSelector(PRInt32&  aDataMask,                                      nsCSSSelector& aSelector,                                      PRInt32& aParsingStatus,                                      PRInt32& aErrorCode){  if (! GetToken(aErrorCode, PR_TRUE)) { // premature EOF    REPORT_UNEXPECTED_EOF(NS_LITERAL_STRING("attribute name"));    aParsingStatus = SELECTOR_PARSING_STOPPED_ERROR;    return;  }  PRInt32 nameSpaceID = kNameSpaceID_None;  nsAutoString  attr;  if (mToken.IsSymbol('*')) { // wildcard namespace    nameSpaceID = kNameSpaceID_Unknown;    if (ExpectSymbol(aErrorCode, '|', PR_FALSE)) {      if (! GetToken(aErrorCode, PR_FALSE)) { // premature EOF        REPORT_UNEXPECTED_EOF(NS_LITERAL_STRING("attribute name"));        aParsingStatus = SELECTOR_PARSING_STOPPED_ERROR;        return;      }      if (eCSSToken_Ident == mToken.mType) { // attr name        attr = mToken.mIdent;      }      else {        REPORT_UNEXPECTED_TOKEN(NS_LITERAL_STRING("Expected identifier for attribute name but found"));        UngetToken();        aParsingStatus = SELECTOR_PARSING_STOPPED_ERROR;        return;       }    }    else {      REPORT_UNEXPECTED_TOKEN(          NS_LITERAL_STRING("Expected '|' but found"));      aParsingStatus = SELECTOR_PARSING_STOPPED_ERROR;      return;    }  }  else if (mToken.IsSymbol('|')) { // NO namespace    if (! GetToken(aErrorCode, PR_FALSE)) { // premature EOF      REPORT_UNEXPECTED_EOF(NS_LITERAL_STRING("attribute name"));      aParsingStatus = SELECTOR_PARSING_STOPPED_ERROR;      return;    }    if (eCSSToken_Ident == mToken.mType) { // attr name      attr = mToken.mIdent;    }    else {      REPORT_UNEXPECTED_TOKEN(NS_LITERAL_STRING("Expected identifier for attribute name but found"));      UngetToken();      aParsingStatus = SELECTOR_PARSING_STOPPED_ERROR;      return;    }  }  else if (eCSSToken_Ident == mToken.mType) { // attr name or namespace    attr = mToken.mIdent; // hang on to it    if (ExpectSymbol(aErrorCode, '|', PR_FALSE)) {  // was a namespace      nameSpaceID = kNameSpaceID_Unknown;      if (mNameSpace) {        ToLowerCase(attr); // always case insensitive, since stays within CSS        nsCOMPtr<nsIAtom> prefix = do_GetAtom(attr);        mNameSpace->FindNameSpaceID(prefix, nameSpaceID);      } // else, no declared namespaces      if (kNameSpaceID_Unknown == nameSpaceID) {  // unknown prefix, dump it        REPORT_UNEXPECTED(NS_LITERAL_STRING("Unknown namespace prefix '") +                          attr + NS_LITERAL_STRING("'."));        aParsingStatus = SELECTOR_PARSING_STOPPED_ERROR;        return;      }      if (! GetToken(aErrorCode, PR_FALSE)) { // premature EOF        REPORT_UNEXPECTED_EOF(NS_LITERAL_STRING("attribute name"));        aParsingStatus = SELECTOR_PARSING_STOPPED_ERROR;        return;      }      if (eCSSToken_Ident == mToken.mType) { // attr name        attr = mToken.mIdent;      }      else {        REPORT_UNEXPECTED_TOKEN(NS_LITERAL_STRING("Expected identifier for attribute name but found"));        UngetToken();        aParsingStatus = SELECTOR_PARSING_STOPPED_ERROR;        return;      }    }  }  else {  // malformed    REPORT_UNEXPECTED_TOKEN(      NS_LITERAL_STRING("Expected attribute name or namespace but found"));    UngetToken();    aParsingStatus = SELECTOR_PARSING_STOPPED_ERROR;    return;  }  if (! mCaseSensitive) {    ToLowerCase(attr);  }  if (! GetToken(aErrorCode, PR_TRUE)) { // premature EOF    REPORT_UNEXPECTED_EOF(NS_LITERAL_STRING("part of attribute selector"));    aParsingStatus = SELECTOR_PARSING_STOPPED_ERROR;    return;  }  if ((eCSSToken_Symbol == mToken.mType) ||      (eCSSToken_Includes == mToken.mType) ||      (eCSSToken_Dashmatch == mToken.mType) ||      (eCSSToken_Beginsmatch == mToken.mType) ||      (eCSSToken_Endsmatch == mToken.mType) ||      (eCSSToken_Containsmatch == mToken.mType)) {    PRUint8 func;    if (eCSSToken_Includes == mToken.mType) {      func = NS_ATTR_FUNC_INCLUDES;    }    else if (eCSSToken_Dashmatch == mToken.mType) {      func = NS_ATTR_FUNC_DASHMATCH;    }    else if (eCSSToken_Beginsmatch == mToken.mType) {      func = NS_ATTR_FUNC_BEGINSMATCH;    }    else if (eCSSToken_Endsmatch == mToken.mType) {      func = NS_ATTR_FUNC_ENDSMATCH;    }    else if (eCSSToken_Containsmatch == mToken.mType) {      func = NS_ATTR_FUNC_CONTAINSMATCH;    }    else if (']' == mToken.mSymbol) {      aDataMask |= SEL_MASK_ATTRIB;      aSelector.AddAttribute(nameSpaceID, attr);      func = NS_ATTR_FUNC_SET;    }    else if ('=' == mToken.mSymbol) {      func = NS_ATTR_FUNC_EQUALS;    }    else {      REPORT_UNEXPECTED_TOKEN(        NS_LITERAL_STRING("Unexpected token in attribute selector: "));      UngetToken(); // bad function      aParsingStatus = SELECTOR_PARSING_STOPPED_ERROR;      return;    }    if (NS_ATTR_FUNC_SET != func) { // get value      if (! GetToken(aErrorCode, PR_TRUE)) { // premature EOF        REPORT_UNEXPECTED_EOF(NS_LITERAL_STRING("attribute value"));        aParsingStatus = SELECTOR_PARSING_STOPPED_ERROR;        return;      }      if ((eCSSToken_Ident == mToken.mType) || (eCSSToken_String == mToken.mType)) {        nsAutoString  value(mToken.mIdent);        if (! GetToken(aErrorCode, PR_TRUE)) { // premature EOF          REPORT_UNEXPECTED_EOF(                             NS_LITERAL_STRING("] to end attribute selector"));          aParsingStatus = SELECTOR_PARSING_STOPPED_ERROR;          return;        }        if (mToken.IsSymbol(']')) {          PRBool isCaseSensitive = mCaseSensitive;          if (nameSpaceID == kNameSpaceID_None ||              nameSpaceID == kNameSpaceID_XHTML) {            static const char* caseSensitiveHTMLAttribute[] = {              // list based on http://www.w3.org/TR/REC-html40/index/attributes.html              "abbr",          "alt",        "label",              "prompt",        "standby",     "summary",              "title",         nsnull            };            short i = 0;            const char* htmlAttr;            while ((htmlAttr = caseSensitiveHTMLAttribute[i++])) {              if (attr.EqualsIgnoreCase(htmlAttr)) {                isCaseSensitive = PR_TRUE;                break;              }            }          }          aDataMask |= SEL_MASK_ATTRIB;          aSelector.AddAttribute(nameSpaceID, attr, func, value, isCaseSensitive);        }        else {          REPORT_UNEXPECTED_TOKEN(NS_LITERAL_STRING("Expected ']' to terminate attribute selector but found"));          UngetToken();          aParsingStatus = SELECTOR_PARSING_STOPPED_ERROR;          return;        }      }      else {        REPORT_UNEXPECTED_TOKEN(NS_LITERAL_STRING("Expected identifier or string for value in attribute selector but found"));        UngetToken();        aParsingStatus = SELECTOR_PARSING_STOPPED_ERROR;        return;      }    }  }  else {    REPORT_UNEXPECTED_TOKEN(      NS_LITERAL_STRING("Unexpected token in attribute selector: "));    UngetToken(); // bad dog, no biscut!    aParsingStatus = SELECTOR_PARSING_STOPPED_ERROR;    return;   }   aParsingStatus = SELECTOR_PARSING_ENDED_OK;}