Chromium Code Reviews| 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, 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 Loading... | |
| 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*) { } | |
|
Mads Ager (chromium)
2014/03/10 12:32:57
Make this a pure virtual as well? (Either that or
zerny-chromium
2014/03/10 14:00:21
The plugin should warn that this trace is not call
Erik Corry
2014/03/12 10:36:41
Done.
Erik Corry
2014/03/12 10:36:41
Done.
| |
| 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. |
| 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 CSSRuleList::trace(visitor); | |
|
Mads Ager (chromium)
2014/03/10 12:32:57
If you make it pure virtual you can leave this one
Erik Corry
2014/03/12 10:36:41
Done.
| |
| 105 visitor->trace(m_rule); | |
| 106 } | |
| 107 | |
| 108 private: | |
| 78 LiveCSSRuleList(Rule* rule) : m_rule(rule) { } | 109 LiveCSSRuleList(Rule* rule) : m_rule(rule) { } |
| 79 | 110 |
| 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(); } | 111 virtual unsigned length() const OVERRIDE { return m_rule->length(); } |
| 85 virtual CSSRule* item(unsigned index) const OVERRIDE { return m_rule->item(i ndex); } | 112 virtual CSSRule* item(unsigned index) const OVERRIDE { return m_rule->item(i ndex); } |
| 86 virtual CSSStyleSheet* styleSheet() const OVERRIDE { return m_rule->parentSt yleSheet(); } | 113 virtual CSSStyleSheet* styleSheet() const OVERRIDE { return m_rule->parentSt yleSheet(); } |
| 87 | 114 |
| 88 // FIXME: oilpan: This is always a subclass of CSSRule, so it should be | 115 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 }; | 116 }; |
| 96 | 117 |
| 97 } // namespace WebCore | 118 } // namespace WebCore |
| 98 | 119 |
| 99 #endif // CSSRuleList_h | 120 #endif // CSSRuleList_h |
| OLD | NEW |