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

Side by Side 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, 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 /* 1 /*
2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
3 * (C) 1999 Antti Koivisto (koivisto@kde.org) 3 * (C) 1999 Antti Koivisto (koivisto@kde.org)
4 * (C) 2001 Dirk Mueller (mueller@kde.org) 4 * (C) 2001 Dirk Mueller (mueller@kde.org)
5 * (C) 2006 Alexey Proskuryakov (ap@webkit.org) 5 * (C) 2006 Alexey Proskuryakov (ap@webkit.org)
6 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2011, 2012 Apple Inc. All r ights reserved. 6 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2011, 2012 Apple Inc. All r ights reserved.
7 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.t orchmobile.com/) 7 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.t orchmobile.com/)
8 * Copyright (C) 2008, 2009, 2011, 2012 Google Inc. All rights reserved. 8 * Copyright (C) 2008, 2009, 2011, 2012 Google Inc. All rights reserved.
9 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies) 9 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies)
10 * Copyright (C) Research In Motion Limited 2010-2011. All rights reserved. 10 * Copyright (C) Research In Motion Limited 2010-2011. All rights reserved.
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
85 #include "core/dom/NodeComputedStyle.h" 85 #include "core/dom/NodeComputedStyle.h"
86 #include "core/dom/NodeFilter.h" 86 #include "core/dom/NodeFilter.h"
87 #include "core/dom/NodeIterator.h" 87 #include "core/dom/NodeIterator.h"
88 #include "core/dom/NodeRareData.h" 88 #include "core/dom/NodeRareData.h"
89 #include "core/dom/NodeTraversal.h" 89 #include "core/dom/NodeTraversal.h"
90 #include "core/dom/NodeWithIndex.h" 90 #include "core/dom/NodeWithIndex.h"
91 #include "core/dom/NthIndexCache.h" 91 #include "core/dom/NthIndexCache.h"
92 #include "core/dom/ProcessingInstruction.h" 92 #include "core/dom/ProcessingInstruction.h"
93 #include "core/dom/ScriptRunner.h" 93 #include "core/dom/ScriptRunner.h"
94 #include "core/dom/ScriptedAnimationController.h" 94 #include "core/dom/ScriptedAnimationController.h"
95 #include "core/dom/ScriptedIdleTaskController.h"
95 #include "core/dom/SelectorQuery.h" 96 #include "core/dom/SelectorQuery.h"
96 #include "core/dom/StaticNodeList.h" 97 #include "core/dom/StaticNodeList.h"
97 #include "core/dom/StyleEngine.h" 98 #include "core/dom/StyleEngine.h"
98 #include "core/dom/TouchList.h" 99 #include "core/dom/TouchList.h"
99 #include "core/dom/TransformSource.h" 100 #include "core/dom/TransformSource.h"
100 #include "core/dom/TreeWalker.h" 101 #include "core/dom/TreeWalker.h"
101 #include "core/dom/VisitedLinkState.h" 102 #include "core/dom/VisitedLinkState.h"
102 #include "core/dom/XMLDocument.h" 103 #include "core/dom/XMLDocument.h"
103 #include "core/dom/custom/CustomElementMicrotaskRunQueue.h" 104 #include "core/dom/custom/CustomElementMicrotaskRunQueue.h"
104 #include "core/dom/custom/CustomElementRegistrationContext.h" 105 #include "core/dom/custom/CustomElementRegistrationContext.h"
(...skipping 479 matching lines...) Expand 10 before | Expand all | Expand 10 after
584 585
585 m_markers->clear(); 586 m_markers->clear();
586 587
587 m_cssCanvasElements.clear(); 588 m_cssCanvasElements.clear();
588 589
589 // FIXME: consider using ActiveDOMObject. 590 // FIXME: consider using ActiveDOMObject.
590 if (m_scriptedAnimationController) 591 if (m_scriptedAnimationController)
591 m_scriptedAnimationController->clearDocumentPointer(); 592 m_scriptedAnimationController->clearDocumentPointer();
592 m_scriptedAnimationController.clear(); 593 m_scriptedAnimationController.clear();
593 594
595 m_scriptedIdleTaskController.clear();
596
594 if (svgExtensions()) 597 if (svgExtensions())
595 accessSVGExtensions().pauseAnimations(); 598 accessSVGExtensions().pauseAnimations();
596 599
597 m_lifecycle.advanceTo(DocumentLifecycle::Disposed); 600 m_lifecycle.advanceTo(DocumentLifecycle::Disposed);
598 DocumentLifecycleNotifier::notifyDocumentWasDisposed(); 601 DocumentLifecycleNotifier::notifyDocumentWasDisposed();
599 602
600 m_canvasFontCache.clear(); 603 m_canvasFontCache.clear();
601 } 604 }
602 #endif 605 #endif
603 606
(...skipping 1536 matching lines...) Expand 10 before | Expand all | Expand 10 after
2140 if (m_frame->loader().client()->sharedWorkerRepositoryClient()) 2143 if (m_frame->loader().client()->sharedWorkerRepositoryClient())
2141 m_frame->loader().client()->sharedWorkerRepositoryClient()->documentDeta ched(this); 2144 m_frame->loader().client()->sharedWorkerRepositoryClient()->documentDeta ched(this);
2142 2145
2143 stopActiveDOMObjects(); 2146 stopActiveDOMObjects();
2144 2147
2145 // FIXME: consider using ActiveDOMObject. 2148 // FIXME: consider using ActiveDOMObject.
2146 if (m_scriptedAnimationController) 2149 if (m_scriptedAnimationController)
2147 m_scriptedAnimationController->clearDocumentPointer(); 2150 m_scriptedAnimationController->clearDocumentPointer();
2148 m_scriptedAnimationController.clear(); 2151 m_scriptedAnimationController.clear();
2149 2152
2153 m_scriptedIdleTaskController.clear();
2154
2150 if (svgExtensions()) 2155 if (svgExtensions())
2151 accessSVGExtensions().pauseAnimations(); 2156 accessSVGExtensions().pauseAnimations();
2152 2157
2153 // FIXME: This shouldn't be needed once LocalDOMWindow becomes ExecutionCont ext. 2158 // FIXME: This shouldn't be needed once LocalDOMWindow becomes ExecutionCont ext.
2154 if (m_domWindow) 2159 if (m_domWindow)
2155 m_domWindow->clearEventQueue(); 2160 m_domWindow->clearEventQueue();
2156 2161
2157 if (m_layoutView) 2162 if (m_layoutView)
2158 m_layoutView->setIsInWindow(false); 2163 m_layoutView->setIsInWindow(false);
2159 2164
(...skipping 3074 matching lines...) Expand 10 before | Expand all | Expand 10 after
5234 m_scriptedAnimationController->cancelCallback(id); 5239 m_scriptedAnimationController->cancelCallback(id);
5235 } 5240 }
5236 5241
5237 void Document::serviceScriptedAnimations(double monotonicAnimationStartTime) 5242 void Document::serviceScriptedAnimations(double monotonicAnimationStartTime)
5238 { 5243 {
5239 if (!m_scriptedAnimationController) 5244 if (!m_scriptedAnimationController)
5240 return; 5245 return;
5241 m_scriptedAnimationController->serviceScriptedAnimations(monotonicAnimationS tartTime); 5246 m_scriptedAnimationController->serviceScriptedAnimations(monotonicAnimationS tartTime);
5242 } 5247 }
5243 5248
5249 ScriptedIdleTaskController& Document::ensureScriptedIdleTaskController()
5250 {
5251 if (!m_scriptedIdleTaskController) {
jochen (gone - plz use gerrit) 2015/07/31 09:19:19 no { }
rmcilroy 2015/08/11 16:30:51 Done.
5252 m_scriptedIdleTaskController = ScriptedIdleTaskController::create(this, loader()->timing());
5253 }
5254 return *m_scriptedIdleTaskController;
5255 }
5256
5257 int Document::requestIdleCallback(IdleRequestCallback* callback, double timeout)
5258 {
5259 return ensureScriptedIdleTaskController().registerCallback(callback, timeout );
5260 }
5261
5262 void Document::cancelIdleCallback(int id)
5263 {
5264 if (!m_scriptedIdleTaskController)
5265 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
5266 m_scriptedIdleTaskController->cancelCallback(id);
5267 }
5268
5244 PassRefPtrWillBeRawPtr<Touch> Document::createTouch(DOMWindow* window, EventTarg et* target, int identifier, double pageX, double pageY, double screenX, double s creenY, double radiusX, double radiusY, float rotationAngle, float force) const 5269 PassRefPtrWillBeRawPtr<Touch> Document::createTouch(DOMWindow* window, EventTarg et* target, int identifier, double pageX, double pageY, double screenX, double s creenY, double radiusX, double radiusY, float rotationAngle, float force) const
5245 { 5270 {
5246 // Match behavior from when these types were integers, and avoid surprises f rom someone explicitly 5271 // Match behavior from when these types were integers, and avoid surprises f rom someone explicitly
5247 // passing Infinity/NaN. 5272 // passing Infinity/NaN.
5248 if (!std::isfinite(pageX)) 5273 if (!std::isfinite(pageX))
5249 pageX = 0; 5274 pageX = 0;
5250 if (!std::isfinite(pageY)) 5275 if (!std::isfinite(pageY))
5251 pageY = 0; 5276 pageY = 0;
5252 if (!std::isfinite(screenX)) 5277 if (!std::isfinite(screenX))
5253 screenX = 0; 5278 screenX = 0;
(...skipping 508 matching lines...) Expand 10 before | Expand all | Expand 10 after
5762 visitor->trace(m_formController); 5787 visitor->trace(m_formController);
5763 visitor->trace(m_visitedLinkState); 5788 visitor->trace(m_visitedLinkState);
5764 visitor->trace(m_frame); 5789 visitor->trace(m_frame);
5765 visitor->trace(m_domWindow); 5790 visitor->trace(m_domWindow);
5766 visitor->trace(m_fetcher); 5791 visitor->trace(m_fetcher);
5767 visitor->trace(m_parser); 5792 visitor->trace(m_parser);
5768 visitor->trace(m_contextFeatures); 5793 visitor->trace(m_contextFeatures);
5769 visitor->trace(m_styleSheetList); 5794 visitor->trace(m_styleSheetList);
5770 visitor->trace(m_mediaQueryMatcher); 5795 visitor->trace(m_mediaQueryMatcher);
5771 visitor->trace(m_scriptedAnimationController); 5796 visitor->trace(m_scriptedAnimationController);
5797 visitor->trace(m_scriptedIdleTaskController);
5772 visitor->trace(m_textAutosizer); 5798 visitor->trace(m_textAutosizer);
5773 visitor->trace(m_registrationContext); 5799 visitor->trace(m_registrationContext);
5774 visitor->trace(m_customElementMicrotaskRunQueue); 5800 visitor->trace(m_customElementMicrotaskRunQueue);
5775 visitor->trace(m_elementDataCache); 5801 visitor->trace(m_elementDataCache);
5776 visitor->trace(m_associatedFormControls); 5802 visitor->trace(m_associatedFormControls);
5777 visitor->trace(m_useElementsNeedingUpdate); 5803 visitor->trace(m_useElementsNeedingUpdate);
5778 visitor->trace(m_layerUpdateSVGFilterElements); 5804 visitor->trace(m_layerUpdateSVGFilterElements);
5779 visitor->trace(m_timers); 5805 visitor->trace(m_timers);
5780 visitor->trace(m_templateDocument); 5806 visitor->trace(m_templateDocument);
5781 visitor->trace(m_templateDocumentHost); 5807 visitor->trace(m_templateDocumentHost);
(...skipping 19 matching lines...) Expand all
5801 #ifndef NDEBUG 5827 #ifndef NDEBUG
5802 using namespace blink; 5828 using namespace blink;
5803 void showLiveDocumentInstances() 5829 void showLiveDocumentInstances()
5804 { 5830 {
5805 WeakDocumentSet& set = liveDocumentSet(); 5831 WeakDocumentSet& set = liveDocumentSet();
5806 fprintf(stderr, "There are %u documents currently alive:\n", set.size()); 5832 fprintf(stderr, "There are %u documents currently alive:\n", set.size());
5807 for (Document* document : set) 5833 for (Document* document : set)
5808 fprintf(stderr, "- Document %p URL: %s\n", document, document->url().str ing().utf8().data()); 5834 fprintf(stderr, "- Document %p URL: %s\n", document, document->url().str ing().utf8().data());
5809 } 5835 }
5810 #endif 5836 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698