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" | |
37 #include "platform/weborigin/KURL.h" | 36 #include "platform/weborigin/KURL.h" |
38 #include "platform/weborigin/Referrer.h" | 37 #include "platform/weborigin/Referrer.h" |
39 | 38 |
40 namespace blink { | 39 namespace blink { |
41 | 40 |
42 class Document; | 41 class Document; |
43 class LocalFrame; | |
44 | 42 |
45 // Must not grow beyond 3 bits, due to packing in StylePropertySet. | 43 // Must not grow beyond 3 bits, due to packing in StylePropertySet. |
46 enum CSSParserMode { | 44 enum CSSParserMode { |
47 HTMLStandardMode, | 45 HTMLStandardMode, |
48 HTMLQuirksMode, | 46 HTMLQuirksMode, |
49 // HTML attributes are parsed in quirks mode but also allows internal proper
ties and values. | 47 // HTML attributes are parsed in quirks mode but also allows internal proper
ties and values. |
50 HTMLAttributeMode, | 48 HTMLAttributeMode, |
51 // SVG attributes are parsed in quirks mode but rules differ slightly. | 49 // SVG attributes are parsed in quirks mode but rules differ slightly. |
52 SVGAttributeMode, | 50 SVGAttributeMode, |
53 // @viewport rules are parsed in standards mode but CSSOM modifications (via
StylePropertySet) | 51 // @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... |
87 | 85 |
88 class CORE_EXPORT CSSParserContext { | 86 class CORE_EXPORT CSSParserContext { |
89 WTF_MAKE_FAST_ALLOCATED(CSSParserContext); | 87 WTF_MAKE_FAST_ALLOCATED(CSSParserContext); |
90 public: | 88 public: |
91 CSSParserContext(CSSParserMode, UseCounter*); | 89 CSSParserContext(CSSParserMode, UseCounter*); |
92 // FIXME: We shouldn't need the UseCounter argument as we could infer it fro
m the Document | 90 // FIXME: We shouldn't need the UseCounter argument as we could infer it fro
m the Document |
93 // but some callers want to disable use counting (e.g. the WebInspector). | 91 // but some callers want to disable use counting (e.g. the WebInspector). |
94 CSSParserContext(const Document&, UseCounter*, const KURL& baseURL = KURL(),
const String& charset = emptyString()); | 92 CSSParserContext(const Document&, UseCounter*, const KURL& baseURL = KURL(),
const String& charset = emptyString()); |
95 // FIXME: This constructor shouldn't exist if we properly piped the UseCount
er through the CSS | 93 // FIXME: This constructor shouldn't exist if we properly piped the UseCount
er through the CSS |
96 // subsystem. Currently the UseCounter life time is too crazy and we need a
way to override it. | 94 // subsystem. Currently the UseCounter life time is too crazy and we need a
way to override it. |
97 CSSParserContext(const CSSParserContext&, LocalFrame*, UseCounter*); | 95 CSSParserContext(const CSSParserContext&, UseCounter*); |
98 ~CSSParserContext(); | |
99 | 96 |
100 bool operator==(const CSSParserContext&) const; | 97 bool operator==(const CSSParserContext&) const; |
101 bool operator!=(const CSSParserContext& other) const { return !(*this == oth
er); } | 98 bool operator!=(const CSSParserContext& other) const { return !(*this == oth
er); } |
102 | 99 |
103 CSSParserMode mode() const { return m_mode; } | 100 CSSParserMode mode() const { return m_mode; } |
104 const KURL& baseURL() const { return m_baseURL; } | 101 const KURL& baseURL() const { return m_baseURL; } |
105 const String& charset() const { return m_charset; } | 102 const String& charset() const { return m_charset; } |
106 const Referrer& referrer() const { return m_referrer; } | 103 const Referrer& referrer() const { return m_referrer; } |
107 bool isHTMLDocument() const { return m_isHTMLDocument; } | 104 bool isHTMLDocument() const { return m_isHTMLDocument; } |
108 | 105 |
109 // This quirk is to maintain compatibility with Android apps built on | 106 // This quirk is to maintain compatibility with Android apps built on |
110 // the Android SDK prior to and including version 18. Presumably, this | 107 // the Android SDK prior to and including version 18. Presumably, this |
111 // can be removed any time after 2015. See http://crbug.com/277157. | 108 // can be removed any time after 2015. See http://crbug.com/277157. |
112 bool useLegacyBackgroundSizeShorthandBehavior() const { return m_useLegacyBa
ckgroundSizeShorthandBehavior; } | 109 bool useLegacyBackgroundSizeShorthandBehavior() const { return m_useLegacyBa
ckgroundSizeShorthandBehavior; } |
113 | 110 |
114 // FIXME: These setters shouldn't exist, however the current lifetime of CSS
ParserContext | 111 // FIXME: These setters shouldn't exist, however the current lifetime of CSS
ParserContext |
115 // is not well understood and thus we sometimes need to override these field
s. | 112 // is not well understood and thus we sometimes need to override these field
s. |
116 void setMode(CSSParserMode mode) { m_mode = mode; } | 113 void setMode(CSSParserMode mode) { m_mode = mode; } |
117 void setBaseURL(const KURL& baseURL) { m_baseURL = baseURL; } | 114 void setBaseURL(const KURL& baseURL) { m_baseURL = baseURL; } |
118 void setCharset(const String& charset) { m_charset = charset; } | 115 void setCharset(const String& charset) { m_charset = charset; } |
119 void setReferrer(const Referrer& referrer) { m_referrer = referrer; } | 116 void setReferrer(const Referrer& referrer) { m_referrer = referrer; } |
120 | 117 |
121 KURL completeURL(const String& url) const; | 118 KURL completeURL(const String& url) const; |
122 | 119 |
123 LocalFrame* frame() const { return m_frame.get(); } // may be null | |
124 UseCounter* useCounter() const { return m_useCounter; } | 120 UseCounter* useCounter() const { return m_useCounter; } |
125 | 121 |
126 ContentSecurityPolicyDisposition shouldCheckContentSecurityPolicy() const {
return m_shouldCheckContentSecurityPolicy; } | 122 ContentSecurityPolicyDisposition shouldCheckContentSecurityPolicy() const {
return m_shouldCheckContentSecurityPolicy; } |
127 | 123 |
128 private: | 124 private: |
129 KURL m_baseURL; | 125 KURL m_baseURL; |
130 String m_charset; | 126 String m_charset; |
131 CSSParserMode m_mode; | 127 CSSParserMode m_mode; |
132 Referrer m_referrer; | 128 Referrer m_referrer; |
133 bool m_isHTMLDocument; | 129 bool m_isHTMLDocument; |
134 bool m_useLegacyBackgroundSizeShorthandBehavior; | 130 bool m_useLegacyBackgroundSizeShorthandBehavior; |
135 ContentSecurityPolicyDisposition m_shouldCheckContentSecurityPolicy; | 131 ContentSecurityPolicyDisposition m_shouldCheckContentSecurityPolicy; |
136 | 132 |
137 RefPtrWillBePersistent<LocalFrame> m_frame; | |
138 UseCounter* m_useCounter; | 133 UseCounter* m_useCounter; |
139 }; | 134 }; |
140 | 135 |
141 CORE_EXPORT const CSSParserContext& strictCSSParserContext(); | 136 CORE_EXPORT const CSSParserContext& strictCSSParserContext(); |
142 | 137 |
143 }; | 138 }; |
144 | 139 |
145 #endif // CSSParserMode_h | 140 #endif // CSSParserMode_h |
OLD | NEW |