void MediaQueryParser::readFeatureValue(CSSParserTokenType type, const CSSParserToken& token) { if (type == DimensionToken && token.unitType() == CSSPrimitiveValue::CSS_UNKNOWN) { m_state = SkipUntilComma; } else { m_mediaQueryData.addParserValue(type, token); m_state = ReadFeatureEnd; } }
bool SizesCalcParser::appendLength(const CSSParserToken& token) { SizesCalcValue value; double result = 0; if (!m_mediaValues->computeLength(token.numericValue(), token.unitType(), result)) return false; value.value = result; value.isLength = true; m_valueList.append(value); return true; }
void MediaQueryParser::readFeatureValue(CSSParserTokenType type, const CSSParserToken& token) { if (type == DimensionToken && token.unitType() == CSSPrimitiveValue::UnitType::Unknown) { m_state = SkipUntilComma; } else { if (m_mediaQueryData.tryAddParserToken(type, token)) m_state = ReadFeatureEnd; else m_state = SkipUntilBlockEnd; } }
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); }