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

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

Issue 1942703002: Fix handling of multiple keyframes at same offset (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove unneeded 0<offset<1 case for equal offsets Created 4 years, 8 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 | « third_party/WebKit/Source/core/animation/InterpolationEffect.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/core/animation/KeyframeEffectModel.cpp
diff --git a/third_party/WebKit/Source/core/animation/KeyframeEffectModel.cpp b/third_party/WebKit/Source/core/animation/KeyframeEffectModel.cpp
index bfd271fce467035d3f85a3fe4a16e7c311e6e706..f7f6dbf810751be06d765c5cef52386f6b632754 100644
--- a/third_party/WebKit/Source/core/animation/KeyframeEffectModel.cpp
+++ b/third_party/WebKit/Source/core/animation/KeyframeEffectModel.cpp
@@ -209,10 +209,20 @@ void KeyframeEffectModelBase::ensureInterpolationEffectPopulated() const
for (size_t i = 0; i < keyframes.size() - 1; i++) {
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.addInterpolationsFromKeyframes(entry.key, *keyframes[i], *keyframes[i + 1], applyFrom, applyTo);
+ if (keyframes[i]->offset() == keyframes[i + 1]->offset()) {
+ // There are three cases here:
+ // - offset 0, used for iteration progress (-inf,0), which should use the first offset 0 value
+ // - offset 1, used for iteration progress [1,inf), which should use the second offset 1 value
+ // - 0 < offset < 1, never used in sampling
alancutter (OOO until 2018) 2016/05/04 01:32:31 This comment is a touch close to being a straight
alancutter (OOO until 2018) 2016/05/04 01:35:32 Possible suggestion: if (offset == 0) { ASSERT
suzyh_UTC10 (ex-contributor) 2016/05/04 01:41:00 Fair. I was trying to explain why the first two ca
+ if (keyframes[i]->offset() == 0) {
+ m_interpolationEffect.addInterpolationsFromKeyframes(entry.key, *keyframes[i], *keyframes[i], applyFrom, applyTo);
+ } else if (keyframes[i]->offset() == 1) {
+ m_interpolationEffect.addInterpolationsFromKeyframes(entry.key, *keyframes[i + 1], *keyframes[i + 1], applyFrom, applyTo);
+ }
+ } else {
+ m_interpolationEffect.addInterpolationsFromKeyframes(entry.key, *keyframes[i], *keyframes[i + 1], applyFrom, applyTo);
+ }
}
}
@@ -247,17 +257,15 @@ void KeyframeEffectModelBase::PropertySpecificKeyframeGroup::appendKeyframe(Pass
void KeyframeEffectModelBase::PropertySpecificKeyframeGroup::removeRedundantKeyframes()
{
- // As an optimization, removes keyframes in the following categories, as
- // they will never be used by sample().
- // - End keyframes with the same offset as their neighbor
- // - Interior keyframes with the same offset as both their neighbors
+ // As an optimization, removes interior keyframes that have the same offset
+ // as both their neighbours, as they will never be used by sample().
// Note that synthetic keyframes must be added before this method is
// called.
ASSERT(m_keyframes.size() >= 2);
- for (int i = m_keyframes.size() - 1; i >= 0; --i) {
+ for (int i = m_keyframes.size() - 2; i > 0; --i) {
double offset = m_keyframes[i]->offset();
- bool hasSameOffsetAsPreviousNeighbor = !i || m_keyframes[i - 1]->offset() == offset;
- bool hasSameOffsetAsNextNeighbor = i == static_cast<int>(m_keyframes.size() - 1) || m_keyframes[i + 1]->offset() == offset;
+ bool hasSameOffsetAsPreviousNeighbor = m_keyframes[i - 1]->offset() == offset;
+ bool hasSameOffsetAsNextNeighbor = m_keyframes[i + 1]->offset() == offset;
if (hasSameOffsetAsPreviousNeighbor && hasSameOffsetAsNextNeighbor)
m_keyframes.remove(i);
}
« no previous file with comments | « third_party/WebKit/Source/core/animation/InterpolationEffect.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698