| 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 363 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 374 for (Vector<AtomicString>::const_iterator iter = update->animationsWithPause
Toggled().begin(); iter != update->animationsWithPauseToggled().end(); ++iter) { | 374 for (Vector<AtomicString>::const_iterator iter = update->animationsWithPause
Toggled().begin(); iter != update->animationsWithPauseToggled().end(); ++iter) { |
| 375 AnimationPlayer* player = m_animations.get(*iter); | 375 AnimationPlayer* player = m_animations.get(*iter); |
| 376 if (player->paused()) | 376 if (player->paused()) |
| 377 player->unpause(); | 377 player->unpause(); |
| 378 else | 378 else |
| 379 player->pause(); | 379 player->pause(); |
| 380 if (player->outdated()) | 380 if (player->outdated()) |
| 381 player->update(TimingUpdateOnDemand); | 381 player->update(TimingUpdateOnDemand); |
| 382 } | 382 } |
| 383 | 383 |
| 384 for (Vector<CSSAnimationUpdate::NewAnimation>::const_iterator iter = update-
>newAnimations().begin(); iter != update->newAnimations().end(); ++iter) { | 384 for (WillBeHeapVector<CSSAnimationUpdate::NewAnimation>::const_iterator iter
= update->newAnimations().begin(); iter != update->newAnimations().end(); ++ite
r) { |
| 385 const InertAnimation* inertAnimation = iter->animation.get(); | 385 const InertAnimation* inertAnimation = iter->animation.get(); |
| 386 OwnPtr<AnimationEventDelegate> eventDelegate = adoptPtr(new AnimationEve
ntDelegate(element, iter->name)); | 386 OwnPtr<AnimationEventDelegate> eventDelegate = adoptPtr(new AnimationEve
ntDelegate(element, iter->name)); |
| 387 RefPtr<Animation> animation = Animation::create(element, inertAnimation-
>effect(), inertAnimation->specifiedTiming(), Animation::DefaultPriority, eventD
elegate.release()); | 387 RefPtrWillBeRawPtr<Animation> animation = Animation::create(element, ine
rtAnimation->effect(), inertAnimation->specifiedTiming(), Animation::DefaultPrio
rity, eventDelegate.release()); |
| 388 RefPtr<AnimationPlayer> player = element->document().timeline().createAn
imationPlayer(animation.get()); | 388 RefPtrWillBeRawPtr<AnimationPlayer> player = element->document().timelin
e().createAnimationPlayer(animation.get()); |
| 389 element->document().compositorPendingAnimations().add(player.get()); | 389 element->document().compositorPendingAnimations().add(player.get()); |
| 390 if (inertAnimation->paused()) | 390 if (inertAnimation->paused()) |
| 391 player->pause(); | 391 player->pause(); |
| 392 player->update(TimingUpdateOnDemand); | 392 player->update(TimingUpdateOnDemand); |
| 393 m_animations.set(iter->name, player.get()); | 393 m_animations.set(iter->name, player.get()); |
| 394 } | 394 } |
| 395 | 395 |
| 396 // Transitions that are run on the compositor only update main-thread state | 396 // Transitions that are run on the compositor only update main-thread state |
| 397 // lazily. However, we need the new state to know what the from state shoud | 397 // lazily. However, we need the new state to know what the from state shoud |
| 398 // be when transitions are retargeted. Instead of triggering complete style | 398 // be when transitions are retargeted. Instead of triggering complete style |
| 399 // recalculation, we find these cases by searching for new transitions that | 399 // recalculation, we find these cases by searching for new transitions that |
| 400 // have matching cancelled animation property IDs on the compositor. | 400 // have matching cancelled animation property IDs on the compositor. |
| 401 HashMap<CSSPropertyID, std::pair<RefPtr<Animation>, double> > retargetedComp
ositorTransitions; | 401 WillBeHeapHashMap<CSSPropertyID, std::pair<RefPtrWillBeMember<Animation>, do
uble> > retargetedCompositorTransitions; |
| 402 for (HashSet<CSSPropertyID>::iterator iter = update->cancelledTransitions().
begin(); iter != update->cancelledTransitions().end(); ++iter) { | 402 for (HashSet<CSSPropertyID>::iterator iter = update->cancelledTransitions().
begin(); iter != update->cancelledTransitions().end(); ++iter) { |
| 403 CSSPropertyID id = *iter; | 403 CSSPropertyID id = *iter; |
| 404 ASSERT(m_transitions.contains(id)); | 404 ASSERT(m_transitions.contains(id)); |
| 405 | 405 |
| 406 RefPtr<AnimationPlayer> player = m_transitions.take(id).player; | 406 RefPtrWillBeRawPtr<AnimationPlayer> player = m_transitions.take(id).play
er; |
| 407 Animation* animation = toAnimation(player->source()); | 407 Animation* animation = toAnimation(player->source()); |
| 408 if (animation->hasActiveAnimationsOnCompositor(id) && update->newTransit
ions().find(id) != update->newTransitions().end()) | 408 if (animation->hasActiveAnimationsOnCompositor(id) && update->newTransit
ions().find(id) != update->newTransitions().end()) |
| 409 retargetedCompositorTransitions.add(id, std::pair<RefPtr<Animation>,
double>(animation, player->startTimeInternal())); | 409 retargetedCompositorTransitions.add(id, std::pair<RefPtrWillBeMember
<Animation>, double>(animation, player->startTimeInternal())); |
| 410 player->cancel(); | 410 player->cancel(); |
| 411 player->update(TimingUpdateOnDemand); | 411 player->update(TimingUpdateOnDemand); |
| 412 } | 412 } |
| 413 | 413 |
| 414 for (CSSAnimationUpdate::NewTransitionMap::const_iterator iter = update->new
Transitions().begin(); iter != update->newTransitions().end(); ++iter) { | 414 for (CSSAnimationUpdate::NewTransitionMap::const_iterator iter = update->new
Transitions().begin(); iter != update->newTransitions().end(); ++iter) { |
| 415 const CSSAnimationUpdate::NewTransition& newTransition = iter->value; | 415 const CSSAnimationUpdate::NewTransition& newTransition = iter->value; |
| 416 | 416 |
| 417 RunningTransition runningTransition; | 417 RunningTransition runningTransition; |
| 418 runningTransition.from = newTransition.from; | 418 runningTransition.from = newTransition.from; |
| 419 runningTransition.to = newTransition.to; | 419 runningTransition.to = newTransition.to; |
| 420 | 420 |
| 421 CSSPropertyID id = newTransition.id; | 421 CSSPropertyID id = newTransition.id; |
| 422 InertAnimation* inertAnimation = newTransition.animation.get(); | 422 InertAnimation* inertAnimation = newTransition.animation.get(); |
| 423 OwnPtr<TransitionEventDelegate> eventDelegate = adoptPtr(new TransitionE
ventDelegate(element, newTransition.eventId)); | 423 OwnPtr<TransitionEventDelegate> eventDelegate = adoptPtr(new TransitionE
ventDelegate(element, newTransition.eventId)); |
| 424 | 424 |
| 425 RefPtrWillBeRawPtr<AnimationEffect> effect = inertAnimation->effect(); | 425 RefPtrWillBeRawPtr<AnimationEffect> effect = inertAnimation->effect(); |
| 426 | 426 |
| 427 if (retargetedCompositorTransitions.contains(id)) { | 427 if (retargetedCompositorTransitions.contains(id)) { |
| 428 const std::pair<RefPtr<Animation>, double>& oldTransition = retarget
edCompositorTransitions.get(id); | 428 const std::pair<RefPtrWillBeMember<Animation>, double>& oldTransitio
n = retargetedCompositorTransitions.get(id); |
| 429 RefPtr<Animation> oldAnimation = oldTransition.first; | 429 RefPtrWillBeRawPtr<Animation> oldAnimation = oldTransition.first; |
| 430 double oldStartTime = oldTransition.second; | 430 double oldStartTime = oldTransition.second; |
| 431 double inheritedTime = isNull(oldStartTime) ? 0 : element->document(
).transitionTimeline().currentTimeInternal() - oldStartTime; | 431 double inheritedTime = isNull(oldStartTime) ? 0 : element->document(
).transitionTimeline().currentTimeInternal() - oldStartTime; |
| 432 | 432 |
| 433 AnimatableValueKeyframeEffectModel* oldEffect = toAnimatableValueKey
frameEffectModel(inertAnimation->effect()); | 433 AnimatableValueKeyframeEffectModel* oldEffect = toAnimatableValueKey
frameEffectModel(inertAnimation->effect()); |
| 434 const KeyframeVector& frames = oldEffect->getFrames(); | 434 const KeyframeVector& frames = oldEffect->getFrames(); |
| 435 | 435 |
| 436 AnimatableValueKeyframeVector newFrames; | 436 AnimatableValueKeyframeVector newFrames; |
| 437 newFrames.append(toAnimatableValueKeyframe(frames[0]->clone().get())
); | 437 newFrames.append(toAnimatableValueKeyframe(frames[0]->clone().get())
); |
| 438 newFrames.append(toAnimatableValueKeyframe(frames[1]->clone().get())
); | 438 newFrames.append(toAnimatableValueKeyframe(frames[1]->clone().get())
); |
| 439 | 439 |
| 440 newFrames[0]->clearPropertyValue(id); | 440 newFrames[0]->clearPropertyValue(id); |
| 441 RefPtr<InertAnimation> inertAnimationForSampling = InertAnimation::c
reate(oldAnimation->effect(), oldAnimation->specifiedTiming(), false); | 441 RefPtrWillBeRawPtr<InertAnimation> inertAnimationForSampling = Inert
Animation::create(oldAnimation->effect(), oldAnimation->specifiedTiming(), false
); |
| 442 OwnPtrWillBeRawPtr<WillBeHeapVector<RefPtrWillBeMember<Interpolation
> > > sample = inertAnimationForSampling->sample(inheritedTime); | 442 OwnPtrWillBeRawPtr<WillBeHeapVector<RefPtrWillBeMember<Interpolation
> > > sample = inertAnimationForSampling->sample(inheritedTime); |
| 443 ASSERT(sample->size() == 1); | 443 ASSERT(sample->size() == 1); |
| 444 newFrames[0]->setPropertyValue(id, toLegacyStyleInterpolation(sample
->at(0).get())->currentValue()); | 444 newFrames[0]->setPropertyValue(id, toLegacyStyleInterpolation(sample
->at(0).get())->currentValue()); |
| 445 | 445 |
| 446 effect = AnimatableValueKeyframeEffectModel::create(newFrames); | 446 effect = AnimatableValueKeyframeEffectModel::create(newFrames); |
| 447 } | 447 } |
| 448 | 448 |
| 449 RefPtr<Animation> transition = Animation::create(element, effect, inertA
nimation->specifiedTiming(), Animation::TransitionPriority, eventDelegate.releas
e()); | 449 RefPtrWillBeRawPtr<Animation> transition = Animation::create(element, ef
fect, inertAnimation->specifiedTiming(), Animation::TransitionPriority, eventDel
egate.release()); |
| 450 RefPtr<AnimationPlayer> player = element->document().transitionTimeline(
).createAnimationPlayer(transition.get()); | 450 RefPtrWillBeRawPtr<AnimationPlayer> player = element->document().transit
ionTimeline().createAnimationPlayer(transition.get()); |
| 451 element->document().compositorPendingAnimations().add(player.get()); | 451 element->document().compositorPendingAnimations().add(player.get()); |
| 452 player->update(TimingUpdateOnDemand); | 452 player->update(TimingUpdateOnDemand); |
| 453 runningTransition.player = player; | 453 runningTransition.player = player; |
| 454 m_transitions.set(id, runningTransition); | 454 m_transitions.set(id, runningTransition); |
| 455 ASSERT(id != CSSPropertyInvalid); | 455 ASSERT(id != CSSPropertyInvalid); |
| 456 blink::Platform::current()->histogramSparse("WebCore.Animation.CSSProper
ties", UseCounter::mapCSSPropertyIdToCSSSampleIdForHistogram(id)); | 456 blink::Platform::current()->histogramSparse("WebCore.Animation.CSSProper
ties", UseCounter::mapCSSPropertyIdToCSSSampleIdForHistogram(id)); |
| 457 } | 457 } |
| 458 } | 458 } |
| 459 | 459 |
| 460 void CSSAnimations::calculateTransitionUpdateForProperty(CSSPropertyID id, const
CSSAnimationData* anim, const RenderStyle& oldStyle, const RenderStyle& style,
const TransitionMap* activeTransitions, CSSAnimationUpdate* update, const Elemen
t* element) | 460 void CSSAnimations::calculateTransitionUpdateForProperty(CSSPropertyID id, const
CSSAnimationData* anim, const RenderStyle& oldStyle, const RenderStyle& style,
const TransitionMap* activeTransitions, CSSAnimationUpdate* update, const Elemen
t* element) |
| (...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 602 { | 602 { |
| 603 ActiveAnimations* activeAnimations = element ? element->activeAnimations() :
0; | 603 ActiveAnimations* activeAnimations = element ? element->activeAnimations() :
0; |
| 604 AnimationStack* animationStack = activeAnimations ? &activeAnimations->defau
ltStack() : 0; | 604 AnimationStack* animationStack = activeAnimations ? &activeAnimations->defau
ltStack() : 0; |
| 605 | 605 |
| 606 if (update->newAnimations().isEmpty() && update->cancelledAnimationAnimation
Players().isEmpty()) { | 606 if (update->newAnimations().isEmpty() && update->cancelledAnimationAnimation
Players().isEmpty()) { |
| 607 WillBeHeapHashMap<CSSPropertyID, RefPtrWillBeMember<Interpolation> > act
iveInterpolationsForAnimations(AnimationStack::activeInterpolations(animationSta
ck, 0, 0, Animation::DefaultPriority, timelineCurrentTime)); | 607 WillBeHeapHashMap<CSSPropertyID, RefPtrWillBeMember<Interpolation> > act
iveInterpolationsForAnimations(AnimationStack::activeInterpolations(animationSta
ck, 0, 0, Animation::DefaultPriority, timelineCurrentTime)); |
| 608 update->adoptActiveInterpolationsForAnimations(activeInterpolationsForAn
imations); | 608 update->adoptActiveInterpolationsForAnimations(activeInterpolationsForAn
imations); |
| 609 return; | 609 return; |
| 610 } | 610 } |
| 611 | 611 |
| 612 Vector<InertAnimation*> newAnimations; | 612 WillBeHeapVector<RawPtrWillBeMember<InertAnimation> > newAnimations; |
| 613 for (size_t i = 0; i < update->newAnimations().size(); ++i) { | 613 for (size_t i = 0; i < update->newAnimations().size(); ++i) { |
| 614 newAnimations.append(update->newAnimations()[i].animation.get()); | 614 newAnimations.append(update->newAnimations()[i].animation.get()); |
| 615 } | 615 } |
| 616 WillBeHeapHashMap<CSSPropertyID, RefPtrWillBeMember<Interpolation> > activeI
nterpolationsForAnimations(AnimationStack::activeInterpolations(animationStack,
&newAnimations, &update->cancelledAnimationAnimationPlayers(), Animation::Defaul
tPriority, timelineCurrentTime)); | 616 WillBeHeapHashMap<CSSPropertyID, RefPtrWillBeMember<Interpolation> > activeI
nterpolationsForAnimations(AnimationStack::activeInterpolations(animationStack,
&newAnimations, &update->cancelledAnimationAnimationPlayers(), Animation::Defaul
tPriority, timelineCurrentTime)); |
| 617 update->adoptActiveInterpolationsForAnimations(activeInterpolationsForAnimat
ions); | 617 update->adoptActiveInterpolationsForAnimations(activeInterpolationsForAnimat
ions); |
| 618 } | 618 } |
| 619 | 619 |
| 620 void CSSAnimations::calculateTransitionActiveInterpolations(CSSAnimationUpdate*
update, const Element* element, double timelineCurrentTime) | 620 void CSSAnimations::calculateTransitionActiveInterpolations(CSSAnimationUpdate*
update, const Element* element, double timelineCurrentTime) |
| 621 { | 621 { |
| 622 ActiveAnimations* activeAnimations = element ? element->activeAnimations() :
0; | 622 ActiveAnimations* activeAnimations = element ? element->activeAnimations() :
0; |
| 623 AnimationStack* animationStack = activeAnimations ? &activeAnimations->defau
ltStack() : 0; | 623 AnimationStack* animationStack = activeAnimations ? &activeAnimations->defau
ltStack() : 0; |
| 624 | 624 |
| 625 WillBeHeapHashMap<CSSPropertyID, RefPtrWillBeMember<Interpolation> > activeI
nterpolationsForTransitions; | 625 WillBeHeapHashMap<CSSPropertyID, RefPtrWillBeMember<Interpolation> > activeI
nterpolationsForTransitions; |
| 626 if (update->newTransitions().isEmpty() && update->cancelledTransitions().isE
mpty()) { | 626 if (update->newTransitions().isEmpty() && update->cancelledTransitions().isE
mpty()) { |
| 627 activeInterpolationsForTransitions = AnimationStack::activeInterpolation
s(animationStack, 0, 0, Animation::TransitionPriority, timelineCurrentTime); | 627 activeInterpolationsForTransitions = AnimationStack::activeInterpolation
s(animationStack, 0, 0, Animation::TransitionPriority, timelineCurrentTime); |
| 628 } else { | 628 } else { |
| 629 Vector<InertAnimation*> newTransitions; | 629 WillBeHeapVector<RawPtrWillBeMember<InertAnimation> > newTransitions; |
| 630 for (CSSAnimationUpdate::NewTransitionMap::const_iterator iter = update-
>newTransitions().begin(); iter != update->newTransitions().end(); ++iter) | 630 for (CSSAnimationUpdate::NewTransitionMap::const_iterator iter = update-
>newTransitions().begin(); iter != update->newTransitions().end(); ++iter) |
| 631 newTransitions.append(iter->value.animation.get()); | 631 newTransitions.append(iter->value.animation.get()); |
| 632 | 632 |
| 633 HashSet<const AnimationPlayer*> cancelledAnimationPlayers; | 633 WillBeHeapHashSet<RawPtrWillBeMember<const AnimationPlayer> > cancelledA
nimationPlayers; |
| 634 if (!update->cancelledTransitions().isEmpty()) { | 634 if (!update->cancelledTransitions().isEmpty()) { |
| 635 ASSERT(activeAnimations); | 635 ASSERT(activeAnimations); |
| 636 const TransitionMap& transitionMap = activeAnimations->cssAnimations
().m_transitions; | 636 const TransitionMap& transitionMap = activeAnimations->cssAnimations
().m_transitions; |
| 637 for (HashSet<CSSPropertyID>::iterator iter = update->cancelledTransi
tions().begin(); iter != update->cancelledTransitions().end(); ++iter) { | 637 for (HashSet<CSSPropertyID>::iterator iter = update->cancelledTransi
tions().begin(); iter != update->cancelledTransitions().end(); ++iter) { |
| 638 ASSERT(transitionMap.contains(*iter)); | 638 ASSERT(transitionMap.contains(*iter)); |
| 639 cancelledAnimationPlayers.add(transitionMap.get(*iter).player.ge
t()); | 639 cancelledAnimationPlayers.add(transitionMap.get(*iter).player.ge
t()); |
| 640 } | 640 } |
| 641 } | 641 } |
| 642 | 642 |
| 643 activeInterpolationsForTransitions = AnimationStack::activeInterpolation
s(animationStack, &newTransitions, &cancelledAnimationPlayers, Animation::Transi
tionPriority, timelineCurrentTime); | 643 activeInterpolationsForTransitions = AnimationStack::activeInterpolation
s(animationStack, &newTransitions, &cancelledAnimationPlayers, Animation::Transi
tionPriority, timelineCurrentTime); |
| (...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 881 return false; | 881 return false; |
| 882 default: | 882 default: |
| 883 return true; | 883 return true; |
| 884 } | 884 } |
| 885 } | 885 } |
| 886 | 886 |
| 887 void CSSAnimations::trace(Visitor* visitor) | 887 void CSSAnimations::trace(Visitor* visitor) |
| 888 { | 888 { |
| 889 visitor->trace(m_transitions); | 889 visitor->trace(m_transitions); |
| 890 visitor->trace(m_pendingUpdate); | 890 visitor->trace(m_pendingUpdate); |
| 891 visitor->trace(m_animations); |
| 891 visitor->trace(m_previousActiveInterpolationsForAnimations); | 892 visitor->trace(m_previousActiveInterpolationsForAnimations); |
| 892 } | 893 } |
| 893 | 894 |
| 894 void CSSAnimationUpdate::trace(Visitor* visitor) | 895 void CSSAnimationUpdate::trace(Visitor* visitor) |
| 895 { | 896 { |
| 896 visitor->trace(m_newTransitions); | 897 visitor->trace(m_newTransitions); |
| 897 visitor->trace(m_activeInterpolationsForAnimations); | 898 visitor->trace(m_activeInterpolationsForAnimations); |
| 898 visitor->trace(m_activeInterpolationsForTransitions); | 899 visitor->trace(m_activeInterpolationsForTransitions); |
| 900 visitor->trace(m_newAnimations); |
| 901 visitor->trace(m_cancelledAnimationPlayers); |
| 899 } | 902 } |
| 900 | 903 |
| 901 } // namespace WebCore | 904 } // namespace WebCore |
| OLD | NEW |