Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(325)

Unified Diff: Source/core/animation/KeyframeEffectModel.cpp

Issue 203463009: Web Animations API: Fix Synthetic keyframes + partial keyframes (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Return nullptr after exception + fixmes Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/core/animation/KeyframeEffectModel.h ('k') | Source/core/animation/KeyframeEffectModelTest.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/animation/KeyframeEffectModel.cpp
diff --git a/Source/core/animation/KeyframeEffectModel.cpp b/Source/core/animation/KeyframeEffectModel.cpp
index b6f813f8ada431190082cdb48cad2f8ada85ca79..595c0d1af287597077ffe04aa573eb678e58ce29 100644
--- a/Source/core/animation/KeyframeEffectModel.cpp
+++ b/Source/core/animation/KeyframeEffectModel.cpp
@@ -205,6 +205,7 @@ void KeyframeEffectModel::ensureKeyframeGroups() const
else
group = groupIter->value.get();
+ ASSERT(keyframe->composite() == AnimationEffect::CompositeReplace);
group->appendKeyframe(adoptPtr(
new PropertySpecificKeyframe(keyframe->offset(), keyframe->easing(), keyframe->propertyValue(property), keyframe->composite())));
}
@@ -225,9 +226,11 @@ 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());
@@ -243,25 +246,39 @@ void KeyframeEffectModel::ensureInterpolationEffect() const
}
}
+bool KeyframeEffectModel::isReplaceOnly()
+{
+ ensureKeyframeGroups();
+ for (KeyframeGroupMap::iterator iter = m_keyframeGroups->begin(); iter != m_keyframeGroups->end(); ++iter) {
+ const PropertySpecificKeyframeVector& keyframeVector = iter->value->keyframes();
+ for (size_t i = 0; i < keyframeVector.size(); ++i) {
+ if (keyframeVector[i]->composite() != AnimationEffect::CompositeReplace)
+ return false;
+ }
+ }
+ return true;
+}
+
KeyframeEffectModel::PropertySpecificKeyframe::PropertySpecificKeyframe(double offset, PassRefPtr<TimingFunction> easing, const AnimatableValue* value, CompositeOperation composite)
: m_offset(offset)
, m_easing(easing)
+ , m_composite(composite)
{
- ASSERT(composite == AnimationEffect::CompositeReplace);
m_value = AnimatableValue::takeConstRef(value);
}
-KeyframeEffectModel::PropertySpecificKeyframe::PropertySpecificKeyframe(double offset, PassRefPtr<TimingFunction> easing, PassRefPtr<AnimatableValue> value)
+KeyframeEffectModel::PropertySpecificKeyframe::PropertySpecificKeyframe(double offset, PassRefPtr<TimingFunction> easing, PassRefPtr<AnimatableValue> value, CompositeOperation composite)
: m_offset(offset)
, m_easing(easing)
, m_value(value)
+ , m_composite(composite)
{
ASSERT(!isNull(m_offset));
}
PassOwnPtr<KeyframeEffectModel::PropertySpecificKeyframe> KeyframeEffectModel::PropertySpecificKeyframe::cloneWithOffset(double offset) const
{
- return adoptPtr(new PropertySpecificKeyframe(offset, m_easing, m_value));
+ return adoptPtr(new PropertySpecificKeyframe(offset, m_easing, m_value, m_composite));
}
@@ -293,21 +310,10 @@ void KeyframeEffectModel::PropertySpecificKeyframeGroup::removeRedundantKeyframe
void KeyframeEffectModel::PropertySpecificKeyframeGroup::addSyntheticKeyframeIfRequired()
{
ASSERT(!m_keyframes.isEmpty());
- double offset = m_keyframes.first()->offset();
- bool allOffsetsEqual = true;
- for (PropertySpecificKeyframeVector::const_iterator iter = m_keyframes.begin() + 1; iter != m_keyframes.end(); ++iter) {
- if ((*iter)->offset() != offset) {
- allOffsetsEqual = false;
- break;
- }
- }
- if (!allOffsetsEqual)
- return;
-
- if (!offset)
- appendKeyframe(m_keyframes.first()->cloneWithOffset(1.0));
- else
- m_keyframes.insert(0, adoptPtr(new PropertySpecificKeyframe(0.0, nullptr, AnimatableValue::neutralValue(), CompositeAdd)));
+ if (m_keyframes.first()->offset() != 0.0)
+ m_keyframes.insert(0, adoptPtr(new PropertySpecificKeyframe(0, nullptr, AnimatableValue::neutralValue(), CompositeAdd)));
+ if (m_keyframes.last()->offset() != 1.0)
+ appendKeyframe(adoptPtr(new PropertySpecificKeyframe(1, nullptr, AnimatableValue::neutralValue(), CompositeAdd)));
}
void KeyframeEffectModel::trace(Visitor* visitor)
« no previous file with comments | « Source/core/animation/KeyframeEffectModel.h ('k') | Source/core/animation/KeyframeEffectModelTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698