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

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

Issue 1119683003: Implement requestIdleCallback API (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Add LayoutTest and fix minor spec violation Created 5 years, 5 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
Index: Source/core/dom/Document.cpp
diff --git a/Source/core/dom/Document.cpp b/Source/core/dom/Document.cpp
index f18cc7d8cf3952aaeab7152d10290a11ae22f8cd..fd03bf53cad5acbd6c55051f310ab4ae6a39fac9 100644
--- a/Source/core/dom/Document.cpp
+++ b/Source/core/dom/Document.cpp
@@ -92,6 +92,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"
@@ -591,6 +592,8 @@ void Document::dispose()
m_scriptedAnimationController->clearDocumentPointer();
m_scriptedAnimationController.clear();
+ m_scriptedIdleTaskController.clear();
+
if (svgExtensions())
accessSVGExtensions().pauseAnimations();
@@ -2147,6 +2150,8 @@ void Document::detach(const AttachContext& context)
m_scriptedAnimationController->clearDocumentPointer();
m_scriptedAnimationController.clear();
+ m_scriptedIdleTaskController.clear();
+
if (svgExtensions())
accessSVGExtensions().pauseAnimations();
@@ -5241,6 +5246,26 @@ void Document::serviceScriptedAnimations(double monotonicAnimationStartTime)
m_scriptedAnimationController->serviceScriptedAnimations(monotonicAnimationStartTime);
}
+ScriptedIdleTaskController& Document::ensureScriptedIdleTaskController()
+{
+ if (!m_scriptedIdleTaskController) {
jochen (gone - plz use gerrit) 2015/07/31 09:19:19 no { }
rmcilroy 2015/08/11 16:30:51 Done.
+ m_scriptedIdleTaskController = ScriptedIdleTaskController::create(this, loader()->timing());
+ }
+ return *m_scriptedIdleTaskController;
+}
+
+int Document::requestIdleCallback(IdleRequestCallback* callback, double timeout)
+{
+ return ensureScriptedIdleTaskController().registerCallback(callback, timeout);
+}
+
+void Document::cancelIdleCallback(int id)
+{
+ if (!m_scriptedIdleTaskController)
+ return;
jochen (gone - plz use gerrit) 2015/07/31 09:19:19 that should be unreachable, no?
rmcilroy 2015/08/11 16:30:51 If the page calls cancelIdleCallback (with a rando
+ 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
@@ -5769,6 +5794,7 @@ DEFINE_TRACE(Document)
visitor->trace(m_styleSheetList);
visitor->trace(m_mediaQueryMatcher);
visitor->trace(m_scriptedAnimationController);
+ visitor->trace(m_scriptedIdleTaskController);
visitor->trace(m_textAutosizer);
visitor->trace(m_registrationContext);
visitor->trace(m_customElementMicrotaskRunQueue);

Powered by Google App Engine
This is Rietveld 408576698