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

Side by Side Diff: third_party/WebKit/Source/core/animation/CSSInterpolationType.cpp

Issue 2340893003: Support interpolation of animatable shorthand properties containing var() (Closed)
Patch Set: Update DCHECK 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 unified diff | Download patch
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "core/animation/CSSInterpolationType.h" 5 #include "core/animation/CSSInterpolationType.h"
6 6
7 #include "core/StylePropertyShorthand.h" 7 #include "core/StylePropertyShorthand.h"
8 #include "core/animation/StringKeyframe.h" 8 #include "core/animation/StringKeyframe.h"
9 #include "core/css/CSSVariableReferenceValue.h" 9 #include "core/css/CSSVariableReferenceValue.h"
10 #include "core/css/resolver/CSSVariableResolver.h" 10 #include "core/css/resolver/CSSVariableResolver.h"
11 #include "core/css/resolver/StyleResolverState.h" 11 #include "core/css/resolver/StyleResolverState.h"
12 #include "platform/RuntimeEnabledFeatures.h" 12 #include "platform/RuntimeEnabledFeatures.h"
13 #include "wtf/PtrUtil.h" 13 #include "wtf/PtrUtil.h"
14 #include <memory> 14 #include <memory>
15 15
16 namespace blink { 16 namespace blink {
17 17
18 class ResolvedVariableChecker : public InterpolationType::ConversionChecker { 18 class ResolvedVariableChecker : public InterpolationType::ConversionChecker {
19 public: 19 public:
20 static std::unique_ptr<ResolvedVariableChecker> create(CSSPropertyID propert y, const CSSVariableReferenceValue* variableReference, const CSSValue* resolvedV alue) 20 static std::unique_ptr<ResolvedVariableChecker> create(CSSPropertyID propert y, const CSSValue* variableReference, const CSSValue* resolvedValue)
21 { 21 {
22 return wrapUnique(new ResolvedVariableChecker(property, variableReferenc e, resolvedValue)); 22 return wrapUnique(new ResolvedVariableChecker(property, variableReferenc e, resolvedValue));
23 } 23 }
24 24
25 private: 25 private:
26 ResolvedVariableChecker(CSSPropertyID property, const CSSVariableReferenceVa lue* variableReference, const CSSValue* resolvedValue) 26 ResolvedVariableChecker(CSSPropertyID property, const CSSValue* variableRefe rence, const CSSValue* resolvedValue)
27 : m_property(property) 27 : m_property(property)
28 , m_variableReference(variableReference) 28 , m_variableReference(variableReference)
29 , m_resolvedValue(resolvedValue) 29 , m_resolvedValue(resolvedValue)
30 { } 30 { }
31 31
32 bool isValid(const InterpolationEnvironment& environment, const Interpolatio nValue& underlying) const final 32 bool isValid(const InterpolationEnvironment& environment, const Interpolatio nValue& underlying) const final
33 { 33 {
34 // TODO(alancutter): Just check the variables referenced instead of doin g a full CSSValue resolve. 34 // TODO(alancutter): Just check the variables referenced instead of doin g a full CSSValue resolve.
35 const CSSValue* resolvedValue = CSSVariableResolver::resolveVariableRefe rences(environment.state(), m_property, *m_variableReference); 35 const CSSValue* resolvedValue = CSSVariableResolver::resolveVariableRefe rences(environment.state(), m_property, *m_variableReference);
36 return m_resolvedValue->equals(*resolvedValue); 36 return m_resolvedValue->equals(*resolvedValue);
37 } 37 }
38 38
39 CSSPropertyID m_property; 39 CSSPropertyID m_property;
40 Persistent<const CSSVariableReferenceValue> m_variableReference; 40 Persistent<const CSSValue> m_variableReference;
41 Persistent<const CSSValue> m_resolvedValue; 41 Persistent<const CSSValue> m_resolvedValue;
42 }; 42 };
43 43
44 CSSInterpolationType::CSSInterpolationType(CSSPropertyID property)
45 : InterpolationType(PropertyHandle(property))
46 {
47 DCHECK(!isShorthandProperty(cssProperty()));
48 }
49
44 InterpolationValue CSSInterpolationType::maybeConvertSingle(const PropertySpecif icKeyframe& keyframe, const InterpolationEnvironment& environment, const Interpo lationValue& underlying, ConversionCheckers& conversionCheckers) const 50 InterpolationValue CSSInterpolationType::maybeConvertSingle(const PropertySpecif icKeyframe& keyframe, const InterpolationEnvironment& environment, const Interpo lationValue& underlying, ConversionCheckers& conversionCheckers) const
45 { 51 {
46 const CSSValue* resolvedCSSValueOwner; 52 const CSSValue* resolvedCSSValueOwner;
47 const CSSValue* value = toCSSPropertySpecificKeyframe(keyframe).value(); 53 const CSSValue* value = toCSSPropertySpecificKeyframe(keyframe).value();
48 54
49 if (!value) 55 if (!value)
50 return maybeConvertNeutral(underlying, conversionCheckers); 56 return maybeConvertNeutral(underlying, conversionCheckers);
51 57
52 // TODO(alancutter): Support animation of var() in shorthand properties. 58 if (value->isVariableReferenceValue() || value->isPendingSubstitutionValue() ) {
53 if (value->isPendingSubstitutionValue()) 59 resolvedCSSValueOwner = CSSVariableResolver::resolveVariableReferences(e nvironment.state(), cssProperty(), *value);
54 return nullptr; 60 conversionCheckers.append(ResolvedVariableChecker::create(cssProperty(), value, resolvedCSSValueOwner));
55
56 if (value->isVariableReferenceValue() && !isShorthandProperty(cssProperty()) ) {
57 resolvedCSSValueOwner = CSSVariableResolver::resolveVariableReferences(e nvironment.state(), cssProperty(), toCSSVariableReferenceValue(*value));
58 conversionCheckers.append(ResolvedVariableChecker::create(cssProperty(), toCSSVariableReferenceValue(value), resolvedCSSValueOwner));
59 value = resolvedCSSValueOwner; 61 value = resolvedCSSValueOwner;
60 } 62 }
61 63
62 if (value->isInitialValue() || (value->isUnsetValue() && !CSSPropertyMetadat a::isInheritedProperty(cssProperty()))) 64 if (value->isInitialValue() || (value->isUnsetValue() && !CSSPropertyMetadat a::isInheritedProperty(cssProperty())))
63 return maybeConvertInitial(environment.state(), conversionCheckers); 65 return maybeConvertInitial(environment.state(), conversionCheckers);
64 66
65 if (value->isInheritedValue() || (value->isUnsetValue() && CSSPropertyMetada ta::isInheritedProperty(cssProperty()))) 67 if (value->isInheritedValue() || (value->isUnsetValue() && CSSPropertyMetada ta::isInheritedProperty(cssProperty())))
66 return maybeConvertInherit(environment.state(), conversionCheckers); 68 return maybeConvertInherit(environment.state(), conversionCheckers);
67 69
68 return maybeConvertValue(*value, environment.state(), conversionCheckers); 70 return maybeConvertValue(*value, environment.state(), conversionCheckers);
69 } 71 }
70 72
71 } // namespace blink 73 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698