1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef CSSParserToken_h
6 #define CSSParserToken_h
8 #include "core/css/CSSPrimitiveValue.h"
9 #include "wtf/text/WTFString.h"
13 enum CSSParserTokenType {
29 RightParenthesisToken,
40 enum NumericValueType {
47 HashTokenUnrestricted,
50 class CSSParserToken {
58 CSSParserToken(CSSParserTokenType, BlockType = NotBlock);
59 CSSParserToken(CSSParserTokenType, String value, BlockType = NotBlock);
61 CSSParserToken(CSSParserTokenType, UChar); // for DelimiterToken
62 CSSParserToken(CSSParserTokenType, double, NumericValueType); // for NumberToken
63 CSSParserToken(CSSParserTokenType, UChar32, UChar32); // for UnicodeRangeToken
65 CSSParserToken(HashTokenType, String);
67 // Converts NumberToken to DimensionToken.
68 void convertToDimensionWithUnit(String);
70 // Converts NumberToken to PercentageToken.
71 void convertToPercentage();
73 CSSParserTokenType type() const { return m_type; }
74 String value() const { return m_value; }
76 UChar delimiter() const;
77 NumericValueType numericValueType() const;
78 double numericValue() const;
79 HashTokenType hashTokenType() const { ASSERT(m_type == HashToken); return m_hashTokenType; }
80 BlockType blockType() const { return m_blockType; }
81 CSSPrimitiveValue::UnitType unitType() const { return m_unit; }
82 UChar32 unicodeRangeStart() const { ASSERT(m_type == UnicodeRangeToken); return m_unicodeRangeStart; }
83 UChar32 unicodeRangeEnd() const { ASSERT(m_type == UnicodeRangeToken); return m_unicodeRangeEnd; }
86 CSSParserTokenType m_type;
89 // This could be a union to save space
91 HashTokenType m_hashTokenType;
92 NumericValueType m_numericValueType;
93 double m_numericValue;
94 CSSPrimitiveValue::UnitType m_unit;
95 UChar32 m_unicodeRangeStart;
96 UChar32 m_unicodeRangeEnd;
98 BlockType m_blockType;
101 typedef Vector<CSSParserToken>::iterator CSSParserTokenIterator;
105 #endif // MediaQueryToken_h