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

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: Feedback from Haraken-san 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
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. 88 // The rule owns the live list. FIXME: oilpan: Delete this comment.
Mads Ager (chromium) 2014/03/12 12:24:42 Let's just remove this comment. The fact that OwnP
Erik Corry 2014/03/12 12:31:27 Done.
75 template <class Rule> 89 template <class Rule>
76 class LiveCSSRuleList FINAL : public CSSRuleList { 90 class LiveCSSRuleList FINAL : public CSSRuleList {
77 public: 91 public:
92 static PassOwnPtrWillBeRawPtr<LiveCSSRuleList> create(Rule* rule)
93 {
94 return adoptPtrWillBeNoop(new LiveCSSRuleList(rule));
95 }
96
97 #if !ENABLE(OILPAN)
98 virtual void ref() OVERRIDE { m_rule->ref(); }
99 virtual void deref() OVERRIDE { m_rule->deref(); }
100 #endif
101
102 virtual void trace(Visitor* visitor) OVERRIDE
103 {
104 visitor->trace(m_rule);
105 }
106
107 private:
78 LiveCSSRuleList(Rule* rule) : m_rule(rule) { } 108 LiveCSSRuleList(Rule* rule) : m_rule(rule) { }
79 109
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(); } 110 virtual unsigned length() const OVERRIDE { return m_rule->length(); }
85 virtual CSSRule* item(unsigned index) const OVERRIDE { return m_rule->item(i ndex); } 111 virtual CSSRule* item(unsigned index) const OVERRIDE { return m_rule->item(i ndex); }
86 virtual CSSStyleSheet* styleSheet() const OVERRIDE { return m_rule->parentSt yleSheet(); } 112 virtual CSSStyleSheet* styleSheet() const OVERRIDE { return m_rule->parentSt yleSheet(); }
87 113
88 // FIXME: oilpan: This is always a subclass of CSSRule, so it should be 114 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 }; 115 };
96 116
97 } // namespace WebCore 117 } // namespace WebCore
98 118
99 #endif // CSSRuleList_h 119 #endif // CSSRuleList_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698