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

Side by Side Diff: third_party/WebKit/Source/core/css/parser/CSSTokenizer.h

Issue 2503683003: [WIP] Streaming CSS parser (Closed)
Patch Set: rebase Created 3 years, 11 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
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/css/parser/CSSTokenizerInputStream.h" 10 #include "core/css/parser/CSSTokenizerInputStream.h"
11 #include "core/html/parser/InputStreamPreprocessor.h" 11 #include "core/html/parser/InputStreamPreprocessor.h"
12 #include "wtf/Allocator.h" 12 #include "wtf/Allocator.h"
13 #include "wtf/text/StringView.h" 13 #include "wtf/text/StringView.h"
14 #include "wtf/text/WTFString.h" 14 #include "wtf/text/WTFString.h"
15 15
16 #include <climits> 16 #include <climits>
17 17
18 namespace blink { 18 namespace blink {
19 19
20 class CSSTokenizerInputStream; 20 class CSSTokenizerInputStream;
21 class CSSParserObserverWrapper; 21 class CSSParserObserver;
22 class CSSParserTokenRange; 22 class CSSParserTokenRange;
23 23
24 class CORE_EXPORT CSSTokenizer { 24 class CORE_EXPORT CSSTokenizer {
25 WTF_MAKE_NONCOPYABLE(CSSTokenizer); 25 WTF_MAKE_NONCOPYABLE(CSSTokenizer);
26 DISALLOW_NEW(); 26 DISALLOW_NEW();
27 27
28 public: 28 public:
29 CSSTokenizer(const String&); 29 CSSTokenizer(const String&, size_t startOffset = 0);
30 CSSTokenizer(const String&, CSSParserObserverWrapper&); // For the inspector
31 30
32 CSSParserTokenRange tokenRange(); 31 CSSParserTokenRange tokenRange();
33 unsigned tokenCount();
34 32
35 Vector<String> takeEscapedStrings() { return std::move(m_stringPool); } 33 Vector<String> takeEscapedStrings() { return std::move(m_stringPool); }
36 34
37 private: 35 private:
38 CSSParserToken nextToken(); 36 CSSParserToken nextToken();
37 void tokenizeSingle();
39 38
40 UChar consume(); 39 UChar consume();
41 void reconsume(UChar); 40 void reconsume(UChar);
42 41
43 CSSParserToken consumeNumericToken(); 42 CSSParserToken consumeNumericToken();
44 CSSParserToken consumeIdentLikeToken(); 43 CSSParserToken consumeIdentLikeToken();
45 CSSParserToken consumeNumber(); 44 CSSParserToken consumeNumber();
46 CSSParserToken consumeStringTokenUntil(UChar); 45 CSSParserToken consumeStringTokenUntil(UChar);
47 CSSParserToken consumeUnicodeRange(); 46 CSSParserToken consumeUnicodeRange();
48 CSSParserToken consumeUrlToken(); 47 CSSParserToken consumeUrlToken();
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
93 CSSParserToken letterU(UChar); 92 CSSParserToken letterU(UChar);
94 CSSParserToken nameStart(UChar); 93 CSSParserToken nameStart(UChar);
95 CSSParserToken stringStart(UChar); 94 CSSParserToken stringStart(UChar);
96 CSSParserToken endOfFile(UChar); 95 CSSParserToken endOfFile(UChar);
97 96
98 StringView registerString(const String&); 97 StringView registerString(const String&);
99 98
100 using CodePoint = CSSParserToken (CSSTokenizer::*)(UChar); 99 using CodePoint = CSSParserToken (CSSTokenizer::*)(UChar);
101 static const CodePoint codePoints[]; 100 static const CodePoint codePoints[];
102 101
102 void skipToBlockEnd();
103 void skipComments();
104 void skipWhitespaceAndComments();
105 void yieldComments(CSSParserObserver&);
106
107 bool skipIdentCharacters(UChar);
108 void skipIdentCharacters();
109
103 CSSTokenizerInputStream m_input; 110 CSSTokenizerInputStream m_input;
104 Vector<CSSParserTokenType, 8> m_blockStack; 111 Vector<CSSParserTokenType, 8> m_blockStack;
105 112
106 Vector<CSSParserToken, 32> m_tokens; 113 Vector<CSSParserToken, 32> m_tokens;
107 // We only allocate strings when escapes are used. 114 // We only allocate strings when escapes are used.
108 Vector<String> m_stringPool; 115 Vector<String> m_stringPool;
116
117 bool m_finishedTokenizing = false;
118
119 friend class CSSParserTokenStream;
109 }; 120 };
110 121
111 } // namespace blink 122 } // namespace blink
112 123
113 #endif // CSSTokenizer_h 124 #endif // CSSTokenizer_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698