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

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

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, 2005, 2006, 2008, 2012 Apple Inc. All rights reserved. 4 * Copyright (C) 2002, 2005, 2006, 2008, 2012 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 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
45 PassRefPtrWillBeRawPtr<CSSRule> StyleRuleBase::createCSSOMWrapper(CSSStyleSheet* parentSheet) const 45 PassRefPtrWillBeRawPtr<CSSRule> StyleRuleBase::createCSSOMWrapper(CSSStyleSheet* parentSheet) const
46 { 46 {
47 return createCSSOMWrapper(parentSheet, 0); 47 return createCSSOMWrapper(parentSheet, 0);
48 } 48 }
49 49
50 PassRefPtrWillBeRawPtr<CSSRule> StyleRuleBase::createCSSOMWrapper(CSSRule* paren tRule) const 50 PassRefPtrWillBeRawPtr<CSSRule> StyleRuleBase::createCSSOMWrapper(CSSRule* paren tRule) const
51 { 51 {
52 return createCSSOMWrapper(0, parentRule); 52 return createCSSOMWrapper(0, parentRule);
53 } 53 }
54 54
55 void StyleRuleBase::purgeMemory()
56 {
57 switch (type()) {
58 case Charset:
59 toStyleRuleCharset(this)->purgeMemory();
60 return;
61 case Style:
62 toStyleRule(this)->purgeMemory();
63 return;
64 case Page:
65 toStyleRulePage(this)->purgeMemory();
66 return;
67 case FontFace:
68 toStyleRuleFontFace(this)->purgeMemory();
69 return;
70 case Media:
71 toStyleRuleMedia(this)->purgeMemory();
72 return;
73 case Supports:
74 toStyleRuleSupports(this)->purgeMemory();
75 return;
76 case Import:
77 toStyleRuleImport(this)->purgeMemory();
78 return;
79 case Keyframes:
80 toStyleRuleKeyframes(this)->purgeMemory();
81 return;
82 case Keyframe:
83 toStyleRuleKeyframe(this)->purgeMemory();
84 return;
85 case Namespace:
86 toStyleRuleNamespace(this)->purgeMemory();
87 return;
88 case Viewport:
89 toStyleRuleViewport(this)->purgeMemory();
90 return;
91 }
92 ASSERT_NOT_REACHED();
93 }
94
55 DEFINE_TRACE(StyleRuleBase) 95 DEFINE_TRACE(StyleRuleBase)
56 { 96 {
57 switch (type()) { 97 switch (type()) {
58 case Charset: 98 case Charset:
59 toStyleRuleCharset(this)->traceAfterDispatch(visitor); 99 toStyleRuleCharset(this)->traceAfterDispatch(visitor);
60 return; 100 return;
61 case Style: 101 case Style:
62 toStyleRule(this)->traceAfterDispatch(visitor); 102 toStyleRule(this)->traceAfterDispatch(visitor);
63 return; 103 return;
64 case Page: 104 case Page:
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after
268 { 308 {
269 } 309 }
270 310
271 MutableStylePropertySet& StyleRule::mutableProperties() 311 MutableStylePropertySet& StyleRule::mutableProperties()
272 { 312 {
273 if (!m_properties->isMutable()) 313 if (!m_properties->isMutable())
274 m_properties = m_properties->mutableCopy(); 314 m_properties = m_properties->mutableCopy();
275 return *toMutableStylePropertySet(m_properties.get()); 315 return *toMutableStylePropertySet(m_properties.get());
276 } 316 }
277 317
318
319 void StyleRule::purgeMemory()
320 {
321 m_properties->purgeMemory();
322 }
323
278 DEFINE_TRACE_AFTER_DISPATCH(StyleRule) 324 DEFINE_TRACE_AFTER_DISPATCH(StyleRule)
279 { 325 {
280 visitor->trace(m_properties); 326 visitor->trace(m_properties);
281 StyleRuleBase::traceAfterDispatch(visitor); 327 StyleRuleBase::traceAfterDispatch(visitor);
282 } 328 }
283 329
284 StyleRulePage::StyleRulePage(CSSSelectorList selectorList, PassRefPtrWillBeRawPt r<StylePropertySet> properties) 330 StyleRulePage::StyleRulePage(CSSSelectorList selectorList, PassRefPtrWillBeRawPt r<StylePropertySet> properties)
285 : StyleRuleBase(Page) 331 : StyleRuleBase(Page)
286 , m_properties(properties) 332 , m_properties(properties)
287 , m_selectorList(std::move(selectorList)) 333 , m_selectorList(std::move(selectorList))
(...skipping 11 matching lines...) Expand all
299 { 345 {
300 } 346 }
301 347
302 MutableStylePropertySet& StyleRulePage::mutableProperties() 348 MutableStylePropertySet& StyleRulePage::mutableProperties()
303 { 349 {
304 if (!m_properties->isMutable()) 350 if (!m_properties->isMutable())
305 m_properties = m_properties->mutableCopy(); 351 m_properties = m_properties->mutableCopy();
306 return *toMutableStylePropertySet(m_properties.get()); 352 return *toMutableStylePropertySet(m_properties.get());
307 } 353 }
308 354
355 void StyleRulePage::purgeMemory()
356 {
357 m_properties->purgeMemory();
358 }
359
309 DEFINE_TRACE_AFTER_DISPATCH(StyleRulePage) 360 DEFINE_TRACE_AFTER_DISPATCH(StyleRulePage)
310 { 361 {
311 visitor->trace(m_properties); 362 visitor->trace(m_properties);
312 StyleRuleBase::traceAfterDispatch(visitor); 363 StyleRuleBase::traceAfterDispatch(visitor);
313 } 364 }
314 365
315 StyleRuleFontFace::StyleRuleFontFace(PassRefPtrWillBeRawPtr<StylePropertySet> pr operties) 366 StyleRuleFontFace::StyleRuleFontFace(PassRefPtrWillBeRawPtr<StylePropertySet> pr operties)
316 : StyleRuleBase(FontFace) 367 : StyleRuleBase(FontFace)
317 , m_properties(properties) 368 , m_properties(properties)
318 { 369 {
319 } 370 }
320 371
321 StyleRuleFontFace::StyleRuleFontFace(const StyleRuleFontFace& o) 372 StyleRuleFontFace::StyleRuleFontFace(const StyleRuleFontFace& o)
322 : StyleRuleBase(o) 373 : StyleRuleBase(o)
323 , m_properties(o.m_properties->mutableCopy()) 374 , m_properties(o.m_properties->mutableCopy())
324 { 375 {
325 } 376 }
326 377
327 StyleRuleFontFace::~StyleRuleFontFace() 378 StyleRuleFontFace::~StyleRuleFontFace()
328 { 379 {
329 } 380 }
330 381
331 MutableStylePropertySet& StyleRuleFontFace::mutableProperties() 382 MutableStylePropertySet& StyleRuleFontFace::mutableProperties()
332 { 383 {
333 if (!m_properties->isMutable()) 384 if (!m_properties->isMutable())
334 m_properties = m_properties->mutableCopy(); 385 m_properties = m_properties->mutableCopy();
335 return *toMutableStylePropertySet(m_properties); 386 return *toMutableStylePropertySet(m_properties);
336 } 387 }
337 388
389 void StyleRuleFontFace::purgeMemory()
390 {
391 m_properties->purgeMemory();
392 }
393
338 DEFINE_TRACE_AFTER_DISPATCH(StyleRuleFontFace) 394 DEFINE_TRACE_AFTER_DISPATCH(StyleRuleFontFace)
339 { 395 {
340 visitor->trace(m_properties); 396 visitor->trace(m_properties);
341 StyleRuleBase::traceAfterDispatch(visitor); 397 StyleRuleBase::traceAfterDispatch(visitor);
342 } 398 }
343 399
344 StyleRuleGroup::StyleRuleGroup(Type type, WillBeHeapVector<RefPtrWillBeMember<St yleRuleBase>>& adoptRule) 400 StyleRuleGroup::StyleRuleGroup(Type type, WillBeHeapVector<RefPtrWillBeMember<St yleRuleBase>>& adoptRule)
345 : StyleRuleBase(type) 401 : StyleRuleBase(type)
346 { 402 {
347 m_childRules.swap(adoptRule); 403 m_childRules.swap(adoptRule);
(...skipping 10 matching lines...) Expand all
358 void StyleRuleGroup::wrapperInsertRule(unsigned index, PassRefPtrWillBeRawPtr<St yleRuleBase> rule) 414 void StyleRuleGroup::wrapperInsertRule(unsigned index, PassRefPtrWillBeRawPtr<St yleRuleBase> rule)
359 { 415 {
360 m_childRules.insert(index, rule); 416 m_childRules.insert(index, rule);
361 } 417 }
362 418
363 void StyleRuleGroup::wrapperRemoveRule(unsigned index) 419 void StyleRuleGroup::wrapperRemoveRule(unsigned index)
364 { 420 {
365 m_childRules.remove(index); 421 m_childRules.remove(index);
366 } 422 }
367 423
424 void StyleRuleGroup::purgeMemory()
425 {
426 for (StyleRuleBase* childRule : m_childRules)
427 childRule->purgeMemory();
428 }
429
368 DEFINE_TRACE_AFTER_DISPATCH(StyleRuleGroup) 430 DEFINE_TRACE_AFTER_DISPATCH(StyleRuleGroup)
369 { 431 {
370 visitor->trace(m_childRules); 432 visitor->trace(m_childRules);
371 StyleRuleBase::traceAfterDispatch(visitor); 433 StyleRuleBase::traceAfterDispatch(visitor);
372 } 434 }
373 435
374 StyleRuleMedia::StyleRuleMedia(PassRefPtrWillBeRawPtr<MediaQuerySet> media, Will BeHeapVector<RefPtrWillBeMember<StyleRuleBase>>& adoptRules) 436 StyleRuleMedia::StyleRuleMedia(PassRefPtrWillBeRawPtr<MediaQuerySet> media, Will BeHeapVector<RefPtrWillBeMember<StyleRuleBase>>& adoptRules)
375 : StyleRuleGroup(Media, adoptRules) 437 : StyleRuleGroup(Media, adoptRules)
376 , m_mediaQueries(media) 438 , m_mediaQueries(media)
377 { 439 {
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
420 { 482 {
421 } 483 }
422 484
423 MutableStylePropertySet& StyleRuleViewport::mutableProperties() 485 MutableStylePropertySet& StyleRuleViewport::mutableProperties()
424 { 486 {
425 if (!m_properties->isMutable()) 487 if (!m_properties->isMutable())
426 m_properties = m_properties->mutableCopy(); 488 m_properties = m_properties->mutableCopy();
427 return *toMutableStylePropertySet(m_properties); 489 return *toMutableStylePropertySet(m_properties);
428 } 490 }
429 491
492 void StyleRuleViewport::purgeMemory()
493 {
494 m_properties->purgeMemory();
495 }
496
430 DEFINE_TRACE_AFTER_DISPATCH(StyleRuleViewport) 497 DEFINE_TRACE_AFTER_DISPATCH(StyleRuleViewport)
431 { 498 {
432 visitor->trace(m_properties); 499 visitor->trace(m_properties);
433 StyleRuleBase::traceAfterDispatch(visitor); 500 StyleRuleBase::traceAfterDispatch(visitor);
434 } 501 }
435 502
436 } // namespace blink 503 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/css/StyleRule.h ('k') | third_party/WebKit/Source/core/css/StyleRuleImport.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698