| 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" |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 | 22 |
| 23 class CORE_EXPORT CSSTokenizer { | 23 class CORE_EXPORT CSSTokenizer { |
| 24 WTF_MAKE_NONCOPYABLE(CSSTokenizer); | 24 WTF_MAKE_NONCOPYABLE(CSSTokenizer); |
| 25 USING_FAST_MALLOC(CSSTokenizer); | 25 USING_FAST_MALLOC(CSSTokenizer); |
| 26 | 26 |
| 27 public: | 27 public: |
| 28 class CORE_EXPORT Scope { | 28 class CORE_EXPORT Scope { |
| 29 DISALLOW_NEW(); | 29 DISALLOW_NEW(); |
| 30 | 30 |
| 31 public: | 31 public: |
| 32 Scope() {} |
| 32 Scope(const String&); | 33 Scope(const String&); |
| 33 Scope(const String&, CSSParserObserverWrapper&); // For the inspector | 34 Scope(const String&, CSSParserObserverWrapper&); // For the inspector |
| 34 | 35 |
| 35 CSSParserTokenRange tokenRange(); | 36 CSSParserTokenRange tokenRange(); |
| 36 unsigned tokenCount(); | 37 unsigned tokenCount(); |
| 37 | 38 |
| 39 std::unique_ptr<Vector<String>> releaseEscapedStrings() { |
| 40 return std::move(m_stringPool); |
| 41 } |
| 42 |
| 38 private: | 43 private: |
| 39 void storeString(const String& string) { m_stringPool.append(string); } | 44 void storeString(const String&); |
| 40 Vector<CSSParserToken, 32> m_tokens; | 45 Vector<CSSParserToken, 32> m_tokens; |
| 41 // We only allocate strings when escapes are used. | 46 |
| 42 Vector<String> m_stringPool; | 47 // We only allocate strings when escapes are used. This member is lazily |
| 48 // initialized. |
| 49 std::unique_ptr<Vector<String>> m_stringPool; |
| 43 String m_string; | 50 String m_string; |
| 44 | 51 |
| 45 friend class CSSTokenizer; | 52 friend class CSSTokenizer; |
| 46 }; | 53 }; |
| 47 | 54 |
| 48 private: | 55 private: |
| 49 CSSTokenizer(CSSTokenizerInputStream&, Scope&); | 56 CSSTokenizer(CSSTokenizerInputStream&, Scope&); |
| 50 | 57 |
| 51 CSSParserToken nextToken(); | 58 CSSParserToken nextToken(); |
| 52 | 59 |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 114 static const CodePoint codePoints[]; | 121 static const CodePoint codePoints[]; |
| 115 | 122 |
| 116 Vector<CSSParserTokenType, 8> m_blockStack; | 123 Vector<CSSParserTokenType, 8> m_blockStack; |
| 117 CSSTokenizerInputStream& m_input; | 124 CSSTokenizerInputStream& m_input; |
| 118 Scope& m_scope; | 125 Scope& m_scope; |
| 119 }; | 126 }; |
| 120 | 127 |
| 121 } // namespace blink | 128 } // namespace blink |
| 122 | 129 |
| 123 #endif // CSSTokenizer_h | 130 #endif // CSSTokenizer_h |
| OLD | NEW |