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 26 matching lines...) Expand all Loading... |
37 #include "platform/weborigin/Referrer.h" | 37 #include "platform/weborigin/Referrer.h" |
38 | 38 |
39 namespace blink { | 39 namespace blink { |
40 | 40 |
41 class Document; | 41 class Document; |
42 | 42 |
43 // Must not grow beyond 3 bits, due to packing in StylePropertySet. | 43 // Must not grow beyond 3 bits, due to packing in StylePropertySet. |
44 enum CSSParserMode { | 44 enum CSSParserMode { |
45 HTMLStandardMode, | 45 HTMLStandardMode, |
46 HTMLQuirksMode, | 46 HTMLQuirksMode, |
47 // HTML attributes are parsed in quirks mode but also allows internal properti
es and values. | 47 // HTML attributes are parsed in quirks mode but also allows internal |
| 48 // properties and values. |
48 HTMLAttributeMode, | 49 HTMLAttributeMode, |
49 // SVG attributes are parsed in quirks mode but rules differ slightly. | 50 // SVG attributes are parsed in quirks mode but rules differ slightly. |
50 SVGAttributeMode, | 51 SVGAttributeMode, |
51 // @viewport/@font-face rules are specially tagged in StylePropertySet so CSSO
M modifications don't treat them as style rules. | 52 // @viewport/@font-face rules are specially tagged in StylePropertySet so |
| 53 // CSSOM modifications don't treat them as style rules. |
52 CSSViewportRuleMode, | 54 CSSViewportRuleMode, |
53 CSSFontFaceRuleMode, | 55 CSSFontFaceRuleMode, |
54 // User agent stylesheets are parsed in standards mode but also allows interna
l properties and values. | 56 // User agent stylesheets are parsed in standards mode but also allows |
| 57 // internal properties and values. |
55 UASheetMode | 58 UASheetMode |
56 }; | 59 }; |
57 | 60 |
58 inline bool isQuirksModeBehavior(CSSParserMode mode) { | 61 inline bool isQuirksModeBehavior(CSSParserMode mode) { |
59 return mode == HTMLQuirksMode; // || mode == HTMLAttributeMode; | 62 return mode == HTMLQuirksMode; // || mode == HTMLAttributeMode; |
60 } | 63 } |
61 | 64 |
62 inline bool isUASheetBehavior(CSSParserMode mode) { | 65 inline bool isUASheetBehavior(CSSParserMode mode) { |
63 return mode == UASheetMode; | 66 return mode == UASheetMode; |
64 } | 67 } |
(...skipping 11 matching lines...) Expand all Loading... |
76 return mode != UASheetMode; | 79 return mode != UASheetMode; |
77 } | 80 } |
78 | 81 |
79 class UseCounter; | 82 class UseCounter; |
80 | 83 |
81 class CORE_EXPORT CSSParserContext { | 84 class CORE_EXPORT CSSParserContext { |
82 USING_FAST_MALLOC(CSSParserContext); | 85 USING_FAST_MALLOC(CSSParserContext); |
83 | 86 |
84 public: | 87 public: |
85 CSSParserContext(CSSParserMode, UseCounter*); | 88 CSSParserContext(CSSParserMode, UseCounter*); |
86 // FIXME: We shouldn't need the UseCounter argument as we could infer it from
the Document | 89 // FIXME: We shouldn't need the UseCounter argument as we could infer it from |
87 // but some callers want to disable use counting (e.g. the WebInspector). | 90 // the Document but some callers want to disable use counting (e.g. the |
| 91 // WebInspector). |
88 CSSParserContext(const Document&, | 92 CSSParserContext(const Document&, |
89 UseCounter*, | 93 UseCounter*, |
90 const KURL& baseURL = KURL(), | 94 const KURL& baseURL = KURL(), |
91 const String& charset = emptyString()); | 95 const String& charset = emptyString()); |
92 // FIXME: This constructor shouldn't exist if we properly piped the UseCounter
through the CSS | 96 // FIXME: This constructor shouldn't exist if we properly piped the UseCounter |
93 // subsystem. Currently the UseCounter life time is too crazy and we need a wa
y to override it. | 97 // through the CSS subsystem. Currently the UseCounter life time is too crazy |
| 98 // and we need a way to override it. |
94 CSSParserContext(const CSSParserContext&, UseCounter*); | 99 CSSParserContext(const CSSParserContext&, UseCounter*); |
95 | 100 |
96 bool operator==(const CSSParserContext&) const; | 101 bool operator==(const CSSParserContext&) const; |
97 bool operator!=(const CSSParserContext& other) const { | 102 bool operator!=(const CSSParserContext& other) const { |
98 return !(*this == other); | 103 return !(*this == other); |
99 } | 104 } |
100 | 105 |
101 CSSParserMode mode() const { return m_mode; } | 106 CSSParserMode mode() const { return m_mode; } |
102 CSSParserMode matchMode() const { return m_matchMode; } | 107 CSSParserMode matchMode() const { return m_matchMode; } |
103 const KURL& baseURL() const { return m_baseURL; } | 108 const KURL& baseURL() const { return m_baseURL; } |
104 const String& charset() const { return m_charset; } | 109 const String& charset() const { return m_charset; } |
105 const Referrer& referrer() const { return m_referrer; } | 110 const Referrer& referrer() const { return m_referrer; } |
106 bool isHTMLDocument() const { return m_isHTMLDocument; } | 111 bool isHTMLDocument() const { return m_isHTMLDocument; } |
107 | 112 |
108 // This quirk is to maintain compatibility with Android apps built on | 113 // This quirk is to maintain compatibility with Android apps built on |
109 // the Android SDK prior to and including version 18. Presumably, this | 114 // the Android SDK prior to and including version 18. Presumably, this |
110 // can be removed any time after 2015. See http://crbug.com/277157. | 115 // can be removed any time after 2015. See http://crbug.com/277157. |
111 bool useLegacyBackgroundSizeShorthandBehavior() const { | 116 bool useLegacyBackgroundSizeShorthandBehavior() const { |
112 return m_useLegacyBackgroundSizeShorthandBehavior; | 117 return m_useLegacyBackgroundSizeShorthandBehavior; |
113 } | 118 } |
114 | 119 |
115 // FIXME: These setters shouldn't exist, however the current lifetime of CSSPa
rserContext | 120 // FIXME: These setters shouldn't exist, however the current lifetime of |
116 // is not well understood and thus we sometimes need to override these fields. | 121 // CSSParserContext is not well understood and thus we sometimes need to |
| 122 // override these fields. |
117 void setMode(CSSParserMode mode) { m_mode = mode; } | 123 void setMode(CSSParserMode mode) { m_mode = mode; } |
118 void setBaseURL(const KURL& baseURL) { m_baseURL = baseURL; } | 124 void setBaseURL(const KURL& baseURL) { m_baseURL = baseURL; } |
119 void setCharset(const String& charset) { m_charset = charset; } | 125 void setCharset(const String& charset) { m_charset = charset; } |
120 void setReferrer(const Referrer& referrer) { m_referrer = referrer; } | 126 void setReferrer(const Referrer& referrer) { m_referrer = referrer; } |
121 | 127 |
122 KURL completeURL(const String& url) const; | 128 KURL completeURL(const String& url) const; |
123 | 129 |
124 // This may return nullptr if counting is disabled. | 130 // This may return nullptr if counting is disabled. |
125 // See comments on constructors. | 131 // See comments on constructors. |
126 UseCounter* useCounter() const { return m_useCounter; } | 132 UseCounter* useCounter() const { return m_useCounter; } |
(...skipping 13 matching lines...) Expand all Loading... |
140 ContentSecurityPolicyDisposition m_shouldCheckContentSecurityPolicy; | 146 ContentSecurityPolicyDisposition m_shouldCheckContentSecurityPolicy; |
141 | 147 |
142 UseCounter* m_useCounter; | 148 UseCounter* m_useCounter; |
143 }; | 149 }; |
144 | 150 |
145 CORE_EXPORT const CSSParserContext& strictCSSParserContext(); | 151 CORE_EXPORT const CSSParserContext& strictCSSParserContext(); |
146 | 152 |
147 } // namespace blink | 153 } // namespace blink |
148 | 154 |
149 #endif // CSSParserMode_h | 155 #endif // CSSParserMode_h |
OLD | NEW |