Index: third_party/WebKit/Source/core/css/resolver/StyleResolver.cpp |
diff --git a/third_party/WebKit/Source/core/css/resolver/StyleResolver.cpp b/third_party/WebKit/Source/core/css/resolver/StyleResolver.cpp |
index 8af35a7ace223f3b9858ab3a6ab7c659f18f2f48..71de34d0600e12cbf69eaed63cb843a4f344bb02 100644 |
--- a/third_party/WebKit/Source/core/css/resolver/StyleResolver.cpp |
+++ b/third_party/WebKit/Source/core/css/resolver/StyleResolver.cpp |
@@ -61,6 +61,7 @@ |
#include "core/css/StyleRuleImport.h" |
#include "core/css/StyleSheetContents.h" |
#include "core/css/resolver/AnimatedStyleBuilder.h" |
+#include "core/css/resolver/CSSVariableResolver.h" |
#include "core/css/resolver/MatchResult.h" |
#include "core/css/resolver/MediaQueryResult.h" |
#include "core/css/resolver/ScopedStyleResolver.h" |
@@ -1230,6 +1231,11 @@ static inline bool isPropertyInWhitelist(PropertyWhitelistType propertyWhitelist |
template <CSSPropertyPriority priority> |
void StyleResolver::applyAllProperty(StyleResolverState& state, CSSValue* allValue, bool inheritedOnly, PropertyWhitelistType propertyWhitelistType) |
{ |
+ // The 'all' property doesn't apply to variables: |
+ // https://drafts.csswg.org/css-variables/#defining-variables |
+ if (priority == ResolveVariables) |
+ return; |
+ |
unsigned startCSSProperty = CSSPropertyPriorityData<priority>::first(); |
unsigned endCSSProperty = CSSPropertyPriorityData<priority>::last(); |
@@ -1369,6 +1375,14 @@ void StyleResolver::applyMatchedProperties(StyleResolverState& state, const Matc |
applyInheritedOnly = true; |
} |
+ // TODO(leviw): We need the proper bit for tracking whether we need to do this work. |
+ if (RuntimeEnabledFeatures::cssVariablesEnabled()) { |
+ applyMatchedProperties<ResolveVariables>(state, matchResult.authorRules(), false, applyInheritedOnly); |
+ applyMatchedProperties<ResolveVariables>(state, matchResult.authorRules(), true, applyInheritedOnly); |
+ // TODO(leviw): stop recalculating every time |
+ CSSVariableResolver::resolveVariableDefinitions(state.style()->variables()); |
+ } |
+ |
// Now we have all of the matched rules in the appropriate order. Walk the rules and apply |
// high-priority properties first, i.e., those properties that other properties depend on. |
// The order is (1) high-priority not important, (2) high-priority important, (3) normal not important |