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

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

Issue 2808013002: Resolve promises synchronously sometimes (Closed)
Patch Set: Created 3 years, 8 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 56de1eb35efc75eba918e066a1d71393c6437358..58d7236724b35d060588822f1c74e07cc8d40e10 100644
--- a/third_party/WebKit/Source/core/animation/Animation.cpp
+++ b/third_party/WebKit/Source/core/animation/Animation.cpp
@@ -44,6 +44,7 @@
#include "core/inspector/InspectorTraceEvents.h"
#include "core/probe/CoreProbes.h"
#include "platform/RuntimeEnabledFeatures.h"
+#include "platform/ScriptForbiddenScope.h"
#include "platform/WebTaskRunner.h"
#include "platform/animation/CompositorAnimationPlayer.h"
#include "platform/heap/Persistent.h"
@@ -1038,9 +1039,9 @@ Animation::PlayStateUpdateScope::~PlayStateUpdateScope() {
animation_->ready_promise_->Reject(DOMException::Create(kAbortError));
}
animation_->ready_promise_->Reset();
- animation_->ResolvePromiseAsync(animation_->ready_promise_.Get());
+ animation_->ResolvePromiseMaybeAsync(animation_->ready_promise_.Get());
} else if (old_play_state == kPending) {
- animation_->ResolvePromiseAsync(animation_->ready_promise_.Get());
+ animation_->ResolvePromiseMaybeAsync(animation_->ready_promise_.Get());
} else if (new_play_state == kPending) {
DCHECK_NE(animation_->ready_promise_->GetState(),
AnimationPromise::kPending);
@@ -1057,7 +1058,7 @@ Animation::PlayStateUpdateScope::~PlayStateUpdateScope() {
}
animation_->finished_promise_->Reset();
} else if (new_play_state == kFinished) {
- animation_->ResolvePromiseAsync(animation_->finished_promise_.Get());
+ animation_->ResolvePromiseMaybeAsync(animation_->finished_promise_.Get());
} else if (old_play_state == kFinished) {
animation_->finished_promise_->Reset();
}
@@ -1136,11 +1137,15 @@ void Animation::InvalidateKeyframeEffect(const TreeScope& tree_scope) {
StyleChangeReason::kStyleSheetChange));
}
-void Animation::ResolvePromiseAsync(AnimationPromise* promise) {
- TaskRunnerHelper::Get(TaskType::kDOMManipulation, GetExecutionContext())
- ->PostTask(BLINK_FROM_HERE,
- WTF::Bind(&AnimationPromise::Resolve<Animation*>,
- WrapPersistent(promise), WrapPersistent(this)));
+void Animation::ResolvePromiseMaybeAsync(AnimationPromise* promise) {
+ if (ScriptForbiddenScope::IsScriptForbidden()) {
+ TaskRunnerHelper::Get(TaskType::kDOMManipulation, GetExecutionContext())
+ ->PostTask(BLINK_FROM_HERE,
+ WTF::Bind(&AnimationPromise::Resolve<Animation*>,
+ WrapPersistent(promise), WrapPersistent(this)));
+ } else {
+ promise->Resolve(this);
+ }
}
DEFINE_TRACE(Animation) {
« 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