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

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

Issue 2366313006: CSS Properties and Values API: Support non-inherited custom properties (Closed)
Patch Set: moo Created 4 years, 3 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: third_party/WebKit/Source/core/css/ComputedStyleCSSValueMapping.cpp
diff --git a/third_party/WebKit/Source/core/css/ComputedStyleCSSValueMapping.cpp b/third_party/WebKit/Source/core/css/ComputedStyleCSSValueMapping.cpp
index d362ad3ed16f1828ee47cc99cdce66ee2ddaf6cc..92167a379632c9e0827791494e14d506a1722c75 100644
--- a/third_party/WebKit/Source/core/css/ComputedStyleCSSValueMapping.cpp
+++ b/third_party/WebKit/Source/core/css/ComputedStyleCSSValueMapping.cpp
@@ -63,7 +63,8 @@
#include "core/style/CursorData.h"
#include "core/style/QuotesData.h"
#include "core/style/ShadowList.h"
-#include "core/style/StyleVariableData.h"
+#include "core/style/StyleInheritedVariables.h"
+#include "core/style/StyleNonInheritedVariables.h"
#include "platform/LengthFunctions.h"
namespace blink {
@@ -1645,19 +1646,24 @@ static EBreak mapToColumnBreakValue(EBreak genericBreakValue)
const CSSValue* ComputedStyleCSSValueMapping::get(const AtomicString customPropertyName, const ComputedStyle& style, const PropertyRegistry* registry)
{
- StyleVariableData* variables = style.variables();
if (registry) {
const PropertyRegistry::Registration* registration = registry->registration(customPropertyName);
if (registration) {
- if (variables) {
- const CSSValue* result = variables->registeredInheritedProperty(customPropertyName);
- if (result)
- return result;
+ const CSSValue* result = nullptr;
+ if (registration->inherits()) {
+ if (StyleInheritedVariables* variables = style.inheritedVariables())
+ result = variables->registeredVariable(customPropertyName);
+ } else {
+ if (StyleNonInheritedVariables* variables = style.nonInheritedVariables())
+ result = variables->registeredVariable(customPropertyName);
}
+ if (result)
+ return result;
return registration->initial();
}
}
+ StyleInheritedVariables* variables = style.inheritedVariables();
if (!variables)
return nullptr;
@@ -1670,7 +1676,8 @@ const CSSValue* ComputedStyleCSSValueMapping::get(const AtomicString customPrope
std::unique_ptr<HashMap<AtomicString, RefPtr<CSSVariableData>>> ComputedStyleCSSValueMapping::getVariables(const ComputedStyle& style)
{
- StyleVariableData* variables = style.variables();
+ // TODO(timloh): Also return non-inherited variables
+ StyleInheritedVariables* variables = style.inheritedVariables();
if (variables)
return variables->getVariables();
return nullptr;

Powered by Google App Engine
This is Rietveld 408576698