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

Side by Side Diff: Source/core/css/CSSRuleList.h

Issue 192473003: Move CSSRuleList to the garbage collected heap (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: ager feedback Created 6 years, 9 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 | Annotate | Revision Log
« no previous file with comments | « Source/core/css/CSSRule.cpp ('k') | Source/core/css/CSSRuleList.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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, 2012 Apple Computer, Inc. 4 * Copyright (C) 2002, 2006, 2012 Apple Computer, Inc.
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 14 matching lines...) Expand all
25 #include "heap/Handle.h" 25 #include "heap/Handle.h"
26 #include "wtf/PassRefPtr.h" 26 #include "wtf/PassRefPtr.h"
27 #include "wtf/RefPtr.h" 27 #include "wtf/RefPtr.h"
28 #include "wtf/Vector.h" 28 #include "wtf/Vector.h"
29 29
30 namespace WebCore { 30 namespace WebCore {
31 31
32 class CSSRule; 32 class CSSRule;
33 class CSSStyleSheet; 33 class CSSStyleSheet;
34 34
35 class CSSRuleList { 35 class CSSRuleList : public NoBaseWillBeGarbageCollectedFinalized<CSSRuleList> {
36 WTF_MAKE_NONCOPYABLE(CSSRuleList); WTF_MAKE_FAST_ALLOCATED; 36 WTF_MAKE_NONCOPYABLE(CSSRuleList);
37 WTF_MAKE_FAST_ALLOCATED_WILL_BE_REMOVED;
37 public: 38 public:
38 virtual ~CSSRuleList(); 39 virtual ~CSSRuleList();
39 40
41 #if !ENABLE(OILPAN)
40 virtual void ref() = 0; 42 virtual void ref() = 0;
41 virtual void deref() = 0; 43 virtual void deref() = 0;
44 #endif
42 45
43 virtual unsigned length() const = 0; 46 virtual unsigned length() const = 0;
44 virtual CSSRule* item(unsigned index) const = 0; 47 virtual CSSRule* item(unsigned index) const = 0;
45 48
46 virtual CSSStyleSheet* styleSheet() const = 0; 49 virtual CSSStyleSheet* styleSheet() const = 0;
47 50
51 virtual void trace(Visitor*) = 0;
52
48 protected: 53 protected:
49 CSSRuleList(); 54 CSSRuleList();
50 }; 55 };
51 56
52 class StaticCSSRuleList FINAL : public CSSRuleList { 57 class StaticCSSRuleList FINAL : public CSSRuleList {
53 public: 58 public:
54 static PassRefPtr<StaticCSSRuleList> create() { return adoptRef(new StaticCS SRuleList()); } 59 static PassRefPtrWillBeRawPtr<StaticCSSRuleList> create()
60 {
61 return adoptRefWillBeNoop(new StaticCSSRuleList());
62 }
55 63
64 #if !ENABLE(OILPAN)
56 virtual void ref() OVERRIDE { ++m_refCount; } 65 virtual void ref() OVERRIDE { ++m_refCount; }
57 virtual void deref() OVERRIDE; 66 virtual void deref() OVERRIDE;
67 #endif
58 68
59 WillBePersistentHeapVector<RefPtrWillBeMember<CSSRule> >& rules() { return m _rules; } 69 WillBeHeapVector<RefPtrWillBeMember<CSSRule> >& rules() { return m_rules; }
60 70
61 virtual CSSStyleSheet* styleSheet() const OVERRIDE { return 0; } 71 virtual CSSStyleSheet* styleSheet() const OVERRIDE { return 0; }
62 72
73 virtual void trace(Visitor*) OVERRIDE;
74
63 private: 75 private:
64 StaticCSSRuleList(); 76 StaticCSSRuleList();
65 virtual ~StaticCSSRuleList(); 77 virtual ~StaticCSSRuleList();
66 78
67 virtual unsigned length() const OVERRIDE { return m_rules.size(); } 79 virtual unsigned length() const OVERRIDE { return m_rules.size(); }
68 virtual CSSRule* item(unsigned index) const OVERRIDE { return index < m_rule s.size() ? m_rules[index].get() : 0; } 80 virtual CSSRule* item(unsigned index) const OVERRIDE { return index < m_rule s.size() ? m_rules[index].get() : 0; }
69 81
70 WillBePersistentHeapVector<RefPtrWillBeMember<CSSRule> > m_rules; 82 WillBeHeapVector<RefPtrWillBeMember<CSSRule> > m_rules;
83 #if !ENABLE(OILPAN)
71 unsigned m_refCount; 84 unsigned m_refCount;
85 #endif
72 }; 86 };
73 87
74 // The rule owns the live list.
75 template <class Rule> 88 template <class Rule>
76 class LiveCSSRuleList FINAL : public CSSRuleList { 89 class LiveCSSRuleList FINAL : public CSSRuleList {
77 public: 90 public:
91 static PassOwnPtrWillBeRawPtr<LiveCSSRuleList> create(Rule* rule)
92 {
93 return adoptPtrWillBeNoop(new LiveCSSRuleList(rule));
94 }
95
96 #if !ENABLE(OILPAN)
97 virtual void ref() OVERRIDE { m_rule->ref(); }
98 virtual void deref() OVERRIDE { m_rule->deref(); }
99 #endif
100
101 virtual void trace(Visitor* visitor) OVERRIDE
102 {
103 visitor->trace(m_rule);
104 }
105
106 private:
78 LiveCSSRuleList(Rule* rule) : m_rule(rule) { } 107 LiveCSSRuleList(Rule* rule) : m_rule(rule) { }
79 108
80 virtual void ref() OVERRIDE { m_rule->ref(); }
81 virtual void deref() OVERRIDE { m_rule->deref(); }
82
83 private:
84 virtual unsigned length() const OVERRIDE { return m_rule->length(); } 109 virtual unsigned length() const OVERRIDE { return m_rule->length(); }
85 virtual CSSRule* item(unsigned index) const OVERRIDE { return m_rule->item(i ndex); } 110 virtual CSSRule* item(unsigned index) const OVERRIDE { return m_rule->item(i ndex); }
86 virtual CSSStyleSheet* styleSheet() const OVERRIDE { return m_rule->parentSt yleSheet(); } 111 virtual CSSStyleSheet* styleSheet() const OVERRIDE { return m_rule->parentSt yleSheet(); }
87 112
88 // FIXME: oilpan: This is always a subclass of CSSRule, so it should be 113 RawPtrWillBeMember<Rule> m_rule;
89 // RawPtrWillBeMember<Rule>, but that would leak right now in Oilpan mode:
90 // m_ruleListCSSOMWrapper is an OwnPtr pointing at CSSRuleList, which is a
91 // superclass of this class, and this points at things that have an
92 // m_ruleListCSSOMWrapper field. When LiveCSSRuleList is moved to the GCed
93 // heap, this can be fixed.
94 Rule* m_rule;
95 }; 114 };
96 115
97 } // namespace WebCore 116 } // namespace WebCore
98 117
99 #endif // CSSRuleList_h 118 #endif // CSSRuleList_h
OLDNEW
« no previous file with comments | « Source/core/css/CSSRule.cpp ('k') | Source/core/css/CSSRuleList.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698