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

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

Issue 2615253002: Resolve ready and finished promises asynchronously (Closed)
Patch Set: Fix nits Created 3 years, 11 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 5af7bf2ce5ecabb33082d36838744307ba5c1aec..6542483c43e2df7d419c85539a4e1ae048f6764b 100644
--- a/third_party/WebKit/Source/core/animation/Animation.cpp
+++ b/third_party/WebKit/Source/core/animation/Animation.cpp
@@ -37,12 +37,15 @@
#include "core/dom/Document.h"
#include "core/dom/ExceptionCode.h"
#include "core/dom/StyleChangeReason.h"
+#include "core/dom/TaskRunnerHelper.h"
#include "core/events/AnimationPlaybackEvent.h"
#include "core/frame/UseCounter.h"
#include "core/inspector/InspectorInstrumentation.h"
#include "core/inspector/InspectorTraceEvents.h"
#include "platform/RuntimeEnabledFeatures.h"
+#include "platform/WebTaskRunner.h"
#include "platform/animation/CompositorAnimationPlayer.h"
+#include "platform/heap/Persistent.h"
#include "platform/instrumentation/tracing/TraceEvent.h"
#include "public/platform/Platform.h"
#include "public/platform/WebCompositorSupport.h"
@@ -650,7 +653,7 @@ ExecutionContext* Animation::getExecutionContext() const {
bool Animation::hasPendingActivity() const {
bool hasPendingPromise =
- !m_finished && m_finishedPromise &&
+ m_finishedPromise &&
m_finishedPromise->getState() == ScriptPromisePropertyBase::Pending;
return m_pendingFinishedEvent || hasPendingPromise ||
@@ -1012,9 +1015,9 @@ Animation::PlayStateUpdateScope::~PlayStateUpdateScope() {
m_animation->m_readyPromise->reject(DOMException::create(AbortError));
}
m_animation->m_readyPromise->reset();
- m_animation->m_readyPromise->resolve(m_animation);
+ m_animation->resolvePromiseAsync(m_animation->m_readyPromise.get());
} else if (oldPlayState == Pending) {
- m_animation->m_readyPromise->resolve(m_animation);
+ m_animation->resolvePromiseAsync(m_animation->m_readyPromise.get());
} else if (newPlayState == Pending) {
DCHECK_NE(m_animation->m_readyPromise->getState(),
AnimationPromise::Pending);
@@ -1031,7 +1034,7 @@ Animation::PlayStateUpdateScope::~PlayStateUpdateScope() {
}
m_animation->m_finishedPromise->reset();
} else if (newPlayState == Finished) {
- m_animation->m_finishedPromise->resolve(m_animation);
+ m_animation->resolvePromiseAsync(m_animation->m_finishedPromise.get());
} else if (oldPlayState == Finished) {
m_animation->m_finishedPromise->reset();
}
@@ -1109,6 +1112,13 @@ void Animation::invalidateKeyframeEffect(const TreeScope& treeScope) {
StyleChangeReason::StyleSheetChange));
}
+void Animation::resolvePromiseAsync(AnimationPromise* promise) {
+ TaskRunnerHelper::get(TaskType::DOMManipulation, getExecutionContext())
+ ->postTask(BLINK_FROM_HERE,
+ WTF::bind(&AnimationPromise::resolve<Animation*>,
+ wrapPersistent(promise), wrapPersistent(this)));
+}
+
DEFINE_TRACE(Animation) {
visitor->trace(m_content);
visitor->trace(m_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