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

Unified Diff: Source/core/dom/Document.cpp

Issue 1119683003: Implement requestIdleCallback API (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Rebased Created 5 years, 4 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 | « Source/core/dom/Document.h ('k') | Source/core/dom/IdleCallbackDeadline.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/dom/Document.cpp
diff --git a/Source/core/dom/Document.cpp b/Source/core/dom/Document.cpp
index 0fdcc4105945baf18ff9939cd0680d86f154fb6e..b64db4415dd282746cfe66f2dc37d0ce296663c4 100644
--- a/Source/core/dom/Document.cpp
+++ b/Source/core/dom/Document.cpp
@@ -91,6 +91,7 @@
#include "core/dom/ProcessingInstruction.h"
#include "core/dom/ScriptRunner.h"
#include "core/dom/ScriptedAnimationController.h"
+#include "core/dom/ScriptedIdleTaskController.h"
#include "core/dom/SelectorQuery.h"
#include "core/dom/StaticNodeList.h"
#include "core/dom/StyleEngine.h"
@@ -586,6 +587,8 @@ void Document::dispose()
m_scriptedAnimationController->clearDocumentPointer();
m_scriptedAnimationController.clear();
+ m_scriptedIdleTaskController.clear();
+
if (svgExtensions())
accessSVGExtensions().pauseAnimations();
@@ -2136,6 +2139,8 @@ void Document::detach(const AttachContext& context)
m_scriptedAnimationController->clearDocumentPointer();
m_scriptedAnimationController.clear();
+ m_scriptedIdleTaskController.clear();
+
if (svgExtensions())
accessSVGExtensions().pauseAnimations();
@@ -5130,6 +5135,25 @@ void Document::serviceScriptedAnimations(double monotonicAnimationStartTime)
m_scriptedAnimationController->serviceScriptedAnimations(monotonicAnimationStartTime);
}
+ScriptedIdleTaskController& Document::ensureScriptedIdleTaskController()
+{
+ if (!m_scriptedIdleTaskController)
+ m_scriptedIdleTaskController = ScriptedIdleTaskController::create(this, loader()->timing());
+ return *m_scriptedIdleTaskController;
+}
+
+int Document::requestIdleCallback(IdleRequestCallback* callback, double timeoutMillis)
+{
+ return ensureScriptedIdleTaskController().registerCallback(callback, timeoutMillis);
+}
+
+void Document::cancelIdleCallback(int id)
+{
+ if (!m_scriptedIdleTaskController)
+ return;
+ m_scriptedIdleTaskController->cancelCallback(id);
+}
+
PassRefPtrWillBeRawPtr<Touch> Document::createTouch(DOMWindow* window, EventTarget* target, int identifier, double pageX, double pageY, double screenX, double screenY, double radiusX, double radiusY, float rotationAngle, float force) const
{
// Match behavior from when these types were integers, and avoid surprises from someone explicitly
@@ -5660,6 +5684,7 @@ DEFINE_TRACE(Document)
visitor->trace(m_documentTiming);
visitor->trace(m_mediaQueryMatcher);
visitor->trace(m_scriptedAnimationController);
+ visitor->trace(m_scriptedIdleTaskController);
visitor->trace(m_taskRunner);
visitor->trace(m_textAutosizer);
visitor->trace(m_registrationContext);
« no previous file with comments | « Source/core/dom/Document.h ('k') | Source/core/dom/IdleCallbackDeadline.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698