OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef MediaQueryTokenizer_h | 5 #ifndef MediaQueryTokenizer_h |
6 #define MediaQueryTokenizer_h | 6 #define MediaQueryTokenizer_h |
7 | 7 |
8 #include "core/css/parser/MediaQueryToken.h" | 8 #include "core/css/parser/MediaQueryToken.h" |
9 #include "core/html/parser/InputStreamPreprocessor.h" | 9 #include "core/html/parser/InputStreamPreprocessor.h" |
10 #include "wtf/text/WTFString.h" | 10 #include "wtf/text/WTFString.h" |
11 | 11 |
12 #include <climits> | 12 #include <climits> |
13 | 13 |
14 namespace WebCore { | 14 namespace WebCore { |
15 | 15 |
16 class MediaQueryInputStream; | 16 class MediaQueryInputStream; |
17 | 17 |
18 class MediaQueryTokenizer { | 18 class MediaQueryTokenizer { |
19 WTF_MAKE_NONCOPYABLE(MediaQueryTokenizer); | 19 WTF_MAKE_NONCOPYABLE(MediaQueryTokenizer); |
20 WTF_MAKE_FAST_ALLOCATED; | 20 WTF_MAKE_FAST_ALLOCATED; |
21 public: | 21 public: |
22 static void tokenize(String, Vector<MediaQueryToken>&); | 22 static void tokenize(String, Vector<MediaQueryToken>&); |
23 | |
24 private: | 23 private: |
25 class CodePoints; | |
26 | |
27 MediaQueryTokenizer(MediaQueryInputStream&); | 24 MediaQueryTokenizer(MediaQueryInputStream&); |
28 | 25 |
29 MediaQueryToken nextToken(); | 26 MediaQueryToken nextToken(); |
30 | 27 |
31 UChar consume(); | 28 UChar consume(); |
32 void consume(unsigned); | 29 void consume(unsigned); |
33 void reconsume(UChar); | 30 void reconsume(UChar); |
34 | 31 |
35 MediaQueryToken consumeNumericToken(); | 32 MediaQueryToken consumeNumericToken(); |
36 MediaQueryToken consumeIdentLikeToken(); | 33 MediaQueryToken consumeIdentLikeToken(); |
37 MediaQueryToken consumeNumber(); | 34 MediaQueryToken consumeNumber(); |
38 | 35 |
39 void consumeUntilNonWhitespace(); | 36 void consumeUntilNonWhitespace(); |
40 | 37 |
41 bool consumeIfNext(UChar); | 38 bool consumeIfNext(UChar); |
42 String consumeName(); | 39 String consumeName(); |
43 UChar consumeEscape(); | 40 UChar consumeEscape(); |
44 | 41 |
45 bool nextTwoCharsAreValidEscape(); | 42 bool nextTwoCharsAreValidEscape(); |
46 bool nextCharsAreNumber(); | 43 bool nextCharsAreNumber(); |
47 bool nextCharsAreIdentifier(); | 44 bool nextCharsAreIdentifier(); |
48 | 45 |
49 typedef MediaQueryToken (MediaQueryTokenizer::*CodePoint)(UChar); | 46 typedef MediaQueryToken (MediaQueryTokenizer::*CodePoint)(UChar); |
50 | 47 |
| 48 static const CodePoint codePoints[]; |
| 49 |
51 MediaQueryToken whiteSpace(UChar); | 50 MediaQueryToken whiteSpace(UChar); |
52 MediaQueryToken leftParenthesis(UChar); | 51 MediaQueryToken leftParenthesis(UChar); |
53 MediaQueryToken rightParenthesis(UChar); | 52 MediaQueryToken rightParenthesis(UChar); |
54 MediaQueryToken plusOrFullStop(UChar); | 53 MediaQueryToken plusOrFullStop(UChar); |
55 MediaQueryToken comma(UChar); | 54 MediaQueryToken comma(UChar); |
56 MediaQueryToken hyphenMinus(UChar); | 55 MediaQueryToken hyphenMinus(UChar); |
57 MediaQueryToken solidus(UChar); | 56 MediaQueryToken solidus(UChar); |
58 MediaQueryToken colon(UChar); | 57 MediaQueryToken colon(UChar); |
59 MediaQueryToken semiColon(UChar); | 58 MediaQueryToken semiColon(UChar); |
60 MediaQueryToken reverseSolidus(UChar); | 59 MediaQueryToken reverseSolidus(UChar); |
61 MediaQueryToken asciiDigit(UChar); | 60 MediaQueryToken asciiDigit(UChar); |
62 MediaQueryToken nameStart(UChar); | 61 MediaQueryToken nameStart(UChar); |
63 MediaQueryToken endOfFile(UChar); | 62 MediaQueryToken endOfFile(UChar); |
64 | 63 |
65 CodePoints* codePoints(); | |
66 | |
67 MediaQueryInputStream& m_input; | 64 MediaQueryInputStream& m_input; |
68 }; | 65 }; |
69 | 66 |
70 | 67 |
71 | 68 |
72 } // namespace WebCore | 69 } // namespace WebCore |
73 | 70 |
74 #endif // MediaQueryTokenizer_h | 71 #endif // MediaQueryTokenizer_h |
OLD | NEW |