| 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 519 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 530 setCurrentTimeInternal(newCurrentTime, TimingUpdateOnDemand); | 530 setCurrentTimeInternal(newCurrentTime, TimingUpdateOnDemand); |
| 531 if (!paused()) { | 531 if (!paused()) { |
| 532 m_startTime = calculateStartTime(newCurrentTime); | 532 m_startTime = calculateStartTime(newCurrentTime); |
| 533 } | 533 } |
| 534 | 534 |
| 535 m_currentTimePending = false; | 535 m_currentTimePending = false; |
| 536 ASSERT(playStateInternal() != Idle); | 536 ASSERT(playStateInternal() != Idle); |
| 537 ASSERT(limited()); | 537 ASSERT(limited()); |
| 538 } | 538 } |
| 539 | 539 |
| 540 ScriptPromise AnimationPlayer::finished(ScriptState* scriptState) |
| 541 { |
| 542 if (!m_finishedPromise) { |
| 543 m_finishedPromise = new AnimationPlayerPromise(scriptState->executionCon
text(), this, AnimationPlayerPromise::Finished); |
| 544 if (playStateInternal() == Finished) |
| 545 m_finishedPromise->resolve(this); |
| 546 } |
| 547 return m_finishedPromise->promise(scriptState->world()); |
| 548 } |
| 549 |
| 540 const AtomicString& AnimationPlayer::interfaceName() const | 550 const AtomicString& AnimationPlayer::interfaceName() const |
| 541 { | 551 { |
| 542 return EventTargetNames::AnimationPlayer; | 552 return EventTargetNames::AnimationPlayer; |
| 543 } | 553 } |
| 544 | 554 |
| 545 ExecutionContext* AnimationPlayer::executionContext() const | 555 ExecutionContext* AnimationPlayer::executionContext() const |
| 546 { | 556 { |
| 547 return ActiveDOMObject::executionContext(); | 557 return ActiveDOMObject::executionContext(); |
| 548 } | 558 } |
| 549 | 559 |
| (...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 754 } | 764 } |
| 755 | 765 |
| 756 void AnimationPlayer::endUpdatingState() | 766 void AnimationPlayer::endUpdatingState() |
| 757 { | 767 { |
| 758 ASSERT(m_stateIsBeingUpdated); | 768 ASSERT(m_stateIsBeingUpdated); |
| 759 m_stateIsBeingUpdated = false; | 769 m_stateIsBeingUpdated = false; |
| 760 } | 770 } |
| 761 | 771 |
| 762 AnimationPlayer::PlayStateUpdateScope::PlayStateUpdateScope(AnimationPlayer& pla
yer, TimingUpdateReason reason, CompositorPendingChange compositorPendingChange) | 772 AnimationPlayer::PlayStateUpdateScope::PlayStateUpdateScope(AnimationPlayer& pla
yer, TimingUpdateReason reason, CompositorPendingChange compositorPendingChange) |
| 763 : m_player(player) | 773 : m_player(player) |
| 764 , m_initial(m_player->playStateInternal()) | 774 , m_initialPlayState(m_player->playStateInternal()) |
| 765 , m_compositorPendingChange(compositorPendingChange) | 775 , m_compositorPendingChange(compositorPendingChange) |
| 766 { | 776 { |
| 767 m_player->beginUpdatingState(); | 777 m_player->beginUpdatingState(); |
| 768 m_player->updateCurrentTimingState(reason); | 778 m_player->updateCurrentTimingState(reason); |
| 769 } | 779 } |
| 770 | 780 |
| 771 AnimationPlayer::PlayStateUpdateScope::~PlayStateUpdateScope() | 781 AnimationPlayer::PlayStateUpdateScope::~PlayStateUpdateScope() |
| 772 { | 782 { |
| 773 AnimationPlayState oldPlayState = m_initial; | 783 AnimationPlayState oldPlayState = m_initialPlayState; |
| 774 AnimationPlayState newPlayState = m_player->calculatePlayState(); | 784 AnimationPlayState newPlayState = m_player->calculatePlayState(); |
| 775 if (oldPlayState != newPlayState) { | 785 if (oldPlayState != newPlayState) { |
| 776 bool wasActive = oldPlayState == Pending || oldPlayState == Running; | 786 bool wasActive = oldPlayState == Pending || oldPlayState == Running; |
| 777 bool isActive = newPlayState == Pending || newPlayState == Running; | 787 bool isActive = newPlayState == Pending || newPlayState == Running; |
| 778 if (!wasActive && isActive) { | 788 if (!wasActive && isActive) { |
| 779 if (m_player->m_content) { | 789 if (m_player->m_content) { |
| 780 TRACE_EVENT_ASYNC_BEGIN1("blink", "Animation", &m_player, "Name"
, TRACE_STR_COPY(m_player->m_content->name().utf8().data())); | 790 TRACE_EVENT_ASYNC_BEGIN1("blink", "Animation", &m_player, "Name"
, TRACE_STR_COPY(m_player->m_content->name().utf8().data())); |
| 781 } else { | 791 } else { |
| 782 TRACE_EVENT_ASYNC_BEGIN0("blink", "Animation", &m_player); | 792 TRACE_EVENT_ASYNC_BEGIN0("blink", "Animation", &m_player); |
| 783 } | 793 } |
| 784 } else if (wasActive && !isActive) { | 794 } else if (wasActive && !isActive) { |
| 785 if (oldPlayState != Idle && oldPlayState != Finished) { | 795 if (oldPlayState != Idle && oldPlayState != Finished) { |
| 786 TRACE_EVENT_ASYNC_END0("blink", "Animation", &m_player); | 796 TRACE_EVENT_ASYNC_END0("blink", "Animation", &m_player); |
| 787 } | 797 } |
| 788 } | 798 } |
| 789 if (isActive) { | 799 if (isActive) { |
| 790 TRACE_EVENT_ASYNC_STEP_INTO0("blink", "Animation", &m_player, playSt
ateString(newPlayState)); | 800 TRACE_EVENT_ASYNC_STEP_INTO0("blink", "Animation", &m_player, playSt
ateString(newPlayState)); |
| 791 } | 801 } |
| 792 } | 802 } |
| 793 | 803 |
| 804 if (m_player->m_finishedPromise && newPlayState != oldPlayState) { |
| 805 if (newPlayState == Idle) { |
| 806 if (m_player->m_finishedPromise->state() == AnimationPlayerPromise::
Pending) { |
| 807 m_player->m_finishedPromise->reject(DOMException::create(AbortEr
ror)); |
| 808 } |
| 809 m_player->m_finishedPromise->reset(); |
| 810 } |
| 811 |
| 812 if (newPlayState == Finished) { |
| 813 m_player->m_finishedPromise->resolve(m_player); |
| 814 } |
| 815 |
| 816 if (oldPlayState == Finished) { |
| 817 m_player->m_finishedPromise->reset(); |
| 818 } |
| 819 } |
| 820 |
| 794 if (oldPlayState != newPlayState && (oldPlayState == Idle || newPlayState ==
Idle)) { | 821 if (oldPlayState != newPlayState && (oldPlayState == Idle || newPlayState ==
Idle)) { |
| 795 m_player->setOutdated(); | 822 m_player->setOutdated(); |
| 796 } | 823 } |
| 797 | 824 |
| 798 m_player->m_playState = newPlayState; | 825 m_player->m_playState = newPlayState; |
| 799 | 826 |
| 800 #if ENABLE(ASSERT) | 827 #if ENABLE(ASSERT) |
| 801 // Verify that current time is up to date. | 828 // Verify that current time is up to date. |
| 802 m_player->currentTimeInternal(); | 829 m_player->currentTimeInternal(); |
| 803 #endif | 830 #endif |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 842 toAnimation(m_content.get())->pauseAnimationForTestingOnCompositor(curre
ntTimeInternal()); | 869 toAnimation(m_content.get())->pauseAnimationForTestingOnCompositor(curre
ntTimeInternal()); |
| 843 m_isPausedForTesting = true; | 870 m_isPausedForTesting = true; |
| 844 pause(); | 871 pause(); |
| 845 } | 872 } |
| 846 | 873 |
| 847 void AnimationPlayer::trace(Visitor* visitor) | 874 void AnimationPlayer::trace(Visitor* visitor) |
| 848 { | 875 { |
| 849 visitor->trace(m_content); | 876 visitor->trace(m_content); |
| 850 visitor->trace(m_timeline); | 877 visitor->trace(m_timeline); |
| 851 visitor->trace(m_pendingFinishedEvent); | 878 visitor->trace(m_pendingFinishedEvent); |
| 879 visitor->trace(m_finishedPromise); |
| 852 EventTargetWithInlineData::trace(visitor); | 880 EventTargetWithInlineData::trace(visitor); |
| 853 ActiveDOMObject::trace(visitor); | 881 ActiveDOMObject::trace(visitor); |
| 854 } | 882 } |
| 855 | 883 |
| 856 } // namespace | 884 } // namespace |
| OLD | NEW |