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

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: Removed unused IDL callback definition Created 7 years, 6 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 f0f308782671a9e52ec4b5d5cdc7ed8f2d1eacba..9f9bd4960164b8df95bbc7ba69329b3d78d0ad24 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"
@@ -3007,6 +3008,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