Пример #1
0
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 && token.valueEqualsIgnoringASCIICase("not")) {
            setStateAndRestrict(ReadMediaType, MediaQuery::Not);
        } else if (m_state == ReadRestrictor && token.valueEqualsIgnoringASCIICase("only")) {
            setStateAndRestrict(ReadMediaType, MediaQuery::Only);
        } else if (m_mediaQueryData.restrictor() != MediaQuery::None
            && isRestrictorOrLogicalOperator(token)) {
            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);
    }
}
Пример #2
0
static bool isRestrictorOrLogicalOperator(const CSSParserToken& token)
{
    // FIXME: it would be more efficient to use lower-case always for tokenValue.
    return token.valueEqualsIgnoringASCIICase("not")
        || token.valueEqualsIgnoringASCIICase("and")
        || token.valueEqualsIgnoringASCIICase("or")
        || token.valueEqualsIgnoringASCIICase("only");
}
Пример #3
0
void MediaQueryParser::readMediaNot(CSSParserTokenType type, const CSSParserToken& token)
{
    if (type == IdentToken && token.valueEqualsIgnoringASCIICase("not"))
        setStateAndRestrict(ReadFeatureStart, MediaQuery::Not);
    else
        readFeatureStart(type, token);
}
Пример #4
0
void MediaQueryParser::readAnd(CSSParserTokenType type, const CSSParserToken& token)
{
    if (type == IdentToken && token.valueEqualsIgnoringASCIICase("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;
    }
}