OLD | NEW |
1 /* | 1 /* |
2 * (C) 1999-2003 Lars Knoll (knoll@kde.org) | 2 * (C) 1999-2003 Lars Knoll (knoll@kde.org) |
3 * (C) 2002-2003 Dirk Mueller (mueller@kde.org) | 3 * (C) 2002-2003 Dirk Mueller (mueller@kde.org) |
4 * Copyright (C) 2002, 2006, 2008, 2012, 2013 Apple Inc. All rights reserved. | 4 * Copyright (C) 2002, 2006, 2008, 2012, 2013 Apple Inc. All rights reserved. |
5 * | 5 * |
6 * This library is free software; you can redistribute it and/or | 6 * This library is free software; you can redistribute it and/or |
7 * modify it under the terms of the GNU Library General Public | 7 * modify it under the terms of the GNU Library General Public |
8 * License as published by the Free Software Foundation; either | 8 * License as published by the Free Software Foundation; either |
9 * version 2 of the License, or (at your option) any later version. | 9 * version 2 of the License, or (at your option) any later version. |
10 * | 10 * |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
57 bool isKeyframesRule() const { return type() == Keyframes; } | 57 bool isKeyframesRule() const { return type() == Keyframes; } |
58 bool isKeyframeRule() const { return type() == Keyframe; } | 58 bool isKeyframeRule() const { return type() == Keyframe; } |
59 bool isNamespaceRule() const { return type() == Namespace; } | 59 bool isNamespaceRule() const { return type() == Namespace; } |
60 bool isMediaRule() const { return type() == Media; } | 60 bool isMediaRule() const { return type() == Media; } |
61 bool isPageRule() const { return type() == Page; } | 61 bool isPageRule() const { return type() == Page; } |
62 bool isStyleRule() const { return type() == Style; } | 62 bool isStyleRule() const { return type() == Style; } |
63 bool isSupportsRule() const { return type() == Supports; } | 63 bool isSupportsRule() const { return type() == Supports; } |
64 bool isViewportRule() const { return type() == Viewport; } | 64 bool isViewportRule() const { return type() == Viewport; } |
65 bool isImportRule() const { return type() == Import; } | 65 bool isImportRule() const { return type() == Import; } |
66 | 66 |
67 RawPtr<StyleRuleBase> copy() const; | 67 StyleRuleBase* copy() const; |
68 | 68 |
69 #if !ENABLE(OILPAN) | 69 #if !ENABLE(OILPAN) |
70 void deref() | 70 void deref() |
71 { | 71 { |
72 if (derefBase()) | 72 if (derefBase()) |
73 destroy(); | 73 destroy(); |
74 } | 74 } |
75 #endif // !ENABLE(OILPAN) | 75 #endif // !ENABLE(OILPAN) |
76 | 76 |
77 // FIXME: There shouldn't be any need for the null parent version. | 77 // FIXME: There shouldn't be any need for the null parent version. |
78 RawPtr<CSSRule> createCSSOMWrapper(CSSStyleSheet* parentSheet = 0) const; | 78 CSSRule* createCSSOMWrapper(CSSStyleSheet* parentSheet = 0) const; |
79 RawPtr<CSSRule> createCSSOMWrapper(CSSRule* parentRule) const; | 79 CSSRule* createCSSOMWrapper(CSSRule* parentRule) const; |
80 | 80 |
81 DECLARE_TRACE(); | 81 DECLARE_TRACE(); |
82 DEFINE_INLINE_TRACE_AFTER_DISPATCH() { } | 82 DEFINE_INLINE_TRACE_AFTER_DISPATCH() { } |
83 void finalizeGarbageCollectedObject(); | 83 void finalizeGarbageCollectedObject(); |
84 | 84 |
85 // ~StyleRuleBase should be public, because non-public ~StyleRuleBase | 85 // ~StyleRuleBase should be public, because non-public ~StyleRuleBase |
86 // causes C2248 error : 'blink::StyleRuleBase::~StyleRuleBase' : cannot | 86 // causes C2248 error : 'blink::StyleRuleBase::~StyleRuleBase' : cannot |
87 // access protected member declared in class 'blink::StyleRuleBase' when | 87 // access protected member declared in class 'blink::StyleRuleBase' when |
88 // compiling 'source\wtf\refcounted.h' by using msvc. | 88 // compiling 'source\wtf\refcounted.h' by using msvc. |
89 ~StyleRuleBase() { } | 89 ~StyleRuleBase() { } |
90 | 90 |
91 protected: | 91 protected: |
92 StyleRuleBase(RuleType type) : m_type(type) { } | 92 StyleRuleBase(RuleType type) : m_type(type) { } |
93 StyleRuleBase(const StyleRuleBase& o) : m_type(o.m_type) { } | 93 StyleRuleBase(const StyleRuleBase& o) : m_type(o.m_type) { } |
94 | 94 |
95 private: | 95 private: |
96 void destroy(); | 96 void destroy(); |
97 | 97 |
98 RawPtr<CSSRule> createCSSOMWrapper(CSSStyleSheet* parentSheet, CSSRule* pare
ntRule) const; | 98 CSSRule* createCSSOMWrapper(CSSStyleSheet* parentSheet, CSSRule* parentRule)
const; |
99 | 99 |
100 unsigned m_type : 5; | 100 unsigned m_type : 5; |
101 }; | 101 }; |
102 | 102 |
103 class CORE_EXPORT StyleRule : public StyleRuleBase { | 103 class CORE_EXPORT StyleRule : public StyleRuleBase { |
104 public: | 104 public: |
105 // Adopts the selector list | 105 // Adopts the selector list |
106 static RawPtr<StyleRule> create(CSSSelectorList selectorList, RawPtr<StylePr
opertySet> properties) | 106 static StyleRule* create(CSSSelectorList selectorList, StylePropertySet* pro
perties) |
107 { | 107 { |
108 return new StyleRule(std::move(selectorList), properties); | 108 return new StyleRule(std::move(selectorList), properties); |
109 } | 109 } |
110 | 110 |
111 ~StyleRule(); | 111 ~StyleRule(); |
112 | 112 |
113 const CSSSelectorList& selectorList() const { return m_selectorList; } | 113 const CSSSelectorList& selectorList() const { return m_selectorList; } |
114 const StylePropertySet& properties() const { return *m_properties; } | 114 const StylePropertySet& properties() const { return *m_properties; } |
115 MutableStylePropertySet& mutableProperties(); | 115 MutableStylePropertySet& mutableProperties(); |
116 | 116 |
117 void wrapperAdoptSelectorList(CSSSelectorList selectors) { m_selectorList =
std::move(selectors); } | 117 void wrapperAdoptSelectorList(CSSSelectorList selectors) { m_selectorList =
std::move(selectors); } |
118 | 118 |
119 RawPtr<StyleRule> copy() const { return new StyleRule(*this); } | 119 StyleRule* copy() const { return new StyleRule(*this); } |
120 | 120 |
121 static unsigned averageSizeInBytes(); | 121 static unsigned averageSizeInBytes(); |
122 | 122 |
123 DECLARE_TRACE_AFTER_DISPATCH(); | 123 DECLARE_TRACE_AFTER_DISPATCH(); |
124 | 124 |
125 private: | 125 private: |
126 StyleRule(CSSSelectorList, RawPtr<StylePropertySet>); | 126 StyleRule(CSSSelectorList, StylePropertySet*); |
127 StyleRule(const StyleRule&); | 127 StyleRule(const StyleRule&); |
128 | 128 |
129 Member<StylePropertySet> m_properties; // Cannot be null. | 129 Member<StylePropertySet> m_properties; // Cannot be null. |
130 CSSSelectorList m_selectorList; | 130 CSSSelectorList m_selectorList; |
131 }; | 131 }; |
132 | 132 |
133 class StyleRuleFontFace : public StyleRuleBase { | 133 class StyleRuleFontFace : public StyleRuleBase { |
134 public: | 134 public: |
135 static RawPtr<StyleRuleFontFace> create(RawPtr<StylePropertySet> properties) | 135 static StyleRuleFontFace* create(StylePropertySet* properties) |
136 { | 136 { |
137 return new StyleRuleFontFace(properties); | 137 return new StyleRuleFontFace(properties); |
138 } | 138 } |
139 | 139 |
140 ~StyleRuleFontFace(); | 140 ~StyleRuleFontFace(); |
141 | 141 |
142 const StylePropertySet& properties() const { return *m_properties; } | 142 const StylePropertySet& properties() const { return *m_properties; } |
143 MutableStylePropertySet& mutableProperties(); | 143 MutableStylePropertySet& mutableProperties(); |
144 | 144 |
145 RawPtr<StyleRuleFontFace> copy() const { return new StyleRuleFontFace(*this)
; } | 145 StyleRuleFontFace* copy() const { return new StyleRuleFontFace(*this); } |
146 | 146 |
147 DECLARE_TRACE_AFTER_DISPATCH(); | 147 DECLARE_TRACE_AFTER_DISPATCH(); |
148 | 148 |
149 private: | 149 private: |
150 StyleRuleFontFace(RawPtr<StylePropertySet>); | 150 StyleRuleFontFace(StylePropertySet*); |
151 StyleRuleFontFace(const StyleRuleFontFace&); | 151 StyleRuleFontFace(const StyleRuleFontFace&); |
152 | 152 |
153 Member<StylePropertySet> m_properties; // Cannot be null. | 153 Member<StylePropertySet> m_properties; // Cannot be null. |
154 }; | 154 }; |
155 | 155 |
156 class StyleRulePage : public StyleRuleBase { | 156 class StyleRulePage : public StyleRuleBase { |
157 public: | 157 public: |
158 // Adopts the selector list | 158 // Adopts the selector list |
159 static RawPtr<StyleRulePage> create(CSSSelectorList selectorList, RawPtr<Sty
lePropertySet> properties) | 159 static StyleRulePage* create(CSSSelectorList selectorList, StylePropertySet*
properties) |
160 { | 160 { |
161 return new StyleRulePage(std::move(selectorList), properties); | 161 return new StyleRulePage(std::move(selectorList), properties); |
162 } | 162 } |
163 | 163 |
164 ~StyleRulePage(); | 164 ~StyleRulePage(); |
165 | 165 |
166 const CSSSelector* selector() const { return m_selectorList.first(); } | 166 const CSSSelector* selector() const { return m_selectorList.first(); } |
167 const StylePropertySet& properties() const { return *m_properties; } | 167 const StylePropertySet& properties() const { return *m_properties; } |
168 MutableStylePropertySet& mutableProperties(); | 168 MutableStylePropertySet& mutableProperties(); |
169 | 169 |
170 void wrapperAdoptSelectorList(CSSSelectorList selectors) { m_selectorList =
std::move(selectors); } | 170 void wrapperAdoptSelectorList(CSSSelectorList selectors) { m_selectorList =
std::move(selectors); } |
171 | 171 |
172 RawPtr<StyleRulePage> copy() const { return new StyleRulePage(*this); } | 172 StyleRulePage* copy() const { return new StyleRulePage(*this); } |
173 | 173 |
174 DECLARE_TRACE_AFTER_DISPATCH(); | 174 DECLARE_TRACE_AFTER_DISPATCH(); |
175 | 175 |
176 private: | 176 private: |
177 StyleRulePage(CSSSelectorList, RawPtr<StylePropertySet>); | 177 StyleRulePage(CSSSelectorList, StylePropertySet*); |
178 StyleRulePage(const StyleRulePage&); | 178 StyleRulePage(const StyleRulePage&); |
179 | 179 |
180 Member<StylePropertySet> m_properties; // Cannot be null. | 180 Member<StylePropertySet> m_properties; // Cannot be null. |
181 CSSSelectorList m_selectorList; | 181 CSSSelectorList m_selectorList; |
182 }; | 182 }; |
183 | 183 |
184 class StyleRuleGroup : public StyleRuleBase { | 184 class StyleRuleGroup : public StyleRuleBase { |
185 public: | 185 public: |
186 const HeapVector<Member<StyleRuleBase>>& childRules() const { return m_child
Rules; } | 186 const HeapVector<Member<StyleRuleBase>>& childRules() const { return m_child
Rules; } |
187 | 187 |
188 void wrapperInsertRule(unsigned, RawPtr<StyleRuleBase>); | 188 void wrapperInsertRule(unsigned, StyleRuleBase*); |
189 void wrapperRemoveRule(unsigned); | 189 void wrapperRemoveRule(unsigned); |
190 | 190 |
191 DECLARE_TRACE_AFTER_DISPATCH(); | 191 DECLARE_TRACE_AFTER_DISPATCH(); |
192 | 192 |
193 protected: | 193 protected: |
194 StyleRuleGroup(RuleType, HeapVector<Member<StyleRuleBase>>& adoptRule); | 194 StyleRuleGroup(RuleType, HeapVector<Member<StyleRuleBase>>& adoptRule); |
195 StyleRuleGroup(const StyleRuleGroup&); | 195 StyleRuleGroup(const StyleRuleGroup&); |
196 | 196 |
197 private: | 197 private: |
198 HeapVector<Member<StyleRuleBase>> m_childRules; | 198 HeapVector<Member<StyleRuleBase>> m_childRules; |
199 }; | 199 }; |
200 | 200 |
201 class StyleRuleMedia : public StyleRuleGroup { | 201 class StyleRuleMedia : public StyleRuleGroup { |
202 public: | 202 public: |
203 static RawPtr<StyleRuleMedia> create(RawPtr<MediaQuerySet> media, HeapVector
<Member<StyleRuleBase>>& adoptRules) | 203 static StyleRuleMedia* create(MediaQuerySet* media, HeapVector<Member<StyleR
uleBase>>& adoptRules) |
204 { | 204 { |
205 return new StyleRuleMedia(media, adoptRules); | 205 return new StyleRuleMedia(media, adoptRules); |
206 } | 206 } |
207 | 207 |
208 MediaQuerySet* mediaQueries() const { return m_mediaQueries.get(); } | 208 MediaQuerySet* mediaQueries() const { return m_mediaQueries.get(); } |
209 | 209 |
210 RawPtr<StyleRuleMedia> copy() const { return new StyleRuleMedia(*this); } | 210 StyleRuleMedia* copy() const { return new StyleRuleMedia(*this); } |
211 | 211 |
212 DECLARE_TRACE_AFTER_DISPATCH(); | 212 DECLARE_TRACE_AFTER_DISPATCH(); |
213 | 213 |
214 private: | 214 private: |
215 StyleRuleMedia(RawPtr<MediaQuerySet>, HeapVector<Member<StyleRuleBase>>& ado
ptRules); | 215 StyleRuleMedia(MediaQuerySet*, HeapVector<Member<StyleRuleBase>>& adoptRules
); |
216 StyleRuleMedia(const StyleRuleMedia&); | 216 StyleRuleMedia(const StyleRuleMedia&); |
217 | 217 |
218 Member<MediaQuerySet> m_mediaQueries; | 218 Member<MediaQuerySet> m_mediaQueries; |
219 }; | 219 }; |
220 | 220 |
221 class StyleRuleSupports : public StyleRuleGroup { | 221 class StyleRuleSupports : public StyleRuleGroup { |
222 public: | 222 public: |
223 static RawPtr<StyleRuleSupports> create(const String& conditionText, bool co
nditionIsSupported, HeapVector<Member<StyleRuleBase>>& adoptRules) | 223 static StyleRuleSupports* create(const String& conditionText, bool condition
IsSupported, HeapVector<Member<StyleRuleBase>>& adoptRules) |
224 { | 224 { |
225 return new StyleRuleSupports(conditionText, conditionIsSupported, adoptR
ules); | 225 return new StyleRuleSupports(conditionText, conditionIsSupported, adoptR
ules); |
226 } | 226 } |
227 | 227 |
228 String conditionText() const { return m_conditionText; } | 228 String conditionText() const { return m_conditionText; } |
229 bool conditionIsSupported() const { return m_conditionIsSupported; } | 229 bool conditionIsSupported() const { return m_conditionIsSupported; } |
230 RawPtr<StyleRuleSupports> copy() const { return new StyleRuleSupports(*this)
; } | 230 StyleRuleSupports* copy() const { return new StyleRuleSupports(*this); } |
231 | 231 |
232 DEFINE_INLINE_TRACE_AFTER_DISPATCH() { StyleRuleGroup::traceAfterDispatch(vi
sitor); } | 232 DEFINE_INLINE_TRACE_AFTER_DISPATCH() { StyleRuleGroup::traceAfterDispatch(vi
sitor); } |
233 | 233 |
234 private: | 234 private: |
235 StyleRuleSupports(const String& conditionText, bool conditionIsSupported, He
apVector<Member<StyleRuleBase>>& adoptRules); | 235 StyleRuleSupports(const String& conditionText, bool conditionIsSupported, He
apVector<Member<StyleRuleBase>>& adoptRules); |
236 StyleRuleSupports(const StyleRuleSupports&); | 236 StyleRuleSupports(const StyleRuleSupports&); |
237 | 237 |
238 String m_conditionText; | 238 String m_conditionText; |
239 bool m_conditionIsSupported; | 239 bool m_conditionIsSupported; |
240 }; | 240 }; |
241 | 241 |
242 class StyleRuleViewport : public StyleRuleBase { | 242 class StyleRuleViewport : public StyleRuleBase { |
243 public: | 243 public: |
244 static RawPtr<StyleRuleViewport> create(RawPtr<StylePropertySet> properties) | 244 static StyleRuleViewport* create(StylePropertySet* properties) |
245 { | 245 { |
246 return new StyleRuleViewport(properties); | 246 return new StyleRuleViewport(properties); |
247 } | 247 } |
248 | 248 |
249 ~StyleRuleViewport(); | 249 ~StyleRuleViewport(); |
250 | 250 |
251 const StylePropertySet& properties() const { return *m_properties; } | 251 const StylePropertySet& properties() const { return *m_properties; } |
252 MutableStylePropertySet& mutableProperties(); | 252 MutableStylePropertySet& mutableProperties(); |
253 | 253 |
254 RawPtr<StyleRuleViewport> copy() const { return new StyleRuleViewport(*this)
; } | 254 StyleRuleViewport* copy() const { return new StyleRuleViewport(*this); } |
255 | 255 |
256 DECLARE_TRACE_AFTER_DISPATCH(); | 256 DECLARE_TRACE_AFTER_DISPATCH(); |
257 | 257 |
258 private: | 258 private: |
259 StyleRuleViewport(RawPtr<StylePropertySet>); | 259 StyleRuleViewport(StylePropertySet*); |
260 StyleRuleViewport(const StyleRuleViewport&); | 260 StyleRuleViewport(const StyleRuleViewport&); |
261 | 261 |
262 Member<StylePropertySet> m_properties; // Cannot be null | 262 Member<StylePropertySet> m_properties; // Cannot be null |
263 }; | 263 }; |
264 | 264 |
265 // This should only be used within the CSS Parser | 265 // This should only be used within the CSS Parser |
266 class StyleRuleCharset : public StyleRuleBase { | 266 class StyleRuleCharset : public StyleRuleBase { |
267 public: | 267 public: |
268 static RawPtr<StyleRuleCharset> create() { return new StyleRuleCharset(); } | 268 static StyleRuleCharset* create() { return new StyleRuleCharset(); } |
269 DEFINE_INLINE_TRACE_AFTER_DISPATCH() { StyleRuleBase::traceAfterDispatch(vis
itor); } | 269 DEFINE_INLINE_TRACE_AFTER_DISPATCH() { StyleRuleBase::traceAfterDispatch(vis
itor); } |
270 | 270 |
271 private: | 271 private: |
272 StyleRuleCharset() : StyleRuleBase(Charset) { } | 272 StyleRuleCharset() : StyleRuleBase(Charset) { } |
273 }; | 273 }; |
274 | 274 |
275 | 275 |
276 #define DEFINE_STYLE_RULE_TYPE_CASTS(Type) \ | 276 #define DEFINE_STYLE_RULE_TYPE_CASTS(Type) \ |
277 DEFINE_TYPE_CASTS(StyleRule##Type, StyleRuleBase, rule, rule->is##Type##Rule
(), rule.is##Type##Rule()) | 277 DEFINE_TYPE_CASTS(StyleRule##Type, StyleRuleBase, rule, rule->is##Type##Rule
(), rule.is##Type##Rule()) |
278 | 278 |
279 DEFINE_TYPE_CASTS(StyleRule, StyleRuleBase, rule, rule->isStyleRule(), rule.isSt
yleRule()); | 279 DEFINE_TYPE_CASTS(StyleRule, StyleRuleBase, rule, rule->isStyleRule(), rule.isSt
yleRule()); |
280 DEFINE_STYLE_RULE_TYPE_CASTS(FontFace); | 280 DEFINE_STYLE_RULE_TYPE_CASTS(FontFace); |
281 DEFINE_STYLE_RULE_TYPE_CASTS(Page); | 281 DEFINE_STYLE_RULE_TYPE_CASTS(Page); |
282 DEFINE_STYLE_RULE_TYPE_CASTS(Media); | 282 DEFINE_STYLE_RULE_TYPE_CASTS(Media); |
283 DEFINE_STYLE_RULE_TYPE_CASTS(Supports); | 283 DEFINE_STYLE_RULE_TYPE_CASTS(Supports); |
284 DEFINE_STYLE_RULE_TYPE_CASTS(Viewport); | 284 DEFINE_STYLE_RULE_TYPE_CASTS(Viewport); |
285 DEFINE_STYLE_RULE_TYPE_CASTS(Charset); | 285 DEFINE_STYLE_RULE_TYPE_CASTS(Charset); |
286 | 286 |
287 } // namespace blink | 287 } // namespace blink |
288 | 288 |
289 #endif // StyleRule_h | 289 #endif // StyleRule_h |
OLD | NEW |