void MediaQueryParser::readMediaType(CSSParserTokenType type, const CSSParserToken& token) { if (type == LeftParenthesisToken) { if (m_mediaQueryData.restrictor() != MediaQuery::None) m_state = SkipUntilComma; else m_state = ReadFeature; } else if (type == IdentToken) { if (m_state == ReadRestrictor && equalIgnoringCase(token.value(), "not")) { setStateAndRestrict(ReadMediaType, MediaQuery::Not); } else if (m_state == ReadRestrictor && equalIgnoringCase(token.value(), "only")) { setStateAndRestrict(ReadMediaType, MediaQuery::Only); } else if (m_mediaQueryData.restrictor() != MediaQuery::None && isRestrictorOrLogicalOperator(token.value())) { m_state = SkipUntilComma; } else { m_mediaQueryData.setMediaType(token.value()); m_state = ReadAnd; } } else if (type == EOFToken && (!m_querySet->queryVector().size() || m_state != ReadRestrictor)) { m_state = Done; } else { m_state = SkipUntilComma; if (type == CommaToken) skipUntilComma(type, token); } }
static bool isRestrictorOrLogicalOperator(const CSSParserToken& token) { // FIXME: it would be more efficient to use lower-case always for tokenValue. return equalIgnoringASCIICase(token.value(), "not") || equalIgnoringASCIICase(token.value(), "and") || equalIgnoringASCIICase(token.value(), "or") || equalIgnoringASCIICase(token.value(), "only"); }
void MediaQueryParser::readMediaNot(CSSParserTokenType type, const CSSParserToken& token) { if (type == IdentToken && equalIgnoringCase(token.value(), "not")) setStateAndRestrict(ReadFeatureStart, MediaQuery::Not); else readFeatureStart(type, token); }
bool CSSVariableParser::isValidVariableName(const CSSParserToken& token) { if (token.type() != IdentToken) return false; CSSParserString value = token.value(); return value.length() >= 2 && value[0] == '-' && value[1] == '-'; }
void MediaQueryParser::readFeature(CSSParserTokenType type, const CSSParserToken& token) { if (type == IdentToken) { m_mediaQueryData.setMediaFeature(token.value()); m_state = ReadFeatureColon; } else { m_state = SkipUntilComma; } }
void MediaQueryParser::readFeature(CSSParserTokenType type, const CSSParserToken& token) { if (type == IdentToken) { // FIXME-NEWPARSER: Find a way to avoid this. const_cast<CSSParserToken&>(token).convertToASCIILowercaseInPlace(); m_mediaQueryData.setMediaFeature(token.value().toString()); m_state = ReadFeatureColon; } else m_state = SkipUntilComma; }
void MediaQueryParser::readAnd(CSSParserTokenType type, const CSSParserToken& token) { if (type == IdentToken && equalIgnoringASCIICase(token.value(), "and")) { m_state = ReadFeatureStart; } else if (type == CommaToken && m_parserType != MediaConditionParser) { commitMediaQuery(); m_state = ReadRestrictor; } else if (type == EOFToken) m_state = Done; else m_state = SkipUntilComma; }
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; } }
void MediaQueryParser::readAnd(CSSParserTokenType type, const CSSParserToken& token) { if (type == IdentToken && equalIgnoringCase(token.value(), "and")) { m_state = ReadFeatureStart; } else if (type == CommaToken && m_parserType != MediaConditionParser) { m_querySet->addMediaQuery(m_mediaQueryData.takeMediaQuery()); m_state = ReadRestrictor; } else if (type == EOFToken) { m_state = Done; } else { m_state = SkipUntilComma; } }
void CSSVariableData::consumeAndUpdateTokens(const CSSParserTokenRange& range) { StringBuilder stringBuilder; CSSParserTokenRange localRange = range; while (!localRange.atEnd()) { CSSParserToken token = localRange.consume(); if (token.hasStringBacking()) stringBuilder.append(token.value()); } m_backingString = stringBuilder.toString(); if (m_backingString.is8Bit()) updateTokens<LChar>(range); else updateTokens<UChar>(range); }
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); }