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

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

Issue 21006006: Add forEach() to CSSVariablesMap (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Corrected test expectations Created 7 years, 3 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
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));
« Source/bindings/scripts/v8_utilities.py ('K') | « Source/core/css/StylePropertySet.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698