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 26 matching lines...) Expand all Loading... |
37 #include "core/dom/DOMNodeIds.h" | 37 #include "core/dom/DOMNodeIds.h" |
38 #include "core/dom/Document.h" | 38 #include "core/dom/Document.h" |
39 #include "core/dom/ExceptionCode.h" | 39 #include "core/dom/ExceptionCode.h" |
40 #include "core/dom/StyleChangeReason.h" | 40 #include "core/dom/StyleChangeReason.h" |
41 #include "core/dom/TaskRunnerHelper.h" | 41 #include "core/dom/TaskRunnerHelper.h" |
42 #include "core/events/AnimationPlaybackEvent.h" | 42 #include "core/events/AnimationPlaybackEvent.h" |
43 #include "core/frame/UseCounter.h" | 43 #include "core/frame/UseCounter.h" |
44 #include "core/inspector/InspectorTraceEvents.h" | 44 #include "core/inspector/InspectorTraceEvents.h" |
45 #include "core/probe/CoreProbes.h" | 45 #include "core/probe/CoreProbes.h" |
46 #include "platform/RuntimeEnabledFeatures.h" | 46 #include "platform/RuntimeEnabledFeatures.h" |
| 47 #include "platform/ScriptForbiddenScope.h" |
47 #include "platform/WebTaskRunner.h" | 48 #include "platform/WebTaskRunner.h" |
48 #include "platform/animation/CompositorAnimationPlayer.h" | 49 #include "platform/animation/CompositorAnimationPlayer.h" |
49 #include "platform/heap/Persistent.h" | 50 #include "platform/heap/Persistent.h" |
50 #include "platform/instrumentation/tracing/TraceEvent.h" | 51 #include "platform/instrumentation/tracing/TraceEvent.h" |
51 #include "public/platform/Platform.h" | 52 #include "public/platform/Platform.h" |
52 #include "public/platform/WebCompositorSupport.h" | 53 #include "public/platform/WebCompositorSupport.h" |
53 #include "wtf/MathExtras.h" | 54 #include "wtf/MathExtras.h" |
54 #include "wtf/PtrUtil.h" | 55 #include "wtf/PtrUtil.h" |
55 | 56 |
56 namespace blink { | 57 namespace blink { |
(...skipping 974 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1031 | 1032 |
1032 // Ordering is important, the ready promise should resolve/reject before | 1033 // Ordering is important, the ready promise should resolve/reject before |
1033 // the finished promise. | 1034 // the finished promise. |
1034 if (animation_->ready_promise_ && new_play_state != old_play_state) { | 1035 if (animation_->ready_promise_ && new_play_state != old_play_state) { |
1035 if (new_play_state == kIdle) { | 1036 if (new_play_state == kIdle) { |
1036 if (animation_->ready_promise_->GetState() == | 1037 if (animation_->ready_promise_->GetState() == |
1037 AnimationPromise::kPending) { | 1038 AnimationPromise::kPending) { |
1038 animation_->ready_promise_->Reject(DOMException::Create(kAbortError)); | 1039 animation_->ready_promise_->Reject(DOMException::Create(kAbortError)); |
1039 } | 1040 } |
1040 animation_->ready_promise_->Reset(); | 1041 animation_->ready_promise_->Reset(); |
1041 animation_->ResolvePromiseAsync(animation_->ready_promise_.Get()); | 1042 animation_->ResolvePromiseMaybeAsync(animation_->ready_promise_.Get()); |
1042 } else if (old_play_state == kPending) { | 1043 } else if (old_play_state == kPending) { |
1043 animation_->ResolvePromiseAsync(animation_->ready_promise_.Get()); | 1044 animation_->ResolvePromiseMaybeAsync(animation_->ready_promise_.Get()); |
1044 } else if (new_play_state == kPending) { | 1045 } else if (new_play_state == kPending) { |
1045 DCHECK_NE(animation_->ready_promise_->GetState(), | 1046 DCHECK_NE(animation_->ready_promise_->GetState(), |
1046 AnimationPromise::kPending); | 1047 AnimationPromise::kPending); |
1047 animation_->ready_promise_->Reset(); | 1048 animation_->ready_promise_->Reset(); |
1048 } | 1049 } |
1049 } | 1050 } |
1050 | 1051 |
1051 if (animation_->finished_promise_ && new_play_state != old_play_state) { | 1052 if (animation_->finished_promise_ && new_play_state != old_play_state) { |
1052 if (new_play_state == kIdle) { | 1053 if (new_play_state == kIdle) { |
1053 if (animation_->finished_promise_->GetState() == | 1054 if (animation_->finished_promise_->GetState() == |
1054 AnimationPromise::kPending) { | 1055 AnimationPromise::kPending) { |
1055 animation_->finished_promise_->Reject( | 1056 animation_->finished_promise_->Reject( |
1056 DOMException::Create(kAbortError)); | 1057 DOMException::Create(kAbortError)); |
1057 } | 1058 } |
1058 animation_->finished_promise_->Reset(); | 1059 animation_->finished_promise_->Reset(); |
1059 } else if (new_play_state == kFinished) { | 1060 } else if (new_play_state == kFinished) { |
1060 animation_->ResolvePromiseAsync(animation_->finished_promise_.Get()); | 1061 animation_->ResolvePromiseMaybeAsync(animation_->finished_promise_.Get()); |
1061 } else if (old_play_state == kFinished) { | 1062 } else if (old_play_state == kFinished) { |
1062 animation_->finished_promise_->Reset(); | 1063 animation_->finished_promise_->Reset(); |
1063 } | 1064 } |
1064 } | 1065 } |
1065 | 1066 |
1066 if (old_play_state != new_play_state && | 1067 if (old_play_state != new_play_state && |
1067 (old_play_state == kIdle || new_play_state == kIdle)) { | 1068 (old_play_state == kIdle || new_play_state == kIdle)) { |
1068 animation_->SetOutdated(); | 1069 animation_->SetOutdated(); |
1069 } | 1070 } |
1070 | 1071 |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1129 return; | 1130 return; |
1130 | 1131 |
1131 Element& target = *ToKeyframeEffectReadOnly(content_.Get())->Target(); | 1132 Element& target = *ToKeyframeEffectReadOnly(content_.Get())->Target(); |
1132 | 1133 |
1133 if (CSSAnimations::IsAffectedByKeyframesFromScope(target, tree_scope)) | 1134 if (CSSAnimations::IsAffectedByKeyframesFromScope(target, tree_scope)) |
1134 target.SetNeedsStyleRecalc(kLocalStyleChange, | 1135 target.SetNeedsStyleRecalc(kLocalStyleChange, |
1135 StyleChangeReasonForTracing::Create( | 1136 StyleChangeReasonForTracing::Create( |
1136 StyleChangeReason::kStyleSheetChange)); | 1137 StyleChangeReason::kStyleSheetChange)); |
1137 } | 1138 } |
1138 | 1139 |
1139 void Animation::ResolvePromiseAsync(AnimationPromise* promise) { | 1140 void Animation::ResolvePromiseMaybeAsync(AnimationPromise* promise) { |
1140 TaskRunnerHelper::Get(TaskType::kDOMManipulation, GetExecutionContext()) | 1141 if (ScriptForbiddenScope::IsScriptForbidden()) { |
1141 ->PostTask(BLINK_FROM_HERE, | 1142 TaskRunnerHelper::Get(TaskType::kDOMManipulation, GetExecutionContext()) |
1142 WTF::Bind(&AnimationPromise::Resolve<Animation*>, | 1143 ->PostTask(BLINK_FROM_HERE, |
1143 WrapPersistent(promise), WrapPersistent(this))); | 1144 WTF::Bind(&AnimationPromise::Resolve<Animation*>, |
| 1145 WrapPersistent(promise), WrapPersistent(this))); |
| 1146 } else { |
| 1147 promise->Resolve(this); |
| 1148 } |
1144 } | 1149 } |
1145 | 1150 |
1146 DEFINE_TRACE(Animation) { | 1151 DEFINE_TRACE(Animation) { |
1147 visitor->Trace(content_); | 1152 visitor->Trace(content_); |
1148 visitor->Trace(timeline_); | 1153 visitor->Trace(timeline_); |
1149 visitor->Trace(pending_finished_event_); | 1154 visitor->Trace(pending_finished_event_); |
1150 visitor->Trace(pending_cancelled_event_); | 1155 visitor->Trace(pending_cancelled_event_); |
1151 visitor->Trace(finished_promise_); | 1156 visitor->Trace(finished_promise_); |
1152 visitor->Trace(ready_promise_); | 1157 visitor->Trace(ready_promise_); |
1153 visitor->Trace(compositor_player_); | 1158 visitor->Trace(compositor_player_); |
(...skipping 21 matching lines...) Expand all Loading... |
1175 DCHECK(!compositor_player_); | 1180 DCHECK(!compositor_player_); |
1176 } | 1181 } |
1177 | 1182 |
1178 void Animation::CompositorAnimationPlayerHolder::Detach() { | 1183 void Animation::CompositorAnimationPlayerHolder::Detach() { |
1179 DCHECK(compositor_player_); | 1184 DCHECK(compositor_player_); |
1180 compositor_player_->SetAnimationDelegate(nullptr); | 1185 compositor_player_->SetAnimationDelegate(nullptr); |
1181 animation_ = nullptr; | 1186 animation_ = nullptr; |
1182 compositor_player_.reset(); | 1187 compositor_player_.reset(); |
1183 } | 1188 } |
1184 } // namespace blink | 1189 } // namespace blink |
OLD | NEW |