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