OLD | NEW |
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" |
(...skipping 14 matching lines...) Expand all Loading... |
25 private: | 25 private: |
26 ResolvedVariableChecker(CSSPropertyID property, const CSSVariableReferenceVa
lue* variableReference, const CSSValue* resolvedValue) | 26 ResolvedVariableChecker(CSSPropertyID property, const CSSVariableReferenceVa
lue* variableReference, 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().style()->variables(), m_property, *m_variableReferenc
e); | 35 const CSSValue* resolvedValue = CSSVariableResolver::resolveVariableRefe
rences(environment.style().variables(), 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 CSSVariableReferenceValue> m_variableReference; |
41 Persistent<const CSSValue> m_resolvedValue; | 41 Persistent<const CSSValue> m_resolvedValue; |
42 }; | 42 }; |
43 | 43 |
44 InterpolationValue CSSInterpolationType::maybeConvertSingle(const PropertySpecif
icKeyframe& keyframe, const InterpolationEnvironment& environment, const Interpo
lationValue& underlying, ConversionCheckers& conversionCheckers) const | 44 InterpolationValue CSSInterpolationType::maybeConvertSingle(const PropertySpecif
icKeyframe& keyframe, const InterpolationEnvironment& environment, const Interpo
lationValue& underlying, ConversionCheckers& conversionCheckers) const |
45 { | 45 { |
46 const CSSValue* resolvedCSSValueOwner; | 46 const CSSValue* resolvedCSSValueOwner; |
47 const CSSValue* value = toCSSPropertySpecificKeyframe(keyframe).value(); | 47 const CSSValue* value = toCSSPropertySpecificKeyframe(keyframe).value(); |
48 | 48 |
49 if (!value) | 49 if (!value) |
50 return maybeConvertNeutral(underlying, conversionCheckers); | 50 return maybeConvertNeutral(underlying, conversionCheckers); |
51 | 51 |
52 // TODO(alancutter): Support animation of var() in shorthand properties. | 52 // TODO(alancutter): Support animation of var() in shorthand properties. |
53 if (value->isPendingSubstitutionValue()) | 53 if (value->isPendingSubstitutionValue()) |
54 return nullptr; | 54 return nullptr; |
55 | 55 |
56 if (value->isVariableReferenceValue() && !isShorthandProperty(cssProperty())
) { | 56 if (value->isVariableReferenceValue() && !isShorthandProperty(cssProperty())
) { |
57 resolvedCSSValueOwner = CSSVariableResolver::resolveVariableReferences(e
nvironment.state().style()->variables(), cssProperty(), toCSSVariableReferenceVa
lue(*value)); | 57 resolvedCSSValueOwner = CSSVariableResolver::resolveVariableReferences(e
nvironment.style().variables(), cssProperty(), toCSSVariableReferenceValue(*valu
e)); |
58 conversionCheckers.append(ResolvedVariableChecker::create(cssProperty(),
toCSSVariableReferenceValue(value), resolvedCSSValueOwner)); | 58 conversionCheckers.append(ResolvedVariableChecker::create(cssProperty(),
toCSSVariableReferenceValue(value), resolvedCSSValueOwner)); |
59 value = resolvedCSSValueOwner; | 59 value = resolvedCSSValueOwner; |
60 } | 60 } |
61 | 61 |
62 if (value->isInitialValue() || (value->isUnsetValue() && !CSSPropertyMetadat
a::isInheritedProperty(cssProperty()))) | 62 if (value->isInitialValue() || (value->isUnsetValue() && !CSSPropertyMetadat
a::isInheritedProperty(cssProperty()))) |
63 return maybeConvertInitial(environment.state(), conversionCheckers); | 63 return maybeConvertInitial(environment.state(), conversionCheckers); |
64 | 64 |
65 if (value->isInheritedValue() || (value->isUnsetValue() && CSSPropertyMetada
ta::isInheritedProperty(cssProperty()))) | 65 if (value->isInheritedValue() || (value->isUnsetValue() && CSSPropertyMetada
ta::isInheritedProperty(cssProperty()))) |
66 return maybeConvertInherit(environment.state(), conversionCheckers); | 66 return maybeConvertInherit(environment.state(), conversionCheckers); |
67 | 67 |
68 return maybeConvertValue(*value, environment.state(), conversionCheckers); | 68 return maybeConvertValue(*value, environment.state(), conversionCheckers); |
69 } | 69 } |
70 | 70 |
71 } // namespace blink | 71 } // namespace blink |
OLD | NEW |