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 20 matching lines...) Expand all Loading... |
31 #include "core/animation/css/CSSAnimations.h" | 31 #include "core/animation/css/CSSAnimations.h" |
32 | 32 |
33 #include "core/StylePropertyShorthand.h" | 33 #include "core/StylePropertyShorthand.h" |
34 #include "core/animation/Animation.h" | 34 #include "core/animation/Animation.h" |
35 #include "core/animation/CompositorAnimations.h" | 35 #include "core/animation/CompositorAnimations.h" |
36 #include "core/animation/DocumentTimeline.h" | 36 #include "core/animation/DocumentTimeline.h" |
37 #include "core/animation/ElementAnimations.h" | 37 #include "core/animation/ElementAnimations.h" |
38 #include "core/animation/InertEffect.h" | 38 #include "core/animation/InertEffect.h" |
39 #include "core/animation/Interpolation.h" | 39 #include "core/animation/Interpolation.h" |
40 #include "core/animation/KeyframeEffectModel.h" | 40 #include "core/animation/KeyframeEffectModel.h" |
| 41 #include "core/animation/KeyframeEffectReadOnly.h" |
41 #include "core/animation/LegacyStyleInterpolation.h" | 42 #include "core/animation/LegacyStyleInterpolation.h" |
42 #include "core/animation/css/CSSAnimatableValueFactory.h" | 43 #include "core/animation/css/CSSAnimatableValueFactory.h" |
43 #include "core/css/CSSKeyframeRule.h" | 44 #include "core/css/CSSKeyframeRule.h" |
44 #include "core/css/CSSPropertyEquality.h" | 45 #include "core/css/CSSPropertyEquality.h" |
45 #include "core/css/CSSPropertyMetadata.h" | 46 #include "core/css/CSSPropertyMetadata.h" |
46 #include "core/css/CSSValueList.h" | 47 #include "core/css/CSSValueList.h" |
47 #include "core/css/resolver/CSSToStyleMap.h" | 48 #include "core/css/resolver/CSSToStyleMap.h" |
48 #include "core/css/resolver/StyleResolver.h" | 49 #include "core/css/resolver/StyleResolver.h" |
49 #include "core/dom/Element.h" | 50 #include "core/dom/Element.h" |
50 #include "core/dom/PseudoElement.h" | 51 #include "core/dom/PseudoElement.h" |
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
243 calculateAnimationActiveInterpolations(animationUpdate, animatingElement); | 244 calculateAnimationActiveInterpolations(animationUpdate, animatingElement); |
244 calculateTransitionUpdate(animationUpdate, animatingElement, style); | 245 calculateTransitionUpdate(animationUpdate, animatingElement, style); |
245 calculateTransitionActiveInterpolations(animationUpdate, animatingElement); | 246 calculateTransitionActiveInterpolations(animationUpdate, animatingElement); |
246 } | 247 } |
247 | 248 |
248 static const KeyframeEffectModelBase* getKeyframeEffectModelBase( | 249 static const KeyframeEffectModelBase* getKeyframeEffectModelBase( |
249 const AnimationEffectReadOnly* effect) { | 250 const AnimationEffectReadOnly* effect) { |
250 if (!effect) | 251 if (!effect) |
251 return nullptr; | 252 return nullptr; |
252 const EffectModel* model = nullptr; | 253 const EffectModel* model = nullptr; |
253 if (effect->isKeyframeEffect()) | 254 if (effect->isKeyframeEffectReadOnly()) |
254 model = toKeyframeEffect(effect)->model(); | 255 model = toKeyframeEffectReadOnly(effect)->model(); |
255 else if (effect->isInertEffect()) | 256 else if (effect->isInertEffect()) |
256 model = toInertEffect(effect)->model(); | 257 model = toInertEffect(effect)->model(); |
257 if (!model || !model->isKeyframeEffectModel()) | 258 if (!model || !model->isKeyframeEffectModel()) |
258 return nullptr; | 259 return nullptr; |
259 return toKeyframeEffectModelBase(model); | 260 return toKeyframeEffectModelBase(model); |
260 } | 261 } |
261 | 262 |
262 void CSSAnimations::calculateCompositorAnimationUpdate( | 263 void CSSAnimations::calculateCompositorAnimationUpdate( |
263 CSSAnimationUpdate& update, | 264 CSSAnimationUpdate& update, |
264 const Element* animatingElement, | 265 const Element* animatingElement, |
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
480 else | 481 else |
481 animation.pause(); | 482 animation.pause(); |
482 if (animation.outdated()) | 483 if (animation.outdated()) |
483 animation.update(TimingUpdateOnDemand); | 484 animation.update(TimingUpdateOnDemand); |
484 } | 485 } |
485 | 486 |
486 for (const auto& animation : m_pendingUpdate.updatedCompositorKeyframes()) | 487 for (const auto& animation : m_pendingUpdate.updatedCompositorKeyframes()) |
487 animation->setCompositorPending(true); | 488 animation->setCompositorPending(true); |
488 | 489 |
489 for (const auto& entry : m_pendingUpdate.animationsWithUpdates()) { | 490 for (const auto& entry : m_pendingUpdate.animationsWithUpdates()) { |
490 KeyframeEffect* effect = toKeyframeEffect(entry.animation->effect()); | 491 KeyframeEffectReadOnly* effect = |
| 492 toKeyframeEffectReadOnly(entry.animation->effect()); |
491 | 493 |
492 effect->setModel(entry.effect->model()); | 494 effect->setModel(entry.effect->model()); |
493 effect->updateSpecifiedTiming(entry.effect->specifiedTiming()); | 495 effect->updateSpecifiedTiming(entry.effect->specifiedTiming()); |
494 | 496 |
495 m_runningAnimations[entry.index]->update(entry); | 497 m_runningAnimations[entry.index]->update(entry); |
496 } | 498 } |
497 | 499 |
498 const Vector<size_t>& cancelledIndices = | 500 const Vector<size_t>& cancelledIndices = |
499 m_pendingUpdate.cancelledAnimationIndices(); | 501 m_pendingUpdate.cancelledAnimationIndices(); |
500 for (size_t i = cancelledIndices.size(); i-- > 0;) { | 502 for (size_t i = cancelledIndices.size(); i-- > 0;) { |
(...skipping 19 matching lines...) Expand all Loading... |
520 animation->update(TimingUpdateOnDemand); | 522 animation->update(TimingUpdateOnDemand); |
521 | 523 |
522 m_runningAnimations.append(new RunningAnimation(animation, entry)); | 524 m_runningAnimations.append(new RunningAnimation(animation, entry)); |
523 } | 525 } |
524 | 526 |
525 // Transitions that are run on the compositor only update main-thread state | 527 // Transitions that are run on the compositor only update main-thread state |
526 // lazily. However, we need the new state to know what the from state shoud | 528 // lazily. However, we need the new state to know what the from state shoud |
527 // be when transitions are retargeted. Instead of triggering complete style | 529 // be when transitions are retargeted. Instead of triggering complete style |
528 // recalculation, we find these cases by searching for new transitions that | 530 // recalculation, we find these cases by searching for new transitions that |
529 // have matching cancelled animation property IDs on the compositor. | 531 // have matching cancelled animation property IDs on the compositor. |
530 HeapHashMap<CSSPropertyID, std::pair<Member<KeyframeEffect>, double>> | 532 HeapHashMap<CSSPropertyID, std::pair<Member<KeyframeEffectReadOnly>, double>> |
531 retargetedCompositorTransitions; | 533 retargetedCompositorTransitions; |
532 for (CSSPropertyID id : m_pendingUpdate.cancelledTransitions()) { | 534 for (CSSPropertyID id : m_pendingUpdate.cancelledTransitions()) { |
533 DCHECK(m_transitions.contains(id)); | 535 DCHECK(m_transitions.contains(id)); |
534 | 536 |
535 Animation* animation = m_transitions.take(id).animation; | 537 Animation* animation = m_transitions.take(id).animation; |
536 KeyframeEffect* effect = toKeyframeEffect(animation->effect()); | 538 KeyframeEffectReadOnly* effect = |
| 539 toKeyframeEffectReadOnly(animation->effect()); |
537 if (effect->hasActiveAnimationsOnCompositor(id) && | 540 if (effect->hasActiveAnimationsOnCompositor(id) && |
538 m_pendingUpdate.newTransitions().find(id) != | 541 m_pendingUpdate.newTransitions().find(id) != |
539 m_pendingUpdate.newTransitions().end() && | 542 m_pendingUpdate.newTransitions().end() && |
540 !animation->limited()) | 543 !animation->limited()) |
541 retargetedCompositorTransitions.add( | 544 retargetedCompositorTransitions.add( |
542 id, std::pair<KeyframeEffect*, double>( | 545 id, std::pair<KeyframeEffectReadOnly*, double>( |
543 effect, animation->startTimeInternal())); | 546 effect, animation->startTimeInternal())); |
544 animation->cancel(); | 547 animation->cancel(); |
545 // after cancelation, transitions must be downgraded or they'll fail | 548 // after cancelation, transitions must be downgraded or they'll fail |
546 // to be considered when retriggering themselves. This can happen if | 549 // to be considered when retriggering themselves. This can happen if |
547 // the transition is captured through getAnimations then played. | 550 // the transition is captured through getAnimations then played. |
548 if (animation->effect() && animation->effect()->isKeyframeEffect()) | 551 if (animation->effect() && animation->effect()->isKeyframeEffectReadOnly()) |
549 toKeyframeEffect(animation->effect())->downgradeToNormal(); | 552 toKeyframeEffectReadOnly(animation->effect())->downgradeToNormal(); |
550 animation->update(TimingUpdateOnDemand); | 553 animation->update(TimingUpdateOnDemand); |
551 } | 554 } |
552 | 555 |
553 for (CSSPropertyID id : m_pendingUpdate.finishedTransitions()) { | 556 for (CSSPropertyID id : m_pendingUpdate.finishedTransitions()) { |
554 // This transition can also be cancelled and finished at the same time | 557 // This transition can also be cancelled and finished at the same time |
555 if (m_transitions.contains(id)) { | 558 if (m_transitions.contains(id)) { |
556 Animation* animation = m_transitions.take(id).animation; | 559 Animation* animation = m_transitions.take(id).animation; |
557 // Transition must be downgraded | 560 // Transition must be downgraded |
558 if (animation->effect() && animation->effect()->isKeyframeEffect()) | 561 if (animation->effect() && |
559 toKeyframeEffect(animation->effect())->downgradeToNormal(); | 562 animation->effect()->isKeyframeEffectReadOnly()) |
| 563 toKeyframeEffectReadOnly(animation->effect())->downgradeToNormal(); |
560 } | 564 } |
561 } | 565 } |
562 | 566 |
563 for (const auto& entry : m_pendingUpdate.newTransitions()) { | 567 for (const auto& entry : m_pendingUpdate.newTransitions()) { |
564 const CSSAnimationUpdate::NewTransition& newTransition = entry.value; | 568 const CSSAnimationUpdate::NewTransition& newTransition = entry.value; |
565 | 569 |
566 RunningTransition runningTransition; | 570 RunningTransition runningTransition; |
567 runningTransition.from = newTransition.from; | 571 runningTransition.from = newTransition.from; |
568 runningTransition.to = newTransition.to; | 572 runningTransition.to = newTransition.to; |
569 runningTransition.reversingAdjustedStartValue = | 573 runningTransition.reversingAdjustedStartValue = |
570 newTransition.reversingAdjustedStartValue; | 574 newTransition.reversingAdjustedStartValue; |
571 runningTransition.reversingShorteningFactor = | 575 runningTransition.reversingShorteningFactor = |
572 newTransition.reversingShorteningFactor; | 576 newTransition.reversingShorteningFactor; |
573 | 577 |
574 CSSPropertyID id = newTransition.id; | 578 CSSPropertyID id = newTransition.id; |
575 const InertEffect* inertAnimation = newTransition.effect.get(); | 579 const InertEffect* inertAnimation = newTransition.effect.get(); |
576 TransitionEventDelegate* eventDelegate = | 580 TransitionEventDelegate* eventDelegate = |
577 new TransitionEventDelegate(element, id); | 581 new TransitionEventDelegate(element, id); |
578 | 582 |
579 EffectModel* model = inertAnimation->model(); | 583 EffectModel* model = inertAnimation->model(); |
580 | 584 |
581 if (retargetedCompositorTransitions.contains(id)) { | 585 if (retargetedCompositorTransitions.contains(id)) { |
582 const std::pair<Member<KeyframeEffect>, double>& oldTransition = | 586 const std::pair<Member<KeyframeEffectReadOnly>, double>& oldTransition = |
583 retargetedCompositorTransitions.get(id); | 587 retargetedCompositorTransitions.get(id); |
584 KeyframeEffect* oldAnimation = oldTransition.first; | 588 KeyframeEffectReadOnly* oldAnimation = oldTransition.first; |
585 double oldStartTime = oldTransition.second; | 589 double oldStartTime = oldTransition.second; |
586 double inheritedTime = | 590 double inheritedTime = |
587 isNull(oldStartTime) | 591 isNull(oldStartTime) |
588 ? 0 | 592 ? 0 |
589 : element->document().timeline().currentTimeInternal() - | 593 : element->document().timeline().currentTimeInternal() - |
590 oldStartTime; | 594 oldStartTime; |
591 | 595 |
592 AnimatableValueKeyframeEffectModel* oldEffect = | 596 AnimatableValueKeyframeEffectModel* oldEffect = |
593 toAnimatableValueKeyframeEffectModel(inertAnimation->model()); | 597 toAnimatableValueKeyframeEffectModel(inertAnimation->model()); |
594 const KeyframeVector& frames = oldEffect->getFrames(); | 598 const KeyframeVector& frames = oldEffect->getFrames(); |
(...skipping 488 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1083 return toShadowRoot(treeScope.rootNode()).host() == element; | 1087 return toShadowRoot(treeScope.rootNode()).host() == element; |
1084 } | 1088 } |
1085 | 1089 |
1086 DEFINE_TRACE(CSSAnimations) { | 1090 DEFINE_TRACE(CSSAnimations) { |
1087 visitor->trace(m_transitions); | 1091 visitor->trace(m_transitions); |
1088 visitor->trace(m_pendingUpdate); | 1092 visitor->trace(m_pendingUpdate); |
1089 visitor->trace(m_runningAnimations); | 1093 visitor->trace(m_runningAnimations); |
1090 } | 1094 } |
1091 | 1095 |
1092 } // namespace blink | 1096 } // namespace blink |
OLD | NEW |