Chromium Code Reviews| 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 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 CSSTokenizerScope { | |
|
leviw_travelin_and_unemployed
2015/06/20 00:58:15
This change is leftover, not intentional/required.
| |
| 23 WTF_MAKE_FAST_ALLOCATED(CSSTokenizerScope); | |
| 24 public: | |
| 25 CSSTokenizerScope(const String&); | |
| 26 CSSTokenizerScope(const String&, CSSParserObserverWrapper&); // For the insp ector | |
| 27 | |
| 28 CSSParserTokenRange tokenRange(); | |
| 29 unsigned tokenCount(); | |
| 30 | |
| 31 String string() const { return m_string; } | |
| 32 public: | |
| 33 void storeString(const String& string) { m_stringPool.append(string); } | |
| 34 Vector<CSSParserToken> m_tokens; | |
| 35 // We only allocate strings when escapes are used. | |
| 36 Vector<String> m_stringPool; | |
| 37 String m_string; | |
| 38 | |
| 39 bool m_hasVariableReference; | |
| 40 | |
| 41 friend class CSSTokenizer; | |
| 42 }; | |
| 43 | |
| 22 class CORE_EXPORT CSSTokenizer { | 44 class CORE_EXPORT CSSTokenizer { |
| 23 WTF_MAKE_NONCOPYABLE(CSSTokenizer); | 45 WTF_MAKE_NONCOPYABLE(CSSTokenizer); |
| 24 WTF_MAKE_FAST_ALLOCATED(CSSTokenizer); | 46 WTF_MAKE_FAST_ALLOCATED(CSSTokenizer); |
| 25 public: | |
| 26 class CORE_EXPORT Scope { | |
| 27 public: | |
| 28 Scope(const String&); | |
| 29 Scope(const String&, CSSParserObserverWrapper&); // For the inspector | |
| 30 | |
| 31 CSSParserTokenRange tokenRange(); | |
| 32 unsigned tokenCount(); | |
| 33 | |
| 34 private: | |
| 35 void storeString(const String& string) { m_stringPool.append(string); } | |
| 36 Vector<CSSParserToken> m_tokens; | |
| 37 // We only allocate strings when escapes are used. | |
| 38 Vector<String> m_stringPool; | |
| 39 String m_string; | |
| 40 | |
| 41 friend class CSSTokenizer; | |
| 42 }; | |
| 43 | |
| 44 private: | 47 private: |
| 45 CSSTokenizer(CSSTokenizerInputStream&, Scope&); | 48 CSSTokenizer(CSSTokenizerInputStream&, CSSTokenizerScope&); |
| 46 | 49 |
| 47 CSSParserToken nextToken(); | 50 CSSParserToken nextToken(); |
| 48 | 51 |
| 49 UChar consume(); | 52 UChar consume(); |
| 50 void consume(unsigned); | 53 void consume(unsigned); |
| 51 void reconsume(UChar); | 54 void reconsume(UChar); |
| 52 | 55 |
| 53 CSSParserToken consumeNumericToken(); | 56 CSSParserToken consumeNumericToken(); |
| 54 CSSParserToken consumeIdentLikeToken(); | 57 CSSParserToken consumeIdentLikeToken(); |
| 55 CSSParserToken consumeNumber(); | 58 CSSParserToken consumeNumber(); |
| 56 CSSParserToken consumeStringTokenUntil(UChar); | 59 CSSParserToken consumeStringTokenUntil(UChar); |
| 57 CSSParserToken consumeUnicodeRange(); | 60 CSSParserToken consumeUnicodeRange(); |
| 58 CSSParserToken consumeUrlToken(); | 61 CSSParserToken consumeUrlToken(); |
| 59 | 62 |
| 60 void consumeBadUrlRemnants(); | 63 void consumeBadUrlRemnants(); |
| 61 void consumeUntilNonWhitespace(); | 64 unsigned consumeUntilNonWhitespace(); |
| 62 void consumeSingleWhitespaceIfNext(); | 65 void consumeSingleWhitespaceIfNext(); |
| 63 void consumeUntilCommentEndFound(); | 66 void consumeUntilCommentEndFound(); |
| 64 | 67 |
| 65 bool consumeIfNext(UChar); | 68 bool consumeIfNext(UChar); |
| 66 CSSParserString consumeName(); | 69 CSSParserString consumeName(); |
| 70 CSSParserString lastConsumedCharacter(); | |
| 67 UChar32 consumeEscape(); | 71 UChar32 consumeEscape(); |
| 68 | 72 |
| 69 bool nextTwoCharsAreValidEscape(); | 73 bool nextTwoCharsAreValidEscape(); |
| 70 bool nextCharsAreNumber(UChar); | 74 bool nextCharsAreNumber(UChar); |
| 71 bool nextCharsAreNumber(); | 75 bool nextCharsAreNumber(); |
| 72 bool nextCharsAreIdentifier(UChar); | 76 bool nextCharsAreIdentifier(UChar); |
| 73 bool nextCharsAreIdentifier(); | 77 bool nextCharsAreIdentifier(); |
| 74 CSSParserToken blockStart(CSSParserTokenType); | 78 CSSParserToken blockStart(CSSParserTokenType); |
| 75 CSSParserToken blockStart(CSSParserTokenType blockType, CSSParserTokenType, CSSParserString); | 79 CSSParserToken blockStart(CSSParserTokenType blockType, CSSParserTokenType, CSSParserString); |
| 76 CSSParserToken blockEnd(CSSParserTokenType, CSSParserTokenType startType); | 80 CSSParserToken blockEnd(CSSParserTokenType, CSSParserTokenType startType); |
| (...skipping 26 matching lines...) Expand all Loading... | |
| 103 CSSParserToken commercialAt(UChar); | 107 CSSParserToken commercialAt(UChar); |
| 104 CSSParserToken reverseSolidus(UChar); | 108 CSSParserToken reverseSolidus(UChar); |
| 105 CSSParserToken asciiDigit(UChar); | 109 CSSParserToken asciiDigit(UChar); |
| 106 CSSParserToken letterU(UChar); | 110 CSSParserToken letterU(UChar); |
| 107 CSSParserToken nameStart(UChar); | 111 CSSParserToken nameStart(UChar); |
| 108 CSSParserToken stringStart(UChar); | 112 CSSParserToken stringStart(UChar); |
| 109 CSSParserToken endOfFile(UChar); | 113 CSSParserToken endOfFile(UChar); |
| 110 | 114 |
| 111 CSSParserString registerString(const String&); | 115 CSSParserString registerString(const String&); |
| 112 | 116 |
| 117 friend class CSSTokenizerScope; | |
| 118 | |
| 113 CSSTokenizerInputStream& m_input; | 119 CSSTokenizerInputStream& m_input; |
| 114 Scope& m_scope; | 120 CSSTokenizerScope& m_scope; |
| 115 }; | 121 }; |
| 116 | 122 |
| 117 | 123 |
| 118 | 124 |
| 119 } // namespace blink | 125 } // namespace blink |
| 120 | 126 |
| 121 #endif // CSSTokenizer_h | 127 #endif // CSSTokenizer_h |
| OLD | NEW |