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

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

Issue 18311002: Partial implementation of CSSVariablesMap for CSS Variables CSSOM (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Minor optimisation to clearVariables 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/CSSComputedStyleDeclaration.cpp
diff --git a/Source/core/css/CSSComputedStyleDeclaration.cpp b/Source/core/css/CSSComputedStyleDeclaration.cpp
index a5fb17fd6a9e5cd6effddd361e355746e08fb920..353acb026df472460b50df6d620780ed76fc0c51 100644
--- a/Source/core/css/CSSComputedStyleDeclaration.cpp
+++ b/Source/core/css/CSSComputedStyleDeclaration.cpp
@@ -26,6 +26,7 @@
#include "CSSPropertyNames.h"
#include "FontFamilyNames.h"
+#include "RuntimeEnabledFeatures.h"
#include "core/css/BasicShapeFunctions.h"
#include "core/css/CSSArrayFunctionValue.h"
#include "core/css/CSSAspectRatioValue.h"
@@ -3009,6 +3010,57 @@ void CSSComputedStyleDeclaration::setPropertyInternal(CSSPropertyID, const Strin
ec = NO_MODIFICATION_ALLOWED_ERR;
}
+const HashMap<AtomicString, String>* CSSComputedStyleDeclaration::variableMap() const
+{
+ ASSERT(RuntimeEnabledFeatures::cssVariablesEnabled());
+ Node* styledNode = this->styledNode();
+ if (!styledNode)
+ return 0;
+ RefPtr<RenderStyle> style = styledNode->computedStyle(styledNode->isPseudoElement() ? NOPSEUDO : m_pseudoElementSpecifier);
+ if (!style)
+ return 0;
+ return style->variables();
+}
+
+unsigned CSSComputedStyleDeclaration::variableCount() const
+{
+ ASSERT(RuntimeEnabledFeatures::cssVariablesEnabled());
+ const HashMap<AtomicString, String>* variables = variableMap();
+ if (!variables)
+ return 0;
+ return variables->size();
+}
+
+String CSSComputedStyleDeclaration::variableValue(const AtomicString& name) const
+{
+ ASSERT(RuntimeEnabledFeatures::cssVariablesEnabled());
+ const HashMap<AtomicString, String>* variables = variableMap();
+ if (!variables)
+ return emptyString();
+ HashMap<AtomicString, String>::const_iterator it = variables->find(name);
+ if (it == variables->end())
+ return emptyString();
+ return it->value;
+}
+
+void CSSComputedStyleDeclaration::setVariableValue(const AtomicString&, const String&, ExceptionCode& ec)
+{
+ ASSERT(RuntimeEnabledFeatures::cssVariablesEnabled());
+ ec = NO_MODIFICATION_ALLOWED_ERR;
+}
+
+bool CSSComputedStyleDeclaration::removeVariable(const AtomicString&)
+{
+ ASSERT(RuntimeEnabledFeatures::cssVariablesEnabled());
+ return false;
+}
+
+void CSSComputedStyleDeclaration::clearVariables(ExceptionCode& ec)
+{
+ ASSERT(RuntimeEnabledFeatures::cssVariablesEnabled());
+ ec = NO_MODIFICATION_ALLOWED_ERR;
+}
+
PassRefPtr<CSSValueList> CSSComputedStyleDeclaration::getBackgroundShorthandValue() const
{
static const CSSPropertyID propertiesBeforeSlashSeperator[5] = { CSSPropertyBackgroundColor, CSSPropertyBackgroundImage,

Powered by Google App Engine
This is Rietveld 408576698