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

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

Issue 1164573002: CSSValue Immediates: Change CSSValue to an object instead of a pointer (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Rebase Created 5 years, 5 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/CSSParser.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 3d2c8f737a19d8f0daa014857a884dc053040963..4faea219044b1a2edac335dcdd63184cc360f449 100644
--- a/Source/core/css/StylePropertySet.cpp
+++ b/Source/core/css/StylePropertySet.cpp
@@ -81,24 +81,20 @@ ImmutableStylePropertySet::ImmutableStylePropertySet(const CSSProperty* properti
: StylePropertySet(cssParserMode, length)
{
StylePropertyMetadata* metadataArray = const_cast<StylePropertyMetadata*>(this->metadataArray());
- RawPtrWillBeMember<CSSValue>* valueArray = const_cast<RawPtrWillBeMember<CSSValue>*>(this->valueArray());
+ CSSValue* valueArray = const_cast<CSSValue*>(this->valueArray());
for (unsigned i = 0; i < m_arraySize; ++i) {
metadataArray[i] = properties[i].metadata();
- valueArray[i] = properties[i].value();
-#if !ENABLE(OILPAN)
- valueArray[i]->ref();
-#endif
+ // Can't use operator= here since valueArray[i] is an invalid CSSValue.
+ new(&valueArray[i]) CSSValue(properties[i].value());
}
}
ImmutableStylePropertySet::~ImmutableStylePropertySet()
{
#if !ENABLE(OILPAN)
- RawPtrWillBeMember<CSSValue>* valueArray = const_cast<RawPtrWillBeMember<CSSValue>*>(this->valueArray());
+ CSSValue* valueArray = const_cast<CSSValue*>(this->valueArray());
for (unsigned i = 0; i < m_arraySize; ++i) {
- // Checking for nullptr here is a workaround to prevent crashing. http://crbug.com/449032
- if (valueArray[i])
- valueArray[i]->deref();
+ valueArray[i].~CSSValue();
}
#endif
}
@@ -121,7 +117,7 @@ int ImmutableStylePropertySet::findPropertyIndex(CSSPropertyID propertyID) const
DEFINE_TRACE_AFTER_DISPATCH(ImmutableStylePropertySet)
{
- const RawPtrWillBeMember<CSSValue>* values = valueArray();
+ const CSSValue* values = valueArray();
for (unsigned i = 0; i < m_arraySize; i++)
visitor->trace(values[i]);
StylePropertySet::traceAfterDispatch(visitor);
@@ -141,14 +137,14 @@ MutableStylePropertySet::MutableStylePropertySet(const StylePropertySet& other)
String StylePropertySet::getPropertyValue(CSSPropertyID propertyID) const
{
- RefPtrWillBeRawPtr<CSSValue> value = getPropertyCSSValue(propertyID);
+ NullableCSSValue value = getPropertyCSSValue(propertyID);
if (value)
return value->cssText();
return StylePropertySerializer(*this).getPropertyValue(propertyID);
}
-PassRefPtrWillBeRawPtr<CSSValue> StylePropertySet::getPropertyCSSValue(CSSPropertyID propertyID) const
+NullableCSSValue StylePropertySet::getPropertyCSSValue(CSSPropertyID propertyID) const
{
int foundPropertyIndex = findPropertyIndex(propertyID);
if (foundPropertyIndex == -1)
@@ -200,7 +196,7 @@ bool MutableStylePropertySet::removeProperty(CSSPropertyID propertyID, String* r
}
if (returnText)
- *returnText = propertyAt(foundPropertyIndex).value()->cssText();
+ *returnText = propertyAt(foundPropertyIndex).value().cssText();
// A more efficient removal strategy would involve marking entries as empty
// and sweeping them when the vector grows too big.
@@ -254,7 +250,7 @@ bool MutableStylePropertySet::setProperty(CSSPropertyID unresolvedProperty, cons
return CSSParser::parseValue(this, unresolvedProperty, value, important, cssParserMode(), contextStyleSheet);
}
-void MutableStylePropertySet::setProperty(CSSPropertyID propertyID, PassRefPtrWillBeRawPtr<CSSValue> prpValue, bool important)
+void MutableStylePropertySet::setProperty(CSSPropertyID propertyID, CSSValue prpValue, bool important)
{
StylePropertyShorthand shorthand = shorthandForProperty(propertyID);
if (!shorthand.length()) {
@@ -264,7 +260,7 @@ void MutableStylePropertySet::setProperty(CSSPropertyID propertyID, PassRefPtrWi
removePropertiesInSet(shorthand.properties(), shorthand.length());
- RefPtrWillBeRawPtr<CSSValue> value = prpValue;
+ CSSValue value = prpValue;
for (unsigned i = 0; i < shorthand.length(); ++i)
m_propertyVector.append(CSSProperty(shorthand.properties()[i], value, important));
}
@@ -342,7 +338,7 @@ bool StylePropertySet::hasFailedOrCanceledSubresources() const
{
unsigned size = propertyCount();
for (unsigned i = 0; i < size; ++i) {
- if (propertyAt(i).value()->hasFailedOrCanceledSubresources())
+ if (propertyAt(i).value().hasFailedOrCanceledSubresources())
return true;
}
return false;
@@ -392,12 +388,12 @@ CSSProperty* MutableStylePropertySet::findCSSPropertyWithID(CSSPropertyID proper
return &m_propertyVector.at(foundPropertyIndex);
}
-bool StylePropertySet::propertyMatches(CSSPropertyID propertyID, const CSSValue* propertyValue) const
+bool StylePropertySet::propertyMatches(CSSPropertyID propertyID, const CSSValue propertyValue) const
{
int foundPropertyIndex = findPropertyIndex(propertyID);
if (foundPropertyIndex == -1)
return false;
- return propertyAt(foundPropertyIndex).value()->equals(*propertyValue);
+ return propertyAt(foundPropertyIndex).value().equals(propertyValue);
}
void MutableStylePropertySet::removeEquivalentProperties(const StylePropertySet* style)
@@ -438,9 +434,9 @@ PassRefPtrWillBeRawPtr<MutableStylePropertySet> StylePropertySet::copyProperties
WillBeHeapVector<CSSProperty, 256> list;
list.reserveInitialCapacity(properties.size());
for (unsigned i = 0; i < properties.size(); ++i) {
- RefPtrWillBeRawPtr<CSSValue> value = getPropertyCSSValue(properties[i]);
+ NullableCSSValue value = getPropertyCSSValue(properties[i]);
if (value)
- list.append(CSSProperty(properties[i], value.release(), false));
+ list.append(CSSProperty(properties[i], *value, false));
}
return MutableStylePropertySet::create(list.data(), list.size());
}
« no previous file with comments | « Source/core/css/StylePropertySet.h ('k') | Source/core/css/parser/CSSParser.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698