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

Unified Diff: third_party/WebKit/Source/core/css/resolver/CSSVariableResolver.cpp

Issue 2358203003: CSS Properties and Values API: Use initial value where appropriate for var() (Closed)
Patch Set: bla 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
« no previous file with comments | « third_party/WebKit/Source/core/css/PropertyRegistry.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/core/css/resolver/CSSVariableResolver.cpp
diff --git a/third_party/WebKit/Source/core/css/resolver/CSSVariableResolver.cpp b/third_party/WebKit/Source/core/css/resolver/CSSVariableResolver.cpp
index 3e16a9ecf3240761382af71ff95884f1207f3358..13aa3992fd017ea0be97ec82e6df300d54c0608c 100644
--- a/third_party/WebKit/Source/core/css/resolver/CSSVariableResolver.cpp
+++ b/third_party/WebKit/Source/core/css/resolver/CSSVariableResolver.cpp
@@ -35,38 +35,37 @@ bool CSSVariableResolver::resolveFallback(CSSParserTokenRange range, Vector<CSSP
CSSVariableData* CSSVariableResolver::valueForCustomProperty(AtomicString name)
{
- // TODO(timloh): Registered properties shouldn't return nullptr in failure
- // cases (aside from cycles?), but instead return the initial/inherited value.
if (m_variablesSeen.contains(name)) {
m_cycleStartPoints.add(name);
return nullptr;
}
- if (!m_styleVariableData)
- return nullptr;
- CSSVariableData* variableData = m_styleVariableData->getVariable(name);
+ DCHECK(m_registry || !RuntimeEnabledFeatures::cssVariables2Enabled());
+ const PropertyRegistry::Registration* registration = m_registry ? m_registry->registration(name) : nullptr;
+
+ CSSVariableData* variableData = nullptr;
+ if (m_styleVariableData)
+ variableData = m_styleVariableData->getVariable(name);
if (!variableData)
- return nullptr;
+ return registration ? registration->initialVariableData() : nullptr;
if (!variableData->needsVariableResolution())
return variableData;
- RefPtr<CSSVariableData> newVariableData = resolveCustomProperty(name, *variableData);
- DCHECK(m_registry || !RuntimeEnabledFeatures::cssVariables2Enabled());
- if (m_registry) {
- const PropertyRegistry::Registration* registration = m_registry->registration(name);
- if (registration) {
- const CSSValue* parsedValue = nullptr;
- if (newVariableData) {
- parsedValue = newVariableData->parseForSyntax(registration->syntax());
- if (parsedValue)
- parsedValue = &StyleBuilderConverter::convertRegisteredPropertyValue(m_styleResolverState, *parsedValue);
- else
- newVariableData = nullptr;
- }
- m_styleVariableData->setVariable(name, newVariableData);
- m_styleVariableData->setRegisteredInheritedProperty(name, parsedValue);
- return newVariableData.get();
+ RefPtr<CSSVariableData> newVariableData = resolveCustomProperty(name, *variableData);
+ if (registration) {
+ const CSSValue* parsedValue = nullptr;
+ if (newVariableData) {
+ parsedValue = newVariableData->parseForSyntax(registration->syntax());
+ if (parsedValue)
+ parsedValue = &StyleBuilderConverter::convertRegisteredPropertyValue(m_styleResolverState, *parsedValue);
+ else
+ newVariableData = nullptr;
}
+ m_styleVariableData->setVariable(name, newVariableData);
+ m_styleVariableData->setRegisteredInheritedProperty(name, parsedValue);
+ if (!newVariableData)
+ return registration->initialVariableData();
Timothy Loh 2016/09/22 10:01:25 We could alternatively set the initial values into
meade_UTC10 2016/09/23 01:16:50 seems fine as is.
+ return newVariableData.get();
}
m_styleVariableData->setVariable(name, newVariableData);
« no previous file with comments | « third_party/WebKit/Source/core/css/PropertyRegistry.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698