Chromium Code Reviews| Index: Source/core/css/StylePropertySet.h |
| diff --git a/Source/core/css/StylePropertySet.h b/Source/core/css/StylePropertySet.h |
| index 50087aa3b2e7c5ba6c934eadbee7723791eb94db..cf33f4afa004abb34d02338ac8b6168b02658784 100644 |
| --- a/Source/core/css/StylePropertySet.h |
| +++ b/Source/core/css/StylePropertySet.h |
| @@ -41,12 +41,17 @@ class MutableStylePropertySet; |
| class StylePropertyShorthand; |
| class StyleSheetContents; |
| -class StylePropertySet : public RefCounted<StylePropertySet> { |
| +class StylePropertySet : public RefCountedWillBeRefCountedGarbageCollected<StylePropertySet> { |
| friend class PropertyReference; |
| public: |
| + |
| +#if !ENABLE(OILPAN) |
| // Override RefCounted's deref() to ensure operator delete is called on |
| // the appropriate subclass type. |
| + // When oilpan is enabled there is no need for the destructors since the |
| + // memory management will be handled by the garbage collector. |
| void deref(); |
|
Mads Ager (chromium)
2014/03/06 13:30:10
I think you need to have a finalize method then? I
wibling-chromium
2014/03/06 13:34:36
Thanks for catching that. I had missed the OwnPtr.
|
| +#endif |
| class PropertyReference { |
| public: |
| @@ -117,6 +122,9 @@ public: |
| bool propertyMatches(CSSPropertyID, const CSSValue*) const; |
| + void trace(Visitor*); |
| + void traceAfterDispatch(Visitor*) { } |
| + |
| protected: |
| enum { MaxArraySize = (1 << 28) - 1 }; |
| @@ -142,29 +150,38 @@ protected: |
| class ImmutableStylePropertySet : public StylePropertySet { |
| public: |
| +#if !ENABLE(OILPAN) |
| ~ImmutableStylePropertySet(); |
| +#endif |
| static PassRefPtr<ImmutableStylePropertySet> create(const CSSProperty* properties, unsigned count, CSSParserMode); |
| unsigned propertyCount() const { return m_arraySize; } |
| - const CSSValue** valueArray() const; |
| + const RawPtrWillBeMember<CSSValue>* valueArray() const; |
| const StylePropertyMetadata* metadataArray() const; |
| int findPropertyIndex(CSSPropertyID) const; |
| + void traceAfterDispatch(Visitor*); |
| + |
| + void* operator new(std::size_t, void* location) |
| + { |
| + return location; |
| + } |
| + |
| void* m_storage; |
| private: |
| ImmutableStylePropertySet(const CSSProperty*, unsigned count, CSSParserMode); |
| }; |
| -inline const CSSValue** ImmutableStylePropertySet::valueArray() const |
| +inline const RawPtrWillBeMember<CSSValue>* ImmutableStylePropertySet::valueArray() const |
| { |
| - return reinterpret_cast<const CSSValue**>(const_cast<const void**>(&(this->m_storage))); |
| + return reinterpret_cast<const RawPtrWillBeMember<CSSValue>*>(const_cast<const void**>(&(this->m_storage))); |
| } |
| inline const StylePropertyMetadata* ImmutableStylePropertySet::metadataArray() const |
| { |
| - return reinterpret_cast<const StylePropertyMetadata*>(&reinterpret_cast<const char*>(&(this->m_storage))[m_arraySize * sizeof(CSSValue*)]); |
| + return reinterpret_cast<const StylePropertyMetadata*>(&reinterpret_cast<const char*>(&(this->m_storage))[m_arraySize * sizeof(RawPtrWillBeMember<CSSValue>)]); |
| } |
| DEFINE_TYPE_CASTS(ImmutableStylePropertySet, StylePropertySet, set, !set->isMutable(), !set.isMutable()); |
| @@ -176,13 +193,15 @@ inline ImmutableStylePropertySet* toImmutableStylePropertySet(const RefPtr<Style |
| class MutableStylePropertySet : public StylePropertySet { |
| public: |
| +#if !ENABLE(OILPAN) |
| ~MutableStylePropertySet() { } |
| +#endif |
| static PassRefPtr<MutableStylePropertySet> create(CSSParserMode = HTMLQuirksMode); |
| static PassRefPtr<MutableStylePropertySet> create(const CSSProperty* properties, unsigned count); |
| unsigned propertyCount() const { return m_propertyVector.size(); } |
| - void addParsedProperties(const Vector<CSSProperty, 256>&); |
| + void addParsedProperties(const WillBeHeapVector<CSSProperty, 256>&); |
| void addParsedProperty(const CSSProperty&); |
| // These expand shorthand properties into multiple properties. |
| @@ -211,6 +230,8 @@ public: |
| CSSStyleDeclaration* ensureCSSStyleDeclaration(); |
| int findPropertyIndex(CSSPropertyID) const; |
| + void traceAfterDispatch(Visitor*); |
| + |
| private: |
| explicit MutableStylePropertySet(CSSParserMode); |
| explicit MutableStylePropertySet(const StylePropertySet&); |
| @@ -222,7 +243,7 @@ private: |
| friend class StylePropertySet; |
| - Vector<CSSProperty, 4> m_propertyVector; |
| + WillBeHeapVector<CSSProperty, 4> m_propertyVector; |
| }; |
| DEFINE_TYPE_CASTS(MutableStylePropertySet, StylePropertySet, set, set->isMutable(), set.isMutable()); |
| @@ -258,6 +279,7 @@ inline bool StylePropertySet::isEmpty() const |
| return !propertyCount(); |
| } |
| +#if !ENABLE(OILPAN) |
| inline void StylePropertySet::deref() |
| { |
| if (!derefBase()) |
| @@ -268,6 +290,7 @@ inline void StylePropertySet::deref() |
| else |
| delete toImmutableStylePropertySet(this); |
| } |
| +#endif // !ENABLE(OILPAN) |
| inline int StylePropertySet::findPropertyIndex(CSSPropertyID propertyID) const |
| { |