Index: third_party/WebKit/Source/modules/compositorworker/CompositorWorkerGlobalScope.cpp |
diff --git a/third_party/WebKit/Source/modules/compositorworker/CompositorWorkerGlobalScope.cpp b/third_party/WebKit/Source/modules/compositorworker/CompositorWorkerGlobalScope.cpp |
index 9389cb2ee960d0cc95ef6bf6ccbfa40146865ad8..c825786c34ce0d856830c5af711c25ee72506bb0 100644 |
--- a/third_party/WebKit/Source/modules/compositorworker/CompositorWorkerGlobalScope.cpp |
+++ b/third_party/WebKit/Source/modules/compositorworker/CompositorWorkerGlobalScope.cpp |
@@ -24,8 +24,16 @@ CompositorWorkerGlobalScope* CompositorWorkerGlobalScope::create(CompositorWorke |
CompositorWorkerGlobalScope::CompositorWorkerGlobalScope(const KURL& url, const String& userAgent, CompositorWorkerThread* thread, double timeOrigin, PassOwnPtr<SecurityOrigin::PrivilegeData> starterOriginPrivilegeData, WorkerClients* workerClients) |
: WorkerGlobalScope(url, userAgent, thread, timeOrigin, starterOriginPrivilegeData, workerClients) |
+ , m_executingAnimationFrameCallbacks(false) |
, m_callbackCollection(this) |
{ |
+ CompositorProxyClient::from(clients())->setGlobalScope(this); |
+ ThreadState::current()->registerPreFinalizer(this); |
+} |
+ |
+void CompositorWorkerGlobalScope::dispose() |
+{ |
+ CompositorProxyClient::from(clients())->setGlobalScope(nullptr); |
} |
CompositorWorkerGlobalScope::~CompositorWorkerGlobalScope() |
@@ -54,6 +62,9 @@ void CompositorWorkerGlobalScope::postMessage(ExecutionContext* executionContext |
int CompositorWorkerGlobalScope::requestAnimationFrame(FrameRequestCallback* callback) |
{ |
+ const bool shouldSignal = !m_executingAnimationFrameCallbacks && m_callbackCollection.isEmpty(); |
+ if (shouldSignal) |
+ CompositorProxyClient::from(clients())->requestAnimationFrame(); |
return m_callbackCollection.registerCallback(callback); |
} |
@@ -62,9 +73,11 @@ void CompositorWorkerGlobalScope::cancelAnimationFrame(int id) |
m_callbackCollection.cancelCallback(id); |
} |
-void CompositorWorkerGlobalScope::executeAnimationFrameCallbacks(double highResTimeNow) |
+bool CompositorWorkerGlobalScope::executeAnimationFrameCallbacks(double highResTimeMs) |
{ |
- m_callbackCollection.executeCallbacks(highResTimeNow, highResTimeNow); |
+ TemporaryChange<bool> temporaryChange(m_executingAnimationFrameCallbacks, true); |
+ m_callbackCollection.executeCallbacks(highResTimeMs, highResTimeMs); |
+ return !m_callbackCollection.isEmpty(); |
} |
CompositorWorkerThread* CompositorWorkerGlobalScope::thread() const |