OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2012 Adobe Systems Incorporated. All rights reserved. | 2 * Copyright (C) 2012 Adobe Systems Incorporated. All rights reserved. |
3 * Copyright (C) 2012 Apple Inc. All rights reserved. | 3 * Copyright (C) 2012 Apple Inc. All rights reserved. |
4 * | 4 * |
5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
6 * modification, are permitted provided that the following conditions | 6 * modification, are permitted provided that the following conditions |
7 * are met: | 7 * are met: |
8 * | 8 * |
9 * 1. Redistributions of source code must retain the above | 9 * 1. Redistributions of source code must retain the above |
10 * copyright notice, this list of conditions and the following | 10 * copyright notice, this list of conditions and the following |
(...skipping 15 matching lines...) Expand all Loading... |
26 * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF | 26 * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF |
27 * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | 27 * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
28 * SUCH DAMAGE. | 28 * SUCH DAMAGE. |
29 */ | 29 */ |
30 | 30 |
31 #ifndef CSSParserMode_h | 31 #ifndef CSSParserMode_h |
32 #define CSSParserMode_h | 32 #define CSSParserMode_h |
33 | 33 |
34 #include "core/CoreExport.h" | 34 #include "core/CoreExport.h" |
35 #include "core/fetch/ResourceLoaderOptions.h" | 35 #include "core/fetch/ResourceLoaderOptions.h" |
| 36 #include "core/frame/LocalFrame.h" |
36 #include "platform/weborigin/KURL.h" | 37 #include "platform/weborigin/KURL.h" |
37 #include "platform/weborigin/Referrer.h" | 38 #include "platform/weborigin/Referrer.h" |
38 | 39 |
39 namespace blink { | 40 namespace blink { |
40 | 41 |
41 class Document; | 42 class Document; |
| 43 class LocalFrame; |
42 | 44 |
43 // Must not grow beyond 3 bits, due to packing in StylePropertySet. | 45 // Must not grow beyond 3 bits, due to packing in StylePropertySet. |
44 enum CSSParserMode { | 46 enum CSSParserMode { |
45 HTMLStandardMode, | 47 HTMLStandardMode, |
46 HTMLQuirksMode, | 48 HTMLQuirksMode, |
47 // HTML attributes are parsed in quirks mode but also allows internal proper
ties and values. | 49 // HTML attributes are parsed in quirks mode but also allows internal proper
ties and values. |
48 HTMLAttributeMode, | 50 HTMLAttributeMode, |
49 // SVG attributes are parsed in quirks mode but rules differ slightly. | 51 // SVG attributes are parsed in quirks mode but rules differ slightly. |
50 SVGAttributeMode, | 52 SVGAttributeMode, |
51 // @viewport rules are parsed in standards mode but CSSOM modifications (via
StylePropertySet) | 53 // @viewport rules are parsed in standards mode but CSSOM modifications (via
StylePropertySet) |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
85 | 87 |
86 class CORE_EXPORT CSSParserContext { | 88 class CORE_EXPORT CSSParserContext { |
87 WTF_MAKE_FAST_ALLOCATED(CSSParserContext); | 89 WTF_MAKE_FAST_ALLOCATED(CSSParserContext); |
88 public: | 90 public: |
89 CSSParserContext(CSSParserMode, UseCounter*); | 91 CSSParserContext(CSSParserMode, UseCounter*); |
90 // FIXME: We shouldn't need the UseCounter argument as we could infer it fro
m the Document | 92 // FIXME: We shouldn't need the UseCounter argument as we could infer it fro
m the Document |
91 // but some callers want to disable use counting (e.g. the WebInspector). | 93 // but some callers want to disable use counting (e.g. the WebInspector). |
92 CSSParserContext(const Document&, UseCounter*, const KURL& baseURL = KURL(),
const String& charset = emptyString()); | 94 CSSParserContext(const Document&, UseCounter*, const KURL& baseURL = KURL(),
const String& charset = emptyString()); |
93 // FIXME: This constructor shouldn't exist if we properly piped the UseCount
er through the CSS | 95 // FIXME: This constructor shouldn't exist if we properly piped the UseCount
er through the CSS |
94 // subsystem. Currently the UseCounter life time is too crazy and we need a
way to override it. | 96 // subsystem. Currently the UseCounter life time is too crazy and we need a
way to override it. |
95 CSSParserContext(const CSSParserContext&, UseCounter*); | 97 CSSParserContext(const CSSParserContext&, LocalFrame*, UseCounter*); |
| 98 ~CSSParserContext(); |
96 | 99 |
97 bool operator==(const CSSParserContext&) const; | 100 bool operator==(const CSSParserContext&) const; |
98 bool operator!=(const CSSParserContext& other) const { return !(*this == oth
er); } | 101 bool operator!=(const CSSParserContext& other) const { return !(*this == oth
er); } |
99 | 102 |
100 CSSParserMode mode() const { return m_mode; } | 103 CSSParserMode mode() const { return m_mode; } |
101 const KURL& baseURL() const { return m_baseURL; } | 104 const KURL& baseURL() const { return m_baseURL; } |
102 const String& charset() const { return m_charset; } | 105 const String& charset() const { return m_charset; } |
103 const Referrer& referrer() const { return m_referrer; } | 106 const Referrer& referrer() const { return m_referrer; } |
104 bool isHTMLDocument() const { return m_isHTMLDocument; } | 107 bool isHTMLDocument() const { return m_isHTMLDocument; } |
105 | 108 |
106 // This quirk is to maintain compatibility with Android apps built on | 109 // This quirk is to maintain compatibility with Android apps built on |
107 // the Android SDK prior to and including version 18. Presumably, this | 110 // the Android SDK prior to and including version 18. Presumably, this |
108 // can be removed any time after 2015. See http://crbug.com/277157. | 111 // can be removed any time after 2015. See http://crbug.com/277157. |
109 bool useLegacyBackgroundSizeShorthandBehavior() const { return m_useLegacyBa
ckgroundSizeShorthandBehavior; } | 112 bool useLegacyBackgroundSizeShorthandBehavior() const { return m_useLegacyBa
ckgroundSizeShorthandBehavior; } |
110 | 113 |
111 // FIXME: These setters shouldn't exist, however the current lifetime of CSS
ParserContext | 114 // FIXME: These setters shouldn't exist, however the current lifetime of CSS
ParserContext |
112 // is not well understood and thus we sometimes need to override these field
s. | 115 // is not well understood and thus we sometimes need to override these field
s. |
113 void setMode(CSSParserMode mode) { m_mode = mode; } | 116 void setMode(CSSParserMode mode) { m_mode = mode; } |
114 void setBaseURL(const KURL& baseURL) { m_baseURL = baseURL; } | 117 void setBaseURL(const KURL& baseURL) { m_baseURL = baseURL; } |
115 void setCharset(const String& charset) { m_charset = charset; } | 118 void setCharset(const String& charset) { m_charset = charset; } |
116 void setReferrer(const Referrer& referrer) { m_referrer = referrer; } | 119 void setReferrer(const Referrer& referrer) { m_referrer = referrer; } |
117 | 120 |
118 KURL completeURL(const String& url) const; | 121 KURL completeURL(const String& url) const; |
119 | 122 |
| 123 LocalFrame* frame() const { return m_frame.get(); } // may be null |
120 UseCounter* useCounter() const { return m_useCounter; } | 124 UseCounter* useCounter() const { return m_useCounter; } |
121 | 125 |
122 ContentSecurityPolicyDisposition shouldCheckContentSecurityPolicy() const {
return m_shouldCheckContentSecurityPolicy; } | 126 ContentSecurityPolicyDisposition shouldCheckContentSecurityPolicy() const {
return m_shouldCheckContentSecurityPolicy; } |
123 | 127 |
124 private: | 128 private: |
125 KURL m_baseURL; | 129 KURL m_baseURL; |
126 String m_charset; | 130 String m_charset; |
127 CSSParserMode m_mode; | 131 CSSParserMode m_mode; |
128 Referrer m_referrer; | 132 Referrer m_referrer; |
129 bool m_isHTMLDocument; | 133 bool m_isHTMLDocument; |
130 bool m_useLegacyBackgroundSizeShorthandBehavior; | 134 bool m_useLegacyBackgroundSizeShorthandBehavior; |
131 ContentSecurityPolicyDisposition m_shouldCheckContentSecurityPolicy; | 135 ContentSecurityPolicyDisposition m_shouldCheckContentSecurityPolicy; |
132 | 136 |
| 137 RefPtrWillBePersistent<LocalFrame> m_frame; |
133 UseCounter* m_useCounter; | 138 UseCounter* m_useCounter; |
134 }; | 139 }; |
135 | 140 |
136 CORE_EXPORT const CSSParserContext& strictCSSParserContext(); | 141 CORE_EXPORT const CSSParserContext& strictCSSParserContext(); |
137 | 142 |
138 }; | 143 }; |
139 | 144 |
140 #endif // CSSParserMode_h | 145 #endif // CSSParserMode_h |
OLD | NEW |