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

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

Issue 2616093003: Make CSSParserContext be garbage collected. (Closed)
Patch Set: comments 1 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 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 CSSParserContext_h 5 #ifndef CSSParserContext_h
6 #define CSSParserContext_h 6 #define CSSParserContext_h
7 7
8 #include "core/CoreExport.h" 8 #include "core/CoreExport.h"
9 #include "core/css/parser/CSSParserMode.h" 9 #include "core/css/parser/CSSParserMode.h"
10 #include "core/fetch/ResourceLoaderOptions.h" 10 #include "core/fetch/ResourceLoaderOptions.h"
11 #include "platform/weborigin/KURL.h" 11 #include "platform/weborigin/KURL.h"
12 #include "platform/weborigin/Referrer.h" 12 #include "platform/weborigin/Referrer.h"
13 13
14 namespace blink { 14 namespace blink {
15 15
16 class CSSStyleSheet;
16 class Document; 17 class Document;
18 class StyleSheetContents;
17 class UseCounter; 19 class UseCounter;
18 20
19 class CORE_EXPORT CSSParserContext { 21 class CORE_EXPORT CSSParserContext
20 USING_FAST_MALLOC(CSSParserContext); 22 : public GarbageCollectedFinalized<CSSParserContext> {
21
22 public: 23 public:
23 // https://drafts.csswg.org/selectors/#profiles 24 // https://drafts.csswg.org/selectors/#profiles
24 enum SelectorProfile { DynamicProfile, StaticProfile }; 25 enum SelectorProfile { DynamicProfile, StaticProfile };
25 26
26 CSSParserContext(CSSParserMode, 27 static CSSParserContext* create(const CSSParserContext*,
27 UseCounter*, 28 const CSSStyleSheet*);
28 SelectorProfile = DynamicProfile); 29 static CSSParserContext* create(const CSSParserContext*,
30 const StyleSheetContents*);
31
32 CSSParserContext(CSSParserMode, SelectorProfile = DynamicProfile);
haraken 2017/01/12 04:51:13 Put these constructors in a private section.
Bret 2017/01/13 02:15:28 Done.
29 // FIXME: We shouldn't need the UseCounter argument as we could infer it from 33 // FIXME: We shouldn't need the UseCounter argument as we could infer it from
30 // the Document but some callers want to disable use counting (e.g. the 34 // the Document but some callers want to disable use counting (e.g. the
31 // WebInspector). 35 // WebInspector).
32 CSSParserContext(const Document&, 36 CSSParserContext(const Document&,
33 UseCounter*,
34 const KURL& baseURL = KURL(), 37 const KURL& baseURL = KURL(),
35 const String& charset = emptyString(), 38 const String& charset = emptyString(),
36 SelectorProfile = DynamicProfile); 39 SelectorProfile = DynamicProfile);
37 // FIXME: This constructor shouldn't exist if we properly piped the UseCounter 40 // FIXME: This constructor shouldn't exist if we properly piped the UseCounter
38 // through the CSS subsystem. Currently the UseCounter life time is too crazy 41 // through the CSS subsystem. Currently the UseCounter life time is too crazy
39 // and we need a way to override it. 42 // and we need a way to override it.
40 CSSParserContext(const CSSParserContext&, UseCounter*); 43 CSSParserContext(const CSSParserContext*, UseCounter*);
41 44
42 bool operator==(const CSSParserContext&) const; 45 bool operator==(const CSSParserContext&) const;
43 bool operator!=(const CSSParserContext& other) const { 46 bool operator!=(const CSSParserContext& other) const {
44 return !(*this == other); 47 return !(*this == other);
45 } 48 }
46 49
47 CSSParserMode mode() const { return m_mode; } 50 CSSParserMode mode() const { return m_mode; }
48 CSSParserMode matchMode() const { return m_matchMode; } 51 CSSParserMode matchMode() const { return m_matchMode; }
49 const KURL& baseURL() const { return m_baseURL; } 52 const KURL& baseURL() const { return m_baseURL; }
50 const String& charset() const { return m_charset; } 53 const String& charset() const { return m_charset; }
(...skipping 15 matching lines...) Expand all
66 void setMode(CSSParserMode mode) { m_mode = mode; } 69 void setMode(CSSParserMode mode) { m_mode = mode; }
67 void setBaseURL(const KURL& baseURL) { m_baseURL = baseURL; } 70 void setBaseURL(const KURL& baseURL) { m_baseURL = baseURL; }
68 void setCharset(const String& charset) { m_charset = charset; } 71 void setCharset(const String& charset) { m_charset = charset; }
69 void setReferrer(const Referrer& referrer) { m_referrer = referrer; } 72 void setReferrer(const Referrer& referrer) { m_referrer = referrer; }
70 73
71 KURL completeURL(const String& url) const; 74 KURL completeURL(const String& url) const;
72 75
73 // This may return nullptr if counting is disabled. 76 // This may return nullptr if counting is disabled.
74 // See comments on constructors. 77 // See comments on constructors.
75 UseCounter* useCounter() const { return m_useCounter; } 78 UseCounter* useCounter() const { return m_useCounter; }
79 bool isUseCounterRecordingEnabled() const { return m_useCounter; }
80 void setUseCounter(UseCounter* useCounter) { m_useCounter = useCounter; }
76 81
77 ContentSecurityPolicyDisposition shouldCheckContentSecurityPolicy() const { 82 ContentSecurityPolicyDisposition shouldCheckContentSecurityPolicy() const {
78 return m_shouldCheckContentSecurityPolicy; 83 return m_shouldCheckContentSecurityPolicy;
79 } 84 }
80 85
86 DEFINE_INLINE_TRACE() {}
87
81 private: 88 private:
82 KURL m_baseURL; 89 KURL m_baseURL;
83 String m_charset; 90 String m_charset;
84 CSSParserMode m_mode; 91 CSSParserMode m_mode;
85 CSSParserMode m_matchMode; 92 CSSParserMode m_matchMode;
86 SelectorProfile m_profile = DynamicProfile; 93 SelectorProfile m_profile = DynamicProfile;
87 Referrer m_referrer; 94 Referrer m_referrer;
88 bool m_isHTMLDocument; 95 bool m_isHTMLDocument;
89 bool m_useLegacyBackgroundSizeShorthandBehavior; 96 bool m_useLegacyBackgroundSizeShorthandBehavior;
90 ContentSecurityPolicyDisposition m_shouldCheckContentSecurityPolicy; 97 ContentSecurityPolicyDisposition m_shouldCheckContentSecurityPolicy;
91 98
92 UseCounter* m_useCounter; 99 UseCounter* m_useCounter;
93 }; 100 };
94 101
95 CORE_EXPORT const CSSParserContext& strictCSSParserContext(); 102 CORE_EXPORT const CSSParserContext* strictCSSParserContext();
96 103
97 } // namespace blink 104 } // namespace blink
98 105
99 #endif // CSSParserMode_h 106 #endif // CSSParserContext_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698