Chromium Code Reviews

Unified Diff: Source/core/css/CSSComputedStyleDeclaration.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.
Jump to:
View side-by-side diff with in-line comments
Index: Source/core/css/CSSComputedStyleDeclaration.cpp
diff --git a/Source/core/css/CSSComputedStyleDeclaration.cpp b/Source/core/css/CSSComputedStyleDeclaration.cpp
index dd2e82d38908db2c89904c793b053b3e464b3a1c..9f1a5902179c3f8c7fb381f29511906043065858 100644
--- a/Source/core/css/CSSComputedStyleDeclaration.cpp
+++ b/Source/core/css/CSSComputedStyleDeclaration.cpp
@@ -3168,10 +3168,11 @@ String CSSComputedStyleDeclaration::variableValue(const AtomicString& name) cons
return it->value;
}
-void CSSComputedStyleDeclaration::setVariableValue(const AtomicString& name, const String&, ExceptionState& es)
+bool CSSComputedStyleDeclaration::setVariableValue(const AtomicString& name, const String&, ExceptionState& es)
{
ASSERT(RuntimeEnabledFeatures::cssVariablesEnabled());
es.throwDOMException(NoModificationAllowedError, "Failed to set the '" + name + "' property on a computed 'CSSStyleDeclaration': computed styles are read-only.");
+ return false;
}
bool CSSComputedStyleDeclaration::removeVariable(const AtomicString&)
@@ -3180,10 +3181,40 @@ bool CSSComputedStyleDeclaration::removeVariable(const AtomicString&)
return false;
}
-void CSSComputedStyleDeclaration::clearVariables(ExceptionState& es)
+bool CSSComputedStyleDeclaration::clearVariables(ExceptionState& es)
{
ASSERT(RuntimeEnabledFeatures::cssVariablesEnabled());
es.throwDOMException(NoModificationAllowedError, "Failed to clear variables from a computed 'CSSStyleDeclaration': computed styles are read-only.");
+ return false;
+}
+
+CSSComputedStyleDeclaration::ComputedCSSVariablesIterator::ComputedCSSVariablesIterator(const HashMap<AtomicString, String>* variables)
+ : m_active(variables)
+{
+ ASSERT(RuntimeEnabledFeatures::cssVariablesEnabled());
+ if (m_active) {
+ m_it = variables->begin();
+ m_end = variables->end();
+ }
+}
+
+void CSSComputedStyleDeclaration::ComputedCSSVariablesIterator::advance()
+{
+ ASSERT(m_active);
+ ++m_it;
+ m_active = !atEnd();
+}
+
+AtomicString CSSComputedStyleDeclaration::ComputedCSSVariablesIterator::name() const
+{
+ ASSERT(m_active);
+ return m_it->key;
+}
+
+String CSSComputedStyleDeclaration::ComputedCSSVariablesIterator::value() const
+{
+ ASSERT(m_active);
+ return m_it->value;
}
PassRefPtr<CSSValueList> CSSComputedStyleDeclaration::valuesForBackgroundShorthand() const

Powered by Google App Engine