Chromium Code Reviews| Index: Source/core/css/CSSPropertySourceData.h |
| diff --git a/Source/core/css/CSSPropertySourceData.h b/Source/core/css/CSSPropertySourceData.h |
| index b5d51e21312990709ae308a4fa310391221f640b..f211b0344dd756b1f8e442e629814803b6305cf7 100644 |
| --- a/Source/core/css/CSSPropertySourceData.h |
| +++ b/Source/core/css/CSSPropertySourceData.h |
| @@ -31,6 +31,7 @@ |
| #ifndef CSSPropertySourceData_h |
| #define CSSPropertySourceData_h |
| +#include "heap/Handle.h" |
| #include "wtf/Forward.h" |
| #include "wtf/RefCounted.h" |
| #include "wtf/Vector.h" |
| @@ -41,17 +42,21 @@ namespace WebCore { |
| class StyleRuleBase; |
| struct SourceRange { |
| + ALLOW_ONLY_INLINE_ALLOCATION(); |
| +public: |
| SourceRange(); |
| SourceRange(unsigned start, unsigned end); |
| unsigned length() const; |
| + void trace(Visitor*) { } |
| + |
| unsigned start; |
| unsigned end; |
| }; |
| struct CSSPropertySourceData { |
| - static void init(); |
| - |
| + ALLOW_ONLY_INLINE_ALLOCATION(); |
| +public: |
| CSSPropertySourceData(const String& name, const String& value, bool important, bool disabled, bool parsedOk, const SourceRange& range); |
| CSSPropertySourceData(const CSSPropertySourceData& other); |
| CSSPropertySourceData(); |
| @@ -59,6 +64,8 @@ struct CSSPropertySourceData { |
| String toString() const; |
| unsigned hash() const; |
| + void trace(Visitor* visitor) { visitor->trace(range); } |
| + |
| String name; |
| String value; |
| bool important; |
| @@ -67,24 +74,22 @@ struct CSSPropertySourceData { |
| SourceRange range; |
| }; |
| -#ifndef CSSPROPERTYSOURCEDATA_HIDE_GLOBALS |
| -extern const CSSPropertySourceData emptyCSSPropertySourceData; |
| -#endif |
| - |
| -struct CSSStyleSourceData : public RefCounted<CSSStyleSourceData> { |
| - static PassRefPtr<CSSStyleSourceData> create() |
| +struct CSSStyleSourceData : public RefCountedWillBeGarbageCollected<CSSStyleSourceData> { |
| + static PassRefPtrWillBeRawPtr<CSSStyleSourceData> create() |
| { |
| - return adoptRef(new CSSStyleSourceData()); |
| + return adoptRefWillBeNoop(new CSSStyleSourceData()); |
| } |
| - Vector<CSSPropertySourceData> propertyData; |
| + void trace(Visitor* visitor) { visitor->trace(propertyData); } |
| + |
| + WillBeHeapVector<CSSPropertySourceData> propertyData; |
| }; |
| struct CSSRuleSourceData; |
| -typedef Vector<RefPtr<CSSRuleSourceData> > RuleSourceDataList; |
| -typedef Vector<SourceRange> SelectorRangeList; |
| +typedef WillBeHeapVector<RefPtrWillBeMember<CSSRuleSourceData> > RuleSourceDataList; |
| +typedef WillBeHeapVector<SourceRange> SelectorRangeList; |
| -struct CSSRuleSourceData : public RefCounted<CSSRuleSourceData> { |
| +struct CSSRuleSourceData : public RefCountedWillBeGarbageCollectedFinalized<CSSRuleSourceData> { |
|
haraken
2014/03/28 14:15:00
Can this be RefCountedWillBeGarbageCollected?
wibling-chromium
2014/03/31 09:38:28
Yes, done.
|
| enum Type { |
| UNKNOWN_RULE, |
| STYLE_RULE, |
| @@ -99,14 +104,14 @@ struct CSSRuleSourceData : public RefCounted<CSSRuleSourceData> { |
| FILTER_RULE |
| }; |
| - static PassRefPtr<CSSRuleSourceData> create(Type type) |
| + static PassRefPtrWillBeRawPtr<CSSRuleSourceData> create(Type type) |
| { |
| - return adoptRef(new CSSRuleSourceData(type)); |
| + return adoptRefWillBeNoop(new CSSRuleSourceData(type)); |
| } |
| - static PassRefPtr<CSSRuleSourceData> createUnknown() |
| + static PassRefPtrWillBeRawPtr<CSSRuleSourceData> createUnknown() |
| { |
| - return adoptRef(new CSSRuleSourceData(UNKNOWN_RULE)); |
| + return adoptRefWillBeNoop(new CSSRuleSourceData(UNKNOWN_RULE)); |
| } |
| CSSRuleSourceData(Type type) |
| @@ -116,6 +121,8 @@ struct CSSRuleSourceData : public RefCounted<CSSRuleSourceData> { |
| styleSourceData = CSSStyleSourceData::create(); |
| } |
| + void trace(Visitor*); |
| + |
| Type type; |
| // Range of the selector list in the enclosing source. |
| @@ -128,7 +135,7 @@ struct CSSRuleSourceData : public RefCounted<CSSRuleSourceData> { |
| SelectorRangeList selectorRanges; |
| // Only for CSSStyleRules, CSSFontFaceRules, and CSSPageRules. |
| - RefPtr<CSSStyleSourceData> styleSourceData; |
| + RefPtrWillBeMember<CSSStyleSourceData> styleSourceData; |
| // Only for CSSMediaRules. |
| RuleSourceDataList childRules; |
| @@ -136,4 +143,17 @@ struct CSSRuleSourceData : public RefCounted<CSSRuleSourceData> { |
| } // namespace WebCore |
| +namespace WTF { |
| + |
| +template <> struct VectorTraits<WebCore::SourceRange> : VectorTraitsBase<WebCore::SourceRange> { |
| + static const bool canInitializeWithMemset = true; |
| + static const bool canMoveWithMemcpy = true; |
| +}; |
| + |
| +template <> struct VectorTraits<WebCore::CSSPropertySourceData> : VectorTraitsBase<WebCore::CSSPropertySourceData> { |
| + static const bool canInitializeWithMemset = true; |
|
haraken
2014/03/28 14:15:00
Why don't you need:
static const bool canMoveWi
wibling-chromium
2014/03/31 09:38:28
We cannot use memcpy to copy the CSSPropertySource
|
| +}; |
| + |
| +} |
| + |
| #endif // CSSPropertySourceData_h |