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

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: 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « Source/core/dom/Document.h ('k') | Source/core/dom/IdleCallbackDeadline.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
84 #include "core/dom/NodeComputedStyle.h" 84 #include "core/dom/NodeComputedStyle.h"
85 #include "core/dom/NodeFilter.h" 85 #include "core/dom/NodeFilter.h"
86 #include "core/dom/NodeIterator.h" 86 #include "core/dom/NodeIterator.h"
87 #include "core/dom/NodeRareData.h" 87 #include "core/dom/NodeRareData.h"
88 #include "core/dom/NodeTraversal.h" 88 #include "core/dom/NodeTraversal.h"
89 #include "core/dom/NodeWithIndex.h" 89 #include "core/dom/NodeWithIndex.h"
90 #include "core/dom/NthIndexCache.h" 90 #include "core/dom/NthIndexCache.h"
91 #include "core/dom/ProcessingInstruction.h" 91 #include "core/dom/ProcessingInstruction.h"
92 #include "core/dom/ScriptRunner.h" 92 #include "core/dom/ScriptRunner.h"
93 #include "core/dom/ScriptedAnimationController.h" 93 #include "core/dom/ScriptedAnimationController.h"
94 #include "core/dom/ScriptedIdleTaskController.h"
94 #include "core/dom/SelectorQuery.h" 95 #include "core/dom/SelectorQuery.h"
95 #include "core/dom/StaticNodeList.h" 96 #include "core/dom/StaticNodeList.h"
96 #include "core/dom/StyleEngine.h" 97 #include "core/dom/StyleEngine.h"
97 #include "core/dom/TouchList.h" 98 #include "core/dom/TouchList.h"
98 #include "core/dom/TransformSource.h" 99 #include "core/dom/TransformSource.h"
99 #include "core/dom/TreeWalker.h" 100 #include "core/dom/TreeWalker.h"
100 #include "core/dom/VisitedLinkState.h" 101 #include "core/dom/VisitedLinkState.h"
101 #include "core/dom/XMLDocument.h" 102 #include "core/dom/XMLDocument.h"
102 #include "core/dom/custom/CustomElementMicrotaskRunQueue.h" 103 #include "core/dom/custom/CustomElementMicrotaskRunQueue.h"
103 #include "core/dom/custom/CustomElementRegistrationContext.h" 104 #include "core/dom/custom/CustomElementRegistrationContext.h"
(...skipping 475 matching lines...) Expand 10 before | Expand all | Expand 10 after
579 580
580 m_markers->clear(); 581 m_markers->clear();
581 582
582 m_cssCanvasElements.clear(); 583 m_cssCanvasElements.clear();
583 584
584 // FIXME: consider using ActiveDOMObject. 585 // FIXME: consider using ActiveDOMObject.
585 if (m_scriptedAnimationController) 586 if (m_scriptedAnimationController)
586 m_scriptedAnimationController->clearDocumentPointer(); 587 m_scriptedAnimationController->clearDocumentPointer();
587 m_scriptedAnimationController.clear(); 588 m_scriptedAnimationController.clear();
588 589
590 m_scriptedIdleTaskController.clear();
591
589 if (svgExtensions()) 592 if (svgExtensions())
590 accessSVGExtensions().pauseAnimations(); 593 accessSVGExtensions().pauseAnimations();
591 594
592 m_lifecycle.advanceTo(DocumentLifecycle::Disposed); 595 m_lifecycle.advanceTo(DocumentLifecycle::Disposed);
593 DocumentLifecycleNotifier::notifyDocumentWasDisposed(); 596 DocumentLifecycleNotifier::notifyDocumentWasDisposed();
594 597
595 m_canvasFontCache.clear(); 598 m_canvasFontCache.clear();
596 m_nodeCount = 0; 599 m_nodeCount = 0;
597 } 600 }
598 #endif 601 #endif
(...skipping 1530 matching lines...) Expand 10 before | Expand all | Expand 10 after
2129 if (m_frame->loader().client()->sharedWorkerRepositoryClient()) 2132 if (m_frame->loader().client()->sharedWorkerRepositoryClient())
2130 m_frame->loader().client()->sharedWorkerRepositoryClient()->documentDeta ched(this); 2133 m_frame->loader().client()->sharedWorkerRepositoryClient()->documentDeta ched(this);
2131 2134
2132 stopActiveDOMObjects(); 2135 stopActiveDOMObjects();
2133 2136
2134 // FIXME: consider using ActiveDOMObject. 2137 // FIXME: consider using ActiveDOMObject.
2135 if (m_scriptedAnimationController) 2138 if (m_scriptedAnimationController)
2136 m_scriptedAnimationController->clearDocumentPointer(); 2139 m_scriptedAnimationController->clearDocumentPointer();
2137 m_scriptedAnimationController.clear(); 2140 m_scriptedAnimationController.clear();
2138 2141
2142 m_scriptedIdleTaskController.clear();
2143
2139 if (svgExtensions()) 2144 if (svgExtensions())
2140 accessSVGExtensions().pauseAnimations(); 2145 accessSVGExtensions().pauseAnimations();
2141 2146
2142 // FIXME: This shouldn't be needed once LocalDOMWindow becomes ExecutionCont ext. 2147 // FIXME: This shouldn't be needed once LocalDOMWindow becomes ExecutionCont ext.
2143 if (m_domWindow) 2148 if (m_domWindow)
2144 m_domWindow->clearEventQueue(); 2149 m_domWindow->clearEventQueue();
2145 2150
2146 if (m_layoutView) 2151 if (m_layoutView)
2147 m_layoutView->setIsInWindow(false); 2152 m_layoutView->setIsInWindow(false);
2148 2153
(...skipping 2974 matching lines...) Expand 10 before | Expand all | Expand 10 after
5123 m_scriptedAnimationController->cancelCallback(id); 5128 m_scriptedAnimationController->cancelCallback(id);
5124 } 5129 }
5125 5130
5126 void Document::serviceScriptedAnimations(double monotonicAnimationStartTime) 5131 void Document::serviceScriptedAnimations(double monotonicAnimationStartTime)
5127 { 5132 {
5128 if (!m_scriptedAnimationController) 5133 if (!m_scriptedAnimationController)
5129 return; 5134 return;
5130 m_scriptedAnimationController->serviceScriptedAnimations(monotonicAnimationS tartTime); 5135 m_scriptedAnimationController->serviceScriptedAnimations(monotonicAnimationS tartTime);
5131 } 5136 }
5132 5137
5138 ScriptedIdleTaskController& Document::ensureScriptedIdleTaskController()
5139 {
5140 if (!m_scriptedIdleTaskController)
5141 m_scriptedIdleTaskController = ScriptedIdleTaskController::create(this, loader()->timing());
5142 return *m_scriptedIdleTaskController;
5143 }
5144
5145 int Document::requestIdleCallback(IdleRequestCallback* callback, double timeoutM illis)
5146 {
5147 return ensureScriptedIdleTaskController().registerCallback(callback, timeout Millis);
5148 }
5149
5150 void Document::cancelIdleCallback(int id)
5151 {
5152 if (!m_scriptedIdleTaskController)
5153 return;
5154 m_scriptedIdleTaskController->cancelCallback(id);
5155 }
5156
5133 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 5157 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
5134 { 5158 {
5135 // Match behavior from when these types were integers, and avoid surprises f rom someone explicitly 5159 // Match behavior from when these types were integers, and avoid surprises f rom someone explicitly
5136 // passing Infinity/NaN. 5160 // passing Infinity/NaN.
5137 if (!std::isfinite(pageX)) 5161 if (!std::isfinite(pageX))
5138 pageX = 0; 5162 pageX = 0;
5139 if (!std::isfinite(pageY)) 5163 if (!std::isfinite(pageY))
5140 pageY = 0; 5164 pageY = 0;
5141 if (!std::isfinite(screenX)) 5165 if (!std::isfinite(screenX))
5142 screenX = 0; 5166 screenX = 0;
(...skipping 510 matching lines...) Expand 10 before | Expand all | Expand 10 after
5653 visitor->trace(m_visitedLinkState); 5677 visitor->trace(m_visitedLinkState);
5654 visitor->trace(m_frame); 5678 visitor->trace(m_frame);
5655 visitor->trace(m_domWindow); 5679 visitor->trace(m_domWindow);
5656 visitor->trace(m_fetcher); 5680 visitor->trace(m_fetcher);
5657 visitor->trace(m_parser); 5681 visitor->trace(m_parser);
5658 visitor->trace(m_contextFeatures); 5682 visitor->trace(m_contextFeatures);
5659 visitor->trace(m_styleSheetList); 5683 visitor->trace(m_styleSheetList);
5660 visitor->trace(m_documentTiming); 5684 visitor->trace(m_documentTiming);
5661 visitor->trace(m_mediaQueryMatcher); 5685 visitor->trace(m_mediaQueryMatcher);
5662 visitor->trace(m_scriptedAnimationController); 5686 visitor->trace(m_scriptedAnimationController);
5687 visitor->trace(m_scriptedIdleTaskController);
5663 visitor->trace(m_taskRunner); 5688 visitor->trace(m_taskRunner);
5664 visitor->trace(m_textAutosizer); 5689 visitor->trace(m_textAutosizer);
5665 visitor->trace(m_registrationContext); 5690 visitor->trace(m_registrationContext);
5666 visitor->trace(m_customElementMicrotaskRunQueue); 5691 visitor->trace(m_customElementMicrotaskRunQueue);
5667 visitor->trace(m_elementDataCache); 5692 visitor->trace(m_elementDataCache);
5668 visitor->trace(m_associatedFormControls); 5693 visitor->trace(m_associatedFormControls);
5669 visitor->trace(m_useElementsNeedingUpdate); 5694 visitor->trace(m_useElementsNeedingUpdate);
5670 visitor->trace(m_layerUpdateSVGFilterElements); 5695 visitor->trace(m_layerUpdateSVGFilterElements);
5671 visitor->trace(m_timers); 5696 visitor->trace(m_timers);
5672 visitor->trace(m_templateDocument); 5697 visitor->trace(m_templateDocument);
(...skipping 21 matching lines...) Expand all
5694 #ifndef NDEBUG 5719 #ifndef NDEBUG
5695 using namespace blink; 5720 using namespace blink;
5696 void showLiveDocumentInstances() 5721 void showLiveDocumentInstances()
5697 { 5722 {
5698 Document::WeakDocumentSet& set = Document::liveDocumentSet(); 5723 Document::WeakDocumentSet& set = Document::liveDocumentSet();
5699 fprintf(stderr, "There are %u documents currently alive:\n", set.size()); 5724 fprintf(stderr, "There are %u documents currently alive:\n", set.size());
5700 for (Document* document : set) 5725 for (Document* document : set)
5701 fprintf(stderr, "- Document %p URL: %s\n", document, document->url().str ing().utf8().data()); 5726 fprintf(stderr, "- Document %p URL: %s\n", document, document->url().str ing().utf8().data());
5702 } 5727 }
5703 #endif 5728 #endif
OLDNEW
« 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