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

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

Issue 2474483002: [LazyParseCSS] Ensure UseCounting has parity with strict parsing (Closed)
Patch Set: s/!/!!/ Created 4 years 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 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"
(...skipping 19 matching lines...) Expand all
30 // Helper method used to bump m_totalStyleRules. 30 // Helper method used to bump m_totalStyleRules.
31 CSSLazyPropertyParserImpl* createLazyParser(const CSSParserTokenRange& block); 31 CSSLazyPropertyParserImpl* createLazyParser(const CSSParserTokenRange& block);
32 32
33 const CSSParserContext& context(); 33 const CSSParserContext& context();
34 34
35 void countRuleParsed(); 35 void countRuleParsed();
36 36
37 bool shouldLazilyParseProperties(const CSSSelectorList&, 37 bool shouldLazilyParseProperties(const CSSSelectorList&,
38 const CSSParserTokenRange& block) const; 38 const CSSParserTokenRange& block) const;
39 39
40 DEFINE_INLINE_TRACE() { visitor->trace(m_owningContents); } 40 DECLARE_TRACE();
41 41
42 // Exposed for tests. This enum is used to back a histogram, so new values 42 // Exposed for tests. This enum is used to back a histogram, so new values
43 // must be appended to the end, before UsageLastValue. 43 // must be appended to the end, before UsageLastValue.
44 enum CSSRuleUsage { 44 enum CSSRuleUsage {
45 UsageGe0 = 0, 45 UsageGe0 = 0,
46 UsageGt10 = 1, 46 UsageGt10 = 1,
47 UsageGt25 = 2, 47 UsageGt25 = 2,
48 UsageGt50 = 3, 48 UsageGt50 = 3,
49 UsageGt75 = 4, 49 UsageGt75 = 4,
50 UsageGt90 = 5, 50 UsageGt90 = 5,
51 UsageAll = 6, 51 UsageAll = 6,
52 52
53 // This value must be last. 53 // This value must be last.
54 UsageLastValue = 7 54 UsageLastValue = 7
55 }; 55 };
56 56
57 private: 57 private:
58 void recordUsageMetrics(); 58 void recordUsageMetrics();
59 59
60 CSSParserContext m_context; 60 CSSParserContext m_context;
61 Vector<String> m_escapedStrings; 61 Vector<String> m_escapedStrings;
62 // Also referenced on the css resource. 62 // Also referenced on the css resource.
63 String m_sheetText; 63 String m_sheetText;
64 64
65 // Weak to ensure lazy state will never cause the contents to live longer than 65 // Weak to ensure lazy state will never cause the contents to live longer than
66 // it should (we DCHECK this fact). 66 // it should (we DCHECK this fact).
67 WeakMember<StyleSheetContents> m_owningContents; 67 WeakMember<StyleSheetContents> m_owningContents;
68 68
69 // Cache the document as a proxy for caching the UseCounter. Grabbing the
70 // UseCounter per every property parse is a bit more expensive.
71 WeakMember<Document> m_document;
72
69 // Used for calculating the % of rules that ended up being parsed. 73 // Used for calculating the % of rules that ended up being parsed.
70 int m_parsedStyleRules; 74 int m_parsedStyleRules;
71 int m_totalStyleRules; 75 int m_totalStyleRules;
72 76
73 int m_styleRulesNeededForNextMilestone; 77 int m_styleRulesNeededForNextMilestone;
74 78
75 int m_usage; 79 int m_usage;
80
81 // Whether or not use counting is enabled for parsing. This will usually be
82 // true, except for when stylesheets with @imports are removed from the page.
83 // See StyleRuleImport::setCSSStyleSheet.
84 const bool m_shouldUseCount;
76 }; 85 };
77 86
78 } // namespace blink 87 } // namespace blink
79 88
80 #endif // CSSLazyParsingState_h 89 #endif // CSSLazyParsingState_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698