void compareTokens(const CSSParserToken& expected, const CSSParserToken& actual) { ASSERT_EQ(expected.type(), actual.type()); switch (expected.type()) { case DelimiterToken: ASSERT_EQ(expected.delimiter(), actual.delimiter()); break; case IdentToken: case FunctionToken: case StringToken: case UrlToken: ASSERT_EQ(expected.value(), actual.value()); break; case DimensionToken: ASSERT_EQ(expected.value(), actual.value()); // fallthrough case NumberToken: case PercentageToken: ASSERT_EQ(expected.numericValueType(), actual.numericValueType()); ASSERT_DOUBLE_EQ(expected.numericValue(), actual.numericValue()); break; case UnicodeRangeToken: ASSERT_EQ(expected.unicodeRangeStart(), actual.unicodeRangeStart()); ASSERT_EQ(expected.unicodeRangeEnd(), actual.unicodeRangeEnd()); break; case HashToken: ASSERT_EQ(expected.value(), actual.value()); ASSERT_EQ(expected.hashTokenType(), actual.hashTokenType()); break; default: break; } }
bool parseValue(CSSParserTokenRange& tokens, Value* result) { CSSParserToken token = tokens.consumeIncludingWhitespace(); if (!(token.type() == NumberToken || token.type() == PercentageToken || token.type() == DimensionToken)) return false; CSSPrimitiveValue::UnitType type = token.unitType(); if (unitCategory(type) == CalcOther) return false; result->value = CSSCalcPrimitiveValue::create( CSSPrimitiveValue::create(token.numericValue(), type), token.numericValueType() == IntegerValueType); return true; }
void MediaQueryData::addParserValue(CSSParserTokenType type, const CSSParserToken& token) { CSSParserValue value; if (type == NumberToken || type == PercentageToken || type == DimensionToken) { value.setFromNumber(token.numericValue(), token.unitType()); value.isInt = (token.numericValueType() == IntegerValueType); } else if (type == DelimiterToken) { value.unit = CSSParserValue::Operator; value.iValue = token.delimiter(); value.id = CSSValueInvalid; value.isInt = false; } else { CSSParserString tokenValue; tokenValue.init(token.value()); value.unit = CSSPrimitiveValue::CSS_IDENT; value.string = tokenValue; value.id = cssValueKeywordID(tokenValue); value.isInt = false; } m_valueList.addValue(value); }