Exemplo n.º 1
0
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;
    }
}
Exemplo n.º 2
0
bool CSSParserToken::operator==(const CSSParserToken& other) const
{
    if (m_type != other.m_type)
        return false;
    switch (m_type) {
    case DelimiterToken:
        return delimiter() == other.delimiter();
    case HashToken:
        if (m_hashTokenType != other.m_hashTokenType)
            return false;
        FALLTHROUGH;
    case IdentToken:
    case FunctionToken:
    case StringToken:
    case UrlToken:
        return valueDataCharRawEqual(other);
    case DimensionToken:
        if (!valueDataCharRawEqual(other))
            return false;
        FALLTHROUGH;
    case NumberToken:
    case PercentageToken:
        return m_numericSign == other.m_numericSign && m_numericValue == other.m_numericValue && m_numericValueType == other.m_numericValueType;
    case UnicodeRangeToken:
        return m_unicodeRange.start == other.m_unicodeRange.start && m_unicodeRange.end == other.m_unicodeRange.end;
    default:
        return true;
    }
}
Exemplo n.º 3
0
bool consumeSlashIncludingWhitespace(CSSParserTokenRange& range)
{
    CSSParserToken value = range.peek();
    if (value.type() != DelimiterToken || value.delimiter() != '/')
        return false;
    range.consumeIncludingWhitespace();
    return true;
}
Exemplo n.º 4
0
void MediaQueryParser::readFeatureEnd(CSSParserTokenType type, const CSSParserToken& token)
{
    if (type == RightParenthesisToken || type == EOFToken) {
        if (type != EOFToken && m_mediaQueryData.addExpression())
            m_state = ReadAnd;
        else
            m_state = SkipUntilComma;
    } else if (type == DelimiterToken && token.delimiter() == '/') {
        m_mediaQueryData.tryAddParserToken(type, token);
        m_state = ReadFeatureValue;
    } else
        m_state = SkipUntilBlockEnd;
}
Exemplo n.º 5
0
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);
}
Exemplo n.º 6
0
bool SizesCalcParser::handleOperator(Vector<CSSParserToken>& stack, const CSSParserToken& token)
{
    // If the token is an operator, o1, then:
    // while there is an operator token, o2, at the top of the stack, and
    // either o1 is left-associative and its precedence is equal to that of o2,
    // or o1 has precedence less than that of o2,
    // pop o2 off the stack, onto the output queue;
    // push o1 onto the stack.
    bool stackOperatorPriority;
    bool incomingOperatorPriority;

    if (!operatorPriority(token.delimiter(), incomingOperatorPriority))
        return false;
    if (!stack.isEmpty() && stack.last().type() == DelimiterToken) {
        if (!operatorPriority(stack.last().delimiter(), stackOperatorPriority))
            return false;
        if (!incomingOperatorPriority || stackOperatorPriority) {
            appendOperator(stack.last());
            stack.removeLast();
        }
    }
    stack.append(token);
    return true;
}
Exemplo n.º 7
0
void SizesCalcParser::appendOperator(const CSSParserToken& token)
{
    SizesCalcValue value;
    value.operation = token.delimiter();
    m_valueList.append(value);
}
Exemplo n.º 8
0
 char operatorValue(const CSSParserToken& token)
 {
     if (token.type() == DelimiterToken)
         return token.delimiter();
     return 0;
 }