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

Side by Side Diff: Source/core/animation/KeyframeAnimationEffect.cpp

Issue 21779003: Web Animations CSS: Snapshot missing start/end Keyframes and remove duplicates (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Make it build. Created 7 years, 4 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 | Annotate | Revision Log
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2013 Google Inc. All rights reserved. 2 * Copyright (C) 2013 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
88 BlendedCompositableValue(const AnimationEffect::CompositableValue* before, c onst AnimationEffect::CompositableValue* after, double fraction) 88 BlendedCompositableValue(const AnimationEffect::CompositableValue* before, c onst AnimationEffect::CompositableValue* after, double fraction)
89 : m_before(const_cast<AnimationEffect::CompositableValue*>(before)) 89 : m_before(const_cast<AnimationEffect::CompositableValue*>(before))
90 , m_after(const_cast<AnimationEffect::CompositableValue*>(after)) 90 , m_after(const_cast<AnimationEffect::CompositableValue*>(after))
91 , m_fraction(fraction) 91 , m_fraction(fraction)
92 { } 92 { }
93 RefPtr<AnimationEffect::CompositableValue> m_before; 93 RefPtr<AnimationEffect::CompositableValue> m_before;
94 RefPtr<AnimationEffect::CompositableValue> m_after; 94 RefPtr<AnimationEffect::CompositableValue> m_after;
95 double m_fraction; 95 double m_fraction;
96 }; 96 };
97 97
98 bool compareOffsets(const RefPtr<Keyframe>& a, const RefPtr<Keyframe>& b)
99 {
100 return a->offset() < b->offset();
101 }
102
103 } // namespace 98 } // namespace
104 99
105 100
106 namespace WebCore { 101 namespace WebCore {
107 102
108 Keyframe::Keyframe() 103 Keyframe::Keyframe()
109 : m_offset(std::numeric_limits<double>::quiet_NaN()) 104 : m_offset(std::numeric_limits<double>::quiet_NaN())
110 , m_composite(AnimationEffect::CompositeReplace) 105 , m_composite(AnimationEffect::CompositeReplace)
111 { } 106 { }
112 107
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
160 Keyframe* lastKeyframe = keyframes.last().get(); 155 Keyframe* lastKeyframe = keyframes.last().get();
161 if (lastKeyframe && std::isnan(lastKeyframe->offset())) 156 if (lastKeyframe && std::isnan(lastKeyframe->offset()))
162 lastKeyframe->setOffset(1.0); 157 lastKeyframe->setOffset(1.0);
163 } 158 }
164 159
165 // FIXME: Distribute offsets where missing. 160 // FIXME: Distribute offsets where missing.
166 for (KeyframeVector::iterator iter = keyframes.begin(); iter != keyframes.en d(); ++iter) 161 for (KeyframeVector::iterator iter = keyframes.begin(); iter != keyframes.en d(); ++iter)
167 ASSERT(!std::isnan((*iter)->offset())); 162 ASSERT(!std::isnan((*iter)->offset()));
168 163
169 // Sort by offset. 164 // Sort by offset.
170 std::stable_sort(keyframes.begin(), keyframes.end(), compareOffsets); 165 std::stable_sort(keyframes.begin(), keyframes.end(), Keyframe::compareOffset s);
171 return keyframes; 166 return keyframes;
172 } 167 }
173 168
174 void KeyframeAnimationEffect::ensureKeyframeGroups() 169 void KeyframeAnimationEffect::ensureKeyframeGroups()
175 { 170 {
176 if (m_keyframeGroups) 171 if (m_keyframeGroups)
177 return; 172 return;
178 173
179 m_keyframeGroups = adoptPtr(new KeyframeGroupMap); 174 m_keyframeGroups = adoptPtr(new KeyframeGroupMap);
180 const KeyframeVector& keyframes = normalizedKeyframes(); 175 const KeyframeVector& keyframes = normalizedKeyframes();
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
306 301
307 if ((*before)->offset() == offset) 302 if ((*before)->offset() == offset)
308 return const_cast<CompositableValue*>((*before)->value()); 303 return const_cast<CompositableValue*>((*before)->value());
309 if ((*after)->offset() == offset) 304 if ((*after)->offset() == offset)
310 return const_cast<CompositableValue*>((*after)->value()); 305 return const_cast<CompositableValue*>((*after)->value());
311 return BlendedCompositableValue::create((*before)->value(), (*after)->value( ), 306 return BlendedCompositableValue::create((*before)->value(), (*after)->value( ),
312 (offset - (*before)->offset()) / ((*after)->offset() - (*before)->offset ())); 307 (offset - (*before)->offset()) / ((*after)->offset() - (*before)->offset ()));
313 } 308 }
314 309
315 } // namespace 310 } // namespace
OLDNEW
« no previous file with comments | « Source/core/animation/KeyframeAnimationEffect.h ('k') | Source/core/animation/css/CSSAnimations.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698