Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1231)

Side by Side Diff: Source/core/css/parser/CSSToken.h

Issue 171383002: A thread-safe Media Query Parser (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(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 "core/css/CSSPrimitiveValue.h"
35 #include "wtf/text/WTFString.h"
36
37 namespace WebCore {
38
39 enum CSSTokenType {
40 IdentToken = 0,
41 FunctionToken = 1,
42 AtKeywordToken = 2,
43 HashToken = 3,
44 StringToken = 4,
45 BadStringToken = 5,
46 URLToken = 6,
47 BadURLToken = 7,
48 DelimToken = 8,
49 NumberToken = 9,
50 PercentageToken = 10,
51 DimensionToken = 11,
52 UnicodeRangeToken = 12,
53 IncludeMatchToken = 13,
54 DashMatchToken = 14,
55 PrefixMatchToken = 15,
56 SuffixMatchToken = 16,
57 SubstringMatchToken = 17,
58 ColumnToken = 18,
59 WhitespaceToken = 19,
60 CDOToken = 20,
61 CDCToken = 21,
62 ColonToken = 22,
63 SemicolonToken = 23,
64 CommaToken = 24,
65 LeftBracketToken = 25,
66 RightBracketToken = 26,
67 LeftParenToken = 27,
68 RightParenToken = 28,
69 LeftBraceToken = 29,
70 RightBraceToken = 30,
71 EOFToken = 31,
72 };
73
74 // Probably should just be rolled into TokenType.
75 enum HashTokenType {
76 IdHashToken,
77 UnrestrictedHashToken,
78 };
79
80 // Probably should just be rolled into TokenType.
81 enum NumericValueType {
82 IntegerValueType,
83 NumberValueType,
84 };
85
86 class CSSToken {
87 public:
88 CSSToken(CSSTokenType);
89 CSSToken(CSSTokenType, String);
90
91 CSSToken(CSSTokenType, UChar); // for DelimToken
92 CSSToken(CSSTokenType, String, HashTokenType); // for HashToken
93 CSSToken(CSSTokenType, String, double, NumericValueType); // for NumberToken
94
95 // Converts NumberToken to DimensionToken.
96 void convertToDimensionWithUnit(String);
97
98 // Converts NumberToken to PercentageToken.
99 void convertToPercentage();
100
101 CSSTokenType type() const { return m_type; }
102 String value() const { return m_value; }
103
104 // FIXME: Most of these may not be needed, only to make things compile atm.
105 HashTokenType hashType() const { return m_hashTokenType; }
106 UChar delimiter() const { return m_delimiter; }
107 NumericValueType numericValueType() const { return m_numericValueType; }
108 double numericValue() const { return m_numericValue; }
109 CSSPrimitiveValue::UnitTypes unitType() const { return m_unit; }
110
111 private:
112 CSSTokenType m_type;
113 String m_value;
114 HashTokenType m_hashTokenType;
115
116 UChar m_delimiter; // Could be rolled into m_value?
117
118 NumericValueType m_numericValueType;
119 double m_numericValue;
120 CSSPrimitiveValue::UnitTypes m_unit;
121
122 // UnicodeRangeToken:
123 // unsigned m_start;
124 // unsigned m_end;
125 };
126
127 }
128
129 #endif // CSSToken_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698