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

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

Issue 2315923002: Lazy Parse CSS (Closed)
Patch Set: esprehn review Created 4 years, 1 month 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 CSSParserImpl_h 5 #ifndef CSSParserImpl_h
6 #define CSSParserImpl_h 6 #define CSSParserImpl_h
7 7
8 #include "core/CSSPropertyNames.h" 8 #include "core/CSSPropertyNames.h"
9 #include "core/css/CSSProperty.h" 9 #include "core/css/CSSProperty.h"
10 #include "core/css/CSSPropertySourceData.h" 10 #include "core/css/CSSPropertySourceData.h"
11 #include "core/css/parser/CSSParserMode.h" 11 #include "core/css/parser/CSSParserMode.h"
12 #include "core/css/parser/CSSParserTokenRange.h" 12 #include "core/css/parser/CSSParserTokenRange.h"
13 #include "platform/heap/Handle.h" 13 #include "platform/heap/Handle.h"
14 #include "wtf/Vector.h" 14 #include "wtf/Vector.h"
15 #include "wtf/text/WTFString.h" 15 #include "wtf/text/WTFString.h"
16 #include <memory> 16 #include <memory>
17 17
18 namespace blink { 18 namespace blink {
19 19
20 class CSSLazyParsingState;
20 class CSSParserObserver; 21 class CSSParserObserver;
21 class CSSParserObserverWrapper; 22 class CSSParserObserverWrapper;
22 class StyleRule; 23 class StyleRule;
23 class StyleRuleBase; 24 class StyleRuleBase;
24 class StyleRuleCharset; 25 class StyleRuleCharset;
25 class StyleRuleFontFace; 26 class StyleRuleFontFace;
26 class StyleRuleImport; 27 class StyleRuleImport;
27 class StyleRuleKeyframe; 28 class StyleRuleKeyframe;
28 class StyleRuleKeyframes; 29 class StyleRuleKeyframes;
29 class StyleRuleMedia; 30 class StyleRuleMedia;
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
73 Element*); 74 Element*);
74 static bool parseDeclarationList(MutableStylePropertySet*, 75 static bool parseDeclarationList(MutableStylePropertySet*,
75 const String&, 76 const String&,
76 const CSSParserContext&); 77 const CSSParserContext&);
77 static StyleRuleBase* parseRule(const String&, 78 static StyleRuleBase* parseRule(const String&,
78 const CSSParserContext&, 79 const CSSParserContext&,
79 StyleSheetContents*, 80 StyleSheetContents*,
80 AllowedRulesType); 81 AllowedRulesType);
81 static void parseStyleSheet(const String&, 82 static void parseStyleSheet(const String&,
82 const CSSParserContext&, 83 const CSSParserContext&,
83 StyleSheetContents*); 84 StyleSheetContents*,
85 bool deferPropertyParsing = false);
84 static CSSSelectorList parsePageSelector(CSSParserTokenRange, 86 static CSSSelectorList parsePageSelector(CSSParserTokenRange,
85 StyleSheetContents*); 87 StyleSheetContents*);
86 88
87 static ImmutableStylePropertySet* parseCustomPropertySet(CSSParserTokenRange); 89 static ImmutableStylePropertySet* parseCustomPropertySet(CSSParserTokenRange);
88 90
89 static std::unique_ptr<Vector<double>> parseKeyframeKeyList(const String&); 91 static std::unique_ptr<Vector<double>> parseKeyframeKeyList(const String&);
90 92
91 bool supportsDeclaration(CSSParserTokenRange&); 93 bool supportsDeclaration(CSSParserTokenRange&);
92 94
93 static void parseDeclarationListForInspector(const String&, 95 static void parseDeclarationListForInspector(const String&,
94 const CSSParserContext&, 96 const CSSParserContext&,
95 CSSParserObserver&); 97 CSSParserObserver&);
96 static void parseStyleSheetForInspector(const String&, 98 static void parseStyleSheetForInspector(const String&,
97 const CSSParserContext&, 99 const CSSParserContext&,
98 StyleSheetContents*, 100 StyleSheetContents*,
99 CSSParserObserver&); 101 CSSParserObserver&);
100 102
103 static StylePropertySet* parseDeclarationListForLazyStyle(
104 CSSParserTokenRange block,
105 const CSSParserContext&);
106
101 private: 107 private:
102 enum RuleListType { TopLevelRuleList, RegularRuleList, KeyframesRuleList }; 108 enum RuleListType { TopLevelRuleList, RegularRuleList, KeyframesRuleList };
103 109
104 // Returns whether the first encountered rule was valid 110 // Returns whether the first encountered rule was valid
105 template <typename T> 111 template <typename T>
106 bool consumeRuleList(CSSParserTokenRange, RuleListType, T callback); 112 bool consumeRuleList(CSSParserTokenRange, RuleListType, T callback);
107 113
108 // These two functions update the range they're given 114 // These two functions update the range they're given
109 StyleRuleBase* consumeAtRule(CSSParserTokenRange&, AllowedRulesType); 115 StyleRuleBase* consumeAtRule(CSSParserTokenRange&, AllowedRulesType);
110 StyleRuleBase* consumeQualifiedRule(CSSParserTokenRange&, AllowedRulesType); 116 StyleRuleBase* consumeQualifiedRule(CSSParserTokenRange&, AllowedRulesType);
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
149 155
150 // FIXME: Can we build StylePropertySets directly? 156 // FIXME: Can we build StylePropertySets directly?
151 // FIXME: Investigate using a smaller inline buffer 157 // FIXME: Investigate using a smaller inline buffer
152 HeapVector<CSSProperty, 256> m_parsedProperties; 158 HeapVector<CSSProperty, 256> m_parsedProperties;
153 const CSSParserContext& m_context; 159 const CSSParserContext& m_context;
154 160
155 Member<StyleSheetContents> m_styleSheet; 161 Member<StyleSheetContents> m_styleSheet;
156 162
157 // For the inspector 163 // For the inspector
158 CSSParserObserverWrapper* m_observerWrapper; 164 CSSParserObserverWrapper* m_observerWrapper;
165
166 Member<CSSLazyParsingState> m_lazyState;
159 }; 167 };
160 168
161 } // namespace blink 169 } // namespace blink
162 170
163 #endif // CSSParserImpl_h 171 #endif // CSSParserImpl_h
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/css/parser/CSSParser.cpp ('k') | third_party/WebKit/Source/core/css/parser/CSSParserImpl.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698