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

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

Issue 21006006: Add forEach() to CSSVariablesMap (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Generator & test nits Created 7 years, 4 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/CSSVariablesMap.cpp
diff --git a/Source/core/css/CSSVariablesMap.cpp b/Source/core/css/CSSVariablesMap.cpp
index 599a9dca63968fd571a71c0b2611833ad770ba76..4345d53e439c52ddd744d850dd0255328a87e7cb 100644
--- a/Source/core/css/CSSVariablesMap.cpp
+++ b/Source/core/css/CSSVariablesMap.cpp
@@ -74,4 +74,30 @@ void CSSVariablesMap::clear(ExceptionState& es) const
return m_styleDeclaration->clearVariables(es);
}
+void CSSVariablesMap::forEach(PassRefPtr<CSSVariablesMapForEachCallback> callback, ScriptValue* thisArg) const
+{
+ if (!m_styleDeclaration)
+ return;
+ RefPtr<CSSVariablesIterator> iterator = m_styleDeclaration->variablesIterator();
+ while (!iterator->atEnd()) {
+ String name = iterator->name();
+ String value = iterator->value();
+ if (thisArg)
+ callback->handleItem(*thisArg, value, name, const_cast<CSSVariablesMap*>(this));
+ else
+ callback->handleItem(value, name, const_cast<CSSVariablesMap*>(this));
+ iterator->advance();
+ }
+}
+
+void CSSVariablesMap::forEach(PassRefPtr<CSSVariablesMapForEachCallback> callback, ScriptValue thisArg) const
+{
+ forEach(callback, &thisArg);
+}
+
+void CSSVariablesMap::forEach(PassRefPtr<CSSVariablesMapForEachCallback> callback) const
+{
+ forEach(callback, 0);
+}
+
} // namespace WebCore

Powered by Google App Engine
This is Rietveld 408576698