| 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 1020 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1031 "blink.animations,devtools.timeline,benchmark,rail", "Animation", | 1031 "blink.animations,devtools.timeline,benchmark,rail", "Animation", |
| 1032 animation_, "data", InspectorAnimationStateEvent::Data(*animation_)); | 1032 animation_, "data", InspectorAnimationStateEvent::Data(*animation_)); |
| 1033 } | 1033 } |
| 1034 | 1034 |
| 1035 // Ordering is important, the ready promise should resolve/reject before | 1035 // Ordering is important, the ready promise should resolve/reject before |
| 1036 // the finished promise. | 1036 // the finished promise. |
| 1037 if (animation_->ready_promise_ && new_play_state != old_play_state) { | 1037 if (animation_->ready_promise_ && new_play_state != old_play_state) { |
| 1038 if (new_play_state == kIdle) { | 1038 if (new_play_state == kIdle) { |
| 1039 if (animation_->ready_promise_->GetState() == | 1039 if (animation_->ready_promise_->GetState() == |
| 1040 AnimationPromise::kPending) { | 1040 AnimationPromise::kPending) { |
| 1041 animation_->ready_promise_->Reject(DOMException::Create(kAbortError)); | 1041 animation_->RejectAndResetPromiseMaybeAsync( |
| 1042 animation_->ready_promise_.Get()); |
| 1043 } else { |
| 1044 animation_->ready_promise_->Reset(); |
| 1042 } | 1045 } |
| 1043 animation_->ready_promise_->Reset(); | |
| 1044 animation_->ResolvePromiseMaybeAsync(animation_->ready_promise_.Get()); | 1046 animation_->ResolvePromiseMaybeAsync(animation_->ready_promise_.Get()); |
| 1045 } else if (old_play_state == kPending) { | 1047 } else if (old_play_state == kPending) { |
| 1046 animation_->ResolvePromiseMaybeAsync(animation_->ready_promise_.Get()); | 1048 animation_->ResolvePromiseMaybeAsync(animation_->ready_promise_.Get()); |
| 1047 } else if (new_play_state == kPending) { | 1049 } else if (new_play_state == kPending) { |
| 1048 DCHECK_NE(animation_->ready_promise_->GetState(), | 1050 DCHECK_NE(animation_->ready_promise_->GetState(), |
| 1049 AnimationPromise::kPending); | 1051 AnimationPromise::kPending); |
| 1050 animation_->ready_promise_->Reset(); | 1052 animation_->ready_promise_->Reset(); |
| 1051 } | 1053 } |
| 1052 } | 1054 } |
| 1053 | 1055 |
| 1054 if (animation_->finished_promise_ && new_play_state != old_play_state) { | 1056 if (animation_->finished_promise_ && new_play_state != old_play_state) { |
| 1055 if (new_play_state == kIdle) { | 1057 if (new_play_state == kIdle) { |
| 1056 if (animation_->finished_promise_->GetState() == | 1058 if (animation_->finished_promise_->GetState() == |
| 1057 AnimationPromise::kPending) { | 1059 AnimationPromise::kPending) { |
| 1058 animation_->finished_promise_->Reject( | 1060 animation_->RejectAndResetPromiseMaybeAsync( |
| 1059 DOMException::Create(kAbortError)); | 1061 animation_->finished_promise_.Get()); |
| 1062 } else { |
| 1063 animation_->finished_promise_->Reset(); |
| 1060 } | 1064 } |
| 1061 animation_->finished_promise_->Reset(); | |
| 1062 } else if (new_play_state == kFinished) { | 1065 } else if (new_play_state == kFinished) { |
| 1063 animation_->ResolvePromiseMaybeAsync(animation_->finished_promise_.Get()); | 1066 animation_->ResolvePromiseMaybeAsync(animation_->finished_promise_.Get()); |
| 1064 } else if (old_play_state == kFinished) { | 1067 } else if (old_play_state == kFinished) { |
| 1065 animation_->finished_promise_->Reset(); | 1068 animation_->finished_promise_->Reset(); |
| 1066 } | 1069 } |
| 1067 } | 1070 } |
| 1068 | 1071 |
| 1069 if (old_play_state != new_play_state && | 1072 if (old_play_state != new_play_state && |
| 1070 (old_play_state == kIdle || new_play_state == kIdle)) { | 1073 (old_play_state == kIdle || new_play_state == kIdle)) { |
| 1071 animation_->SetOutdated(); | 1074 animation_->SetOutdated(); |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1143 if (ScriptForbiddenScope::IsScriptForbidden()) { | 1146 if (ScriptForbiddenScope::IsScriptForbidden()) { |
| 1144 TaskRunnerHelper::Get(TaskType::kDOMManipulation, GetExecutionContext()) | 1147 TaskRunnerHelper::Get(TaskType::kDOMManipulation, GetExecutionContext()) |
| 1145 ->PostTask(BLINK_FROM_HERE, | 1148 ->PostTask(BLINK_FROM_HERE, |
| 1146 WTF::Bind(&AnimationPromise::Resolve<Animation*>, | 1149 WTF::Bind(&AnimationPromise::Resolve<Animation*>, |
| 1147 WrapPersistent(promise), WrapPersistent(this))); | 1150 WrapPersistent(promise), WrapPersistent(this))); |
| 1148 } else { | 1151 } else { |
| 1149 promise->Resolve(this); | 1152 promise->Resolve(this); |
| 1150 } | 1153 } |
| 1151 } | 1154 } |
| 1152 | 1155 |
| 1156 void Animation::RejectAndResetPromise(AnimationPromise* promise) { |
| 1157 promise->Reject(DOMException::Create(kAbortError)); |
| 1158 promise->Reset(); |
| 1159 } |
| 1160 |
| 1161 void Animation::RejectAndResetPromiseMaybeAsync(AnimationPromise* promise) { |
| 1162 if (ScriptForbiddenScope::IsScriptForbidden()) { |
| 1163 TaskRunnerHelper::Get(TaskType::kDOMManipulation, GetExecutionContext()) |
| 1164 ->PostTask(BLINK_FROM_HERE, |
| 1165 WTF::Bind(&Animation::RejectAndResetPromise, |
| 1166 WrapPersistent(this), WrapPersistent(promise))); |
| 1167 } else { |
| 1168 RejectAndResetPromise(promise); |
| 1169 } |
| 1170 } |
| 1171 |
| 1153 DEFINE_TRACE(Animation) { | 1172 DEFINE_TRACE(Animation) { |
| 1154 visitor->Trace(content_); | 1173 visitor->Trace(content_); |
| 1155 visitor->Trace(timeline_); | 1174 visitor->Trace(timeline_); |
| 1156 visitor->Trace(pending_finished_event_); | 1175 visitor->Trace(pending_finished_event_); |
| 1157 visitor->Trace(pending_cancelled_event_); | 1176 visitor->Trace(pending_cancelled_event_); |
| 1158 visitor->Trace(finished_promise_); | 1177 visitor->Trace(finished_promise_); |
| 1159 visitor->Trace(ready_promise_); | 1178 visitor->Trace(ready_promise_); |
| 1160 visitor->Trace(compositor_player_); | 1179 visitor->Trace(compositor_player_); |
| 1161 EventTargetWithInlineData::Trace(visitor); | 1180 EventTargetWithInlineData::Trace(visitor); |
| 1162 ContextLifecycleObserver::Trace(visitor); | 1181 ContextLifecycleObserver::Trace(visitor); |
| (...skipping 19 matching lines...) Expand all Loading... |
| 1182 DCHECK(!compositor_player_); | 1201 DCHECK(!compositor_player_); |
| 1183 } | 1202 } |
| 1184 | 1203 |
| 1185 void Animation::CompositorAnimationPlayerHolder::Detach() { | 1204 void Animation::CompositorAnimationPlayerHolder::Detach() { |
| 1186 DCHECK(compositor_player_); | 1205 DCHECK(compositor_player_); |
| 1187 compositor_player_->SetAnimationDelegate(nullptr); | 1206 compositor_player_->SetAnimationDelegate(nullptr); |
| 1188 animation_ = nullptr; | 1207 animation_ = nullptr; |
| 1189 compositor_player_.reset(); | 1208 compositor_player_.reset(); |
| 1190 } | 1209 } |
| 1191 } // namespace blink | 1210 } // namespace blink |
| OLD | NEW |