Index: Source/core/css/StylePropertySet.cpp |
diff --git a/Source/core/css/StylePropertySet.cpp b/Source/core/css/StylePropertySet.cpp |
index 7f906ea77f85182dee7ba68b808a1259be93c1b6..5b30a442e17f8198dfb8ee10b109c6d7b819459b 100644 |
--- a/Source/core/css/StylePropertySet.cpp |
+++ b/Source/core/css/StylePropertySet.cpp |
@@ -285,17 +285,18 @@ bool MutableStylePropertySet::setVariableValue(const AtomicString& name, const S |
size_t index = findVariableIndex(name); |
if (index != notFound) { |
- CSSValue* cssValue = m_propertyVector.at(index).value(); |
+ const CSSValue* cssValue = m_propertyVector.at(index).value(); |
if (toCSSVariableValue(cssValue)->value() == value) |
return false; |
} |
CSSProperty property(CSSPropertyVariable, CSSVariableValue::create(name, value), important); |
- if (index == notFound) |
+ if (index == notFound) { |
m_propertyVector.append(property); |
- else |
- m_propertyVector.at(index) = property; |
- return true; |
+ return true; |
+ } |
+ m_propertyVector.at(index) = property; |
+ return false; |
} |
void MutableStylePropertySet::appendPrefixingVariantProperty(const CSSProperty& property) |
@@ -562,6 +563,56 @@ bool MutableStylePropertySet::clearVariables() |
return removePropertiesInSet(&variablesId, 1); |
} |
+PassRefPtr<MutableStylePropertySet::VariablesIterator> MutableStylePropertySet::VariablesIterator::create(MutableStylePropertySet* propertySet) |
+{ |
+ ASSERT(RuntimeEnabledFeatures::cssVariablesEnabled()); |
+ RefPtr<VariablesIterator> iterator = adoptRef(new VariablesIterator(propertySet)); |
esprehn
2013/09/28 00:44:36
Instead of all this accessing of private vars like
alancutter (OOO until 2018)
2013/09/30 02:54:52
Done.
|
+ const size_t propertyCount = propertySet->propertyCount(); |
+ size_t variableCount = 0; |
+ iterator->m_remainingNames.resize(propertyCount); |
+ for (int i = propertyCount; i--;) { |
esprehn
2013/09/28 00:44:36
missing space after ;
alancutter (OOO until 2018)
2013/09/30 02:54:52
Done.
|
+ const PropertyReference& property = propertySet->propertyAt(i); |
+ if (property.id() == CSSPropertyVariable) |
+ iterator->m_remainingNames[variableCount++] = toCSSVariableValue(property.value())->name(); |
+ } |
+ iterator->m_remainingNames.shrink(variableCount); |
+ |
+ return iterator.release(); |
+} |
+ |
+void MutableStylePropertySet::VariablesIterator::addedVariable(const AtomicString& name) |
+{ |
+ ASSERT(!m_remainingNames.contains(name)); |
+ ASSERT(!m_newNames.contains(name)); |
+ m_newNames.append(name); |
+} |
+ |
+void MutableStylePropertySet::VariablesIterator::removedVariable(const AtomicString& name) |
+{ |
+ size_t index = m_remainingNames.find(name); |
+ if (index != notFound) |
+ m_remainingNames.remove(index); |
+ index = m_newNames.find(name); |
+ if (index != notFound) |
+ m_newNames.remove(index); |
+} |
+ |
+void MutableStylePropertySet::VariablesIterator::clearedVariables() |
+{ |
+ m_remainingNames.clear(); |
+ m_newNames.clear(); |
+} |
+ |
+void MutableStylePropertySet::VariablesIterator::advance() |
+{ |
+ if (!atEnd()) |
+ m_remainingNames.removeLast(); |
+ if (!m_newNames.isEmpty()) { |
+ m_remainingNames.appendVector(m_newNames); |
+ m_newNames.clear(); |
+ } |
+} |
+ |
PassRefPtr<MutableStylePropertySet> StylePropertySet::mutableCopy() const |
{ |
return adoptRef(new MutableStylePropertySet(*this)); |