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

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

Issue 1501313002: Expose custom property values to getComputedStyle. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years 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: third_party/WebKit/Source/core/css/CSSComputedStyleDeclaration.cpp
diff --git a/third_party/WebKit/Source/core/css/CSSComputedStyleDeclaration.cpp b/third_party/WebKit/Source/core/css/CSSComputedStyleDeclaration.cpp
index 2b1a7d97ddc16ab1f4114b418ba9098fd462a7a2..d48c9b646cb182520c5e8bf76115bfd3637220e8 100644
--- a/third_party/WebKit/Source/core/css/CSSComputedStyleDeclaration.cpp
+++ b/third_party/WebKit/Source/core/css/CSSComputedStyleDeclaration.cpp
@@ -32,6 +32,7 @@
#include "core/css/CSSValuePool.h"
#include "core/css/ComputedStyleCSSValueMapping.h"
#include "core/css/parser/CSSParser.h"
+#include "core/css/parser/CSSVariableParser.h"
#include "core/css/resolver/StyleResolver.h"
#include "core/dom/Document.h"
#include "core/dom/ExceptionCode.h"
@@ -528,6 +529,11 @@ Node* CSSComputedStyleDeclaration::styledNode() const
return m_node.get();
}
+PassRefPtrWillBeRawPtr<CSSValue> CSSComputedStyleDeclaration::getPropertyCSSValue(AtomicString customPropertyName) const
+{
+ return ComputedStyleCSSValueMapping::get(customPropertyName, *computeComputedStyle());
+}
+
PassRefPtrWillBeRawPtr<CSSValue> CSSComputedStyleDeclaration::getPropertyCSSValue(CSSPropertyID propertyID) const
{
Node* styledNode = this->styledNode();
@@ -634,8 +640,11 @@ CSSRule* CSSComputedStyleDeclaration::parentRule() const
String CSSComputedStyleDeclaration::getPropertyValue(const String& propertyName)
{
CSSPropertyID propertyID = cssPropertyID(propertyName);
- if (!propertyID)
- return String();
+ if (!propertyID) {
+ if (!RuntimeEnabledFeatures::cssVariablesEnabled() || !CSSVariableParser::isValidVariableName(propertyName))
+ return String();
+ return getPropertyCSSValue(AtomicString(propertyName))->cssText();
+ }
ASSERT(CSSPropertyMetadata::isEnabledProperty(propertyID));
return getPropertyValue(propertyID);
}

Powered by Google App Engine
This is Rietveld 408576698