OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "config.h" | 5 #include "config.h" |
6 #include "core/animation/StringKeyframe.h" | 6 #include "core/animation/StringKeyframe.h" |
7 | 7 |
8 #include "core/animation/Interpolation.h" | 8 #include "core/animation/Interpolation.h" |
| 9 #include "core/animation/LegacyStyleInterpolation.h" |
9 #include "core/animation/css/CSSAnimations.h" | 10 #include "core/animation/css/CSSAnimations.h" |
10 #include "core/css/resolver/StyleResolver.h" | 11 #include "core/css/resolver/StyleResolver.h" |
11 #include "core/rendering/style/RenderStyle.h" | 12 #include "core/rendering/style/RenderStyle.h" |
12 | 13 |
13 namespace WebCore { | 14 namespace WebCore { |
14 | 15 |
15 StringKeyframe::StringKeyframe(const StringKeyframe& copyFrom) | 16 StringKeyframe::StringKeyframe(const StringKeyframe& copyFrom) |
16 : Keyframe(copyFrom.m_offset, copyFrom.m_composite, copyFrom.m_easing) | 17 : Keyframe(copyFrom.m_offset, copyFrom.m_composite, copyFrom.m_easing) |
17 , m_propertySet(copyFrom.m_propertySet->mutableCopy()) | 18 , m_propertySet(copyFrom.m_propertySet->mutableCopy()) |
18 { | 19 { |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
64 | 65 |
65 PassRefPtrWillBeRawPtr<Interpolation> StringKeyframe::PropertySpecificKeyframe::
createInterpolation(CSSPropertyID property, Keyframe::PropertySpecificKeyframe*
end, Element* element) const | 66 PassRefPtrWillBeRawPtr<Interpolation> StringKeyframe::PropertySpecificKeyframe::
createInterpolation(CSSPropertyID property, Keyframe::PropertySpecificKeyframe*
end, Element* element) const |
66 { | 67 { |
67 CSSValue* fromCSSValue = m_value.get(); | 68 CSSValue* fromCSSValue = m_value.get(); |
68 CSSValue* toCSSValue = toStringPropertySpecificKeyframe(end)->value(); | 69 CSSValue* toCSSValue = toStringPropertySpecificKeyframe(end)->value(); |
69 | 70 |
70 if (!CSSAnimations::isAnimatableProperty(property)) | 71 if (!CSSAnimations::isAnimatableProperty(property)) |
71 return DefaultStyleInterpolation::create(fromCSSValue, toCSSValue, prope
rty); | 72 return DefaultStyleInterpolation::create(fromCSSValue, toCSSValue, prope
rty); |
72 | 73 |
73 switch (property) { | 74 switch (property) { |
| 75 case CSSPropertyBorderBottomWidth: |
| 76 case CSSPropertyBorderLeftWidth: |
| 77 case CSSPropertyBorderRightWidth: |
| 78 case CSSPropertyBorderTopWidth: |
| 79 case CSSPropertyHeight: |
74 case CSSPropertyLeft: | 80 case CSSPropertyLeft: |
75 case CSSPropertyRight: | 81 case CSSPropertyRight: |
76 case CSSPropertyWidth: | 82 case CSSPropertyWidth: |
77 case CSSPropertyHeight: | |
78 if (LengthStyleInterpolation::canCreateFrom(*fromCSSValue) && LengthStyl
eInterpolation::canCreateFrom(*toCSSValue)) | 83 if (LengthStyleInterpolation::canCreateFrom(*fromCSSValue) && LengthStyl
eInterpolation::canCreateFrom(*toCSSValue)) |
79 return LengthStyleInterpolation::create(fromCSSValue, toCSSValue, pr
operty); | 84 return LengthStyleInterpolation::create(fromCSSValue, toCSSValue, pr
operty); |
80 break; | 85 break; |
81 default: | 86 default: |
82 break; | 87 break; |
83 } | 88 } |
84 | 89 |
85 // FIXME: Remove the use of AnimatableValues, RenderStyles and Elements here
. | 90 // FIXME: Remove the use of AnimatableValues, RenderStyles and Elements here
. |
86 // FIXME: Remove this cache | 91 // FIXME: Remove this cache |
87 if (!m_animatableValueCache) | 92 if (!m_animatableValueCache && !LegacyStyleInterpolation::interpolationRequi
resStyleResolve(*fromCSSValue)) |
88 m_animatableValueCache = StyleResolver::createAnimatableValueSnapshot(*e
lement, property, fromCSSValue); | 93 m_animatableValueCache = StyleResolver::applyAndSnapshotAnimatableValue(
*element, property, *fromCSSValue); |
| 94 StringPropertySpecificKeyframe& endKeyframe = toStringPropertySpecificKeyfra
me(*end); |
| 95 if (!endKeyframe.m_animatableValueCache && !LegacyStyleInterpolation::interp
olationRequiresStyleResolve(*toCSSValue)) |
| 96 endKeyframe.m_animatableValueCache = StyleResolver::applyAndSnapshotAnim
atableValue(*element, property, *toCSSValue); |
89 | 97 |
90 RefPtrWillBeRawPtr<AnimatableValue> to = StyleResolver::createAnimatableValu
eSnapshot(*element, property, toCSSValue); | 98 return LegacyStyleInterpolation::create(*fromCSSValue, *toCSSValue, property
, *element); |
91 toStringPropertySpecificKeyframe(end)->m_animatableValueCache = to; | |
92 | |
93 return LegacyStyleInterpolation::create(m_animatableValueCache.get(), to.rel
ease(), property); | |
94 } | 99 } |
95 | 100 |
96 PassOwnPtrWillBeRawPtr<Keyframe::PropertySpecificKeyframe> StringKeyframe::Prope
rtySpecificKeyframe::neutralKeyframe(double offset, PassRefPtr<TimingFunction> e
asing) const | 101 PassOwnPtrWillBeRawPtr<Keyframe::PropertySpecificKeyframe> StringKeyframe::Prope
rtySpecificKeyframe::neutralKeyframe(double offset, PassRefPtr<TimingFunction> e
asing) const |
97 { | 102 { |
98 return adoptPtrWillBeNoop(new PropertySpecificKeyframe(offset, easing, 0, An
imationEffect::CompositeAdd)); | 103 return adoptPtrWillBeNoop(new PropertySpecificKeyframe(offset, easing, 0, An
imationEffect::CompositeAdd)); |
99 } | 104 } |
100 | 105 |
101 PassOwnPtrWillBeRawPtr<Keyframe::PropertySpecificKeyframe> StringKeyframe::Prope
rtySpecificKeyframe::cloneWithOffset(double offset) const | 106 PassOwnPtrWillBeRawPtr<Keyframe::PropertySpecificKeyframe> StringKeyframe::Prope
rtySpecificKeyframe::cloneWithOffset(double offset) const |
102 { | 107 { |
103 Keyframe::PropertySpecificKeyframe* theClone = new PropertySpecificKeyframe(
offset, m_easing, m_value.get()); | 108 Keyframe::PropertySpecificKeyframe* theClone = new PropertySpecificKeyframe(
offset, m_easing, m_value.get()); |
104 toStringPropertySpecificKeyframe(theClone)->m_animatableValueCache = m_anima
tableValueCache; | 109 toStringPropertySpecificKeyframe(theClone)->m_animatableValueCache = m_anima
tableValueCache; |
105 return adoptPtrWillBeNoop(theClone); | 110 return adoptPtrWillBeNoop(theClone); |
106 } | 111 } |
107 | 112 |
108 void StringKeyframe::PropertySpecificKeyframe::trace(Visitor* visitor) | 113 void StringKeyframe::PropertySpecificKeyframe::trace(Visitor* visitor) |
109 { | 114 { |
110 visitor->trace(m_value); | 115 visitor->trace(m_value); |
111 visitor->trace(m_animatableValueCache); | 116 visitor->trace(m_animatableValueCache); |
112 Keyframe::PropertySpecificKeyframe::trace(visitor); | 117 Keyframe::PropertySpecificKeyframe::trace(visitor); |
113 } | 118 } |
114 | 119 |
115 } | 120 } |
OLD | NEW |