| Index: Source/core/css/resolver/StyleResolver.cpp
|
| diff --git a/Source/core/css/resolver/StyleResolver.cpp b/Source/core/css/resolver/StyleResolver.cpp
|
| index 50f7ddd9d5dc6d439de33d0130e9fd31c4123e7a..06e99bcb72d495b0ea050a335238e32fb846cf7c 100644
|
| --- a/Source/core/css/resolver/StyleResolver.cpp
|
| +++ b/Source/core/css/resolver/StyleResolver.cpp
|
| @@ -59,6 +59,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"
|
| @@ -645,6 +646,9 @@ PassRefPtr<ComputedStyle> StyleResolver::styleForElement(Element* element, const
|
| if (state.style()->hasRemUnits())
|
| document().styleEngine().setUsesRemUnit(true);
|
|
|
| + if (state.style()->variables())
|
| + document().styleEngine().setUsesVariables(true);
|
| +
|
| // Now return the style.
|
| return state.takeStyle();
|
| }
|
| @@ -1168,6 +1172,11 @@ static bool shouldIgnoreTextTrackAuthorStyle(Document& document)
|
| template <CSSPropertyPriority priority>
|
| void StyleResolver::applyAllProperty(StyleResolverState& state, CSSValue* allValue, bool inheritedOnly)
|
| {
|
| + // 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();
|
|
|
| @@ -1312,6 +1321,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, false, matchResult.beginAuthor(), matchResult.endAuthor(), applyInheritedOnly);
|
| + applyMatchedProperties<ResolveVariables>(state, matchResult, true, matchResult.beginAuthor(), matchResult.endAuthor(), applyInheritedOnly);
|
| + // TODO(leviw): stop recalculating every time
|
| + CSSVariableResolver::resolveVariableDefinitions(state);
|
| + }
|
| +
|
| // 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
|
|
|