OLD | NEW |
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 Document; | 16 class Document; |
17 class UseCounter; | 17 class UseCounter; |
18 | 18 |
19 class CORE_EXPORT CSSParserContext { | 19 class CORE_EXPORT CSSParserContext |
20 USING_FAST_MALLOC(CSSParserContext); | 20 : public GarbageCollectedFinalized<CSSParserContext> { |
21 | |
22 public: | 21 public: |
23 // https://drafts.csswg.org/selectors/#profiles | 22 // https://drafts.csswg.org/selectors/#profiles |
24 enum SelectorProfile { DynamicProfile, StaticProfile }; | 23 enum SelectorProfile { DynamicProfile, StaticProfile }; |
25 | 24 |
26 CSSParserContext(CSSParserMode, | 25 CSSParserContext(CSSParserMode, SelectorProfile = DynamicProfile); |
27 UseCounter*, | |
28 SelectorProfile = DynamicProfile); | |
29 // FIXME: We shouldn't need the UseCounter argument as we could infer it from | 26 // 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 | 27 // the Document but some callers want to disable use counting (e.g. the |
31 // WebInspector). | 28 // WebInspector). |
32 CSSParserContext(const Document&, | 29 CSSParserContext(const Document&, |
33 UseCounter*, | |
34 const KURL& baseURL = KURL(), | 30 const KURL& baseURL = KURL(), |
35 const String& charset = emptyString(), | 31 const String& charset = emptyString(), |
36 SelectorProfile = DynamicProfile); | 32 SelectorProfile = DynamicProfile); |
37 // FIXME: This constructor shouldn't exist if we properly piped the UseCounter | 33 // 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 | 34 // through the CSS subsystem. Currently the UseCounter life time is too crazy |
39 // and we need a way to override it. | 35 // and we need a way to override it. |
40 CSSParserContext(const CSSParserContext&, UseCounter*); | 36 CSSParserContext(const CSSParserContext*, UseCounter*); |
41 | 37 |
42 bool operator==(const CSSParserContext&) const; | 38 bool operator==(const CSSParserContext&) const; |
43 bool operator!=(const CSSParserContext& other) const { | 39 bool operator!=(const CSSParserContext& other) const { |
44 return !(*this == other); | 40 return !(*this == other); |
45 } | 41 } |
46 | 42 |
47 CSSParserMode mode() const { return m_mode; } | 43 CSSParserMode mode() const { return m_mode; } |
48 CSSParserMode matchMode() const { return m_matchMode; } | 44 CSSParserMode matchMode() const { return m_matchMode; } |
49 const KURL& baseURL() const { return m_baseURL; } | 45 const KURL& baseURL() const { return m_baseURL; } |
50 const String& charset() const { return m_charset; } | 46 const String& charset() const { return m_charset; } |
(...skipping 15 matching lines...) Expand all Loading... |
66 void setMode(CSSParserMode mode) { m_mode = mode; } | 62 void setMode(CSSParserMode mode) { m_mode = mode; } |
67 void setBaseURL(const KURL& baseURL) { m_baseURL = baseURL; } | 63 void setBaseURL(const KURL& baseURL) { m_baseURL = baseURL; } |
68 void setCharset(const String& charset) { m_charset = charset; } | 64 void setCharset(const String& charset) { m_charset = charset; } |
69 void setReferrer(const Referrer& referrer) { m_referrer = referrer; } | 65 void setReferrer(const Referrer& referrer) { m_referrer = referrer; } |
70 | 66 |
71 KURL completeURL(const String& url) const; | 67 KURL completeURL(const String& url) const; |
72 | 68 |
73 // This may return nullptr if counting is disabled. | 69 // This may return nullptr if counting is disabled. |
74 // See comments on constructors. | 70 // See comments on constructors. |
75 UseCounter* useCounter() const { return m_useCounter; } | 71 UseCounter* useCounter() const { return m_useCounter; } |
| 72 bool isUseCounterRecordingEnabled() const { return m_useCounter; } |
| 73 void setUseCounter(UseCounter* useCounter) { m_useCounter = useCounter; } |
76 | 74 |
77 ContentSecurityPolicyDisposition shouldCheckContentSecurityPolicy() const { | 75 ContentSecurityPolicyDisposition shouldCheckContentSecurityPolicy() const { |
78 return m_shouldCheckContentSecurityPolicy; | 76 return m_shouldCheckContentSecurityPolicy; |
79 } | 77 } |
80 | 78 |
| 79 DEFINE_INLINE_TRACE() {} |
| 80 |
81 private: | 81 private: |
82 KURL m_baseURL; | 82 KURL m_baseURL; |
83 String m_charset; | 83 String m_charset; |
84 CSSParserMode m_mode; | 84 CSSParserMode m_mode; |
85 CSSParserMode m_matchMode; | 85 CSSParserMode m_matchMode; |
86 SelectorProfile m_profile = DynamicProfile; | 86 SelectorProfile m_profile = DynamicProfile; |
87 Referrer m_referrer; | 87 Referrer m_referrer; |
88 bool m_isHTMLDocument; | 88 bool m_isHTMLDocument; |
89 bool m_useLegacyBackgroundSizeShorthandBehavior; | 89 bool m_useLegacyBackgroundSizeShorthandBehavior; |
90 ContentSecurityPolicyDisposition m_shouldCheckContentSecurityPolicy; | 90 ContentSecurityPolicyDisposition m_shouldCheckContentSecurityPolicy; |
91 | 91 |
92 UseCounter* m_useCounter; | 92 UseCounter* m_useCounter; |
93 }; | 93 }; |
94 | 94 |
95 CORE_EXPORT const CSSParserContext& strictCSSParserContext(); | 95 CORE_EXPORT const CSSParserContext* strictCSSParserContext(); |
96 | 96 |
97 } // namespace blink | 97 } // namespace blink |
98 | 98 |
99 #endif // CSSParserMode_h | 99 #endif // CSSParserContext_h |
OLD | NEW |