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

Side by Side Diff: Source/core/animation/css/CSSAnimations.cpp

Issue 73643004: Web Animations: Extract an API for servicing animations (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Rebase. Created 7 years, 1 month 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 507 matching lines...) Expand 10 before | Expand all | Expand 10 after
518 OwnPtr<AnimationEventDelegate> eventDelegate = adoptPtr(new AnimationEve ntDelegate(element, iter->name)); 518 OwnPtr<AnimationEventDelegate> eventDelegate = adoptPtr(new AnimationEve ntDelegate(element, iter->name));
519 HashSet<RefPtr<Player> > players; 519 HashSet<RefPtr<Player> > players;
520 for (HashSet<RefPtr<InertAnimation> >::const_iterator animationsIter = i ter->animations.begin(); animationsIter != iter->animations.end(); ++animationsI ter) { 520 for (HashSet<RefPtr<InertAnimation> >::const_iterator animationsIter = i ter->animations.begin(); animationsIter != iter->animations.end(); ++animationsI ter) {
521 const InertAnimation* inertAnimation = animationsIter->get(); 521 const InertAnimation* inertAnimation = animationsIter->get();
522 // The event delegate is set on the the first animation only. We 522 // The event delegate is set on the the first animation only. We
523 // rely on the behavior of OwnPtr::release() to achieve this. 523 // rely on the behavior of OwnPtr::release() to achieve this.
524 RefPtr<Animation> animation = Animation::create(element, inertAnimat ion->effect(), inertAnimation->specified(), Animation::DefaultPriority, eventDel egate.release()); 524 RefPtr<Animation> animation = Animation::create(element, inertAnimat ion->effect(), inertAnimation->specified(), Animation::DefaultPriority, eventDel egate.release());
525 Player* player = element->document().timeline()->createPlayer(animat ion.get()); 525 Player* player = element->document().timeline()->createPlayer(animat ion.get());
526 player->setPaused(inertAnimation->paused()); 526 player->setPaused(inertAnimation->paused());
527 element->document().cssPendingAnimations().add(player); 527 element->document().cssPendingAnimations().add(player);
528 player->update();
528 players.add(player); 529 players.add(player);
529 } 530 }
530 m_animations.set(iter->name, players); 531 m_animations.set(iter->name, players);
531 } 532 }
532 533
533 for (HashSet<CSSPropertyID>::iterator iter = update->cancelledTransitions(). begin(); iter != update->cancelledTransitions().end(); ++iter) { 534 for (HashSet<CSSPropertyID>::iterator iter = update->cancelledTransitions(). begin(); iter != update->cancelledTransitions().end(); ++iter) {
534 ASSERT(m_transitions.contains(*iter)); 535 ASSERT(m_transitions.contains(*iter));
535 m_transitions.take(*iter).transition->player()->cancel(); 536 m_transitions.take(*iter).transition->player()->cancel();
536 } 537 }
537 538
538 for (size_t i = 0; i < update->newTransitions().size(); ++i) { 539 for (size_t i = 0; i < update->newTransitions().size(); ++i) {
539 const CSSAnimationUpdate::NewTransition& newTransition = update->newTran sitions()[i]; 540 const CSSAnimationUpdate::NewTransition& newTransition = update->newTran sitions()[i];
540 541
541 RunningTransition runningTransition; 542 RunningTransition runningTransition;
542 runningTransition.from = newTransition.from; 543 runningTransition.from = newTransition.from;
543 runningTransition.to = newTransition.to; 544 runningTransition.to = newTransition.to;
544 545
545 CSSPropertyID id = newTransition.id; 546 CSSPropertyID id = newTransition.id;
546 InertAnimation* inertAnimation = newTransition.animation.get(); 547 InertAnimation* inertAnimation = newTransition.animation.get();
547 OwnPtr<TransitionEventDelegate> eventDelegate = adoptPtr(new TransitionE ventDelegate(element, id)); 548 OwnPtr<TransitionEventDelegate> eventDelegate = adoptPtr(new TransitionE ventDelegate(element, id));
548 RefPtr<Animation> transition = Animation::create(element, inertAnimation ->effect(), inertAnimation->specified(), Animation::TransitionPriority, eventDel egate.release()); 549 RefPtr<Animation> transition = Animation::create(element, inertAnimation ->effect(), inertAnimation->specified(), Animation::TransitionPriority, eventDel egate.release());
549 RefPtr<Player> player = element->document().transitionTimeline()->create Player(transition.get()); 550 RefPtr<Player> player = element->document().transitionTimeline()->create Player(transition.get());
551 player->update();
550 element->document().cssPendingAnimations().add(player.get()); 552 element->document().cssPendingAnimations().add(player.get());
551 runningTransition.transition = transition.get(); 553 runningTransition.transition = transition.get();
552 m_transitions.set(id, runningTransition); 554 m_transitions.set(id, runningTransition);
553 ASSERT(id != CSSPropertyInvalid); 555 ASSERT(id != CSSPropertyInvalid);
554 blink::Platform::current()->histogramSparse("WebCore.Animation.CSSProper ties", UseCounter::mapCSSPropertyIdToCSSSampleIdForHistogram(id)); 556 blink::Platform::current()->histogramSparse("WebCore.Animation.CSSProper ties", UseCounter::mapCSSPropertyIdToCSSSampleIdForHistogram(id));
555 } 557 }
556 } 558 }
557 559
558 void CSSAnimations::calculateTransitionUpdateForProperty(CSSAnimationUpdate* upd ate, CSSPropertyID id, const CandidateTransition& newTransition, const Transitio nMap* existingTransitions) 560 void CSSAnimations::calculateTransitionUpdateForProperty(CSSAnimationUpdate* upd ate, CSSPropertyID id, const CandidateTransition& newTransition, const Transitio nMap* existingTransitions)
559 { 561 {
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
684 } 686 }
685 687
686 // Properties being animated by animations don't get values from transitions applied. 688 // Properties being animated by animations don't get values from transitions applied.
687 if (!update->compositableValuesForAnimations().isEmpty() && !compositableVal uesForTransitions.isEmpty()) { 689 if (!update->compositableValuesForAnimations().isEmpty() && !compositableVal uesForTransitions.isEmpty()) {
688 for (AnimationEffect::CompositableValueMap::const_iterator iter = update ->compositableValuesForAnimations().begin(); iter != update->compositableValuesF orAnimations().end(); ++iter) 690 for (AnimationEffect::CompositableValueMap::const_iterator iter = update ->compositableValuesForAnimations().begin(); iter != update->compositableValuesF orAnimations().end(); ++iter)
689 compositableValuesForTransitions.remove(iter->key); 691 compositableValuesForTransitions.remove(iter->key);
690 } 692 }
691 update->adoptCompositableValuesForTransitions(compositableValuesForTransitio ns); 693 update->adoptCompositableValuesForTransitions(compositableValuesForTransitio ns);
692 } 694 }
693 695
694 bool CSSAnimations::shouldCompositeForPendingAnimations(bool renderViewInComposi tingMode) const
695 {
696 if (!m_pendingUpdate)
697 return false;
698
699 for (size_t i = 0; i < m_pendingUpdate->newAnimations().size(); ++i) {
700 HashSet<RefPtr<InertAnimation> > animations = m_pendingUpdate->newAnimat ions()[i].animations;
701 for (HashSet<RefPtr<InertAnimation> >::const_iterator it = animations.be gin(); it != animations.end(); ++it) {
702 ASSERT((*it)->effect());
703 AnimationEffect* effect = (*it)->effect();
704 // FIXME: Perhaps pass a predicate function so that we can remove th e explicit checks from this file?
705 if ((effect->affects(CSSPropertyOpacity) && renderViewInCompositingM ode)
706 || effect->affects(CSSPropertyWebkitTransform)
707 || effect->affects(CSSPropertyWebkitFilter))
708 return true;
709 }
710 }
711
712 for (size_t i = 0; i < m_pendingUpdate->newTransitions().size(); ++i) {
713 AnimationEffect* effect = m_pendingUpdate->newTransitions()[i].animation ->effect();
714 if ((effect->affects(CSSPropertyOpacity) && renderViewInCompositingMode)
715 || effect->affects(CSSPropertyWebkitTransform)
716 || effect->affects(CSSPropertyWebkitFilter))
717 return true;
718 }
719
720 return false;
721 }
722
723 void CSSAnimations::AnimationEventDelegate::maybeDispatch(Document::ListenerType listenerType, const AtomicString& eventName, double elapsedTime) 696 void CSSAnimations::AnimationEventDelegate::maybeDispatch(Document::ListenerType listenerType, const AtomicString& eventName, double elapsedTime)
724 { 697 {
725 if (m_target->document().hasListenerType(listenerType)) 698 if (m_target->document().hasListenerType(listenerType))
726 m_target->document().timeline()->addEventToDispatch(m_target, WebKitAnim ationEvent::create(eventName, m_name, elapsedTime)); 699 m_target->document().timeline()->addEventToDispatch(m_target, WebKitAnim ationEvent::create(eventName, m_name, elapsedTime));
727 } 700 }
728 701
729 void CSSAnimations::AnimationEventDelegate::onEventCondition(const TimedItem* ti medItem, bool isFirstSample, TimedItem::Phase previousPhase, double previousIter ation) 702 void CSSAnimations::AnimationEventDelegate::onEventCondition(const TimedItem* ti medItem, bool isFirstSample, TimedItem::Phase previousPhase, double previousIter ation)
730 { 703 {
731 // Events for a single document are queued and dispatched as a group at 704 // Events for a single document are queued and dispatched as a group at
732 // the end of DocumentTimeline::serviceAnimations. 705 // the end of DocumentTimeline::serviceAnimations.
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after
908 CSSPropertyID id = convertToCSSPropertyID(i); 881 CSSPropertyID id = convertToCSSPropertyID(i);
909 if (isAnimatableProperty(id)) 882 if (isAnimatableProperty(id))
910 properties.append(id); 883 properties.append(id);
911 } 884 }
912 propertyShorthand = StylePropertyShorthand(CSSPropertyInvalid, propertie s.begin(), properties.size()); 885 propertyShorthand = StylePropertyShorthand(CSSPropertyInvalid, propertie s.begin(), properties.size());
913 } 886 }
914 return propertyShorthand; 887 return propertyShorthand;
915 } 888 }
916 889
917 } // namespace WebCore 890 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/core/animation/css/CSSAnimations.h ('k') | Source/core/animation/css/CSSPendingAnimations.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698