Chromium Code Reviews| Index: Source/core/animation/KeyframeEffectModel.cpp |
| diff --git a/Source/core/animation/KeyframeEffectModel.cpp b/Source/core/animation/KeyframeEffectModel.cpp |
| index a50dff33f5da4fa48202eaab7e6e69438a368c04..0cc00f84a3fff843af06a921ec6c09444c0e3f40 100644 |
| --- a/Source/core/animation/KeyframeEffectModel.cpp |
| +++ b/Source/core/animation/KeyframeEffectModel.cpp |
| @@ -36,72 +36,12 @@ |
| namespace WebCore { |
| -Keyframe::Keyframe() |
| - : m_offset(nullValue()) |
| - , m_composite(AnimationEffect::CompositeReplace) |
| - , m_easing(LinearTimingFunction::preset()) |
| -{ } |
| - |
| -Keyframe::Keyframe(const Keyframe& copyFrom) |
| - : m_offset(copyFrom.m_offset) |
| - , m_composite(copyFrom.m_composite) |
| - , m_easing(copyFrom.m_easing) |
| +bool Keyframe::compareOffsets(const RefPtrWillBeRawPtr<Keyframe>& a, const RefPtrWillBeRawPtr<Keyframe>& b) |
| { |
| - ASSERT(m_easing); |
| - for (PropertyValueMap::const_iterator iter = copyFrom.m_propertyValues.begin(); iter != copyFrom.m_propertyValues.end(); ++iter) |
| - setPropertyValue(iter->key, iter->value.get()); |
| + return a->offset() < b->offset(); |
| } |
| -void Keyframe::setEasing(PassRefPtr<TimingFunction> easing) |
| -{ |
| - ASSERT(easing); |
| - m_easing = easing; |
| -} |
| - |
| -void Keyframe::setPropertyValue(CSSPropertyID property, const AnimatableValue* value) |
| -{ |
| - m_propertyValues.add(property, const_cast<AnimatableValue*>(value)); |
| -} |
| - |
| -void Keyframe::clearPropertyValue(CSSPropertyID property) |
| -{ |
| - m_propertyValues.remove(property); |
| -} |
| - |
| -const AnimatableValue* Keyframe::propertyValue(CSSPropertyID property) const |
| -{ |
| - ASSERT(m_propertyValues.contains(property)); |
| - return m_propertyValues.get(property); |
| -} |
| - |
| -PropertySet Keyframe::properties() const |
| -{ |
| - // This is not used in time-critical code, so we probably don't need to |
| - // worry about caching this result. |
| - PropertySet properties; |
| - for (PropertyValueMap::const_iterator iter = m_propertyValues.begin(); iter != m_propertyValues.end(); ++iter) |
| - properties.add(*iter.keys()); |
| - return properties; |
| -} |
| - |
| -PassRefPtrWillBeRawPtr<Keyframe> Keyframe::cloneWithOffset(double offset) const |
| -{ |
| - RefPtrWillBeRawPtr<Keyframe> theClone = clone(); |
| - theClone->setOffset(offset); |
| - return theClone.release(); |
| -} |
| - |
| -void Keyframe::trace(Visitor* visitor) |
| -{ |
| - visitor->trace(m_propertyValues); |
| -} |
| - |
| -KeyframeEffectModel::KeyframeEffectModel(const KeyframeVector& keyframes) |
| - : m_keyframes(keyframes) |
| -{ |
| -} |
| - |
| -PropertySet KeyframeEffectModel::properties() const |
| +PropertySet KeyframeEffectModelBase::properties() const |
| { |
| PropertySet result; |
| if (!m_keyframes.size()) { |
| @@ -117,7 +57,7 @@ PropertySet KeyframeEffectModel::properties() const |
| return result; |
| } |
| -PassOwnPtrWillBeRawPtr<WillBeHeapVector<RefPtrWillBeMember<Interpolation> > > KeyframeEffectModel::sample(int iteration, double fraction, double iterationDuration) const |
| +PassOwnPtr<Vector<RefPtr<Interpolation> > > KeyframeEffectModelBase::sample(int iteration, double fraction, double iterationDuration) const |
|
alancutter (OOO until 2018)
2014/04/01 03:12:48
We should keep the Oilpan types.
shans
2014/04/01 04:01:27
Bad merge, I think.
|
| { |
| ASSERT(iteration >= 0); |
| ASSERT(!isNull(fraction)); |
| @@ -127,7 +67,7 @@ PassOwnPtrWillBeRawPtr<WillBeHeapVector<RefPtrWillBeMember<Interpolation> > > Ke |
| return m_interpolationEffect->getActiveInterpolations(fraction, iterationDuration); |
| } |
| -KeyframeEffectModel::KeyframeVector KeyframeEffectModel::normalizedKeyframes(const KeyframeVector& keyframes) |
| +KeyframeEffectModelBase::KeyframeVector KeyframeEffectModelBase::normalizedKeyframes(const KeyframeVector& keyframes) |
| { |
| // keyframes [beginIndex, endIndex) will remain after removing all keyframes if they are not |
| // loosely sorted by offset, and after removing keyframes with positional offset outide [0, 1]. |
| @@ -191,7 +131,8 @@ KeyframeEffectModel::KeyframeVector KeyframeEffectModel::normalizedKeyframes(con |
| return result; |
| } |
| -void KeyframeEffectModel::ensureKeyframeGroups() const |
| + |
| +void KeyframeEffectModelBase::ensureKeyframeGroups() const |
| { |
| if (m_keyframeGroups) |
| return; |
| @@ -211,19 +152,18 @@ void KeyframeEffectModel::ensureKeyframeGroups() const |
| group = groupIter->value.get(); |
| ASSERT(keyframe->composite() == AnimationEffect::CompositeReplace); |
| - group->appendKeyframe(adoptPtrWillBeNoop( |
| - new PropertySpecificKeyframe(keyframe->offset(), keyframe->easing(), keyframe->propertyValue(property), keyframe->composite()))); |
| + group->appendKeyframe(keyframe->createPropertySpecificKeyframe(property)); |
| } |
| } |
| // Add synthetic keyframes. |
| for (KeyframeGroupMap::iterator iter = m_keyframeGroups->begin(); iter != m_keyframeGroups->end(); ++iter) { |
| - iter->value->addSyntheticKeyframeIfRequired(); |
| + iter->value->addSyntheticKeyframeIfRequired(this); |
| iter->value->removeRedundantKeyframes(); |
| } |
| } |
| -void KeyframeEffectModel::ensureInterpolationEffect() const |
| +void KeyframeEffectModelBase::ensureInterpolationEffect() const |
| { |
| if (m_interpolationEffect) |
| return; |
| @@ -232,26 +172,20 @@ void KeyframeEffectModel::ensureInterpolationEffect() const |
| for (KeyframeGroupMap::const_iterator iter = m_keyframeGroups->begin(); iter != m_keyframeGroups->end(); ++iter) { |
| const PropertySpecificKeyframeVector& keyframes = iter->value->keyframes(); |
| ASSERT(keyframes[0]->composite() == AnimationEffect::CompositeReplace); |
| - const AnimatableValue* start; |
| - const AnimatableValue* end = keyframes[0]->value(); |
| for (size_t i = 0; i < keyframes.size() - 1; i++) { |
| ASSERT(keyframes[i + 1]->composite() == AnimationEffect::CompositeReplace); |
| - start = end; |
| - end = keyframes[i + 1]->value(); |
| double applyFrom = i ? keyframes[i]->offset() : (-std::numeric_limits<double>::infinity()); |
| double applyTo = i == keyframes.size() - 2 ? std::numeric_limits<double>::infinity() : keyframes[i + 1]->offset(); |
| if (applyTo == 1) |
| applyTo = std::numeric_limits<double>::infinity(); |
| - m_interpolationEffect->addInterpolation( |
| - LegacyStyleInterpolation::create( |
| - AnimatableValue::takeConstRef(start), |
| - AnimatableValue::takeConstRef(end), iter->key), |
| + |
| + m_interpolationEffect->addInterpolation(keyframes[i]->createInterpolation(iter->key, keyframes[i + 1].get()), |
| keyframes[i]->easing(), keyframes[i]->offset(), keyframes[i + 1]->offset(), applyFrom, applyTo); |
| } |
| } |
| } |
| -bool KeyframeEffectModel::isReplaceOnly() |
| +bool KeyframeEffectModelBase::isReplaceOnly() |
| { |
| ensureKeyframeGroups(); |
| for (KeyframeGroupMap::iterator iter = m_keyframeGroups->begin(); iter != m_keyframeGroups->end(); ++iter) { |
| @@ -264,7 +198,7 @@ bool KeyframeEffectModel::isReplaceOnly() |
| return true; |
| } |
| -void KeyframeEffectModel::trace(Visitor* visitor) |
| +void KeyframeEffectModelBase::trace(Visitor* visitor) |
| { |
| visitor->trace(m_keyframes); |
| visitor->trace(m_interpolationEffect); |
| @@ -273,40 +207,20 @@ void KeyframeEffectModel::trace(Visitor* visitor) |
| #endif |
| } |
| -KeyframeEffectModel::PropertySpecificKeyframe::PropertySpecificKeyframe(double offset, PassRefPtr<TimingFunction> easing, const AnimatableValue* value, CompositeOperation composite) |
| +Keyframe::PropertySpecificKeyframe::PropertySpecificKeyframe(double offset, PassRefPtr<TimingFunction> easing, AnimationEffect::CompositeOperation composite) |
| : m_offset(offset) |
| , m_easing(easing) |
| , m_composite(composite) |
| { |
| - m_value = AnimatableValue::takeConstRef(value); |
| } |
| -KeyframeEffectModel::PropertySpecificKeyframe::PropertySpecificKeyframe(double offset, PassRefPtr<TimingFunction> easing, PassRefPtrWillBeRawPtr<AnimatableValue> value, CompositeOperation composite) |
| - : m_offset(offset) |
| - , m_easing(easing) |
| - , m_value(value) |
| - , m_composite(composite) |
| -{ |
| - ASSERT(!isNull(m_offset)); |
| -} |
| - |
| -PassOwnPtrWillBeRawPtr<KeyframeEffectModel::PropertySpecificKeyframe> KeyframeEffectModel::PropertySpecificKeyframe::cloneWithOffset(double offset) const |
| -{ |
| - return adoptPtrWillBeNoop(new PropertySpecificKeyframe(offset, m_easing, m_value.get(), m_composite)); |
| -} |
| - |
| -void KeyframeEffectModel::PropertySpecificKeyframe::trace(Visitor* visitor) |
| -{ |
| - visitor->trace(m_value); |
| -} |
| - |
| -void KeyframeEffectModel::PropertySpecificKeyframeGroup::appendKeyframe(PassOwnPtrWillBeRawPtr<PropertySpecificKeyframe> keyframe) |
| +void KeyframeEffectModelBase::PropertySpecificKeyframeGroup::appendKeyframe(PassOwnPtr<PropertySpecificKeyframe> keyframe) |
| { |
| ASSERT(m_keyframes.isEmpty() || m_keyframes.last()->offset() <= keyframe->offset()); |
| m_keyframes.append(keyframe); |
| } |
| -void KeyframeEffectModel::PropertySpecificKeyframeGroup::removeRedundantKeyframes() |
| +void KeyframeEffectModelBase::PropertySpecificKeyframeGroup::removeRedundantKeyframes() |
| { |
| // As an optimization, removes keyframes in the following categories, as |
| // they will never be used by sample(). |
| @@ -325,20 +239,53 @@ void KeyframeEffectModel::PropertySpecificKeyframeGroup::removeRedundantKeyframe |
| ASSERT(m_keyframes.size() >= 2); |
| } |
| -void KeyframeEffectModel::PropertySpecificKeyframeGroup::addSyntheticKeyframeIfRequired() |
| +void KeyframeEffectModelBase::PropertySpecificKeyframeGroup::addSyntheticKeyframeIfRequired(const KeyframeEffectModelBase *context) |
| { |
| ASSERT(!m_keyframes.isEmpty()); |
| if (m_keyframes.first()->offset() != 0.0) |
| - m_keyframes.insert(0, adoptPtrWillBeNoop(new PropertySpecificKeyframe(0, nullptr, AnimatableValue::neutralValue(), CompositeAdd))); |
| + m_keyframes.insert(0, m_keyframes.first()->neutralKeyframe(0, nullptr)); |
| if (m_keyframes.last()->offset() != 1.0) |
| - appendKeyframe(adoptPtrWillBeNoop(new PropertySpecificKeyframe(1, nullptr, AnimatableValue::neutralValue(), CompositeAdd))); |
| + appendKeyframe(m_keyframes.last()->neutralKeyframe(1, nullptr)); |
| } |
| -void KeyframeEffectModel::PropertySpecificKeyframeGroup::trace(Visitor* visitor) |
| +PassRefPtr<Interpolation> AnimatableValueKeyframe::PropertySpecificKeyframe::createInterpolation(CSSPropertyID property, Keyframe::PropertySpecificKeyframe *end) const |
|
alancutter (OOO until 2018)
2014/04/01 03:12:48
This function and others below are declared in Ani
shans
2014/04/01 04:01:27
Ah yes, forgot to move these when I moved Keyframe
|
| { |
| -#if ENABLE_OILPAN |
| + AnimatableValuePropertySpecificKeyframe* to = toAnimatableValuePropertySpecificKeyframe(end); |
| + return LegacyStyleInterpolation::create(value(), to->value(), property); |
| +} |
| + |
| +PassOwnPtr<Keyframe::PropertySpecificKeyframe> AnimatableValueKeyframe::PropertySpecificKeyframe::neutralKeyframe(double offset, PassRefPtr<TimingFunction> easing) const |
| +{ |
|
alancutter (OOO until 2018)
2014/04/01 03:12:48
Perhaps this should have ASSERT_NOT_REACHED() here
shans
2014/04/01 04:01:27
I think that would be a Very Bad Idea, because it
|
| + return adoptPtr(new AnimatableValueKeyframe::PropertySpecificKeyframe(offset, easing, AnimatableValue::neutralValue(), AnimationEffect::CompositeAdd)); |
| +} |
| + |
| +PassRefPtr<Interpolation> StringKeyframe::PropertySpecificKeyframe::createInterpolation(CSSPropertyID property, Keyframe::PropertySpecificKeyframe *end) const |
| +{ |
| + ASSERT_UNUSED(end, end); |
| + // FIXME: Convert string keyframe value pairs to interpolations. |
| + return nullptr; |
| +} |
| + |
| +PassOwnPtr<Keyframe::PropertySpecificKeyframe> StringKeyframe::PropertySpecificKeyframe::neutralKeyframe(double offset, PassRefPtr<TimingFunction> easing) const |
| +{ |
| + return adoptPtr(new StringKeyframe::PropertySpecificKeyframe(offset, easing, emptyString(), AnimationEffect::CompositeAdd)); |
| +} |
| + |
| +void KeyframeEffectModelBase::PropertySpecificKeyframeGroup::trace(Visitor* visitor) |
| +{ |
| +#if ENABLE(OILPAN) |
| visitor->trace(m_keyframes); |
| #endif |
| } |
| +template <> |
| +bool KeyframeEffectModel<AnimatableValueKeyframe>::isAnimatableValueKeyframeEffectModel() const { return true; } |
| +/*template <> |
| +bool KeyframeEffectModel<AnimatableValueKeyframe>::isStringKeyframeEffectModel() const { return false; } |
| +*/ |
| +template <> |
| +bool KeyframeEffectModel<StringKeyframe>::isStringKeyframeEffectModel() const { return true; } |
| +/*template <> |
| +bool KeyframeEffectModel<StringKeyframe>::isAnimatableValueKeyframeEffectModel() const { return false; } |
| +*/ |
|
alancutter (OOO until 2018)
2014/04/01 01:09:40
Commented code to be removed?
shans
2014/04/01 04:01:27
yeah
|
| } // namespace |