Chromium Code Reviews| Index: Source/core/animation/KeyframeEffectModel.cpp |
| diff --git a/Source/core/animation/KeyframeEffectModel.cpp b/Source/core/animation/KeyframeEffectModel.cpp |
| index 4cebd5c6a3a30f93f0366b49888e5cf605495f04..48bcabc3aa3ea9e65717851a40f590f91549ab88 100644 |
| --- a/Source/core/animation/KeyframeEffectModel.cpp |
| +++ b/Source/core/animation/KeyframeEffectModel.cpp |
| @@ -31,8 +31,12 @@ |
| #include "config.h" |
| #include "core/animation/KeyframeEffectModel.h" |
| +#include "StylePropertyShorthand.h" |
| #include "core/animation/AnimatableDouble.h" |
| #include "core/animation/TimedItem.h" |
| +#include "core/animation/css/CSSAnimations.h" |
| +#include "core/css/StylePropertySet.h" |
| +#include "core/css/resolver/StyleResolver.h" |
| #include "wtf/text/StringHash.h" |
| namespace WebCore { |
| @@ -145,6 +149,7 @@ void KeyframeEffectModelBase::ensureKeyframeGroups() const |
| PropertySet keyframeProperties = keyframe->properties(); |
| for (PropertySet::const_iterator propertyIter = keyframeProperties.begin(); propertyIter != keyframeProperties.end(); ++propertyIter) { |
| CSSPropertyID property = *propertyIter; |
| + ASSERT_WITH_MESSAGE(!isExpandedShorthand(property), "Web Animations: Encountered shorthand CSS property (%d) in normalized keyframes.", property); |
| KeyframeGroupMap::iterator groupIter = m_keyframeGroups->find(property); |
| PropertySpecificKeyframeGroup* group; |
| if (groupIter == m_keyframeGroups->end()) |
| @@ -255,19 +260,43 @@ PassOwnPtr<KeyframeEffectModelBase::PropertySpecificKeyframe> AVKeyframeEffectMo |
| return adoptPtr(new PropertySpecificKeyframe(offset, easing, AnimatableValue::neutralValue(), CompositeAdd)); |
| } |
| +void SKeyframe::setPropertyValue(CSSPropertyID property, const String& value) |
| +{ |
| + ASSERT(property != CSSPropertyInvalid); |
| + RefPtr<MutableStylePropertySet> propertySet = MutableStylePropertySet::create(); |
| + propertySet->setProperty(property, value); |
| + for (size_t i = 0; i < propertySet->propertyCount(); ++i) { |
| + CSSPropertyID id = propertySet->propertyAt(i).id(); |
| + if (CSSAnimations::isAnimatableProperty(id)) |
| + m_propertyValues.add(id, propertySet->getPropertyCSSValue(id)); |
| + } |
| +} |
| + |
| +static bool checkDocumentAndRenderer(Element& element) |
| +{ |
| + if (!element.inActiveDocument()) |
| + return false; |
| + element.document().updateStyleIfNeeded(); |
| + return element.renderer(); |
| +} |
| + |
| PassRefPtr<Interpolation> SKeyframeEffectModel::createInterpolation(CSSPropertyID property, KeyframeEffectModelBase::PropertySpecificKeyframe *start, KeyframeEffectModelBase::PropertySpecificKeyframe *end) const |
| { |
| - PropertySpecificKeyframe *from = toPropertySpecificKeyframe(start); |
| - PropertySpecificKeyframe *to = toPropertySpecificKeyframe(end); |
| - ASSERT_UNUSED(from, from); |
| - ASSERT_UNUSED(to, to); |
| - // create Interpolation here |
| - return RefPtr<Interpolation>(); |
| + // FIXME: This check will not be neccessary once we can avoid snapshotting computed style values for keyframes. |
| + RELEASE_ASSERT(checkDocumentAndRenderer(*m_element.get())); |
| + |
| + CSSValue* fromCSSValue = toPropertySpecificKeyframe(start)->value(); |
| + CSSValue* toCSSValue = toPropertySpecificKeyframe(end)->value(); |
| + |
| + RefPtr<AnimatableValue> from = StyleResolver::createAnimatableValueSnapshot(*m_element.get(), *m_renderStyle.get(), property, fromCSSValue); |
| + RefPtr<AnimatableValue> to = StyleResolver::createAnimatableValueSnapshot(*m_element.get(), *m_renderStyle.get(), property, toCSSValue); |
| + |
| + return LegacyStyleInterpolation::create(from, to, property); |
|
alancutter (OOO until 2018)
2014/03/11 09:45:33
from.release(), to.release()
|
| } |
| PassOwnPtr<KeyframeEffectModelBase::PropertySpecificKeyframe> SKeyframeEffectModel::neutralKeyframe(double offset, PassRefPtr<TimingFunction> easing) const |
| { |
| - return adoptPtr(new PropertySpecificKeyframe(offset, easing, "invalid", CompositeAdd)); |
| + return adoptPtr(new PropertySpecificKeyframe(offset, easing, nullptr, CompositeAdd)); |
| } |
| } // namespace |