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

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

Issue 2711853003: [LazyParseCSS] WIP Implement token discarding
Patch Set: lookup in escape string pool Created 3 years, 9 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
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/css/parser/CSSLazyParsingState.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 CSSLazyParsingState_h 5 #ifndef CSSLazyParsingState_h
6 #define CSSLazyParsingState_h 6 #define CSSLazyParsingState_h
7 7
8 #include "core/css/CSSSelectorList.h" 8 #include "core/css/CSSSelectorList.h"
9 #include "core/css/StyleSheetContents.h" 9 #include "core/css/StyleSheetContents.h"
10 #include "core/css/parser/CSSParserMode.h" 10 #include "core/css/parser/CSSParserMode.h"
11 #include "wtf/HashMap.h"
11 #include "wtf/Vector.h" 12 #include "wtf/Vector.h"
12 #include "wtf/text/WTFString.h" 13 #include "wtf/text/WTFString.h"
13 14
14 namespace blink { 15 namespace blink {
15 16
16 class CSSLazyPropertyParserImpl; 17 class CSSLazyPropertyParserImpl;
17 class CSSParserTokenRange; 18 class CSSParserTokenRange;
18 19
19 // This class helps lazy parsing by retaining necessary state. It should not 20 // This class helps lazy parsing by retaining necessary state. It should not
20 // outlive the StyleSheetContents that initiated the parse, as it retains a raw 21 // outlive the StyleSheetContents that initiated the parse, as it retains a raw
(...skipping 13 matching lines...) Expand all
34 // Helper method used to bump m_totalStyleRules. 35 // Helper method used to bump m_totalStyleRules.
35 CSSLazyPropertyParserImpl* createLazyParser(const CSSParserTokenRange& block); 36 CSSLazyPropertyParserImpl* createLazyParser(const CSSParserTokenRange& block);
36 37
37 const CSSParserContext* context(); 38 const CSSParserContext* context();
38 39
39 void countRuleParsed(); 40 void countRuleParsed();
40 41
41 bool shouldLazilyParseProperties(const CSSSelectorList&, 42 bool shouldLazilyParseProperties(const CSSSelectorList&,
42 const CSSParserTokenRange& block) const; 43 const CSSParserTokenRange& block) const;
43 44
45 bool tokenBackingUsesEscapedString(const void* tokenBackingBytes);
46
44 DECLARE_TRACE(); 47 DECLARE_TRACE();
45 48
46 // Exposed for tests. This enum is used to back a histogram, so new values 49 // Exposed for tests. This enum is used to back a histogram, so new values
47 // must be appended to the end, before UsageLastValue. 50 // must be appended to the end, before UsageLastValue.
48 enum CSSRuleUsage { 51 enum CSSRuleUsage {
49 UsageGe0 = 0, 52 UsageGe0 = 0,
50 UsageGt10 = 1, 53 UsageGt10 = 1,
51 UsageGt25 = 2, 54 UsageGt25 = 2,
52 UsageGt50 = 3, 55 UsageGt50 = 3,
53 UsageGt75 = 4, 56 UsageGt75 = 4,
54 UsageGt90 = 5, 57 UsageGt90 = 5,
55 UsageAll = 6, 58 UsageAll = 6,
56 59
57 // This value must be last. 60 // This value must be last.
58 UsageLastValue = 7 61 UsageLastValue = 7
59 }; 62 };
60 63
61 private: 64 private:
62 void recordUsageMetrics(); 65 void recordUsageMetrics();
63 66
64 Member<const CSSParserContext> m_context; 67 Member<const CSSParserContext> m_context;
65 Vector<String> m_escapedStrings; 68 HashMap<const void*, String> m_escapedStrings;
66 // Also referenced on the css resource. 69 // Also referenced on the css resource.
67 String m_sheetText; 70 String m_sheetText;
68 71
69 // Weak to ensure lazy state will never cause the contents to live longer than 72 // Weak to ensure lazy state will never cause the contents to live longer than
70 // it should (we DCHECK this fact). 73 // it should (we DCHECK this fact).
71 WeakMember<StyleSheetContents> m_owningContents; 74 WeakMember<StyleSheetContents> m_owningContents;
72 75
73 // Cache the document as a proxy for caching the UseCounter. Grabbing the 76 // Cache the document as a proxy for caching the UseCounter. Grabbing the
74 // UseCounter per every property parse is a bit more expensive. 77 // UseCounter per every property parse is a bit more expensive.
75 WeakMember<Document> m_document; 78 WeakMember<Document> m_document;
76 79
77 // Used for calculating the % of rules that ended up being parsed. 80 // Used for calculating the % of rules that ended up being parsed.
78 int m_parsedStyleRules; 81 int m_parsedStyleRules;
79 int m_totalStyleRules; 82 int m_totalStyleRules;
80 83
81 int m_styleRulesNeededForNextMilestone; 84 int m_styleRulesNeededForNextMilestone;
82 85
83 int m_usage; 86 int m_usage;
84 87
85 // Whether or not use counting is enabled for parsing. This will usually be 88 // Whether or not use counting is enabled for parsing. This will usually be
86 // true, except for when stylesheets with @imports are removed from the page. 89 // true, except for when stylesheets with @imports are removed from the page.
87 // See StyleRuleImport::setCSSStyleSheet. 90 // See StyleRuleImport::setCSSStyleSheet.
88 const bool m_shouldUseCount; 91 const bool m_shouldUseCount;
89 }; 92 };
90 93
91 } // namespace blink 94 } // namespace blink
92 95
93 #endif // CSSLazyParsingState_h 96 #endif // CSSLazyParsingState_h
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/css/parser/CSSLazyParsingState.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698