Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(149)

Side by Side Diff: third_party/WebKit/Source/core/animation/Animation.cpp

Issue 2527043002: Blink Animation: Request serviceOnNextFrame on animation's finish and cancel. (Closed)
Patch Set: Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « third_party/WebKit/Source/core/animation/Animation.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 429 matching lines...) Expand 10 before | Expand all | Expand 10 after
440 setCurrentTimeInternal(currentTime, TimingUpdateOnDemand); 440 setCurrentTimeInternal(currentTime, TimingUpdateOnDemand);
441 } 441 }
442 updateCurrentTimingState(TimingUpdateOnDemand); 442 updateCurrentTimingState(TimingUpdateOnDemand);
443 double newCurrentTime = currentTimeInternal(); 443 double newCurrentTime = currentTimeInternal();
444 444
445 if (previousCurrentTime != newCurrentTime) { 445 if (previousCurrentTime != newCurrentTime) {
446 setOutdated(); 446 setOutdated();
447 } else if (!hadStartTime && m_timeline) { 447 } else if (!hadStartTime && m_timeline) {
448 // Even though this animation is not outdated, time to effect change is 448 // Even though this animation is not outdated, time to effect change is
449 // infinity until start time is set. 449 // infinity until start time is set.
450 m_timeline->wake(); 450 forceServiceOnNextFrame();
451 } 451 }
452 } 452 }
453 453
454 void Animation::setEffect(AnimationEffectReadOnly* newEffect) { 454 void Animation::setEffect(AnimationEffectReadOnly* newEffect) {
455 if (m_content == newEffect) 455 if (m_content == newEffect)
456 return; 456 return;
457 PlayStateUpdateScope updateScope(*this, TimingUpdateOnDemand, 457 PlayStateUpdateScope updateScope(*this, TimingUpdateOnDemand,
458 SetCompositorPendingWithEffectChanged); 458 SetCompositorPendingWithEffectChanged);
459 459
460 double storedCurrentTime = currentTimeInternal(); 460 double storedCurrentTime = currentTimeInternal();
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
612 // Avoid updating start time when already finished. 612 // Avoid updating start time when already finished.
613 if (calculatePlayState() == Finished) 613 if (calculatePlayState() == Finished)
614 return; 614 return;
615 615
616 double newCurrentTime = m_playbackRate < 0 ? 0 : effectEnd(); 616 double newCurrentTime = m_playbackRate < 0 ? 0 : effectEnd();
617 setCurrentTimeInternal(newCurrentTime, TimingUpdateOnDemand); 617 setCurrentTimeInternal(newCurrentTime, TimingUpdateOnDemand);
618 m_paused = false; 618 m_paused = false;
619 m_currentTimePending = false; 619 m_currentTimePending = false;
620 m_startTime = calculateStartTime(newCurrentTime); 620 m_startTime = calculateStartTime(newCurrentTime);
621 m_playState = Finished; 621 m_playState = Finished;
622 forceServiceOnNextFrame();
622 } 623 }
623 624
624 ScriptPromise Animation::finished(ScriptState* scriptState) { 625 ScriptPromise Animation::finished(ScriptState* scriptState) {
625 if (!m_finishedPromise) { 626 if (!m_finishedPromise) {
626 m_finishedPromise = new AnimationPromise(scriptState->getExecutionContext(), 627 m_finishedPromise = new AnimationPromise(scriptState->getExecutionContext(),
627 this, AnimationPromise::Finished); 628 this, AnimationPromise::Finished);
628 if (playStateInternal() == Finished) 629 if (playStateInternal() == Finished)
629 m_finishedPromise->resolve(this); 630 m_finishedPromise->resolve(this);
630 } 631 }
631 return m_finishedPromise->promise(scriptState->world()); 632 return m_finishedPromise->promise(scriptState->world());
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
706 } 707 }
707 708
708 void Animation::setOutdated() { 709 void Animation::setOutdated() {
709 if (m_outdated) 710 if (m_outdated)
710 return; 711 return;
711 m_outdated = true; 712 m_outdated = true;
712 if (m_timeline) 713 if (m_timeline)
713 m_timeline->setOutdatedAnimation(this); 714 m_timeline->setOutdatedAnimation(this);
714 } 715 }
715 716
717 void Animation::forceServiceOnNextFrame() {
718 m_timeline->wake();
719 }
720
716 bool Animation::canStartAnimationOnCompositor() const { 721 bool Animation::canStartAnimationOnCompositor() const {
717 if (m_isCompositedAnimationDisabledForTesting || effectSuppressed()) 722 if (m_isCompositedAnimationDisabledForTesting || effectSuppressed())
718 return false; 723 return false;
719 724
720 // FIXME: Timeline playback rates should be compositable 725 // FIXME: Timeline playback rates should be compositable
721 if (m_playbackRate == 0 || (std::isinf(effectEnd()) && m_playbackRate < 0) || 726 if (m_playbackRate == 0 || (std::isinf(effectEnd()) && m_playbackRate < 0) ||
722 (timeline() && timeline()->playbackRate() != 1)) 727 (timeline() && timeline()->playbackRate() != 1))
723 return false; 728 return false;
724 729
725 return m_timeline && m_content && m_content->isKeyframeEffectReadOnly() && 730 return m_timeline && m_content && m_content->isKeyframeEffectReadOnly() &&
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
877 PlayStateUpdateScope updateScope(*this, TimingUpdateOnDemand); 882 PlayStateUpdateScope updateScope(*this, TimingUpdateOnDemand);
878 883
879 if (playStateInternal() == Idle) 884 if (playStateInternal() == Idle)
880 return; 885 return;
881 886
882 m_held = false; 887 m_held = false;
883 m_paused = false; 888 m_paused = false;
884 m_playState = Idle; 889 m_playState = Idle;
885 m_startTime = nullValue(); 890 m_startTime = nullValue();
886 m_currentTimePending = false; 891 m_currentTimePending = false;
892 forceServiceOnNextFrame();
887 } 893 }
888 894
889 void Animation::beginUpdatingState() { 895 void Animation::beginUpdatingState() {
890 // Nested calls are not allowed! 896 // Nested calls are not allowed!
891 DCHECK(!m_stateIsBeingUpdated); 897 DCHECK(!m_stateIsBeingUpdated);
892 m_stateIsBeingUpdated = true; 898 m_stateIsBeingUpdated = true;
893 } 899 }
894 900
895 void Animation::endUpdatingState() { 901 void Animation::endUpdatingState() {
896 DCHECK(m_stateIsBeingUpdated); 902 DCHECK(m_stateIsBeingUpdated);
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after
1114 visitor->trace(m_timeline); 1120 visitor->trace(m_timeline);
1115 visitor->trace(m_pendingFinishedEvent); 1121 visitor->trace(m_pendingFinishedEvent);
1116 visitor->trace(m_pendingCancelledEvent); 1122 visitor->trace(m_pendingCancelledEvent);
1117 visitor->trace(m_finishedPromise); 1123 visitor->trace(m_finishedPromise);
1118 visitor->trace(m_readyPromise); 1124 visitor->trace(m_readyPromise);
1119 EventTargetWithInlineData::trace(visitor); 1125 EventTargetWithInlineData::trace(visitor);
1120 ActiveDOMObject::trace(visitor); 1126 ActiveDOMObject::trace(visitor);
1121 } 1127 }
1122 1128
1123 } // namespace blink 1129 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/animation/Animation.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698