Chromium Code Reviews| Index: Source/core/animation/StringKeyframe.cpp |
| diff --git a/Source/core/animation/StringKeyframe.cpp b/Source/core/animation/StringKeyframe.cpp |
| index e3d84df09f7173d10f6d98aeffe20cecce873ad6..90e6a06a7213ab245ff758a379d19079badaa0f2 100644 |
| --- a/Source/core/animation/StringKeyframe.cpp |
| +++ b/Source/core/animation/StringKeyframe.cpp |
| @@ -6,6 +6,10 @@ |
| #include "core/animation/StringKeyframe.h" |
| #include "core/animation/Interpolation.h" |
| +#include "core/animation/css/CSSAnimations.h" |
| +#include "core/css/StylePropertySet.h" |
| +#include "core/css/resolver/StyleResolver.h" |
| +#include "core/rendering/style/RenderStyle.h" |
| namespace WebCore { |
| @@ -13,7 +17,26 @@ StringKeyframe::StringKeyframe(const StringKeyframe& copyFrom) |
| : Keyframe(copyFrom.m_offset, copyFrom.m_composite, copyFrom.m_easing) |
| { |
| for (PropertyValueMap::const_iterator iter = copyFrom.m_propertyValues.begin(); iter != copyFrom.m_propertyValues.end(); ++iter) |
| - setPropertyValue(iter->key, iter->value); |
| + setPropertyCSSValue(iter->key, iter->value.get()); |
| +} |
| + |
| +void StringKeyframe::setPropertyValue(CSSPropertyID property, const String& value, StyleSheetContents* styleSheetContents) |
| +{ |
| + ASSERT(property != CSSPropertyInvalid); |
| + RefPtr<MutableStylePropertySet> propertySet = MutableStylePropertySet::create(); |
| + propertySet->setProperty(property, value, false, styleSheetContents); |
| + for (size_t i = 0; i < propertySet->propertyCount(); ++i) { |
| + CSSPropertyID id = propertySet->propertyAt(i).id(); |
| + // FIXME: Allow for non-animatable properties. |
| + if (CSSAnimations::isAnimatableProperty(id)) |
| + setPropertyCSSValue(id, propertySet->getPropertyCSSValue(id).get()); |
| + } |
| +} |
| + |
| +void StringKeyframe::setPropertyCSSValue(CSSPropertyID property, CSSValue* value) |
| +{ |
| + ASSERT(property != CSSPropertyInvalid); |
| + m_propertyValues.add(property, value); |
|
esprehn
2014/04/04 22:37:12
Why aren't you using a StylePropertySet? It seems
alancutter (OOO until 2018)
2014/04/07 00:02:26
Good idea, done.
|
| } |
| PropertySet StringKeyframe::properties() const |
| @@ -40,38 +63,46 @@ void StringKeyframe::trace(Visitor* visitor) |
| Keyframe::trace(visitor); |
| } |
| -StringKeyframe::PropertySpecificKeyframe::PropertySpecificKeyframe(double offset, PassRefPtr<TimingFunction> easing, const String& value, AnimationEffect::CompositeOperation op) |
| +StringKeyframe::PropertySpecificKeyframe::PropertySpecificKeyframe(double offset, PassRefPtr<TimingFunction> easing, CSSValue* value, AnimationEffect::CompositeOperation op) |
| : Keyframe::PropertySpecificKeyframe(offset, easing, op) |
| , m_value(value) |
| { } |
| -StringKeyframe::PropertySpecificKeyframe::PropertySpecificKeyframe(double offset, PassRefPtr<TimingFunction> easing, const String& value) |
| +StringKeyframe::PropertySpecificKeyframe::PropertySpecificKeyframe(double offset, PassRefPtr<TimingFunction> easing, CSSValue* value) |
| : Keyframe::PropertySpecificKeyframe(offset, easing, AnimationEffect::CompositeReplace) |
| , m_value(value) |
| { |
| ASSERT(!isNull(m_offset)); |
| } |
| -PassRefPtrWillBeRawPtr<Interpolation> StringKeyframe::PropertySpecificKeyframe::createInterpolation(CSSPropertyID property, Keyframe::PropertySpecificKeyframe* end) const |
| +PassRefPtrWillBeRawPtr<Interpolation> StringKeyframe::PropertySpecificKeyframe::createInterpolation(CSSPropertyID property, Keyframe::PropertySpecificKeyframe* end, Element* element) const |
| { |
| - ASSERT_UNUSED(end, end); |
| - // FIXME: Convert string keyframe value pairs to interpolations. |
| - return nullptr; |
| + ASSERT(element); |
| + CSSValue* fromCSSValue = m_value.get(); |
| + CSSValue* toCSSValue = toStringPropertySpecificKeyframe(end)->value(); |
| + |
| + // FIXME: Remove the use of AnimatableValues and RenderStyles here. |
| + RefPtr<RenderStyle> style = RenderStyle::clone(element->renderStyle()); |
| + RefPtr<AnimatableValue> from = StyleResolver::createAnimatableValueSnapshot(*element, *style.get(), property, fromCSSValue); |
| + RefPtr<AnimatableValue> to = StyleResolver::createAnimatableValueSnapshot(*element, *style.get(), property, toCSSValue); |
|
esprehn
2014/04/04 22:37:12
Why is it okay to reuse the same style object for
alancutter (OOO until 2018)
2014/04/07 00:02:26
It probably isn't in some corner case. Changed to
|
| + |
| + return LegacyStyleInterpolation::create(from.release(), to.release(), property); |
| } |
| PassOwnPtrWillBeRawPtr<Keyframe::PropertySpecificKeyframe> StringKeyframe::PropertySpecificKeyframe::neutralKeyframe(double offset, PassRefPtr<TimingFunction> easing) const |
| { |
| - return adoptPtrWillBeNoop(new StringKeyframe::PropertySpecificKeyframe(offset, easing, emptyString(), AnimationEffect::CompositeAdd)); |
| + return adoptPtrWillBeNoop(new PropertySpecificKeyframe(offset, easing, nullptr, AnimationEffect::CompositeAdd)); |
| } |
| PassOwnPtrWillBeRawPtr<Keyframe::PropertySpecificKeyframe> StringKeyframe::PropertySpecificKeyframe::cloneWithOffset(double offset) const |
| { |
| - Keyframe::PropertySpecificKeyframe *theClone = new PropertySpecificKeyframe(offset, m_easing, m_value); |
| + Keyframe::PropertySpecificKeyframe *theClone = new PropertySpecificKeyframe(offset, m_easing, m_value.get()); |
| return adoptPtrWillBeNoop(theClone); |
| } |
| void StringKeyframe::PropertySpecificKeyframe::trace(Visitor* visitor) |
| { |
| + visitor->trace(m_value); |
| } |
| } |