Chromium Code Reviews| 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 19 matching lines...) Expand all Loading... | |
| 30 | 30 |
| 31 #include "core/animation/Animation.h" | 31 #include "core/animation/Animation.h" |
| 32 | 32 |
| 33 #include "core/animation/AnimationTimeline.h" | 33 #include "core/animation/AnimationTimeline.h" |
| 34 #include "core/animation/CompositorPendingAnimations.h" | 34 #include "core/animation/CompositorPendingAnimations.h" |
| 35 #include "core/animation/KeyframeEffectReadOnly.h" | 35 #include "core/animation/KeyframeEffectReadOnly.h" |
| 36 #include "core/animation/css/CSSAnimations.h" | 36 #include "core/animation/css/CSSAnimations.h" |
| 37 #include "core/dom/Document.h" | 37 #include "core/dom/Document.h" |
| 38 #include "core/dom/ExceptionCode.h" | 38 #include "core/dom/ExceptionCode.h" |
| 39 #include "core/dom/StyleChangeReason.h" | 39 #include "core/dom/StyleChangeReason.h" |
| 40 #include "core/dom/TaskRunnerHelper.h" | |
| 40 #include "core/events/AnimationPlaybackEvent.h" | 41 #include "core/events/AnimationPlaybackEvent.h" |
| 41 #include "core/frame/UseCounter.h" | 42 #include "core/frame/UseCounter.h" |
| 42 #include "core/inspector/InspectorInstrumentation.h" | 43 #include "core/inspector/InspectorInstrumentation.h" |
| 43 #include "core/inspector/InspectorTraceEvents.h" | 44 #include "core/inspector/InspectorTraceEvents.h" |
| 44 #include "platform/RuntimeEnabledFeatures.h" | 45 #include "platform/RuntimeEnabledFeatures.h" |
| 46 #include "platform/WebTaskRunner.h" | |
| 45 #include "platform/animation/CompositorAnimationPlayer.h" | 47 #include "platform/animation/CompositorAnimationPlayer.h" |
| 48 #include "platform/heap/Persistent.h" | |
| 46 #include "platform/instrumentation/tracing/TraceEvent.h" | 49 #include "platform/instrumentation/tracing/TraceEvent.h" |
| 47 #include "public/platform/Platform.h" | 50 #include "public/platform/Platform.h" |
| 48 #include "public/platform/WebCompositorSupport.h" | 51 #include "public/platform/WebCompositorSupport.h" |
| 49 #include "wtf/MathExtras.h" | 52 #include "wtf/MathExtras.h" |
| 50 #include "wtf/PtrUtil.h" | 53 #include "wtf/PtrUtil.h" |
| 51 | 54 |
| 52 namespace blink { | 55 namespace blink { |
| 53 | 56 |
| 54 namespace { | 57 namespace { |
| 55 | 58 |
| (...skipping 587 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 643 const AtomicString& Animation::interfaceName() const { | 646 const AtomicString& Animation::interfaceName() const { |
| 644 return EventTargetNames::AnimationPlayer; | 647 return EventTargetNames::AnimationPlayer; |
| 645 } | 648 } |
| 646 | 649 |
| 647 ExecutionContext* Animation::getExecutionContext() const { | 650 ExecutionContext* Animation::getExecutionContext() const { |
| 648 return ContextLifecycleObserver::getExecutionContext(); | 651 return ContextLifecycleObserver::getExecutionContext(); |
| 649 } | 652 } |
| 650 | 653 |
| 651 bool Animation::hasPendingActivity() const { | 654 bool Animation::hasPendingActivity() const { |
| 652 bool hasPendingPromise = | 655 bool hasPendingPromise = |
| 653 !m_finished && m_finishedPromise && | 656 m_finishedPromise && |
| 654 m_finishedPromise->getState() == ScriptPromisePropertyBase::Pending; | 657 m_finishedPromise->getState() == ScriptPromisePropertyBase::Pending; |
| 655 | 658 |
| 656 return m_pendingFinishedEvent || hasPendingPromise || | 659 return m_pendingFinishedEvent || hasPendingPromise || |
| 657 (!m_finished && hasEventListeners(EventTypeNames::finish)); | 660 (!m_finished && hasEventListeners(EventTypeNames::finish)); |
| 658 } | 661 } |
| 659 | 662 |
| 660 void Animation::contextDestroyed() { | 663 void Animation::contextDestroyed() { |
| 661 PlayStateUpdateScope updateScope(*this, TimingUpdateOnDemand); | 664 PlayStateUpdateScope updateScope(*this, TimingUpdateOnDemand); |
| 662 | 665 |
| 663 m_finished = true; | 666 m_finished = true; |
| (...skipping 341 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1005 | 1008 |
| 1006 // Ordering is important, the ready promise should resolve/reject before | 1009 // Ordering is important, the ready promise should resolve/reject before |
| 1007 // the finished promise. | 1010 // the finished promise. |
| 1008 if (m_animation->m_readyPromise && newPlayState != oldPlayState) { | 1011 if (m_animation->m_readyPromise && newPlayState != oldPlayState) { |
| 1009 if (newPlayState == Idle) { | 1012 if (newPlayState == Idle) { |
| 1010 if (m_animation->m_readyPromise->getState() == | 1013 if (m_animation->m_readyPromise->getState() == |
| 1011 AnimationPromise::Pending) { | 1014 AnimationPromise::Pending) { |
| 1012 m_animation->m_readyPromise->reject(DOMException::create(AbortError)); | 1015 m_animation->m_readyPromise->reject(DOMException::create(AbortError)); |
| 1013 } | 1016 } |
| 1014 m_animation->m_readyPromise->reset(); | 1017 m_animation->m_readyPromise->reset(); |
| 1015 m_animation->m_readyPromise->resolve(m_animation); | 1018 m_animation->resolvePromiseAsync(m_animation->m_readyPromise); |
| 1016 } else if (oldPlayState == Pending) { | 1019 } else if (oldPlayState == Pending) { |
| 1017 m_animation->m_readyPromise->resolve(m_animation); | 1020 m_animation->resolvePromiseAsync(m_animation->m_readyPromise); |
| 1018 } else if (newPlayState == Pending) { | 1021 } else if (newPlayState == Pending) { |
| 1019 DCHECK_NE(m_animation->m_readyPromise->getState(), | 1022 DCHECK_NE(m_animation->m_readyPromise->getState(), |
| 1020 AnimationPromise::Pending); | 1023 AnimationPromise::Pending); |
| 1021 m_animation->m_readyPromise->reset(); | 1024 m_animation->m_readyPromise->reset(); |
| 1022 } | 1025 } |
| 1023 } | 1026 } |
| 1024 | 1027 |
| 1025 if (m_animation->m_finishedPromise && newPlayState != oldPlayState) { | 1028 if (m_animation->m_finishedPromise && newPlayState != oldPlayState) { |
| 1026 if (newPlayState == Idle) { | 1029 if (newPlayState == Idle) { |
| 1027 if (m_animation->m_finishedPromise->getState() == | 1030 if (m_animation->m_finishedPromise->getState() == |
| 1028 AnimationPromise::Pending) { | 1031 AnimationPromise::Pending) { |
| 1029 m_animation->m_finishedPromise->reject( | 1032 m_animation->m_finishedPromise->reject( |
| 1030 DOMException::create(AbortError)); | 1033 DOMException::create(AbortError)); |
| 1031 } | 1034 } |
| 1032 m_animation->m_finishedPromise->reset(); | 1035 m_animation->m_finishedPromise->reset(); |
| 1033 } else if (newPlayState == Finished) { | 1036 } else if (newPlayState == Finished) { |
| 1034 m_animation->m_finishedPromise->resolve(m_animation); | 1037 m_animation->resolvePromiseAsync(m_animation->m_finishedPromise); |
| 1035 } else if (oldPlayState == Finished) { | 1038 } else if (oldPlayState == Finished) { |
| 1036 m_animation->m_finishedPromise->reset(); | 1039 m_animation->m_finishedPromise->reset(); |
| 1037 } | 1040 } |
| 1038 } | 1041 } |
| 1039 | 1042 |
| 1040 if (oldPlayState != newPlayState && | 1043 if (oldPlayState != newPlayState && |
| 1041 (oldPlayState == Idle || newPlayState == Idle)) { | 1044 (oldPlayState == Idle || newPlayState == Idle)) { |
| 1042 m_animation->setOutdated(); | 1045 m_animation->setOutdated(); |
| 1043 } | 1046 } |
| 1044 | 1047 |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1102 return; | 1105 return; |
| 1103 | 1106 |
| 1104 Element& target = *toKeyframeEffectReadOnly(m_content.get())->target(); | 1107 Element& target = *toKeyframeEffectReadOnly(m_content.get())->target(); |
| 1105 | 1108 |
| 1106 if (CSSAnimations::isAffectedByKeyframesFromScope(target, treeScope)) | 1109 if (CSSAnimations::isAffectedByKeyframesFromScope(target, treeScope)) |
| 1107 target.setNeedsStyleRecalc(LocalStyleChange, | 1110 target.setNeedsStyleRecalc(LocalStyleChange, |
| 1108 StyleChangeReasonForTracing::create( | 1111 StyleChangeReasonForTracing::create( |
| 1109 StyleChangeReason::StyleSheetChange)); | 1112 StyleChangeReason::StyleSheetChange)); |
| 1110 } | 1113 } |
| 1111 | 1114 |
| 1115 void Animation::resolvePromiseAsync(Member<AnimationPromise> promise) { | |
| 1116 TaskRunnerHelper::get(TaskType::DOMManipulation, getExecutionContext()) | |
| 1117 ->postTask( | |
| 1118 BLINK_FROM_HERE, | |
| 1119 WTF::bind(&AnimationPromise::resolve<Member<Animation>>, | |
|
jbroman
2017/01/07 04:06:35
nit: Similarly, I'd expect this to be AnimationPro
| |
| 1120 wrapPersistent(promise.get()), wrapPersistent(this))); | |
| 1121 } | |
| 1122 | |
| 1112 DEFINE_TRACE(Animation) { | 1123 DEFINE_TRACE(Animation) { |
| 1113 visitor->trace(m_content); | 1124 visitor->trace(m_content); |
| 1114 visitor->trace(m_timeline); | 1125 visitor->trace(m_timeline); |
| 1115 visitor->trace(m_pendingFinishedEvent); | 1126 visitor->trace(m_pendingFinishedEvent); |
| 1116 visitor->trace(m_pendingCancelledEvent); | 1127 visitor->trace(m_pendingCancelledEvent); |
| 1117 visitor->trace(m_finishedPromise); | 1128 visitor->trace(m_finishedPromise); |
| 1118 visitor->trace(m_readyPromise); | 1129 visitor->trace(m_readyPromise); |
| 1119 visitor->trace(m_compositorPlayer); | 1130 visitor->trace(m_compositorPlayer); |
| 1120 EventTargetWithInlineData::trace(visitor); | 1131 EventTargetWithInlineData::trace(visitor); |
| 1121 ContextLifecycleObserver::trace(visitor); | 1132 ContextLifecycleObserver::trace(visitor); |
| (...skipping 19 matching lines...) Expand all Loading... | |
| 1141 DCHECK(!m_compositorPlayer); | 1152 DCHECK(!m_compositorPlayer); |
| 1142 } | 1153 } |
| 1143 | 1154 |
| 1144 void Animation::CompositorAnimationPlayerHolder::detach() { | 1155 void Animation::CompositorAnimationPlayerHolder::detach() { |
| 1145 DCHECK(m_compositorPlayer); | 1156 DCHECK(m_compositorPlayer); |
| 1146 m_compositorPlayer->setAnimationDelegate(nullptr); | 1157 m_compositorPlayer->setAnimationDelegate(nullptr); |
| 1147 m_animation = nullptr; | 1158 m_animation = nullptr; |
| 1148 m_compositorPlayer.reset(); | 1159 m_compositorPlayer.reset(); |
| 1149 } | 1160 } |
| 1150 } // namespace blink | 1161 } // namespace blink |
| OLD | NEW |