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->startTime())); | 417 retargetedCompositorTransitions.add(id, std::pair<RefPtrWillBeMember
<Animation>, double>(animation, player->startTime())); |
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().currentTime() - oldStartTime; | 438 double inheritedTime = isNull(oldStartTime) ? 0 : element->document(
).transitionTimeline().currentTime() - 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 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
604 { | 604 { |
605 ActiveAnimations* activeAnimations = element ? element->activeAnimations() :
0; | 605 ActiveAnimations* activeAnimations = element ? element->activeAnimations() :
0; |
606 AnimationStack* animationStack = activeAnimations ? &activeAnimations->defau
ltStack() : 0; | 606 AnimationStack* animationStack = activeAnimations ? &activeAnimations->defau
ltStack() : 0; |
607 | 607 |
608 if (update->newAnimations().isEmpty() && update->cancelledAnimationAnimation
Players().isEmpty()) { | 608 if (update->newAnimations().isEmpty() && update->cancelledAnimationAnimation
Players().isEmpty()) { |
609 WillBeHeapHashMap<CSSPropertyID, RefPtrWillBeMember<Interpolation> > act
iveInterpolationsForAnimations(AnimationStack::activeInterpolations(animationSta
ck, 0, 0, Animation::DefaultPriority, timelineCurrentTime)); | 609 WillBeHeapHashMap<CSSPropertyID, RefPtrWillBeMember<Interpolation> > act
iveInterpolationsForAnimations(AnimationStack::activeInterpolations(animationSta
ck, 0, 0, Animation::DefaultPriority, timelineCurrentTime)); |
610 update->adoptActiveInterpolationsForAnimations(activeInterpolationsForAn
imations); | 610 update->adoptActiveInterpolationsForAnimations(activeInterpolationsForAn
imations); |
611 return; | 611 return; |
612 } | 612 } |
613 | 613 |
614 Vector<InertAnimation*> newAnimations; | 614 WillBeHeapVector<RawPtrWillBeMember<InertAnimation> > newAnimations; |
615 for (size_t i = 0; i < update->newAnimations().size(); ++i) { | 615 for (size_t i = 0; i < update->newAnimations().size(); ++i) { |
616 newAnimations.append(update->newAnimations()[i].animation.get()); | 616 newAnimations.append(update->newAnimations()[i].animation.get()); |
617 } | 617 } |
618 WillBeHeapHashMap<CSSPropertyID, RefPtrWillBeMember<Interpolation> > activeI
nterpolationsForAnimations(AnimationStack::activeInterpolations(animationStack,
&newAnimations, &update->cancelledAnimationAnimationPlayers(), Animation::Defaul
tPriority, timelineCurrentTime)); | 618 WillBeHeapHashMap<CSSPropertyID, RefPtrWillBeMember<Interpolation> > activeI
nterpolationsForAnimations(AnimationStack::activeInterpolations(animationStack,
&newAnimations, &update->cancelledAnimationAnimationPlayers(), Animation::Defaul
tPriority, timelineCurrentTime)); |
619 update->adoptActiveInterpolationsForAnimations(activeInterpolationsForAnimat
ions); | 619 update->adoptActiveInterpolationsForAnimations(activeInterpolationsForAnimat
ions); |
620 } | 620 } |
621 | 621 |
622 void CSSAnimations::calculateTransitionActiveInterpolations(CSSAnimationUpdate*
update, const Element* element, double timelineCurrentTime) | 622 void CSSAnimations::calculateTransitionActiveInterpolations(CSSAnimationUpdate*
update, const Element* element, double timelineCurrentTime) |
623 { | 623 { |
624 ActiveAnimations* activeAnimations = element ? element->activeAnimations() :
0; | 624 ActiveAnimations* activeAnimations = element ? element->activeAnimations() :
0; |
625 AnimationStack* animationStack = activeAnimations ? &activeAnimations->defau
ltStack() : 0; | 625 AnimationStack* animationStack = activeAnimations ? &activeAnimations->defau
ltStack() : 0; |
626 | 626 |
627 WillBeHeapHashMap<CSSPropertyID, RefPtrWillBeMember<Interpolation> > activeI
nterpolationsForTransitions; | 627 WillBeHeapHashMap<CSSPropertyID, RefPtrWillBeMember<Interpolation> > activeI
nterpolationsForTransitions; |
628 if (update->newTransitions().isEmpty() && update->cancelledTransitions().isE
mpty()) { | 628 if (update->newTransitions().isEmpty() && update->cancelledTransitions().isE
mpty()) { |
629 activeInterpolationsForTransitions = AnimationStack::activeInterpolation
s(animationStack, 0, 0, Animation::TransitionPriority, timelineCurrentTime); | 629 activeInterpolationsForTransitions = AnimationStack::activeInterpolation
s(animationStack, 0, 0, Animation::TransitionPriority, timelineCurrentTime); |
630 } else { | 630 } else { |
631 Vector<InertAnimation*> newTransitions; | 631 WillBeHeapVector<RawPtrWillBeMember<InertAnimation> > newTransitions; |
632 for (CSSAnimationUpdate::NewTransitionMap::const_iterator iter = update-
>newTransitions().begin(); iter != update->newTransitions().end(); ++iter) | 632 for (CSSAnimationUpdate::NewTransitionMap::const_iterator iter = update-
>newTransitions().begin(); iter != update->newTransitions().end(); ++iter) |
633 newTransitions.append(iter->value.animation.get()); | 633 newTransitions.append(iter->value.animation.get()); |
634 | 634 |
635 HashSet<const AnimationPlayer*> cancelledAnimationPlayers; | 635 HashSet<const AnimationPlayer*> cancelledAnimationPlayers; |
636 if (!update->cancelledTransitions().isEmpty()) { | 636 if (!update->cancelledTransitions().isEmpty()) { |
637 ASSERT(activeAnimations); | 637 ASSERT(activeAnimations); |
638 const TransitionMap& transitionMap = activeAnimations->cssAnimations
().m_transitions; | 638 const TransitionMap& transitionMap = activeAnimations->cssAnimations
().m_transitions; |
639 for (HashSet<CSSPropertyID>::iterator iter = update->cancelledTransi
tions().begin(); iter != update->cancelledTransitions().end(); ++iter) { | 639 for (HashSet<CSSPropertyID>::iterator iter = update->cancelledTransi
tions().begin(); iter != update->cancelledTransitions().end(); ++iter) { |
640 ASSERT(transitionMap.contains(*iter)); | 640 ASSERT(transitionMap.contains(*iter)); |
641 cancelledAnimationPlayers.add(transitionMap.get(*iter).player.ge
t()); | 641 cancelledAnimationPlayers.add(transitionMap.get(*iter).player.ge
t()); |
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
839 } | 839 } |
840 propertyShorthand = StylePropertyShorthand(CSSPropertyInvalid, propertie
s.begin(), properties.size()); | 840 propertyShorthand = StylePropertyShorthand(CSSPropertyInvalid, propertie
s.begin(), properties.size()); |
841 } | 841 } |
842 return propertyShorthand; | 842 return propertyShorthand; |
843 } | 843 } |
844 | 844 |
845 void CSSAnimations::trace(Visitor* visitor) | 845 void CSSAnimations::trace(Visitor* visitor) |
846 { | 846 { |
847 visitor->trace(m_transitions); | 847 visitor->trace(m_transitions); |
848 visitor->trace(m_pendingUpdate); | 848 visitor->trace(m_pendingUpdate); |
| 849 visitor->trace(m_animations); |
849 visitor->trace(m_previousActiveInterpolationsForAnimations); | 850 visitor->trace(m_previousActiveInterpolationsForAnimations); |
850 } | 851 } |
851 | 852 |
852 void CSSAnimationUpdate::trace(Visitor* visitor) | 853 void CSSAnimationUpdate::trace(Visitor* visitor) |
853 { | 854 { |
854 visitor->trace(m_newTransitions); | 855 visitor->trace(m_newTransitions); |
855 visitor->trace(m_activeInterpolationsForAnimations); | 856 visitor->trace(m_activeInterpolationsForAnimations); |
856 visitor->trace(m_activeInterpolationsForTransitions); | 857 visitor->trace(m_activeInterpolationsForTransitions); |
| 858 visitor->trace(m_newAnimations); |
857 } | 859 } |
858 | 860 |
859 } // namespace WebCore | 861 } // namespace WebCore |
OLD | NEW |