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

Side by Side Diff: third_party/WebKit/Source/core/animation/InterpolationEffect.cpp

Issue 1942703002: Fix handling of multiple keyframes at same offset (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Response to review Created 4 years, 7 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 unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "core/animation/InterpolationEffect.h" 5 #include "core/animation/InterpolationEffect.h"
6 6
7 namespace blink { 7 namespace blink {
8 8
9 void InterpolationEffect::getActiveInterpolations(double fraction, double iterat ionDuration, Vector<RefPtr<Interpolation>>& result) const 9 void InterpolationEffect::getActiveInterpolations(double fraction, double iterat ionDuration, Vector<RefPtr<Interpolation>>& result) const
10 { 10 {
11 size_t existingSize = result.size(); 11 size_t existingSize = result.size();
12 size_t resultIndex = 0; 12 size_t resultIndex = 0;
13 13
14 for (const auto& record : m_interpolations) { 14 for (const auto& record : m_interpolations) {
15 if (fraction >= record.m_applyFrom && fraction < record.m_applyTo) { 15 if (fraction >= record.m_applyFrom && fraction < record.m_applyTo) {
16 RefPtr<Interpolation> interpolation = record.m_interpolation; 16 RefPtr<Interpolation> interpolation = record.m_interpolation;
17 double localFraction = (fraction - record.m_start) / (record.m_end - record.m_start); 17 double recordLength = record.m_end - record.m_start;
18 double localFraction = recordLength ? (fraction - record.m_start) / recordLength : 0.0;
18 if (record.m_easing) 19 if (record.m_easing)
19 localFraction = record.m_easing->evaluate(localFraction, accurac yForDuration(iterationDuration)); 20 localFraction = record.m_easing->evaluate(localFraction, accurac yForDuration(iterationDuration));
20 interpolation->interpolate(0, localFraction); 21 interpolation->interpolate(0, localFraction);
21 if (resultIndex < existingSize) 22 if (resultIndex < existingSize)
22 result[resultIndex++] = interpolation; 23 result[resultIndex++] = interpolation;
23 else 24 else
24 result.append(interpolation); 25 result.append(interpolation);
25 } 26 }
26 } 27 }
27 if (resultIndex < existingSize) 28 if (resultIndex < existingSize)
28 result.shrink(resultIndex); 29 result.shrink(resultIndex);
29 } 30 }
30 31
31 void InterpolationEffect::addInterpolationsFromKeyframes(PropertyHandle property , const Keyframe::PropertySpecificKeyframe& keyframeA, const Keyframe::PropertyS pecificKeyframe& keyframeB, double applyFrom, double applyTo) 32 void InterpolationEffect::addInterpolationsFromKeyframes(PropertyHandle property , const Keyframe::PropertySpecificKeyframe& keyframeA, const Keyframe::PropertyS pecificKeyframe& keyframeB, double applyFrom, double applyTo)
32 { 33 {
33 addInterpolation(keyframeA.createInterpolation(property, keyframeB), &keyfra meA.easing(), keyframeA.offset(), keyframeB.offset(), applyFrom, applyTo); 34 addInterpolation(keyframeA.createInterpolation(property, keyframeB), &keyfra meA.easing(), keyframeA.offset(), keyframeB.offset(), applyFrom, applyTo);
34 } 35 }
35 36
36 } // namespace blink 37 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698