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 298 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
309 for (Vector<AtomicString>::const_iterator iter = update->animationsWithPause
Toggled().begin(); iter != update->animationsWithPauseToggled().end(); ++iter) { | 309 for (Vector<AtomicString>::const_iterator iter = update->animationsWithPause
Toggled().begin(); iter != update->animationsWithPauseToggled().end(); ++iter) { |
310 AnimationPlayer* player = m_animations.get(*iter); | 310 AnimationPlayer* player = m_animations.get(*iter); |
311 if (player->paused()) | 311 if (player->paused()) |
312 player->unpause(); | 312 player->unpause(); |
313 else | 313 else |
314 player->pause(); | 314 player->pause(); |
315 if (player->outdated()) | 315 if (player->outdated()) |
316 player->update(TimingUpdateOnDemand); | 316 player->update(TimingUpdateOnDemand); |
317 } | 317 } |
318 | 318 |
319 for (Vector<CSSAnimationUpdate::NewAnimation>::const_iterator iter = update-
>newAnimations().begin(); iter != update->newAnimations().end(); ++iter) { | 319 for (WillBeHeapVector<CSSAnimationUpdate::NewAnimation>::const_iterator iter
= update->newAnimations().begin(); iter != update->newAnimations().end(); ++ite
r) { |
320 const InertAnimation* inertAnimation = iter->animation.get(); | 320 const InertAnimation* inertAnimation = iter->animation.get(); |
321 OwnPtr<AnimationEventDelegate> eventDelegate = adoptPtr(new AnimationEve
ntDelegate(element, iter->name)); | 321 OwnPtr<AnimationEventDelegate> eventDelegate = adoptPtr(new AnimationEve
ntDelegate(element, iter->name)); |
322 RefPtr<Animation> animation = Animation::create(element, inertAnimation-
>effect(), inertAnimation->specifiedTiming(), Animation::DefaultPriority, eventD
elegate.release()); | 322 RefPtrWillBeRawPtr<Animation> animation = Animation::create(element, ine
rtAnimation->effect(), inertAnimation->specifiedTiming(), Animation::DefaultPrio
rity, eventDelegate.release()); |
323 RefPtr<AnimationPlayer> player = element->document().timeline().createAn
imationPlayer(animation.get()); | 323 RefPtrWillBeRawPtr<AnimationPlayer> player = element->document().timelin
e().createAnimationPlayer(animation.get()); |
324 element->document().compositorPendingAnimations().add(player.get()); | 324 element->document().compositorPendingAnimations().add(player.get()); |
325 if (inertAnimation->paused()) | 325 if (inertAnimation->paused()) |
326 player->pause(); | 326 player->pause(); |
327 player->update(TimingUpdateOnDemand); | 327 player->update(TimingUpdateOnDemand); |
328 m_animations.set(iter->name, player.get()); | 328 m_animations.set(iter->name, player.get()); |
329 } | 329 } |
330 | 330 |
331 // Transitions that are run on the compositor only update main-thread state | 331 // Transitions that are run on the compositor only update main-thread state |
332 // lazily. However, we need the new state to know what the from state shoud | 332 // lazily. However, we need the new state to know what the from state shoud |
333 // be when transitions are retargeted. Instead of triggering complete style | 333 // be when transitions are retargeted. Instead of triggering complete style |
334 // recalculation, we find these cases by searching for new transitions that | 334 // recalculation, we find these cases by searching for new transitions that |
335 // have matching cancelled animation property IDs on the compositor. | 335 // have matching cancelled animation property IDs on the compositor. |
336 HashMap<CSSPropertyID, std::pair<RefPtr<Animation>, double> > retargetedComp
ositorTransitions; | 336 WillBeHeapHashMap<CSSPropertyID, std::pair<RefPtrWillBeMember<Animation>, do
uble> > retargetedCompositorTransitions; |
337 for (HashSet<CSSPropertyID>::iterator iter = update->cancelledTransitions().
begin(); iter != update->cancelledTransitions().end(); ++iter) { | 337 for (HashSet<CSSPropertyID>::iterator iter = update->cancelledTransitions().
begin(); iter != update->cancelledTransitions().end(); ++iter) { |
338 CSSPropertyID id = *iter; | 338 CSSPropertyID id = *iter; |
339 ASSERT(m_transitions.contains(id)); | 339 ASSERT(m_transitions.contains(id)); |
340 | 340 |
341 RefPtr<AnimationPlayer> player = m_transitions.take(id).player; | 341 RefPtrWillBeRawPtr<AnimationPlayer> player = m_transitions.take(id).play
er; |
342 Animation* animation = toAnimation(player->source()); | 342 Animation* animation = toAnimation(player->source()); |
343 if (animation->hasActiveAnimationsOnCompositor(id) && update->newTransit
ions().find(id) != update->newTransitions().end()) | 343 if (animation->hasActiveAnimationsOnCompositor(id) && update->newTransit
ions().find(id) != update->newTransitions().end()) |
344 retargetedCompositorTransitions.add(id, std::pair<RefPtr<Animation>,
double>(animation, player->startTimeInternal())); | 344 retargetedCompositorTransitions.add(id, std::pair<RefPtrWillBeMember
<Animation>, double>(animation, player->startTimeInternal())); |
345 player->cancel(); | 345 player->cancel(); |
346 player->update(TimingUpdateOnDemand); | 346 player->update(TimingUpdateOnDemand); |
347 } | 347 } |
348 | 348 |
349 for (CSSAnimationUpdate::NewTransitionMap::const_iterator iter = update->new
Transitions().begin(); iter != update->newTransitions().end(); ++iter) { | 349 for (CSSAnimationUpdate::NewTransitionMap::const_iterator iter = update->new
Transitions().begin(); iter != update->newTransitions().end(); ++iter) { |
350 const CSSAnimationUpdate::NewTransition& newTransition = iter->value; | 350 const CSSAnimationUpdate::NewTransition& newTransition = iter->value; |
351 | 351 |
352 RunningTransition runningTransition; | 352 RunningTransition runningTransition; |
353 runningTransition.from = newTransition.from; | 353 runningTransition.from = newTransition.from; |
354 runningTransition.to = newTransition.to; | 354 runningTransition.to = newTransition.to; |
355 | 355 |
356 CSSPropertyID id = newTransition.id; | 356 CSSPropertyID id = newTransition.id; |
357 InertAnimation* inertAnimation = newTransition.animation.get(); | 357 InertAnimation* inertAnimation = newTransition.animation.get(); |
358 OwnPtr<TransitionEventDelegate> eventDelegate = adoptPtr(new TransitionE
ventDelegate(element, newTransition.eventId)); | 358 OwnPtr<TransitionEventDelegate> eventDelegate = adoptPtr(new TransitionE
ventDelegate(element, newTransition.eventId)); |
359 | 359 |
360 RefPtrWillBeRawPtr<AnimationEffect> effect = inertAnimation->effect(); | 360 RefPtrWillBeRawPtr<AnimationEffect> effect = inertAnimation->effect(); |
361 | 361 |
362 if (retargetedCompositorTransitions.contains(id)) { | 362 if (retargetedCompositorTransitions.contains(id)) { |
363 const std::pair<RefPtr<Animation>, double>& oldTransition = retarget
edCompositorTransitions.get(id); | 363 const std::pair<RefPtrWillBeMember<Animation>, double>& oldTransitio
n = retargetedCompositorTransitions.get(id); |
364 RefPtr<Animation> oldAnimation = oldTransition.first; | 364 RefPtrWillBeRawPtr<Animation> oldAnimation = oldTransition.first; |
365 double oldStartTime = oldTransition.second; | 365 double oldStartTime = oldTransition.second; |
366 double inheritedTime = isNull(oldStartTime) ? 0 : element->document(
).transitionTimeline().currentTimeInternal() - oldStartTime; | 366 double inheritedTime = isNull(oldStartTime) ? 0 : element->document(
).transitionTimeline().currentTimeInternal() - oldStartTime; |
367 | 367 |
368 AnimatableValueKeyframeEffectModel* oldEffect = toAnimatableValueKey
frameEffectModel(inertAnimation->effect()); | 368 AnimatableValueKeyframeEffectModel* oldEffect = toAnimatableValueKey
frameEffectModel(inertAnimation->effect()); |
369 const KeyframeVector& frames = oldEffect->getFrames(); | 369 const KeyframeVector& frames = oldEffect->getFrames(); |
370 | 370 |
371 AnimatableValueKeyframeVector newFrames; | 371 AnimatableValueKeyframeVector newFrames; |
372 newFrames.append(toAnimatableValueKeyframe(frames[0]->clone().get())
); | 372 newFrames.append(toAnimatableValueKeyframe(frames[0]->clone().get())
); |
373 newFrames.append(toAnimatableValueKeyframe(frames[1]->clone().get())
); | 373 newFrames.append(toAnimatableValueKeyframe(frames[1]->clone().get())
); |
374 | 374 |
375 newFrames[0]->clearPropertyValue(id); | 375 newFrames[0]->clearPropertyValue(id); |
376 RefPtr<InertAnimation> inertAnimationForSampling = InertAnimation::c
reate(oldAnimation->effect(), oldAnimation->specifiedTiming(), false); | 376 RefPtrWillBeRawPtr<InertAnimation> inertAnimationForSampling = Inert
Animation::create(oldAnimation->effect(), oldAnimation->specifiedTiming(), false
); |
377 OwnPtrWillBeRawPtr<WillBeHeapVector<RefPtrWillBeMember<Interpolation
> > > sample = inertAnimationForSampling->sample(inheritedTime); | 377 OwnPtrWillBeRawPtr<WillBeHeapVector<RefPtrWillBeMember<Interpolation
> > > sample = inertAnimationForSampling->sample(inheritedTime); |
378 ASSERT(sample->size() == 1); | 378 ASSERT(sample->size() == 1); |
379 newFrames[0]->setPropertyValue(id, toLegacyStyleInterpolation(sample
->at(0).get())->currentValue()); | 379 newFrames[0]->setPropertyValue(id, toLegacyStyleInterpolation(sample
->at(0).get())->currentValue()); |
380 | 380 |
381 effect = AnimatableValueKeyframeEffectModel::create(newFrames); | 381 effect = AnimatableValueKeyframeEffectModel::create(newFrames); |
382 } | 382 } |
383 | 383 |
384 RefPtr<Animation> transition = Animation::create(element, effect, inertA
nimation->specifiedTiming(), Animation::TransitionPriority, eventDelegate.releas
e()); | 384 RefPtrWillBeRawPtr<Animation> transition = Animation::create(element, ef
fect, inertAnimation->specifiedTiming(), Animation::TransitionPriority, eventDel
egate.release()); |
385 RefPtr<AnimationPlayer> player = element->document().transitionTimeline(
).createAnimationPlayer(transition.get()); | 385 RefPtrWillBeRawPtr<AnimationPlayer> player = element->document().transit
ionTimeline().createAnimationPlayer(transition.get()); |
386 element->document().compositorPendingAnimations().add(player.get()); | 386 element->document().compositorPendingAnimations().add(player.get()); |
387 player->update(TimingUpdateOnDemand); | 387 player->update(TimingUpdateOnDemand); |
388 runningTransition.player = player; | 388 runningTransition.player = player; |
389 m_transitions.set(id, runningTransition); | 389 m_transitions.set(id, runningTransition); |
390 ASSERT(id != CSSPropertyInvalid); | 390 ASSERT(id != CSSPropertyInvalid); |
391 blink::Platform::current()->histogramSparse("WebCore.Animation.CSSProper
ties", UseCounter::mapCSSPropertyIdToCSSSampleIdForHistogram(id)); | 391 blink::Platform::current()->histogramSparse("WebCore.Animation.CSSProper
ties", UseCounter::mapCSSPropertyIdToCSSSampleIdForHistogram(id)); |
392 } | 392 } |
393 } | 393 } |
394 | 394 |
395 void CSSAnimations::calculateTransitionUpdateForProperty(CSSPropertyID id, const
CSSTransitionData& transitionData, size_t transitionIndex, const RenderStyle& o
ldStyle, const RenderStyle& style, const TransitionMap* activeTransitions, CSSAn
imationUpdate* update, const Element* element) | 395 void CSSAnimations::calculateTransitionUpdateForProperty(CSSPropertyID id, const
CSSTransitionData& transitionData, size_t transitionIndex, const RenderStyle& o
ldStyle, const RenderStyle& style, const TransitionMap* activeTransitions, CSSAn
imationUpdate* update, const Element* element) |
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
533 { | 533 { |
534 ActiveAnimations* activeAnimations = element ? element->activeAnimations() :
0; | 534 ActiveAnimations* activeAnimations = element ? element->activeAnimations() :
0; |
535 AnimationStack* animationStack = activeAnimations ? &activeAnimations->defau
ltStack() : 0; | 535 AnimationStack* animationStack = activeAnimations ? &activeAnimations->defau
ltStack() : 0; |
536 | 536 |
537 if (update->newAnimations().isEmpty() && update->cancelledAnimationAnimation
Players().isEmpty()) { | 537 if (update->newAnimations().isEmpty() && update->cancelledAnimationAnimation
Players().isEmpty()) { |
538 WillBeHeapHashMap<CSSPropertyID, RefPtrWillBeMember<Interpolation> > act
iveInterpolationsForAnimations(AnimationStack::activeInterpolations(animationSta
ck, 0, 0, Animation::DefaultPriority, timelineCurrentTime)); | 538 WillBeHeapHashMap<CSSPropertyID, RefPtrWillBeMember<Interpolation> > act
iveInterpolationsForAnimations(AnimationStack::activeInterpolations(animationSta
ck, 0, 0, Animation::DefaultPriority, timelineCurrentTime)); |
539 update->adoptActiveInterpolationsForAnimations(activeInterpolationsForAn
imations); | 539 update->adoptActiveInterpolationsForAnimations(activeInterpolationsForAn
imations); |
540 return; | 540 return; |
541 } | 541 } |
542 | 542 |
543 Vector<InertAnimation*> newAnimations; | 543 WillBeHeapVector<RawPtrWillBeMember<InertAnimation> > newAnimations; |
544 for (size_t i = 0; i < update->newAnimations().size(); ++i) { | 544 for (size_t i = 0; i < update->newAnimations().size(); ++i) { |
545 newAnimations.append(update->newAnimations()[i].animation.get()); | 545 newAnimations.append(update->newAnimations()[i].animation.get()); |
546 } | 546 } |
547 WillBeHeapHashMap<CSSPropertyID, RefPtrWillBeMember<Interpolation> > activeI
nterpolationsForAnimations(AnimationStack::activeInterpolations(animationStack,
&newAnimations, &update->cancelledAnimationAnimationPlayers(), Animation::Defaul
tPriority, timelineCurrentTime)); | 547 WillBeHeapHashMap<CSSPropertyID, RefPtrWillBeMember<Interpolation> > activeI
nterpolationsForAnimations(AnimationStack::activeInterpolations(animationStack,
&newAnimations, &update->cancelledAnimationAnimationPlayers(), Animation::Defaul
tPriority, timelineCurrentTime)); |
548 update->adoptActiveInterpolationsForAnimations(activeInterpolationsForAnimat
ions); | 548 update->adoptActiveInterpolationsForAnimations(activeInterpolationsForAnimat
ions); |
549 } | 549 } |
550 | 550 |
551 void CSSAnimations::calculateTransitionActiveInterpolations(CSSAnimationUpdate*
update, const Element* element, double timelineCurrentTime) | 551 void CSSAnimations::calculateTransitionActiveInterpolations(CSSAnimationUpdate*
update, const Element* element, double timelineCurrentTime) |
552 { | 552 { |
553 ActiveAnimations* activeAnimations = element ? element->activeAnimations() :
0; | 553 ActiveAnimations* activeAnimations = element ? element->activeAnimations() :
0; |
554 AnimationStack* animationStack = activeAnimations ? &activeAnimations->defau
ltStack() : 0; | 554 AnimationStack* animationStack = activeAnimations ? &activeAnimations->defau
ltStack() : 0; |
555 | 555 |
556 WillBeHeapHashMap<CSSPropertyID, RefPtrWillBeMember<Interpolation> > activeI
nterpolationsForTransitions; | 556 WillBeHeapHashMap<CSSPropertyID, RefPtrWillBeMember<Interpolation> > activeI
nterpolationsForTransitions; |
557 if (update->newTransitions().isEmpty() && update->cancelledTransitions().isE
mpty()) { | 557 if (update->newTransitions().isEmpty() && update->cancelledTransitions().isE
mpty()) { |
558 activeInterpolationsForTransitions = AnimationStack::activeInterpolation
s(animationStack, 0, 0, Animation::TransitionPriority, timelineCurrentTime); | 558 activeInterpolationsForTransitions = AnimationStack::activeInterpolation
s(animationStack, 0, 0, Animation::TransitionPriority, timelineCurrentTime); |
559 } else { | 559 } else { |
560 Vector<InertAnimation*> newTransitions; | 560 WillBeHeapVector<RawPtrWillBeMember<InertAnimation> > newTransitions; |
561 for (CSSAnimationUpdate::NewTransitionMap::const_iterator iter = update-
>newTransitions().begin(); iter != update->newTransitions().end(); ++iter) | 561 for (CSSAnimationUpdate::NewTransitionMap::const_iterator iter = update-
>newTransitions().begin(); iter != update->newTransitions().end(); ++iter) |
562 newTransitions.append(iter->value.animation.get()); | 562 newTransitions.append(iter->value.animation.get()); |
563 | 563 |
564 HashSet<const AnimationPlayer*> cancelledAnimationPlayers; | 564 WillBeHeapHashSet<RawPtrWillBeMember<const AnimationPlayer> > cancelledA
nimationPlayers; |
565 if (!update->cancelledTransitions().isEmpty()) { | 565 if (!update->cancelledTransitions().isEmpty()) { |
566 ASSERT(activeAnimations); | 566 ASSERT(activeAnimations); |
567 const TransitionMap& transitionMap = activeAnimations->cssAnimations
().m_transitions; | 567 const TransitionMap& transitionMap = activeAnimations->cssAnimations
().m_transitions; |
568 for (HashSet<CSSPropertyID>::iterator iter = update->cancelledTransi
tions().begin(); iter != update->cancelledTransitions().end(); ++iter) { | 568 for (HashSet<CSSPropertyID>::iterator iter = update->cancelledTransi
tions().begin(); iter != update->cancelledTransitions().end(); ++iter) { |
569 ASSERT(transitionMap.contains(*iter)); | 569 ASSERT(transitionMap.contains(*iter)); |
570 cancelledAnimationPlayers.add(transitionMap.get(*iter).player.ge
t()); | 570 cancelledAnimationPlayers.add(transitionMap.get(*iter).player.ge
t()); |
571 } | 571 } |
572 } | 572 } |
573 | 573 |
574 activeInterpolationsForTransitions = AnimationStack::activeInterpolation
s(animationStack, &newTransitions, &cancelledAnimationPlayers, Animation::Transi
tionPriority, timelineCurrentTime); | 574 activeInterpolationsForTransitions = AnimationStack::activeInterpolation
s(animationStack, &newTransitions, &cancelledAnimationPlayers, Animation::Transi
tionPriority, timelineCurrentTime); |
(...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
812 return false; | 812 return false; |
813 default: | 813 default: |
814 return true; | 814 return true; |
815 } | 815 } |
816 } | 816 } |
817 | 817 |
818 void CSSAnimations::trace(Visitor* visitor) | 818 void CSSAnimations::trace(Visitor* visitor) |
819 { | 819 { |
820 visitor->trace(m_transitions); | 820 visitor->trace(m_transitions); |
821 visitor->trace(m_pendingUpdate); | 821 visitor->trace(m_pendingUpdate); |
| 822 visitor->trace(m_animations); |
822 visitor->trace(m_previousActiveInterpolationsForAnimations); | 823 visitor->trace(m_previousActiveInterpolationsForAnimations); |
823 } | 824 } |
824 | 825 |
825 void CSSAnimationUpdate::trace(Visitor* visitor) | 826 void CSSAnimationUpdate::trace(Visitor* visitor) |
826 { | 827 { |
827 visitor->trace(m_newTransitions); | 828 visitor->trace(m_newTransitions); |
828 visitor->trace(m_activeInterpolationsForAnimations); | 829 visitor->trace(m_activeInterpolationsForAnimations); |
829 visitor->trace(m_activeInterpolationsForTransitions); | 830 visitor->trace(m_activeInterpolationsForTransitions); |
| 831 visitor->trace(m_newAnimations); |
| 832 visitor->trace(m_cancelledAnimationPlayers); |
830 } | 833 } |
831 | 834 |
832 } // namespace WebCore | 835 } // namespace WebCore |
OLD | NEW |