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

Unified Diff: Source/core/css/StylePropertySet.cpp

Issue 184313004: Move all RefPtr's to CSSValue to oilpan transition types, except for the one in CSSCursorImageValue. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Fix comment 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/core/css/StylePropertySet.h ('k') | Source/core/css/parser/BisonCSSParser.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/css/StylePropertySet.cpp
diff --git a/Source/core/css/StylePropertySet.cpp b/Source/core/css/StylePropertySet.cpp
index c1e5893137ce023448a6eafc49d029ed8e6cedc3..f94d908a511f1579007bff5ec2493fc5ff3f4ae4 100644
--- a/Source/core/css/StylePropertySet.cpp
+++ b/Source/core/css/StylePropertySet.cpp
@@ -50,8 +50,12 @@ static size_t sizeForImmutableStylePropertySetWithPropertyCount(unsigned count)
PassRefPtr<ImmutableStylePropertySet> ImmutableStylePropertySet::create(const CSSProperty* properties, unsigned count, CSSParserMode cssParserMode)
{
ASSERT(count <= MaxArraySize);
+#if ENABLE(OILPAN)
+ void* slot = Heap::allocate<StylePropertySet>(sizeForImmutableStylePropertySetWithPropertyCount(count));
+#else
void* slot = WTF::fastMalloc(sizeForImmutableStylePropertySetWithPropertyCount(count));
- return adoptRef(new (slot) ImmutableStylePropertySet(properties, count, cssParserMode));
+#endif // ENABLE(OILPAN)
+ return adoptRefWillBeRefCountedGarbageCollected(new (slot) ImmutableStylePropertySet(properties, count, cssParserMode));
}
PassRefPtr<ImmutableStylePropertySet> StylePropertySet::immutableCopyIfNeeded() const
@@ -79,7 +83,7 @@ ImmutableStylePropertySet::ImmutableStylePropertySet(const CSSProperty* properti
: StylePropertySet(cssParserMode, length)
{
StylePropertyMetadata* metadataArray = const_cast<StylePropertyMetadata*>(this->metadataArray());
- CSSValue** valueArray = const_cast<CSSValue**>(this->valueArray());
+ RawPtrWillBeMember<CSSValue>* valueArray = const_cast<RawPtrWillBeMember<CSSValue>*>(this->valueArray());
for (unsigned i = 0; i < m_arraySize; ++i) {
metadataArray[i] = properties[i].metadata();
valueArray[i] = properties[i].value();
@@ -89,9 +93,11 @@ ImmutableStylePropertySet::ImmutableStylePropertySet(const CSSProperty* properti
ImmutableStylePropertySet::~ImmutableStylePropertySet()
{
- CSSValue** valueArray = const_cast<CSSValue**>(this->valueArray());
+#if !ENABLE(OILPAN)
+ RawPtrWillBeMember<CSSValue>* valueArray = const_cast<RawPtrWillBeMember<CSSValue>*>(this->valueArray());
for (unsigned i = 0; i < m_arraySize; ++i)
valueArray[i]->deref();
+#endif
}
int ImmutableStylePropertySet::findPropertyIndex(CSSPropertyID propertyID) const
@@ -110,6 +116,14 @@ int ImmutableStylePropertySet::findPropertyIndex(CSSPropertyID propertyID) const
return -1;
}
+void ImmutableStylePropertySet::traceAfterDispatch(Visitor* visitor)
+{
+ const RawPtrWillBeMember<CSSValue>* values = valueArray();
+ for (unsigned i = 0; i < m_arraySize; i++)
+ visitor->trace(values[i]);
+ StylePropertySet::traceAfterDispatch(visitor);
+}
+
MutableStylePropertySet::MutableStylePropertySet(const StylePropertySet& other)
: StylePropertySet(other.cssParserMode())
{
@@ -139,6 +153,22 @@ PassRefPtrWillBeRawPtr<CSSValue> StylePropertySet::getPropertyCSSValue(CSSProper
return propertyAt(foundPropertyIndex).value();
}
+void StylePropertySet::trace(Visitor* visitor)
+{
+ if (m_isMutable)
+ toMutableStylePropertySet(this)->traceAfterDispatch(visitor);
+ else
+ toImmutableStylePropertySet(this)->traceAfterDispatch(visitor);
+}
+
+void StylePropertySet::finalize()
+{
+ if (m_isMutable)
+ toMutableStylePropertySet(this)->~MutableStylePropertySet();
+ else
+ toImmutableStylePropertySet(this)->~ImmutableStylePropertySet();
+}
+
bool MutableStylePropertySet::removeShorthandProperty(CSSPropertyID propertyID)
{
StylePropertyShorthand shorthand = shorthandForProperty(propertyID);
@@ -319,7 +349,7 @@ void MutableStylePropertySet::parseDeclaration(const String& styleDeclaration, S
parser.parseDeclaration(this, styleDeclaration, 0, contextStyleSheet);
}
-void MutableStylePropertySet::addParsedProperties(const Vector<CSSProperty, 256>& properties)
+void MutableStylePropertySet::addParsedProperties(const WillBeHeapVector<CSSProperty, 256>& properties)
{
m_propertyVector.reserveCapacity(m_propertyVector.size() + properties.size());
for (unsigned i = 0; i < properties.size(); ++i)
@@ -419,7 +449,7 @@ bool MutableStylePropertySet::removePropertiesInSet(const CSSPropertyID* set, un
for (unsigned i = 0; i < length; ++i)
toRemove.add(set[i]);
- Vector<CSSProperty> newProperties;
+ WillBeHeapVector<CSSProperty> newProperties;
newProperties.reserveInitialCapacity(m_propertyVector.size());
unsigned size = m_propertyVector.size();
@@ -484,12 +514,12 @@ void MutableStylePropertySet::removeEquivalentProperties(const CSSStyleDeclarati
PassRefPtr<MutableStylePropertySet> StylePropertySet::mutableCopy() const
{
- return adoptRef(new MutableStylePropertySet(*this));
+ return adoptRefWillBeRefCountedGarbageCollected(new MutableStylePropertySet(*this));
}
PassRefPtr<MutableStylePropertySet> StylePropertySet::copyPropertiesInSet(const Vector<CSSPropertyID>& properties) const
{
- Vector<CSSProperty, 256> list;
+ WillBeHeapVector<CSSProperty, 256> list;
list.reserveInitialCapacity(properties.size());
for (unsigned i = 0; i < properties.size(); ++i) {
RefPtrWillBeRawPtr<CSSValue> value = getPropertyCSSValue(properties[i]);
@@ -528,6 +558,12 @@ int MutableStylePropertySet::findPropertyIndex(CSSPropertyID propertyID) const
return -1;
}
+void MutableStylePropertySet::traceAfterDispatch(Visitor* visitor)
+{
+ visitor->trace(m_propertyVector);
+ StylePropertySet::traceAfterDispatch(visitor);
+}
+
unsigned StylePropertySet::averageSizeInBytes()
{
// Please update this if the storage scheme changes so that this longer reflects the actual size.
@@ -535,7 +571,7 @@ unsigned StylePropertySet::averageSizeInBytes()
}
// See the function above if you need to update this.
-struct SameSizeAsStylePropertySet : public RefCounted<SameSizeAsStylePropertySet> {
+struct SameSizeAsStylePropertySet : public RefCountedWillBeRefCountedGarbageCollected<SameSizeAsStylePropertySet> {
unsigned bitfield;
};
COMPILE_ASSERT(sizeof(StylePropertySet) == sizeof(SameSizeAsStylePropertySet), style_property_set_should_stay_small);
@@ -549,12 +585,12 @@ void StylePropertySet::showStyle()
PassRefPtr<MutableStylePropertySet> MutableStylePropertySet::create(CSSParserMode cssParserMode)
{
- return adoptRef(new MutableStylePropertySet(cssParserMode));
+ return adoptRefWillBeRefCountedGarbageCollected(new MutableStylePropertySet(cssParserMode));
}
PassRefPtr<MutableStylePropertySet> MutableStylePropertySet::create(const CSSProperty* properties, unsigned count)
{
- return adoptRef(new MutableStylePropertySet(properties, count));
+ return adoptRefWillBeRefCountedGarbageCollected(new MutableStylePropertySet(properties, count));
}
String StylePropertySet::PropertyReference::cssName() const
« no previous file with comments | « Source/core/css/StylePropertySet.h ('k') | Source/core/css/parser/BisonCSSParser.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698