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

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

Issue 2809063002: WIP Support var() references in registered custom property keyframes (Closed)
Patch Set: Rebased Created 3 years, 6 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/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 46ca6234c121452cf09e72bbed7f34487015a9ed..ade766d04b9c977bb6949bbb3251d3899a0b141f 100644
--- a/third_party/WebKit/Source/core/css/resolver/CSSVariableResolver.cpp
+++ b/third_party/WebKit/Source/core/css/resolver/CSSVariableResolver.cpp
@@ -8,6 +8,7 @@
#include "core/CSSValueKeywords.h"
#include "core/StyleBuilderFunctions.h"
#include "core/StylePropertyShorthand.h"
+#include "core/css/CSSCustomPropertyDeclaration.h"
#include "core/css/CSSPendingSubstitutionValue.h"
#include "core/css/CSSUnsetValue.h"
#include "core/css/CSSVariableData.h"
@@ -100,6 +101,7 @@ PassRefPtr<CSSVariableData> CSSVariableResolver::ResolveCustomProperty(
Vector<CSSParserToken> tokens;
Vector<String> backing_strings;
backing_strings.AppendVector(variable_data.BackingStrings());
+ DCHECK(!variables_seen_.Contains(name));
variables_seen_.insert(name);
bool success =
ResolveTokenRange(variable_data.Tokens(), disallow_animation_tainted,
@@ -126,6 +128,20 @@ bool CSSVariableResolver::ResolveVariableReference(
range.ConsumeIncludingWhitespace().Value().ToAtomicString();
DCHECK(range.AtEnd() || (range.Peek().GetType() == kCommaToken));
+ PropertyHandle property(variable_name);
+ if (state_.AnimationPendingCustomProperties().Contains(property) &&
+ !variables_seen_.Contains(variable_name)) {
+ // We make the StyleResolverState mutable for animated custom properties as
+ // an optimisation. Without this we would need to compute animated values on
+ // the stack without saving the result or perform an expensive and complex
+ // value dependency graph analysis to compute them in the required order.
+ StyleResolver::ApplyAnimatedCustomProperty(
+ const_cast<StyleResolverState&>(state_), *this, property);
+ // Null custom property storage may become non-null after application, we
+ // must refresh these cached values.
+ inherited_variables_ = state_.Style()->InheritedVariables();
+ non_inherited_variables_ = state_.Style()->NonInheritedVariables();
+ }
CSSVariableData* variable_data = ValueForCustomProperty(variable_name);
if (!variable_data ||
(disallow_animation_tainted && variable_data->IsAnimationTainted())) {
@@ -283,6 +299,31 @@ const CSSValue* CSSVariableResolver::ResolvePendingSubstitutions(
return CSSUnsetValue::Create();
}
+const CSSValue*
+CSSVariableResolver::ResolveRegisteredCustomPropertyAnimationKeyframe(
+ const PropertyRegistration& registration,
+ const CSSCustomPropertyDeclaration& keyframe) {
+ DCHECK(keyframe.Value());
+ const AtomicString& name = keyframe.GetName();
+ DCHECK_EQ(registry_->Registration(name), &registration);
+
+ if (variables_seen_.Contains(name)) {
+ cycle_start_points_.insert(name);
+ return nullptr;
+ }
+
+ if (!keyframe.Value()->NeedsVariableResolution()) {
+ return keyframe.Value()->ParseForSyntax(registration.Syntax());
+ }
+
+ RefPtr<CSSVariableData> resolved_tokens =
+ ResolveCustomProperty(name, *keyframe.Value());
+ if (!resolved_tokens) {
+ return nullptr;
+ }
+ return resolved_tokens->ParseForSyntax(registration.Syntax());
+}
+
void CSSVariableResolver::ResolveVariableDefinitions() {
if (!inherited_variables_ && !non_inherited_variables_)
return;

Powered by Google App Engine
This is Rietveld 408576698