Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 177 } | 177 } |
| 178 } | 178 } |
| 179 | 179 |
| 180 Timing timing; | 180 Timing timing; |
| 181 RefPtr<TimingFunction> defaultTimingFunction = timingFromAnimationDa ta(animationData, timing); | 181 RefPtr<TimingFunction> defaultTimingFunction = timingFromAnimationDa ta(animationData, timing); |
| 182 KeyframeAnimationEffect::KeyframeVector keyframes; | 182 KeyframeAnimationEffect::KeyframeVector keyframes; |
| 183 resolver->resolveKeyframes(element, style, animationName, defaultTim ingFunction.get(), keyframes, timing.timingFunction); | 183 resolver->resolveKeyframes(element, style, animationName, defaultTim ingFunction.get(), keyframes, timing.timingFunction); |
| 184 if (!keyframes.isEmpty()) { | 184 if (!keyframes.isEmpty()) { |
| 185 if (!update) | 185 if (!update) |
| 186 update = adoptPtr(new CSSAnimationUpdate()); | 186 update = adoptPtr(new CSSAnimationUpdate()); |
| 187 HashSet<RefPtr<InertAnimation> > animations; | |
| 187 // FIXME: crbug.com/268791 - Keyframes are already normalized, p erhaps there should be a flag on KeyframeAnimationEffect to skip normalization. | 188 // FIXME: crbug.com/268791 - Keyframes are already normalized, p erhaps there should be a flag on KeyframeAnimationEffect to skip normalization. |
| 188 update->startAnimation(animationName, InertAnimation::create(Key frameAnimationEffect::create(keyframes), timing).get()); | 189 animations.add(InertAnimation::create(KeyframeAnimationEffect::c reate(keyframes), timing)); |
| 190 update->startAnimation(animationName, animations); | |
| 189 } | 191 } |
| 190 } | 192 } |
| 191 } | 193 } |
| 192 | 194 |
| 193 if (!inactive.isEmpty() && !update) | 195 if (!inactive.isEmpty() && !update) |
| 194 update = adoptPtr(new CSSAnimationUpdate()); | 196 update = adoptPtr(new CSSAnimationUpdate()); |
| 195 for (HashSet<AtomicString>::const_iterator iter = inactive.begin(); iter != inactive.end(); ++iter) | 197 for (HashSet<AtomicString>::const_iterator iter = inactive.begin(); iter != inactive.end(); ++iter) |
| 196 update->cancelAnimation(*iter, cssAnimations->m_animations.get(*iter)); | 198 update->cancelAnimation(*iter, cssAnimations->m_animations.get(*iter)); |
| 197 | 199 |
| 198 return update.release(); | 200 return update.release(); |
| 199 } | 201 } |
| 200 | 202 |
| 201 void CSSAnimations::maybeApplyPendingUpdate(Element* element) | 203 void CSSAnimations::maybeApplyPendingUpdate(Element* element) |
| 202 { | 204 { |
| 203 if (!element->renderer()) | 205 if (!element->renderer()) |
| 204 m_pendingUpdate = nullptr; | 206 m_pendingUpdate = nullptr; |
| 205 | 207 |
| 206 if (!m_pendingUpdate) | 208 if (!m_pendingUpdate) |
| 207 return; | 209 return; |
| 208 | 210 |
| 209 OwnPtr<CSSAnimationUpdate> update = m_pendingUpdate.release(); | 211 OwnPtr<CSSAnimationUpdate> update = m_pendingUpdate.release(); |
| 210 | 212 |
| 211 for (Vector<AtomicString>::const_iterator iter = update->cancelledAnimationN ames().begin(); iter != update->cancelledAnimationNames().end(); ++iter) | 213 for (Vector<AtomicString>::const_iterator iter = update->cancelledAnimationN ames().begin(); iter != update->cancelledAnimationNames().end(); ++iter) { |
| 212 m_animations.take(*iter)->cancel(); | 214 const HashSet<RefPtr<Player> >& players = m_animations.take(*iter); |
| 215 for (HashSet<RefPtr<Player> >::const_iterator iter = players.begin(); it er != players.end(); ++iter) | |
| 216 (*iter)->cancel(); | |
| 217 } | |
| 213 | 218 |
| 214 // FIXME: Apply updates to play-state. | 219 // FIXME: Apply updates to play-state. |
| 215 | 220 |
| 216 for (Vector<CSSAnimationUpdate::NewAnimation>::const_iterator iter = update- >newAnimations().begin(); iter != update->newAnimations().end(); ++iter) { | 221 for (Vector<CSSAnimationUpdate::NewAnimation>::const_iterator iter = update- >newAnimations().begin(); iter != update->newAnimations().end(); ++iter) { |
| 217 OwnPtr<CSSAnimations::EventDelegate> eventDelegate = adoptPtr(new EventD elegate(element, iter->name)); | 222 OwnPtr<CSSAnimations::EventDelegate> eventDelegate = adoptPtr(new EventD elegate(element, iter->name)); |
| 218 RefPtr<Animation> animation = Animation::create(element, iter->animation ->effect(), iter->animation->specified(), eventDelegate.release()); | 223 HashSet<RefPtr<Player> > players; |
| 219 RefPtr<Player> player = element->document().timeline()->play(animation.g et()); | 224 for (HashSet<RefPtr<InertAnimation> >::const_iterator animationsIter = i ter->animations.begin(); animationsIter != iter->animations.end(); ++animationsI ter) { |
| 220 m_animations.set(iter->name, player.get()); | 225 const InertAnimation* inertAnimation = animationsIter->get(); |
| 226 RefPtr<Animation> animation = Animation::create(element, inertAnimat ion->effect(), inertAnimation->specified(), eventDelegate.release()); | |
|
dstockwell
2013/09/30 07:30:30
Missed this earlier, probably needs a comment. It'
Steve Block
2013/09/30 11:36:06
Added a comment in https://codereview.chromium.org
| |
| 227 players.add(element->document().timeline()->play(animation.get())); | |
| 228 } | |
| 229 m_animations.set(iter->name, players); | |
| 221 } | 230 } |
| 222 } | 231 } |
| 223 | 232 |
| 224 void CSSAnimations::cancel() | 233 void CSSAnimations::cancel() |
| 225 { | 234 { |
| 226 for (AnimationMap::iterator iter = m_animations.begin(); iter != m_animation s.end(); ++iter) | 235 for (AnimationMap::iterator iter = m_animations.begin(); iter != m_animation s.end(); ++iter) { |
| 227 iter->value->cancel(); | 236 const HashSet<RefPtr<Player> >& players = iter->value; |
| 237 for (HashSet<RefPtr<Player> >::const_iterator animationsIter = players.b egin(); animationsIter != players.end(); ++animationsIter) | |
| 238 (*animationsIter)->cancel(); | |
| 239 } | |
| 228 | 240 |
| 229 m_animations.clear(); | 241 m_animations.clear(); |
| 230 m_pendingUpdate = nullptr; | 242 m_pendingUpdate = nullptr; |
| 231 } | 243 } |
| 232 | 244 |
| 233 void CSSAnimations::EventDelegate::maybeDispatch(Document::ListenerType listener Type, AtomicString& eventName, double elapsedTime) | 245 void CSSAnimations::EventDelegate::maybeDispatch(Document::ListenerType listener Type, AtomicString& eventName, double elapsedTime) |
| 234 { | 246 { |
| 235 if (m_target->document().hasListenerType(listenerType)) | 247 if (m_target->document().hasListenerType(listenerType)) |
| 236 m_target->document().timeline()->addEventToDispatch(m_target, WebKitAnim ationEvent::create(eventName, m_name, elapsedTime)); | 248 m_target->document().timeline()->addEventToDispatch(m_target, WebKitAnim ationEvent::create(eventName, m_name, elapsedTime)); |
| 237 } | 249 } |
| (...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 374 case CSSPropertyWordSpacing: | 386 case CSSPropertyWordSpacing: |
| 375 case CSSPropertyZIndex: | 387 case CSSPropertyZIndex: |
| 376 case CSSPropertyZoom: | 388 case CSSPropertyZoom: |
| 377 return true; | 389 return true; |
| 378 default: | 390 default: |
| 379 return false; | 391 return false; |
| 380 } | 392 } |
| 381 } | 393 } |
| 382 | 394 |
| 383 } // namespace WebCore | 395 } // namespace WebCore |
| OLD | NEW |