Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(206)

Unified Diff: third_party/WebKit/Source/core/animation/Animation.cpp

Issue 2785303002: Post task when rejecting Animation promises inside ScriptForbiddenScope (Closed)
Patch Set: Add layout test Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/WebKit/Source/core/animation/Animation.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/core/animation/Animation.cpp
diff --git a/third_party/WebKit/Source/core/animation/Animation.cpp b/third_party/WebKit/Source/core/animation/Animation.cpp
index b6aa9faaca7005f07091ef3fa11042228d128c2c..1cbacd8654da67728ae677d0ee5120538f098a54 100644
--- a/third_party/WebKit/Source/core/animation/Animation.cpp
+++ b/third_party/WebKit/Source/core/animation/Animation.cpp
@@ -1038,9 +1038,11 @@ Animation::PlayStateUpdateScope::~PlayStateUpdateScope() {
if (new_play_state == kIdle) {
if (animation_->ready_promise_->GetState() ==
AnimationPromise::kPending) {
- animation_->ready_promise_->Reject(DOMException::Create(kAbortError));
+ animation_->RejectAndResetPromiseMaybeAsync(
+ animation_->ready_promise_.Get());
+ } else {
+ animation_->ready_promise_->Reset();
}
- animation_->ready_promise_->Reset();
animation_->ResolvePromiseMaybeAsync(animation_->ready_promise_.Get());
} else if (old_play_state == kPending) {
animation_->ResolvePromiseMaybeAsync(animation_->ready_promise_.Get());
@@ -1055,10 +1057,11 @@ Animation::PlayStateUpdateScope::~PlayStateUpdateScope() {
if (new_play_state == kIdle) {
if (animation_->finished_promise_->GetState() ==
AnimationPromise::kPending) {
- animation_->finished_promise_->Reject(
- DOMException::Create(kAbortError));
+ animation_->RejectAndResetPromiseMaybeAsync(
+ animation_->finished_promise_.Get());
+ } else {
+ animation_->finished_promise_->Reset();
}
- animation_->finished_promise_->Reset();
} else if (new_play_state == kFinished) {
animation_->ResolvePromiseMaybeAsync(animation_->finished_promise_.Get());
} else if (old_play_state == kFinished) {
@@ -1150,6 +1153,22 @@ void Animation::ResolvePromiseMaybeAsync(AnimationPromise* promise) {
}
}
+void Animation::RejectAndResetPromise(AnimationPromise* promise) {
+ promise->Reject(DOMException::Create(kAbortError));
+ promise->Reset();
+}
+
+void Animation::RejectAndResetPromiseMaybeAsync(AnimationPromise* promise) {
+ if (ScriptForbiddenScope::IsScriptForbidden()) {
+ TaskRunnerHelper::Get(TaskType::kDOMManipulation, GetExecutionContext())
+ ->PostTask(BLINK_FROM_HERE,
+ WTF::Bind(&Animation::RejectAndResetPromise,
+ WrapPersistent(this), WrapPersistent(promise)));
+ } else {
+ RejectAndResetPromise(promise);
+ }
+}
+
DEFINE_TRACE(Animation) {
visitor->Trace(content_);
visitor->Trace(timeline_);
« no previous file with comments | « third_party/WebKit/Source/core/animation/Animation.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698