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

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

Issue 21006006: Add forEach() to CSSVariablesMap (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 7 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
Index: Source/core/css/CSSVariablesMap.cpp
diff --git a/Source/core/css/CSSVariablesMap.cpp b/Source/core/css/CSSVariablesMap.cpp
index a104e43e7d8d1080cc6b33d88576f9ccc234438e..380696282a3b368a2c2c5c8a0c3da8d751689d21 100644
--- a/Source/core/css/CSSVariablesMap.cpp
+++ b/Source/core/css/CSSVariablesMap.cpp
@@ -73,4 +73,30 @@ void CSSVariablesMap::clear(ExceptionCode& ec) const
return m_styleDeclaration->clearVariables(ec);
}
+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