OLD | NEW |
---|---|
(Empty) | |
1 /* | |
2 * Copyright (C) 2013 Google Inc. All rights reserved. | |
3 * | |
4 * Redistribution and use in source and binary forms, with or without | |
5 * modification, are permitted provided that the following conditions are | |
6 * met: | |
7 * | |
8 * * Redistributions of source code must retain the above copyright | |
9 * notice, this list of conditions and the following disclaimer. | |
10 * * Redistributions in binary form must reproduce the above | |
11 * copyright notice, this list of conditions and the following disclaimer | |
12 * in the documentation and/or other materials provided with the | |
13 * distribution. | |
14 * * Neither the name of Google Inc. nor the names of its | |
15 * contributors may be used to endorse or promote products derived from | |
16 * this software without specific prior written permission. | |
17 * | |
18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | |
19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | |
20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | |
21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | |
22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | |
23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | |
24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | |
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | |
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | |
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | |
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |
29 */ | |
30 | |
31 #ifndef CSSToken_h | |
32 #define CSSToken_h | |
33 | |
34 #include "wtf/text/WTFString.h" | |
35 | |
36 namespace WebCore { | |
37 | |
38 enum CSSTokenType { | |
39 IdentToken, | |
40 FunctionToken, | |
41 AtKeywordToken, | |
42 HashToken, | |
43 StringToken, | |
44 BadStringToken, | |
45 URLToken, | |
46 BadURLToken, | |
47 DelimToken, | |
48 NumberToken, | |
49 PercentageToken, | |
50 DimensionToken, | |
51 UnicodeRangeToken, | |
52 IncludeMatchToken, | |
53 DashMatchToken, | |
54 PrefixMatchToken, | |
55 SuffixMatchToken, | |
56 SubstringMatchToken, | |
57 ColumnToken, | |
58 WhitespaceToken, | |
59 CDOToken, | |
60 CDCToken, | |
61 ColonToken, | |
62 SemicolonToken, | |
63 CommaToken, | |
64 LeftBracketToken, | |
65 RightBracketToken, | |
66 LeftParenToken, | |
67 RightParenToken, | |
68 LeftBraceToken, | |
69 RightBraceToken, | |
70 EOFToken, | |
71 }; | |
72 | |
73 // Probably should just be rolled into TokenType. | |
74 enum HashTokenType { | |
75 IdHashToken, | |
76 UnrestrictedHashToken, | |
77 }; | |
78 | |
79 // Probably should just be rolled into TokenType. | |
80 enum NumericValueType { | |
81 IntegerValueType, | |
82 NumberValueType, | |
83 }; | |
84 | |
85 class CSSToken { | |
86 public: | |
87 CSSToken(CSSTokenType); | |
abarth-chromium
2014/01/01 18:47:51
Please mark one-argument constructors explicit
| |
88 CSSToken(CSSTokenType, String); | |
89 | |
90 CSSToken(CSSTokenType, UChar); // for DelimToken | |
91 CSSToken(CSSTokenType, String, HashTokenType); // for HashToken | |
92 CSSToken(CSSTokenType, String, double, NumericValueType); // for NumberToken | |
93 | |
94 // Converts NumberToken to DimensionToken. | |
95 void convertToDimensionWithUnit(String); | |
96 | |
97 // Converts NumberToken to PercentageToken. | |
98 void convertToPercentage(); | |
99 | |
100 CSSTokenType type() const { return m_type; } | |
101 | |
102 // FIXME: Most of these may not be needed, only to make things compile atm. | |
103 HashTokenType hashType() const { return m_hashTokenType; } | |
104 UChar delimeter() const { return m_delimeter; } | |
105 NumericValueType numericValueType() const { return m_numericValueType; } | |
106 double numericValue() const { return m_numericValue; } | |
107 String unitType() const { return m_unit; } | |
108 | |
109 private: | |
110 CSSTokenType m_type; | |
111 String m_value; | |
112 HashTokenType m_hashTokenType; | |
113 | |
114 UChar m_delimeter; // Could be rolled into m_value? | |
115 | |
116 NumericValueType m_numericValueType; | |
117 double m_numericValue; | |
118 String m_unit; // FIXME: Is this needed? | |
119 | |
120 // UnicodeRangeToken: | |
121 // unsigned m_start; | |
122 // unsigned m_end; | |
123 }; | |
124 | |
125 } | |
126 | |
127 #endif // CSSToken_h | |
OLD | NEW |