Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(243)

Side by Side Diff: third_party/WebKit/Source/core/css/StyleRule.h

Issue 1658923004: PurgeMemory. Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
72 { 72 {
73 if (derefBase()) 73 if (derefBase())
74 destroy(); 74 destroy();
75 } 75 }
76 #endif // !ENABLE(OILPAN) 76 #endif // !ENABLE(OILPAN)
77 77
78 // FIXME: There shouldn't be any need for the null parent version. 78 // FIXME: There shouldn't be any need for the null parent version.
79 PassRefPtrWillBeRawPtr<CSSRule> createCSSOMWrapper(CSSStyleSheet* parentShee t = 0) const; 79 PassRefPtrWillBeRawPtr<CSSRule> createCSSOMWrapper(CSSStyleSheet* parentShee t = 0) const;
80 PassRefPtrWillBeRawPtr<CSSRule> createCSSOMWrapper(CSSRule* parentRule) cons t; 80 PassRefPtrWillBeRawPtr<CSSRule> createCSSOMWrapper(CSSRule* parentRule) cons t;
81 81
82 void purgeMemory();
83
82 DECLARE_TRACE(); 84 DECLARE_TRACE();
83 DEFINE_INLINE_TRACE_AFTER_DISPATCH() { } 85 DEFINE_INLINE_TRACE_AFTER_DISPATCH() { }
84 void finalizeGarbageCollectedObject(); 86 void finalizeGarbageCollectedObject();
85 87
86 // ~StyleRuleBase should be public, because non-public ~StyleRuleBase 88 // ~StyleRuleBase should be public, because non-public ~StyleRuleBase
87 // causes C2248 error : 'blink::StyleRuleBase::~StyleRuleBase' : cannot 89 // causes C2248 error : 'blink::StyleRuleBase::~StyleRuleBase' : cannot
88 // access protected member declared in class 'blink::StyleRuleBase' when 90 // access protected member declared in class 'blink::StyleRuleBase' when
89 // compiling 'source\wtf\refcounted.h' by using msvc. 91 // compiling 'source\wtf\refcounted.h' by using msvc.
90 ~StyleRuleBase() { } 92 ~StyleRuleBase() { }
91 93
(...skipping 21 matching lines...) Expand all
113 ~StyleRule(); 115 ~StyleRule();
114 116
115 const CSSSelectorList& selectorList() const { return m_selectorList; } 117 const CSSSelectorList& selectorList() const { return m_selectorList; }
116 const StylePropertySet& properties() const { return *m_properties; } 118 const StylePropertySet& properties() const { return *m_properties; }
117 MutableStylePropertySet& mutableProperties(); 119 MutableStylePropertySet& mutableProperties();
118 120
119 void wrapperAdoptSelectorList(CSSSelectorList selectors) { m_selectorList = std::move(selectors); } 121 void wrapperAdoptSelectorList(CSSSelectorList selectors) { m_selectorList = std::move(selectors); }
120 122
121 PassRefPtrWillBeRawPtr<StyleRule> copy() const { return adoptRefWillBeNoop(n ew StyleRule(*this)); } 123 PassRefPtrWillBeRawPtr<StyleRule> copy() const { return adoptRefWillBeNoop(n ew StyleRule(*this)); }
122 124
125 void purgeMemory();
126
123 static unsigned averageSizeInBytes(); 127 static unsigned averageSizeInBytes();
124 128
125 DECLARE_TRACE_AFTER_DISPATCH(); 129 DECLARE_TRACE_AFTER_DISPATCH();
126 130
127 private: 131 private:
128 StyleRule(CSSSelectorList, PassRefPtrWillBeRawPtr<StylePropertySet>); 132 StyleRule(CSSSelectorList, PassRefPtrWillBeRawPtr<StylePropertySet>);
129 StyleRule(const StyleRule&); 133 StyleRule(const StyleRule&);
130 134
131 RefPtrWillBeMember<StylePropertySet> m_properties; // Cannot be null. 135 RefPtrWillBeMember<StylePropertySet> m_properties; // Cannot be null.
132 CSSSelectorList m_selectorList; 136 CSSSelectorList m_selectorList;
133 }; 137 };
134 138
135 class StyleRuleFontFace : public StyleRuleBase { 139 class StyleRuleFontFace : public StyleRuleBase {
136 public: 140 public:
137 static PassRefPtrWillBeRawPtr<StyleRuleFontFace> create(PassRefPtrWillBeRawP tr<StylePropertySet> properties) 141 static PassRefPtrWillBeRawPtr<StyleRuleFontFace> create(PassRefPtrWillBeRawP tr<StylePropertySet> properties)
138 { 142 {
139 return adoptRefWillBeNoop(new StyleRuleFontFace(properties)); 143 return adoptRefWillBeNoop(new StyleRuleFontFace(properties));
140 } 144 }
141 145
142 ~StyleRuleFontFace(); 146 ~StyleRuleFontFace();
143 147
144 const StylePropertySet& properties() const { return *m_properties; } 148 const StylePropertySet& properties() const { return *m_properties; }
145 MutableStylePropertySet& mutableProperties(); 149 MutableStylePropertySet& mutableProperties();
146 150
147 PassRefPtrWillBeRawPtr<StyleRuleFontFace> copy() const { return adoptRefWill BeNoop(new StyleRuleFontFace(*this)); } 151 PassRefPtrWillBeRawPtr<StyleRuleFontFace> copy() const { return adoptRefWill BeNoop(new StyleRuleFontFace(*this)); }
148 152
149 DECLARE_TRACE_AFTER_DISPATCH(); 153 DECLARE_TRACE_AFTER_DISPATCH();
150 154
155 void purgeMemory();
156
151 private: 157 private:
152 StyleRuleFontFace(PassRefPtrWillBeRawPtr<StylePropertySet>); 158 StyleRuleFontFace(PassRefPtrWillBeRawPtr<StylePropertySet>);
153 StyleRuleFontFace(const StyleRuleFontFace&); 159 StyleRuleFontFace(const StyleRuleFontFace&);
154 160
155 RefPtrWillBeMember<StylePropertySet> m_properties; // Cannot be null. 161 RefPtrWillBeMember<StylePropertySet> m_properties; // Cannot be null.
156 }; 162 };
157 163
158 class StyleRulePage : public StyleRuleBase { 164 class StyleRulePage : public StyleRuleBase {
159 public: 165 public:
160 // Adopts the selector list 166 // Adopts the selector list
161 static PassRefPtrWillBeRawPtr<StyleRulePage> create(CSSSelectorList selector List, PassRefPtrWillBeRawPtr<StylePropertySet> properties) 167 static PassRefPtrWillBeRawPtr<StyleRulePage> create(CSSSelectorList selector List, PassRefPtrWillBeRawPtr<StylePropertySet> properties)
162 { 168 {
163 return adoptRefWillBeNoop(new StyleRulePage(std::move(selectorList), pro perties)); 169 return adoptRefWillBeNoop(new StyleRulePage(std::move(selectorList), pro perties));
164 } 170 }
165 171
166 ~StyleRulePage(); 172 ~StyleRulePage();
167 173
168 const CSSSelector* selector() const { return m_selectorList.first(); } 174 const CSSSelector* selector() const { return m_selectorList.first(); }
169 const StylePropertySet& properties() const { return *m_properties; } 175 const StylePropertySet& properties() const { return *m_properties; }
170 MutableStylePropertySet& mutableProperties(); 176 MutableStylePropertySet& mutableProperties();
171 177
172 void wrapperAdoptSelectorList(CSSSelectorList selectors) { m_selectorList = std::move(selectors); } 178 void wrapperAdoptSelectorList(CSSSelectorList selectors) { m_selectorList = std::move(selectors); }
173 179
174 PassRefPtrWillBeRawPtr<StyleRulePage> copy() const { return adoptRefWillBeNo op(new StyleRulePage(*this)); } 180 PassRefPtrWillBeRawPtr<StyleRulePage> copy() const { return adoptRefWillBeNo op(new StyleRulePage(*this)); }
175 181
182 void purgeMemory();
183
176 DECLARE_TRACE_AFTER_DISPATCH(); 184 DECLARE_TRACE_AFTER_DISPATCH();
177 185
178 private: 186 private:
179 StyleRulePage(CSSSelectorList, PassRefPtrWillBeRawPtr<StylePropertySet>); 187 StyleRulePage(CSSSelectorList, PassRefPtrWillBeRawPtr<StylePropertySet>);
180 StyleRulePage(const StyleRulePage&); 188 StyleRulePage(const StyleRulePage&);
181 189
182 RefPtrWillBeMember<StylePropertySet> m_properties; // Cannot be null. 190 RefPtrWillBeMember<StylePropertySet> m_properties; // Cannot be null.
183 CSSSelectorList m_selectorList; 191 CSSSelectorList m_selectorList;
184 }; 192 };
185 193
186 class StyleRuleGroup : public StyleRuleBase { 194 class StyleRuleGroup : public StyleRuleBase {
187 public: 195 public:
188 const WillBeHeapVector<RefPtrWillBeMember<StyleRuleBase>>& childRules() cons t { return m_childRules; } 196 const WillBeHeapVector<RefPtrWillBeMember<StyleRuleBase>>& childRules() cons t { return m_childRules; }
189 197
190 void wrapperInsertRule(unsigned, PassRefPtrWillBeRawPtr<StyleRuleBase>); 198 void wrapperInsertRule(unsigned, PassRefPtrWillBeRawPtr<StyleRuleBase>);
191 void wrapperRemoveRule(unsigned); 199 void wrapperRemoveRule(unsigned);
192 200
193 DECLARE_TRACE_AFTER_DISPATCH(); 201 DECLARE_TRACE_AFTER_DISPATCH();
194 202
203 void purgeMemory();
204
195 protected: 205 protected:
196 StyleRuleGroup(Type, WillBeHeapVector<RefPtrWillBeMember<StyleRuleBase>>& ad optRule); 206 StyleRuleGroup(Type, WillBeHeapVector<RefPtrWillBeMember<StyleRuleBase>>& ad optRule);
197 StyleRuleGroup(const StyleRuleGroup&); 207 StyleRuleGroup(const StyleRuleGroup&);
198 208
199 private: 209 private:
200 WillBeHeapVector<RefPtrWillBeMember<StyleRuleBase>> m_childRules; 210 WillBeHeapVector<RefPtrWillBeMember<StyleRuleBase>> m_childRules;
201 }; 211 };
202 212
203 class StyleRuleMedia : public StyleRuleGroup { 213 class StyleRuleMedia : public StyleRuleGroup {
204 public: 214 public:
205 static PassRefPtrWillBeRawPtr<StyleRuleMedia> create(PassRefPtrWillBeRawPtr< MediaQuerySet> media, WillBeHeapVector<RefPtrWillBeMember<StyleRuleBase>>& adopt Rules) 215 static PassRefPtrWillBeRawPtr<StyleRuleMedia> create(PassRefPtrWillBeRawPtr< MediaQuerySet> media, WillBeHeapVector<RefPtrWillBeMember<StyleRuleBase>>& adopt Rules)
206 { 216 {
207 return adoptRefWillBeNoop(new StyleRuleMedia(media, adoptRules)); 217 return adoptRefWillBeNoop(new StyleRuleMedia(media, adoptRules));
208 } 218 }
209 219
210 MediaQuerySet* mediaQueries() const { return m_mediaQueries.get(); } 220 MediaQuerySet* mediaQueries() const { return m_mediaQueries.get(); }
211 221
212 PassRefPtrWillBeRawPtr<StyleRuleMedia> copy() const { return adoptRefWillBeN oop(new StyleRuleMedia(*this)); } 222 PassRefPtrWillBeRawPtr<StyleRuleMedia> copy() const { return adoptRefWillBeN oop(new StyleRuleMedia(*this)); }
213 223
224 void purgeMemory() { StyleRuleGroup::purgeMemory(); }
225
214 DECLARE_TRACE_AFTER_DISPATCH(); 226 DECLARE_TRACE_AFTER_DISPATCH();
215 227
216 private: 228 private:
217 StyleRuleMedia(PassRefPtrWillBeRawPtr<MediaQuerySet>, WillBeHeapVector<RefPt rWillBeMember<StyleRuleBase>>& adoptRules); 229 StyleRuleMedia(PassRefPtrWillBeRawPtr<MediaQuerySet>, WillBeHeapVector<RefPt rWillBeMember<StyleRuleBase>>& adoptRules);
218 StyleRuleMedia(const StyleRuleMedia&); 230 StyleRuleMedia(const StyleRuleMedia&);
219 231
220 RefPtrWillBeMember<MediaQuerySet> m_mediaQueries; 232 RefPtrWillBeMember<MediaQuerySet> m_mediaQueries;
221 }; 233 };
222 234
223 class StyleRuleSupports : public StyleRuleGroup { 235 class StyleRuleSupports : public StyleRuleGroup {
224 public: 236 public:
225 static PassRefPtrWillBeRawPtr<StyleRuleSupports> create(const String& condit ionText, bool conditionIsSupported, WillBeHeapVector<RefPtrWillBeMember<StyleRul eBase>>& adoptRules) 237 static PassRefPtrWillBeRawPtr<StyleRuleSupports> create(const String& condit ionText, bool conditionIsSupported, WillBeHeapVector<RefPtrWillBeMember<StyleRul eBase>>& adoptRules)
226 { 238 {
227 return adoptRefWillBeNoop(new StyleRuleSupports(conditionText, condition IsSupported, adoptRules)); 239 return adoptRefWillBeNoop(new StyleRuleSupports(conditionText, condition IsSupported, adoptRules));
228 } 240 }
229 241
230 String conditionText() const { return m_conditionText; } 242 String conditionText() const { return m_conditionText; }
231 bool conditionIsSupported() const { return m_conditionIsSupported; } 243 bool conditionIsSupported() const { return m_conditionIsSupported; }
232 PassRefPtrWillBeRawPtr<StyleRuleSupports> copy() const { return adoptRefWill BeNoop(new StyleRuleSupports(*this)); } 244 PassRefPtrWillBeRawPtr<StyleRuleSupports> copy() const { return adoptRefWill BeNoop(new StyleRuleSupports(*this)); }
233 245
234 DEFINE_INLINE_TRACE_AFTER_DISPATCH() { StyleRuleGroup::traceAfterDispatch(vi sitor); } 246 DEFINE_INLINE_TRACE_AFTER_DISPATCH() { StyleRuleGroup::traceAfterDispatch(vi sitor); }
235 247
248 void purgeMemory() { StyleRuleGroup::purgeMemory(); }
249
236 private: 250 private:
237 StyleRuleSupports(const String& conditionText, bool conditionIsSupported, Wi llBeHeapVector<RefPtrWillBeMember<StyleRuleBase>>& adoptRules); 251 StyleRuleSupports(const String& conditionText, bool conditionIsSupported, Wi llBeHeapVector<RefPtrWillBeMember<StyleRuleBase>>& adoptRules);
238 StyleRuleSupports(const StyleRuleSupports&); 252 StyleRuleSupports(const StyleRuleSupports&);
239 253
240 String m_conditionText; 254 String m_conditionText;
241 bool m_conditionIsSupported; 255 bool m_conditionIsSupported;
242 }; 256 };
243 257
244 class StyleRuleViewport : public StyleRuleBase { 258 class StyleRuleViewport : public StyleRuleBase {
245 public: 259 public:
246 static PassRefPtrWillBeRawPtr<StyleRuleViewport> create(PassRefPtrWillBeRawP tr<StylePropertySet> properties) 260 static PassRefPtrWillBeRawPtr<StyleRuleViewport> create(PassRefPtrWillBeRawP tr<StylePropertySet> properties)
247 { 261 {
248 return adoptRefWillBeNoop(new StyleRuleViewport(properties)); 262 return adoptRefWillBeNoop(new StyleRuleViewport(properties));
249 } 263 }
250 264
251 ~StyleRuleViewport(); 265 ~StyleRuleViewport();
252 266
253 const StylePropertySet& properties() const { return *m_properties; } 267 const StylePropertySet& properties() const { return *m_properties; }
254 MutableStylePropertySet& mutableProperties(); 268 MutableStylePropertySet& mutableProperties();
255 269
256 PassRefPtrWillBeRawPtr<StyleRuleViewport> copy() const { return adoptRefWill BeNoop(new StyleRuleViewport(*this)); } 270 PassRefPtrWillBeRawPtr<StyleRuleViewport> copy() const { return adoptRefWill BeNoop(new StyleRuleViewport(*this)); }
257 271
272 void purgeMemory();
273
258 DECLARE_TRACE_AFTER_DISPATCH(); 274 DECLARE_TRACE_AFTER_DISPATCH();
259 275
260 private: 276 private:
261 StyleRuleViewport(PassRefPtrWillBeRawPtr<StylePropertySet>); 277 StyleRuleViewport(PassRefPtrWillBeRawPtr<StylePropertySet>);
262 StyleRuleViewport(const StyleRuleViewport&); 278 StyleRuleViewport(const StyleRuleViewport&);
263 279
264 RefPtrWillBeMember<StylePropertySet> m_properties; // Cannot be null 280 RefPtrWillBeMember<StylePropertySet> m_properties; // Cannot be null
265 }; 281 };
266 282
267 // This should only be used within the CSS Parser 283 // This should only be used within the CSS Parser
268 class StyleRuleCharset : public StyleRuleBase { 284 class StyleRuleCharset : public StyleRuleBase {
269 USING_FAST_MALLOC_WILL_BE_REMOVED(StyleRuleCharset); 285 USING_FAST_MALLOC_WILL_BE_REMOVED(StyleRuleCharset);
270 public: 286 public:
271 static PassRefPtrWillBeRawPtr<StyleRuleCharset> create() { return adoptRefWi llBeNoop(new StyleRuleCharset()); } 287 static PassRefPtrWillBeRawPtr<StyleRuleCharset> create() { return adoptRefWi llBeNoop(new StyleRuleCharset()); }
272 DEFINE_INLINE_TRACE_AFTER_DISPATCH() { StyleRuleBase::traceAfterDispatch(vis itor); } 288 DEFINE_INLINE_TRACE_AFTER_DISPATCH() { StyleRuleBase::traceAfterDispatch(vis itor); }
273 289
290 void purgeMemory() { }
291
274 private: 292 private:
275 StyleRuleCharset() : StyleRuleBase(Charset) { } 293 StyleRuleCharset() : StyleRuleBase(Charset) { }
276 }; 294 };
277 295
278 296
279 #define DEFINE_STYLE_RULE_TYPE_CASTS(Type) \ 297 #define DEFINE_STYLE_RULE_TYPE_CASTS(Type) \
280 DEFINE_TYPE_CASTS(StyleRule##Type, StyleRuleBase, rule, rule->is##Type##Rule (), rule.is##Type##Rule()) 298 DEFINE_TYPE_CASTS(StyleRule##Type, StyleRuleBase, rule, rule->is##Type##Rule (), rule.is##Type##Rule())
281 299
282 DEFINE_TYPE_CASTS(StyleRule, StyleRuleBase, rule, rule->isStyleRule(), rule.isSt yleRule()); 300 DEFINE_TYPE_CASTS(StyleRule, StyleRuleBase, rule, rule->isStyleRule(), rule.isSt yleRule());
283 DEFINE_STYLE_RULE_TYPE_CASTS(FontFace); 301 DEFINE_STYLE_RULE_TYPE_CASTS(FontFace);
284 DEFINE_STYLE_RULE_TYPE_CASTS(Page); 302 DEFINE_STYLE_RULE_TYPE_CASTS(Page);
285 DEFINE_STYLE_RULE_TYPE_CASTS(Media); 303 DEFINE_STYLE_RULE_TYPE_CASTS(Media);
286 DEFINE_STYLE_RULE_TYPE_CASTS(Supports); 304 DEFINE_STYLE_RULE_TYPE_CASTS(Supports);
287 DEFINE_STYLE_RULE_TYPE_CASTS(Viewport); 305 DEFINE_STYLE_RULE_TYPE_CASTS(Viewport);
288 DEFINE_STYLE_RULE_TYPE_CASTS(Charset); 306 DEFINE_STYLE_RULE_TYPE_CASTS(Charset);
289 307
290 } // namespace blink 308 } // namespace blink
291 309
292 #endif // StyleRule_h 310 #endif // StyleRule_h
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/css/StylePropertySet.cpp ('k') | third_party/WebKit/Source/core/css/StyleRule.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698