OLD | NEW |
---|---|
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
Timothy Loh
2015/08/25 09:21:10
Are any of the changes in this file and the cpp re
| |
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 CSSTokenizer_h | 5 #ifndef CSSTokenizer_h |
6 #define CSSTokenizer_h | 6 #define CSSTokenizer_h |
7 | 7 |
8 #include "core/CoreExport.h" | 8 #include "core/CoreExport.h" |
9 #include "core/css/parser/CSSParserToken.h" | 9 #include "core/css/parser/CSSParserToken.h" |
10 #include "core/html/parser/InputStreamPreprocessor.h" | 10 #include "core/html/parser/InputStreamPreprocessor.h" |
11 #include "wtf/text/WTFString.h" | 11 #include "wtf/text/WTFString.h" |
12 | 12 |
13 #include <climits> | 13 #include <climits> |
14 | 14 |
15 namespace blink { | 15 namespace blink { |
16 | 16 |
17 class CSSTokenizerInputStream; | 17 class CSSTokenizerInputStream; |
18 class CSSParserObserverWrapper; | 18 class CSSParserObserverWrapper; |
19 struct CSSParserString; | 19 struct CSSParserString; |
20 class CSSParserTokenRange; | 20 class CSSParserTokenRange; |
21 | 21 |
22 class CORE_EXPORT CSSTokenizer { | 22 class CORE_EXPORT CSSTokenizer { |
23 WTF_MAKE_NONCOPYABLE(CSSTokenizer); | 23 WTF_MAKE_NONCOPYABLE(CSSTokenizer); |
24 WTF_MAKE_FAST_ALLOCATED(CSSTokenizer); | 24 WTF_MAKE_FAST_ALLOCATED(CSSTokenizer); |
25 public: | 25 public: |
26 class CORE_EXPORT Scope { | 26 class CORE_EXPORT Scope { |
27 WTF_MAKE_FAST_ALLOCATED(Scope); | |
27 public: | 28 public: |
28 Scope(const String&); | 29 Scope(const String&); |
29 Scope(const String&, CSSParserObserverWrapper&); // For the inspector | 30 Scope(const String&, CSSParserObserverWrapper&); // For the inspector |
30 | 31 |
31 CSSParserTokenRange tokenRange(); | 32 CSSParserTokenRange tokenRange(); |
32 unsigned tokenCount(); | 33 unsigned tokenCount(); |
33 | 34 |
34 private: | 35 private: |
35 void storeString(const String& string) { m_stringPool.append(string); } | 36 void storeString(const String& string) { m_stringPool.append(string); } |
36 Vector<CSSParserToken> m_tokens; | 37 Vector<CSSParserToken> m_tokens; |
37 // We only allocate strings when escapes are used. | 38 // We only allocate strings when escapes are used. |
38 Vector<String> m_stringPool; | 39 Vector<String> m_stringPool; |
39 String m_string; | 40 String m_string; |
40 | 41 |
41 friend class CSSTokenizer; | 42 friend class CSSTokenizer; |
42 }; | 43 }; |
43 | |
44 private: | 44 private: |
45 CSSTokenizer(CSSTokenizerInputStream&, Scope&); | 45 CSSTokenizer(CSSTokenizerInputStream&, Scope&); |
46 | 46 |
47 CSSParserToken nextToken(); | 47 CSSParserToken nextToken(); |
48 | 48 |
49 UChar consume(); | 49 UChar consume(); |
50 void consume(unsigned); | 50 void consume(unsigned); |
51 void reconsume(UChar); | 51 void reconsume(UChar); |
52 | 52 |
53 CSSParserToken consumeNumericToken(); | 53 CSSParserToken consumeNumericToken(); |
54 CSSParserToken consumeIdentLikeToken(); | 54 CSSParserToken consumeIdentLikeToken(); |
55 CSSParserToken consumeNumber(); | 55 CSSParserToken consumeNumber(); |
56 CSSParserToken consumeStringTokenUntil(UChar); | 56 CSSParserToken consumeStringTokenUntil(UChar); |
57 CSSParserToken consumeUnicodeRange(); | 57 CSSParserToken consumeUnicodeRange(); |
58 CSSParserToken consumeUrlToken(); | 58 CSSParserToken consumeUrlToken(); |
59 | 59 |
60 void consumeBadUrlRemnants(); | 60 void consumeBadUrlRemnants(); |
61 void consumeUntilNonWhitespace(); | 61 unsigned consumeUntilNonWhitespace(); |
62 void consumeSingleWhitespaceIfNext(); | 62 void consumeSingleWhitespaceIfNext(); |
63 void consumeUntilCommentEndFound(); | 63 void consumeUntilCommentEndFound(); |
64 | 64 |
65 bool consumeIfNext(UChar); | 65 bool consumeIfNext(UChar); |
66 CSSParserString consumeName(); | 66 CSSParserString consumeName(); |
67 CSSParserString lastConsumedCharacter(); | |
67 UChar32 consumeEscape(); | 68 UChar32 consumeEscape(); |
68 | 69 |
69 bool nextTwoCharsAreValidEscape(); | 70 bool nextTwoCharsAreValidEscape(); |
70 bool nextCharsAreNumber(UChar); | 71 bool nextCharsAreNumber(UChar); |
71 bool nextCharsAreNumber(); | 72 bool nextCharsAreNumber(); |
72 bool nextCharsAreIdentifier(UChar); | 73 bool nextCharsAreIdentifier(UChar); |
73 bool nextCharsAreIdentifier(); | 74 bool nextCharsAreIdentifier(); |
74 CSSParserToken blockStart(CSSParserTokenType); | 75 CSSParserToken blockStart(CSSParserTokenType); |
75 CSSParserToken blockStart(CSSParserTokenType blockType, CSSParserTokenType, CSSParserString); | 76 CSSParserToken blockStart(CSSParserTokenType blockType, CSSParserTokenType, CSSParserString); |
76 CSSParserToken blockEnd(CSSParserTokenType, CSSParserTokenType startType); | 77 CSSParserToken blockEnd(CSSParserTokenType, CSSParserTokenType startType); |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
112 | 113 |
113 CSSTokenizerInputStream& m_input; | 114 CSSTokenizerInputStream& m_input; |
114 Scope& m_scope; | 115 Scope& m_scope; |
115 }; | 116 }; |
116 | 117 |
117 | 118 |
118 | 119 |
119 } // namespace blink | 120 } // namespace blink |
120 | 121 |
121 #endif // CSSTokenizer_h | 122 #endif // CSSTokenizer_h |
OLD | NEW |