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/css/CSSAnimations.h" | |
10 #include "core/css/resolver/StyleResolver.h" | |
11 #include "core/rendering/style/RenderStyle.h" | |
9 | 12 |
10 namespace WebCore { | 13 namespace WebCore { |
11 | 14 |
12 StringKeyframe::StringKeyframe(const StringKeyframe& copyFrom) | 15 StringKeyframe::StringKeyframe(const StringKeyframe& copyFrom) |
13 : Keyframe(copyFrom.m_offset, copyFrom.m_composite, copyFrom.m_easing) | 16 : Keyframe(copyFrom.m_offset, copyFrom.m_composite, copyFrom.m_easing) |
17 , m_propertySet(copyFrom.m_propertySet->mutableCopy()) | |
14 { | 18 { |
15 for (PropertyValueMap::const_iterator iter = copyFrom.m_propertyValues.begin (); iter != copyFrom.m_propertyValues.end(); ++iter) | 19 } |
16 setPropertyValue(iter->key, iter->value); | 20 |
21 void StringKeyframe::setPropertyValue(CSSPropertyID property, const String& valu e, StyleSheetContents* styleSheetContents) | |
22 { | |
23 ASSERT(property != CSSPropertyInvalid); | |
24 m_propertySet->setProperty(property, value, false, styleSheetContents); | |
17 } | 25 } |
18 | 26 |
19 PropertySet StringKeyframe::properties() const | 27 PropertySet StringKeyframe::properties() const |
20 { | 28 { |
21 // This is not used in time-critical code, so we probably don't need to | 29 // This is not used in time-critical code, so we probably don't need to |
22 // worry about caching this result. | 30 // worry about caching this result. |
23 PropertySet properties; | 31 PropertySet properties; |
24 for (PropertyValueMap::const_iterator iter = m_propertyValues.begin(); iter != m_propertyValues.end(); ++iter) | 32 for (unsigned i = 0; i < m_propertySet->propertyCount(); ++i) { |
25 properties.add(*iter.keys()); | 33 // FIXME: Allow for non-animatable properties. |
34 CSSPropertyID property = m_propertySet->propertyAt(i).id(); | |
35 if (CSSAnimations::isAnimatableProperty(property)) | |
36 properties.add(property); | |
37 } | |
26 return properties; | 38 return properties; |
27 } | 39 } |
28 | 40 |
29 PassRefPtrWillBeRawPtr<Keyframe> StringKeyframe::clone() const | 41 PassRefPtrWillBeRawPtr<Keyframe> StringKeyframe::clone() const |
30 { | 42 { |
31 return adoptRefWillBeNoop(new StringKeyframe(*this)); | 43 return adoptRefWillBeNoop(new StringKeyframe(*this)); |
32 } | 44 } |
33 PassOwnPtrWillBeRawPtr<Keyframe::PropertySpecificKeyframe> StringKeyframe::creat ePropertySpecificKeyframe(CSSPropertyID property) const | 45 PassOwnPtrWillBeRawPtr<Keyframe::PropertySpecificKeyframe> StringKeyframe::creat ePropertySpecificKeyframe(CSSPropertyID property) const |
34 { | 46 { |
35 return adoptPtrWillBeNoop(new PropertySpecificKeyframe(offset(), easing(), p ropertyValue(property), composite())); | 47 return adoptPtrWillBeNoop(new PropertySpecificKeyframe(offset(), easing(), p ropertyValue(property), composite())); |
36 } | 48 } |
37 | 49 |
38 void StringKeyframe::trace(Visitor* visitor) | 50 void StringKeyframe::trace(Visitor* visitor) |
39 { | 51 { |
40 Keyframe::trace(visitor); | 52 Keyframe::trace(visitor); |
41 } | 53 } |
42 | 54 |
43 StringKeyframe::PropertySpecificKeyframe::PropertySpecificKeyframe(double offset , PassRefPtr<TimingFunction> easing, const String& value, AnimationEffect::Compo siteOperation op) | 55 StringKeyframe::PropertySpecificKeyframe::PropertySpecificKeyframe(double offset , PassRefPtr<TimingFunction> easing, CSSValue* value, AnimationEffect::Composite Operation op) |
44 : Keyframe::PropertySpecificKeyframe(offset, easing, op) | 56 : Keyframe::PropertySpecificKeyframe(offset, easing, op) |
45 , m_value(value) | 57 , m_value(value) |
46 { } | 58 { } |
47 | 59 |
48 StringKeyframe::PropertySpecificKeyframe::PropertySpecificKeyframe(double offset , PassRefPtr<TimingFunction> easing, const String& value) | 60 StringKeyframe::PropertySpecificKeyframe::PropertySpecificKeyframe(double offset , PassRefPtr<TimingFunction> easing, CSSValue* value) |
49 : Keyframe::PropertySpecificKeyframe(offset, easing, AnimationEffect::Compos iteReplace) | 61 : Keyframe::PropertySpecificKeyframe(offset, easing, AnimationEffect::Compos iteReplace) |
50 , m_value(value) | 62 , m_value(value) |
51 { | 63 { |
52 ASSERT(!isNull(m_offset)); | 64 ASSERT(!isNull(m_offset)); |
53 } | 65 } |
54 | 66 |
55 PassRefPtrWillBeRawPtr<Interpolation> StringKeyframe::PropertySpecificKeyframe:: createInterpolation(CSSPropertyID property, Keyframe::PropertySpecificKeyframe* end) const | 67 PassRefPtrWillBeRawPtr<Interpolation> StringKeyframe::PropertySpecificKeyframe:: createInterpolation(CSSPropertyID property, Keyframe::PropertySpecificKeyframe* end, Element* element) const |
56 { | 68 { |
57 ASSERT_UNUSED(end, end); | 69 CSSValue* fromCSSValue = m_value.get(); |
58 // FIXME: Convert string keyframe value pairs to interpolations. | 70 CSSValue* toCSSValue = toStringPropertySpecificKeyframe(end)->value(); |
59 return nullptr; | 71 |
72 // FIXME: Remove the use of AnimatableValues and RenderStyles here. | |
dstockwell
2014/04/07 00:14:06
and element?
alancutter (OOO until 2018)
2014/04/07 01:06:02
Done.
| |
73 RefPtr<AnimatableValue> from = StyleResolver::createAnimatableValueSnapshot( *element, property, fromCSSValue); | |
74 RefPtr<AnimatableValue> to = StyleResolver::createAnimatableValueSnapshot(*e lement, property, toCSSValue); | |
75 | |
76 return LegacyStyleInterpolation::create(from.release(), to.release(), proper ty); | |
60 } | 77 } |
61 | 78 |
62 PassOwnPtrWillBeRawPtr<Keyframe::PropertySpecificKeyframe> StringKeyframe::Prope rtySpecificKeyframe::neutralKeyframe(double offset, PassRefPtr<TimingFunction> e asing) const | 79 PassOwnPtrWillBeRawPtr<Keyframe::PropertySpecificKeyframe> StringKeyframe::Prope rtySpecificKeyframe::neutralKeyframe(double offset, PassRefPtr<TimingFunction> e asing) const |
63 { | 80 { |
64 return adoptPtrWillBeNoop(new StringKeyframe::PropertySpecificKeyframe(offse t, easing, emptyString(), AnimationEffect::CompositeAdd)); | 81 return adoptPtrWillBeNoop(new PropertySpecificKeyframe(offset, easing, nullp tr, AnimationEffect::CompositeAdd)); |
65 } | 82 } |
66 | 83 |
67 PassOwnPtrWillBeRawPtr<Keyframe::PropertySpecificKeyframe> StringKeyframe::Prope rtySpecificKeyframe::cloneWithOffset(double offset) const | 84 PassOwnPtrWillBeRawPtr<Keyframe::PropertySpecificKeyframe> StringKeyframe::Prope rtySpecificKeyframe::cloneWithOffset(double offset) const |
68 { | 85 { |
69 Keyframe::PropertySpecificKeyframe *theClone = new PropertySpecificKeyframe( offset, m_easing, m_value); | 86 Keyframe::PropertySpecificKeyframe *theClone = new PropertySpecificKeyframe( offset, m_easing, m_value.get()); |
70 return adoptPtrWillBeNoop(theClone); | 87 return adoptPtrWillBeNoop(theClone); |
71 } | 88 } |
72 | 89 |
73 void StringKeyframe::PropertySpecificKeyframe::trace(Visitor* visitor) | 90 void StringKeyframe::PropertySpecificKeyframe::trace(Visitor* visitor) |
74 { | 91 { |
92 visitor->trace(m_value); | |
75 } | 93 } |
76 | 94 |
77 } | 95 } |
OLD | NEW |