diff options
Diffstat (limited to 'chromium/third_party/WebKit/Source/core/css/StyleRule.h')
-rw-r--r-- | chromium/third_party/WebKit/Source/core/css/StyleRule.h | 134 |
1 files changed, 68 insertions, 66 deletions
diff --git a/chromium/third_party/WebKit/Source/core/css/StyleRule.h b/chromium/third_party/WebKit/Source/core/css/StyleRule.h index e1216ebeedd..ab0853d7844 100644 --- a/chromium/third_party/WebKit/Source/core/css/StyleRule.h +++ b/chromium/third_party/WebKit/Source/core/css/StyleRule.h @@ -24,6 +24,7 @@ #include "core/css/CSSSelectorList.h" #include "core/css/MediaList.h" +#include "platform/heap/Handle.h" #include "wtf/RefPtr.h" namespace WebCore { @@ -34,8 +35,8 @@ class CSSStyleSheet; class MutableStylePropertySet; class StylePropertySet; -class StyleRuleBase : public WTF::RefCountedBase { - WTF_MAKE_FAST_ALLOCATED; +class StyleRuleBase : public RefCountedWillBeGarbageCollectedFinalized<StyleRuleBase> { + WTF_MAKE_FAST_ALLOCATED_WILL_BE_REMOVED; public: enum Type { Unknown, // Not used. @@ -49,7 +50,6 @@ public: Keyframe, // Not used. These are internally non-rule StyleKeyframe objects. Supports = 12, Viewport = 15, - Region = 16, Filter = 17 }; @@ -61,213 +61,216 @@ public: bool isMediaRule() const { return type() == Media; } bool isPageRule() const { return type() == Page; } bool isStyleRule() const { return type() == Style; } - bool isRegionRule() const { return type() == Region; } bool isSupportsRule() const { return type() == Supports; } bool isViewportRule() const { return type() == Viewport; } bool isImportRule() const { return type() == Import; } bool isFilterRule() const { return type() == Filter; } - PassRefPtr<StyleRuleBase> copy() const; + PassRefPtrWillBeRawPtr<StyleRuleBase> copy() const; +#if !ENABLE(OILPAN) void deref() { if (derefBase()) destroy(); } +#endif // !ENABLE(OILPAN) // FIXME: There shouldn't be any need for the null parent version. - PassRefPtr<CSSRule> createCSSOMWrapper(CSSStyleSheet* parentSheet = 0) const; - PassRefPtr<CSSRule> createCSSOMWrapper(CSSRule* parentRule) const; + PassRefPtrWillBeRawPtr<CSSRule> createCSSOMWrapper(CSSStyleSheet* parentSheet = 0) const; + PassRefPtrWillBeRawPtr<CSSRule> createCSSOMWrapper(CSSRule* parentRule) const; + + void trace(Visitor*); + void traceAfterDispatch(Visitor*) { }; + void finalizeGarbageCollectedObject(); protected: StyleRuleBase(Type type) : m_type(type) { } - StyleRuleBase(const StyleRuleBase& o) : WTF::RefCountedBase(), m_type(o.m_type) { } + StyleRuleBase(const StyleRuleBase& o) : m_type(o.m_type) { } ~StyleRuleBase() { } private: void destroy(); - PassRefPtr<CSSRule> createCSSOMWrapper(CSSStyleSheet* parentSheet, CSSRule* parentRule) const; + PassRefPtrWillBeRawPtr<CSSRule> createCSSOMWrapper(CSSStyleSheet* parentSheet, CSSRule* parentRule) const; unsigned m_type : 5; }; class StyleRule : public StyleRuleBase { - WTF_MAKE_FAST_ALLOCATED; + WTF_MAKE_FAST_ALLOCATED_WILL_BE_REMOVED; public: - static PassRefPtr<StyleRule> create() { return adoptRef(new StyleRule()); } + static PassRefPtrWillBeRawPtr<StyleRule> create() { return adoptRefWillBeNoop(new StyleRule()); } ~StyleRule(); const CSSSelectorList& selectorList() const { return m_selectorList; } - const StylePropertySet* properties() const { return m_properties.get(); } - MutableStylePropertySet* mutableProperties(); + const StylePropertySet& properties() const { return *m_properties; } + MutableStylePropertySet& mutableProperties(); void parserAdoptSelectorVector(Vector<OwnPtr<CSSParserSelector> >& selectors) { m_selectorList.adoptSelectorVector(selectors); } void wrapperAdoptSelectorList(CSSSelectorList& selectors) { m_selectorList.adopt(selectors); } void setProperties(PassRefPtr<StylePropertySet>); - PassRefPtr<StyleRule> copy() const { return adoptRef(new StyleRule(*this)); } + PassRefPtrWillBeRawPtr<StyleRule> copy() const { return adoptRefWillBeNoop(new StyleRule(*this)); } static unsigned averageSizeInBytes(); + void traceAfterDispatch(Visitor* visitor) { StyleRuleBase::traceAfterDispatch(visitor); } + private: StyleRule(); StyleRule(const StyleRule&); - RefPtr<StylePropertySet> m_properties; + RefPtr<StylePropertySet> m_properties; // Cannot be null. CSSSelectorList m_selectorList; }; class StyleRuleFontFace : public StyleRuleBase { public: - static PassRefPtr<StyleRuleFontFace> create() { return adoptRef(new StyleRuleFontFace); } + static PassRefPtrWillBeRawPtr<StyleRuleFontFace> create() { return adoptRefWillBeNoop(new StyleRuleFontFace); } ~StyleRuleFontFace(); - const StylePropertySet* properties() const { return m_properties.get(); } - MutableStylePropertySet* mutableProperties(); + const StylePropertySet& properties() const { return *m_properties; } + MutableStylePropertySet& mutableProperties(); void setProperties(PassRefPtr<StylePropertySet>); - PassRefPtr<StyleRuleFontFace> copy() const { return adoptRef(new StyleRuleFontFace(*this)); } + PassRefPtrWillBeRawPtr<StyleRuleFontFace> copy() const { return adoptRefWillBeNoop(new StyleRuleFontFace(*this)); } + + void traceAfterDispatch(Visitor* visitor) { StyleRuleBase::traceAfterDispatch(visitor); } private: StyleRuleFontFace(); StyleRuleFontFace(const StyleRuleFontFace&); - RefPtr<StylePropertySet> m_properties; + RefPtr<StylePropertySet> m_properties; // Cannot be null. }; class StyleRulePage : public StyleRuleBase { public: - static PassRefPtr<StyleRulePage> create() { return adoptRef(new StyleRulePage); } + static PassRefPtrWillBeRawPtr<StyleRulePage> create() { return adoptRefWillBeNoop(new StyleRulePage); } ~StyleRulePage(); const CSSSelector* selector() const { return m_selectorList.first(); } - const StylePropertySet* properties() const { return m_properties.get(); } - MutableStylePropertySet* mutableProperties(); + const StylePropertySet& properties() const { return *m_properties; } + MutableStylePropertySet& mutableProperties(); void parserAdoptSelectorVector(Vector<OwnPtr<CSSParserSelector> >& selectors) { m_selectorList.adoptSelectorVector(selectors); } void wrapperAdoptSelectorList(CSSSelectorList& selectors) { m_selectorList.adopt(selectors); } void setProperties(PassRefPtr<StylePropertySet>); - PassRefPtr<StyleRulePage> copy() const { return adoptRef(new StyleRulePage(*this)); } + PassRefPtrWillBeRawPtr<StyleRulePage> copy() const { return adoptRefWillBeNoop(new StyleRulePage(*this)); } + + void traceAfterDispatch(Visitor* visitor) { StyleRuleBase::traceAfterDispatch(visitor); } private: StyleRulePage(); StyleRulePage(const StyleRulePage&); - RefPtr<StylePropertySet> m_properties; + RefPtr<StylePropertySet> m_properties; // Cannot be null. CSSSelectorList m_selectorList; }; class StyleRuleGroup : public StyleRuleBase { public: - const Vector<RefPtr<StyleRuleBase> >& childRules() const { return m_childRules; } + const WillBeHeapVector<RefPtrWillBeMember<StyleRuleBase> >& childRules() const { return m_childRules; } - void wrapperInsertRule(unsigned, PassRefPtr<StyleRuleBase>); + void wrapperInsertRule(unsigned, PassRefPtrWillBeRawPtr<StyleRuleBase>); void wrapperRemoveRule(unsigned); + void traceAfterDispatch(Visitor*); + protected: - StyleRuleGroup(Type, Vector<RefPtr<StyleRuleBase> >& adoptRule); + StyleRuleGroup(Type, WillBeHeapVector<RefPtrWillBeMember<StyleRuleBase> >& adoptRule); StyleRuleGroup(const StyleRuleGroup&); private: - Vector<RefPtr<StyleRuleBase> > m_childRules; + WillBeHeapVector<RefPtrWillBeMember<StyleRuleBase> > m_childRules; }; class StyleRuleMedia : public StyleRuleGroup { public: - static PassRefPtr<StyleRuleMedia> create(PassRefPtr<MediaQuerySet> media, Vector<RefPtr<StyleRuleBase> >& adoptRules) + static PassRefPtrWillBeRawPtr<StyleRuleMedia> create(PassRefPtrWillBeRawPtr<MediaQuerySet> media, WillBeHeapVector<RefPtrWillBeMember<StyleRuleBase> >& adoptRules) { - return adoptRef(new StyleRuleMedia(media, adoptRules)); + return adoptRefWillBeNoop(new StyleRuleMedia(media, adoptRules)); } MediaQuerySet* mediaQueries() const { return m_mediaQueries.get(); } - PassRefPtr<StyleRuleMedia> copy() const { return adoptRef(new StyleRuleMedia(*this)); } + PassRefPtrWillBeRawPtr<StyleRuleMedia> copy() const { return adoptRefWillBeNoop(new StyleRuleMedia(*this)); } + + void traceAfterDispatch(Visitor*); private: - StyleRuleMedia(PassRefPtr<MediaQuerySet>, Vector<RefPtr<StyleRuleBase> >& adoptRules); + StyleRuleMedia(PassRefPtrWillBeRawPtr<MediaQuerySet>, WillBeHeapVector<RefPtrWillBeMember<StyleRuleBase> >& adoptRules); StyleRuleMedia(const StyleRuleMedia&); - RefPtr<MediaQuerySet> m_mediaQueries; + RefPtrWillBeMember<MediaQuerySet> m_mediaQueries; }; class StyleRuleSupports : public StyleRuleGroup { public: - static PassRefPtr<StyleRuleSupports> create(const String& conditionText, bool conditionIsSupported, Vector<RefPtr<StyleRuleBase> >& adoptRules) + static PassRefPtrWillBeRawPtr<StyleRuleSupports> create(const String& conditionText, bool conditionIsSupported, WillBeHeapVector<RefPtrWillBeMember<StyleRuleBase> >& adoptRules) { - return adoptRef(new StyleRuleSupports(conditionText, conditionIsSupported, adoptRules)); + return adoptRefWillBeNoop(new StyleRuleSupports(conditionText, conditionIsSupported, adoptRules)); } String conditionText() const { return m_conditionText; } bool conditionIsSupported() const { return m_conditionIsSupported; } - PassRefPtr<StyleRuleSupports> copy() const { return adoptRef(new StyleRuleSupports(*this)); } + PassRefPtrWillBeRawPtr<StyleRuleSupports> copy() const { return adoptRefWillBeNoop(new StyleRuleSupports(*this)); } + + void traceAfterDispatch(Visitor* visitor) { StyleRuleGroup::traceAfterDispatch(visitor); } private: - StyleRuleSupports(const String& conditionText, bool conditionIsSupported, Vector<RefPtr<StyleRuleBase> >& adoptRules); + StyleRuleSupports(const String& conditionText, bool conditionIsSupported, WillBeHeapVector<RefPtrWillBeMember<StyleRuleBase> >& adoptRules); StyleRuleSupports(const StyleRuleSupports&); String m_conditionText; bool m_conditionIsSupported; }; -class StyleRuleRegion : public StyleRuleGroup { -public: - static PassRefPtr<StyleRuleRegion> create(Vector<OwnPtr<CSSParserSelector> >* selectors, Vector<RefPtr<StyleRuleBase> >& adoptRules) - { - return adoptRef(new StyleRuleRegion(selectors, adoptRules)); - } - - const CSSSelectorList& selectorList() const { return m_selectorList; } - - PassRefPtr<StyleRuleRegion> copy() const { return adoptRef(new StyleRuleRegion(*this)); } - -private: - StyleRuleRegion(Vector<OwnPtr<CSSParserSelector> >*, Vector<RefPtr<StyleRuleBase> >& adoptRules); - StyleRuleRegion(const StyleRuleRegion&); - - CSSSelectorList m_selectorList; -}; - class StyleRuleViewport : public StyleRuleBase { public: - static PassRefPtr<StyleRuleViewport> create() { return adoptRef(new StyleRuleViewport); } + static PassRefPtrWillBeRawPtr<StyleRuleViewport> create() { return adoptRefWillBeNoop(new StyleRuleViewport); } ~StyleRuleViewport(); - const StylePropertySet* properties() const { return m_properties.get(); } - MutableStylePropertySet* mutableProperties(); + const StylePropertySet& properties() const { return *m_properties; } + MutableStylePropertySet& mutableProperties(); void setProperties(PassRefPtr<StylePropertySet>); - PassRefPtr<StyleRuleViewport> copy() const { return adoptRef(new StyleRuleViewport(*this)); } + PassRefPtrWillBeRawPtr<StyleRuleViewport> copy() const { return adoptRefWillBeNoop(new StyleRuleViewport(*this)); } + + void traceAfterDispatch(Visitor* visitor) { StyleRuleBase::traceAfterDispatch(visitor); } private: StyleRuleViewport(); StyleRuleViewport(const StyleRuleViewport&); - RefPtr<StylePropertySet> m_properties; + RefPtr<StylePropertySet> m_properties; // Cannot be null }; class StyleRuleFilter : public StyleRuleBase { public: - static PassRefPtr<StyleRuleFilter> create(const String& filterName) { return adoptRef(new StyleRuleFilter(filterName)); } + static PassRefPtrWillBeRawPtr<StyleRuleFilter> create(const String& filterName) { return adoptRefWillBeNoop(new StyleRuleFilter(filterName)); } ~StyleRuleFilter(); const String& filterName() const { return m_filterName; } - const StylePropertySet* properties() const { return m_properties.get(); } - MutableStylePropertySet* mutableProperties(); + const StylePropertySet& properties() const { return *m_properties; } + MutableStylePropertySet& mutableProperties(); void setProperties(PassRefPtr<StylePropertySet>); - PassRefPtr<StyleRuleFilter> copy() const { return adoptRef(new StyleRuleFilter(*this)); } + PassRefPtrWillBeRawPtr<StyleRuleFilter> copy() const { return adoptRefWillBeNoop(new StyleRuleFilter(*this)); } + + void traceAfterDispatch(Visitor* visitor) { StyleRuleBase::traceAfterDispatch(visitor); } private: StyleRuleFilter(const String&); @@ -285,7 +288,6 @@ DEFINE_STYLE_RULE_TYPE_CASTS(FontFace); DEFINE_STYLE_RULE_TYPE_CASTS(Page); DEFINE_STYLE_RULE_TYPE_CASTS(Media); DEFINE_STYLE_RULE_TYPE_CASTS(Supports); -DEFINE_STYLE_RULE_TYPE_CASTS(Region); DEFINE_STYLE_RULE_TYPE_CASTS(Viewport); DEFINE_STYLE_RULE_TYPE_CASTS(Filter); |