| 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 595 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 606 setCurrentTimeInternal(newCurrentTime, TimingUpdateOnDemand); | 606 setCurrentTimeInternal(newCurrentTime, TimingUpdateOnDemand); |
| 607 m_paused = false; | 607 m_paused = false; |
| 608 m_currentTimePending = false; | 608 m_currentTimePending = false; |
| 609 m_startTime = calculateStartTime(newCurrentTime); | 609 m_startTime = calculateStartTime(newCurrentTime); |
| 610 m_playState = Finished; | 610 m_playState = Finished; |
| 611 } | 611 } |
| 612 | 612 |
| 613 ScriptPromise Animation::finished(ScriptState* scriptState) | 613 ScriptPromise Animation::finished(ScriptState* scriptState) |
| 614 { | 614 { |
| 615 if (!m_finishedPromise) { | 615 if (!m_finishedPromise) { |
| 616 m_finishedPromise = new AnimationPromise(scriptState->executionContext()
, this, AnimationPromise::Finished); | 616 m_finishedPromise = new AnimationPromise(scriptState->getExecutionContex
t(), this, AnimationPromise::Finished); |
| 617 if (playStateInternal() == Finished) | 617 if (playStateInternal() == Finished) |
| 618 m_finishedPromise->resolve(this); | 618 m_finishedPromise->resolve(this); |
| 619 } | 619 } |
| 620 return m_finishedPromise->promise(scriptState->world()); | 620 return m_finishedPromise->promise(scriptState->world()); |
| 621 } | 621 } |
| 622 | 622 |
| 623 ScriptPromise Animation::ready(ScriptState* scriptState) | 623 ScriptPromise Animation::ready(ScriptState* scriptState) |
| 624 { | 624 { |
| 625 if (!m_readyPromise) { | 625 if (!m_readyPromise) { |
| 626 m_readyPromise = new AnimationPromise(scriptState->executionContext(), t
his, AnimationPromise::Ready); | 626 m_readyPromise = new AnimationPromise(scriptState->getExecutionContext()
, this, AnimationPromise::Ready); |
| 627 if (playStateInternal() != Pending) | 627 if (playStateInternal() != Pending) |
| 628 m_readyPromise->resolve(this); | 628 m_readyPromise->resolve(this); |
| 629 } | 629 } |
| 630 return m_readyPromise->promise(scriptState->world()); | 630 return m_readyPromise->promise(scriptState->world()); |
| 631 } | 631 } |
| 632 | 632 |
| 633 const AtomicString& Animation::interfaceName() const | 633 const AtomicString& Animation::interfaceName() const |
| 634 { | 634 { |
| 635 return EventTargetNames::AnimationPlayer; | 635 return EventTargetNames::AnimationPlayer; |
| 636 } | 636 } |
| 637 | 637 |
| 638 ExecutionContext* Animation::executionContext() const | 638 ExecutionContext* Animation::getExecutionContext() const |
| 639 { | 639 { |
| 640 return ContextLifecycleObserver::executionContext(); | 640 return ContextLifecycleObserver::getExecutionContext(); |
| 641 } | 641 } |
| 642 | 642 |
| 643 bool Animation::hasPendingActivity() const | 643 bool Animation::hasPendingActivity() const |
| 644 { | 644 { |
| 645 return m_pendingFinishedEvent || (!m_finished && hasEventListeners(EventType
Names::finish)); | 645 return m_pendingFinishedEvent || (!m_finished && hasEventListeners(EventType
Names::finish)); |
| 646 } | 646 } |
| 647 | 647 |
| 648 void Animation::contextDestroyed() | 648 void Animation::contextDestroyed() |
| 649 { | 649 { |
| 650 PlayStateUpdateScope updateScope(*this, TimingUpdateOnDemand); | 650 PlayStateUpdateScope updateScope(*this, TimingUpdateOnDemand); |
| (...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 824 // Special case for end-exclusivity when playing backwards. | 824 // Special case for end-exclusivity when playing backwards. |
| 825 if (inheritedTime == 0 && m_playbackRate < 0) | 825 if (inheritedTime == 0 && m_playbackRate < 0) |
| 826 inheritedTime = -1; | 826 inheritedTime = -1; |
| 827 m_content->updateInheritedTime(inheritedTime, reason); | 827 m_content->updateInheritedTime(inheritedTime, reason); |
| 828 } | 828 } |
| 829 | 829 |
| 830 if ((idle || limited()) && !m_finished) { | 830 if ((idle || limited()) && !m_finished) { |
| 831 if (reason == TimingUpdateForAnimationFrame && (idle || hasStartTime()))
{ | 831 if (reason == TimingUpdateForAnimationFrame && (idle || hasStartTime()))
{ |
| 832 if (idle) { | 832 if (idle) { |
| 833 const AtomicString& eventType = EventTypeNames::cancel; | 833 const AtomicString& eventType = EventTypeNames::cancel; |
| 834 if (executionContext() && hasEventListeners(eventType)) { | 834 if (getExecutionContext() && hasEventListeners(eventType)) { |
| 835 double eventCurrentTime = nullValue(); | 835 double eventCurrentTime = nullValue(); |
| 836 m_pendingCancelledEvent = AnimationPlayerEvent::create(event
Type, eventCurrentTime, timeline()->currentTime()); | 836 m_pendingCancelledEvent = AnimationPlayerEvent::create(event
Type, eventCurrentTime, timeline()->currentTime()); |
| 837 m_pendingCancelledEvent->setTarget(this); | 837 m_pendingCancelledEvent->setTarget(this); |
| 838 m_pendingCancelledEvent->setCurrentTarget(this); | 838 m_pendingCancelledEvent->setCurrentTarget(this); |
| 839 m_timeline->document()->enqueueAnimationFrameEvent(m_pending
CancelledEvent); | 839 m_timeline->document()->enqueueAnimationFrameEvent(m_pending
CancelledEvent); |
| 840 } | 840 } |
| 841 } else { | 841 } else { |
| 842 const AtomicString& eventType = EventTypeNames::finish; | 842 const AtomicString& eventType = EventTypeNames::finish; |
| 843 if (executionContext() && hasEventListeners(eventType)) { | 843 if (getExecutionContext() && hasEventListeners(eventType)) { |
| 844 double eventCurrentTime = currentTimeInternal() * 1000; | 844 double eventCurrentTime = currentTimeInternal() * 1000; |
| 845 m_pendingFinishedEvent = AnimationPlayerEvent::create(eventT
ype, eventCurrentTime, timeline()->currentTime()); | 845 m_pendingFinishedEvent = AnimationPlayerEvent::create(eventT
ype, eventCurrentTime, timeline()->currentTime()); |
| 846 m_pendingFinishedEvent->setTarget(this); | 846 m_pendingFinishedEvent->setTarget(this); |
| 847 m_pendingFinishedEvent->setCurrentTarget(this); | 847 m_pendingFinishedEvent->setCurrentTarget(this); |
| 848 m_timeline->document()->enqueueAnimationFrameEvent(m_pending
FinishedEvent); | 848 m_timeline->document()->enqueueAnimationFrameEvent(m_pending
FinishedEvent); |
| 849 } | 849 } |
| 850 } | 850 } |
| 851 m_finished = true; | 851 m_finished = true; |
| 852 } | 852 } |
| 853 } | 853 } |
| (...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1045 } | 1045 } |
| 1046 m_animation->endUpdatingState(); | 1046 m_animation->endUpdatingState(); |
| 1047 | 1047 |
| 1048 if (oldPlayState != newPlayState) | 1048 if (oldPlayState != newPlayState) |
| 1049 InspectorInstrumentation::animationPlayStateChanged(m_animation->timelin
e()->document(), m_animation, oldPlayState, newPlayState); | 1049 InspectorInstrumentation::animationPlayStateChanged(m_animation->timelin
e()->document(), m_animation, oldPlayState, newPlayState); |
| 1050 } | 1050 } |
| 1051 | 1051 |
| 1052 bool Animation::addEventListenerInternal(const AtomicString& eventType, PassRefP
trWillBeRawPtr<EventListener> listener, const EventListenerOptions& options) | 1052 bool Animation::addEventListenerInternal(const AtomicString& eventType, PassRefP
trWillBeRawPtr<EventListener> listener, const EventListenerOptions& options) |
| 1053 { | 1053 { |
| 1054 if (eventType == EventTypeNames::finish) | 1054 if (eventType == EventTypeNames::finish) |
| 1055 UseCounter::count(executionContext(), UseCounter::AnimationFinishEvent); | 1055 UseCounter::count(getExecutionContext(), UseCounter::AnimationFinishEven
t); |
| 1056 return EventTargetWithInlineData::addEventListenerInternal(eventType, listen
er, options); | 1056 return EventTargetWithInlineData::addEventListenerInternal(eventType, listen
er, options); |
| 1057 } | 1057 } |
| 1058 | 1058 |
| 1059 void Animation::pauseForTesting(double pauseTime) | 1059 void Animation::pauseForTesting(double pauseTime) |
| 1060 { | 1060 { |
| 1061 RELEASE_ASSERT(!paused()); | 1061 RELEASE_ASSERT(!paused()); |
| 1062 setCurrentTimeInternal(pauseTime, TimingUpdateOnDemand); | 1062 setCurrentTimeInternal(pauseTime, TimingUpdateOnDemand); |
| 1063 if (hasActiveAnimationsOnCompositor()) | 1063 if (hasActiveAnimationsOnCompositor()) |
| 1064 toKeyframeEffect(m_content.get())->pauseAnimationForTestingOnCompositor(
currentTimeInternal()); | 1064 toKeyframeEffect(m_content.get())->pauseAnimationForTestingOnCompositor(
currentTimeInternal()); |
| 1065 m_isPausedForTesting = true; | 1065 m_isPausedForTesting = true; |
| (...skipping 12 matching lines...) Expand all Loading... |
| 1078 visitor->trace(m_timeline); | 1078 visitor->trace(m_timeline); |
| 1079 visitor->trace(m_pendingFinishedEvent); | 1079 visitor->trace(m_pendingFinishedEvent); |
| 1080 visitor->trace(m_pendingCancelledEvent); | 1080 visitor->trace(m_pendingCancelledEvent); |
| 1081 visitor->trace(m_finishedPromise); | 1081 visitor->trace(m_finishedPromise); |
| 1082 visitor->trace(m_readyPromise); | 1082 visitor->trace(m_readyPromise); |
| 1083 RefCountedGarbageCollectedEventTargetWithInlineData<Animation>::trace(visito
r); | 1083 RefCountedGarbageCollectedEventTargetWithInlineData<Animation>::trace(visito
r); |
| 1084 ContextLifecycleObserver::trace(visitor); | 1084 ContextLifecycleObserver::trace(visitor); |
| 1085 } | 1085 } |
| 1086 | 1086 |
| 1087 } // namespace blink | 1087 } // namespace blink |
| OLD | NEW |