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

Side by Side Diff: third_party/WebKit/Source/core/dom/Document.cpp

Issue 1449623002: IntersectionObserver: second cut. (Closed) Base URL: https://chromium.googlesource.com/chromium/src@master
Patch Set: Added dispose() methods for expicit cleanup Created 5 years 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
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 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
69 #include "core/dom/DocumentFragment.h" 69 #include "core/dom/DocumentFragment.h"
70 #include "core/dom/DocumentLifecycleObserver.h" 70 #include "core/dom/DocumentLifecycleObserver.h"
71 #include "core/dom/DocumentType.h" 71 #include "core/dom/DocumentType.h"
72 #include "core/dom/Element.h" 72 #include "core/dom/Element.h"
73 #include "core/dom/ElementDataCache.h" 73 #include "core/dom/ElementDataCache.h"
74 #include "core/dom/ElementRegistrationOptions.h" 74 #include "core/dom/ElementRegistrationOptions.h"
75 #include "core/dom/ElementTraversal.h" 75 #include "core/dom/ElementTraversal.h"
76 #include "core/dom/ExceptionCode.h" 76 #include "core/dom/ExceptionCode.h"
77 #include "core/dom/ExecutionContextTask.h" 77 #include "core/dom/ExecutionContextTask.h"
78 #include "core/dom/FrameRequestCallback.h" 78 #include "core/dom/FrameRequestCallback.h"
79 #include "core/dom/IntersectionObserverController.h"
79 #include "core/dom/LayoutTreeBuilderTraversal.h" 80 #include "core/dom/LayoutTreeBuilderTraversal.h"
80 #include "core/dom/MainThreadTaskRunner.h" 81 #include "core/dom/MainThreadTaskRunner.h"
81 #include "core/dom/Microtask.h" 82 #include "core/dom/Microtask.h"
82 #include "core/dom/MutationObserver.h" 83 #include "core/dom/MutationObserver.h"
83 #include "core/dom/NodeChildRemovalTracker.h" 84 #include "core/dom/NodeChildRemovalTracker.h"
84 #include "core/dom/NodeComputedStyle.h" 85 #include "core/dom/NodeComputedStyle.h"
85 #include "core/dom/NodeFilter.h" 86 #include "core/dom/NodeFilter.h"
86 #include "core/dom/NodeIterator.h" 87 #include "core/dom/NodeIterator.h"
87 #include "core/dom/NodeRareData.h" 88 #include "core/dom/NodeRareData.h"
88 #include "core/dom/NodeTraversal.h" 89 #include "core/dom/NodeTraversal.h"
(...skipping 506 matching lines...) Expand 10 before | Expand all | Expand 10 after
595 // FIXME: consider using ActiveDOMObject. 596 // FIXME: consider using ActiveDOMObject.
596 if (m_scriptedAnimationController) 597 if (m_scriptedAnimationController)
597 m_scriptedAnimationController->clearDocumentPointer(); 598 m_scriptedAnimationController->clearDocumentPointer();
598 m_scriptedAnimationController.clear(); 599 m_scriptedAnimationController.clear();
599 600
600 m_scriptedIdleTaskController.clear(); 601 m_scriptedIdleTaskController.clear();
601 602
602 if (svgExtensions()) 603 if (svgExtensions())
603 accessSVGExtensions().pauseAnimations(); 604 accessSVGExtensions().pauseAnimations();
604 605
606 if (m_intersectionObserverController) {
607 m_intersectionObserverController->dispose();
608 m_intersectionObserverController.clear();
609 }
610
605 m_lifecycle.advanceTo(DocumentLifecycle::Disposed); 611 m_lifecycle.advanceTo(DocumentLifecycle::Disposed);
606 DocumentLifecycleNotifier::notifyDocumentWasDisposed(); 612 DocumentLifecycleNotifier::notifyDocumentWasDisposed();
607 613
608 m_canvasFontCache.clear(); 614 m_canvasFontCache.clear();
609 } 615 }
610 #endif 616 #endif
611 617
612 SelectorQueryCache& Document::selectorQueryCache() 618 SelectorQueryCache& Document::selectorQueryCache()
613 { 619 {
614 if (!m_selectorQueryCache) 620 if (!m_selectorQueryCache)
(...skipping 3870 matching lines...) Expand 10 before | Expand all | Expand 10 after
4485 4491
4486 ASSERT(doc); 4492 ASSERT(doc);
4487 return *doc; 4493 return *doc;
4488 } 4494 }
4489 4495
4490 WeakPtrWillBeRawPtr<Document> Document::contextDocument() 4496 WeakPtrWillBeRawPtr<Document> Document::contextDocument()
4491 { 4497 {
4492 if (m_contextDocument) 4498 if (m_contextDocument)
4493 return m_contextDocument; 4499 return m_contextDocument;
4494 if (m_frame) { 4500 if (m_frame) {
4495 #if ENABLE(OILPAN) 4501 return createWeakPtr();
4496 return this;
4497 #else
4498 return m_weakFactory.createWeakPtr();
4499 #endif
4500 } 4502 }
4501 return nullptr; 4503 return nullptr;
4502 } 4504 }
4503 4505
4504 PassRefPtrWillBeRawPtr<Attr> Document::createAttribute(const AtomicString& name, ExceptionState& exceptionState) 4506 PassRefPtrWillBeRawPtr<Attr> Document::createAttribute(const AtomicString& name, ExceptionState& exceptionState)
4505 { 4507 {
4506 if (isHTMLDocument() && name != name.lower()) 4508 if (isHTMLDocument() && name != name.lower())
4507 UseCounter::count(*this, UseCounter::HTMLDocumentCreateAttributeNameNotL owercase); 4509 UseCounter::count(*this, UseCounter::HTMLDocumentCreateAttributeNameNotL owercase);
4508 return createAttributeNS(nullAtom, name, exceptionState, true); 4510 return createAttributeNS(nullAtom, name, exceptionState, true);
4509 } 4511 }
(...skipping 455 matching lines...) Expand 10 before | Expand all | Expand 10 after
4965 { 4967 {
4966 if (equalIgnoringCase(dnsPrefetchControl, "on") && !m_haveExplicitlyDisabled DNSPrefetch) { 4968 if (equalIgnoringCase(dnsPrefetchControl, "on") && !m_haveExplicitlyDisabled DNSPrefetch) {
4967 m_isDNSPrefetchEnabled = true; 4969 m_isDNSPrefetchEnabled = true;
4968 return; 4970 return;
4969 } 4971 }
4970 4972
4971 m_isDNSPrefetchEnabled = false; 4973 m_isDNSPrefetchEnabled = false;
4972 m_haveExplicitlyDisabledDNSPrefetch = true; 4974 m_haveExplicitlyDisabledDNSPrefetch = true;
4973 } 4975 }
4974 4976
4977 WeakPtrWillBeRawPtr<Document> Document::createWeakPtr()
4978 {
4979 #if ENABLE(OILPAN)
4980 return this;
4981 #else
4982 return m_weakFactory.createWeakPtr();
4983 #endif
4984 }
4985
4986 IntersectionObserverController* Document::intersectionObserverController()
esprehn 2015/12/17 01:40:28 We usually make these return a reference since it
szager1 2015/12/17 20:27:25 Done.
4987 {
4988 if (!m_intersectionObserverController)
4989 m_intersectionObserverController = new IntersectionObserverController();
4990 return m_intersectionObserverController.get();
4991 }
4992
4975 void Document::reportBlockedScriptExecutionToInspector(const String& directiveTe xt) 4993 void Document::reportBlockedScriptExecutionToInspector(const String& directiveTe xt)
4976 { 4994 {
4977 InspectorInstrumentation::scriptExecutionBlockedByCSP(this, directiveText); 4995 InspectorInstrumentation::scriptExecutionBlockedByCSP(this, directiveText);
4978 } 4996 }
4979 4997
4980 void Document::addConsoleMessage(PassRefPtrWillBeRawPtr<ConsoleMessage> consoleM essage) 4998 void Document::addConsoleMessage(PassRefPtrWillBeRawPtr<ConsoleMessage> consoleM essage)
4981 { 4999 {
4982 if (!isContextThread()) { 5000 if (!isContextThread()) {
4983 m_taskRunner->postTask(BLINK_FROM_HERE, AddConsoleMessageTask::create(co nsoleMessage->source(), consoleMessage->level(), consoleMessage->message())); 5001 m_taskRunner->postTask(BLINK_FROM_HERE, AddConsoleMessageTask::create(co nsoleMessage->source(), consoleMessage->level(), consoleMessage->message()));
4984 return; 5002 return;
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
5022 void Document::tasksWereResumed() 5040 void Document::tasksWereResumed()
5023 { 5041 {
5024 scriptRunner()->resume(); 5042 scriptRunner()->resume();
5025 5043
5026 if (m_parser) 5044 if (m_parser)
5027 m_parser->resumeScheduledTasks(); 5045 m_parser->resumeScheduledTasks();
5028 if (m_scriptedAnimationController) 5046 if (m_scriptedAnimationController)
5029 m_scriptedAnimationController->resume(); 5047 m_scriptedAnimationController->resume();
5030 5048
5031 MutationObserver::resumeSuspendedObservers(); 5049 MutationObserver::resumeSuspendedObservers();
5050 if (m_intersectionObserverController)
5051 m_intersectionObserverController->resumeSuspendedIntersectionObservers() ;
5032 if (m_domWindow) 5052 if (m_domWindow)
5033 DOMWindowPerformance::performance(*m_domWindow)->resumeSuspendedObserver s(); 5053 DOMWindowPerformance::performance(*m_domWindow)->resumeSuspendedObserver s();
5034 } 5054 }
5035 5055
5036 // FIXME: suspendScheduledTasks(), resumeScheduledTasks(), tasksNeedSuspension() 5056 // FIXME: suspendScheduledTasks(), resumeScheduledTasks(), tasksNeedSuspension()
5037 // should be moved to LocalDOMWindow once it inherits ExecutionContext 5057 // should be moved to LocalDOMWindow once it inherits ExecutionContext
5038 void Document::suspendScheduledTasks() 5058 void Document::suspendScheduledTasks()
5039 { 5059 {
5040 ExecutionContext::suspendScheduledTasks(); 5060 ExecutionContext::suspendScheduledTasks();
5041 m_taskRunner->suspend(); 5061 m_taskRunner->suspend();
(...skipping 773 matching lines...) Expand 10 before | Expand all | Expand 10 after
5815 visitor->trace(m_timers); 5835 visitor->trace(m_timers);
5816 visitor->trace(m_templateDocument); 5836 visitor->trace(m_templateDocument);
5817 visitor->trace(m_templateDocumentHost); 5837 visitor->trace(m_templateDocumentHost);
5818 visitor->trace(m_visibilityObservers); 5838 visitor->trace(m_visibilityObservers);
5819 visitor->trace(m_userActionElements); 5839 visitor->trace(m_userActionElements);
5820 visitor->trace(m_svgExtensions); 5840 visitor->trace(m_svgExtensions);
5821 visitor->trace(m_timeline); 5841 visitor->trace(m_timeline);
5822 visitor->trace(m_compositorPendingAnimations); 5842 visitor->trace(m_compositorPendingAnimations);
5823 visitor->trace(m_contextDocument); 5843 visitor->trace(m_contextDocument);
5824 visitor->trace(m_canvasFontCache); 5844 visitor->trace(m_canvasFontCache);
5845 visitor->trace(m_intersectionObserverController);
5825 WillBeHeapSupplementable<Document>::trace(visitor); 5846 WillBeHeapSupplementable<Document>::trace(visitor);
5826 #endif 5847 #endif
5827 TreeScope::trace(visitor); 5848 TreeScope::trace(visitor);
5828 ContainerNode::trace(visitor); 5849 ContainerNode::trace(visitor);
5829 ExecutionContext::trace(visitor); 5850 ExecutionContext::trace(visitor);
5830 DocumentLifecycleNotifier::trace(visitor); 5851 DocumentLifecycleNotifier::trace(visitor);
5831 SecurityContext::trace(visitor); 5852 SecurityContext::trace(visitor);
5832 } 5853 }
5833 5854
5834 template class CORE_TEMPLATE_EXPORT WillBeHeapSupplement<Document>; 5855 template class CORE_TEMPLATE_EXPORT WillBeHeapSupplement<Document>;
5835 5856
5836 } // namespace blink 5857 } // namespace blink
5837 5858
5838 #ifndef NDEBUG 5859 #ifndef NDEBUG
5839 using namespace blink; 5860 using namespace blink;
5840 void showLiveDocumentInstances() 5861 void showLiveDocumentInstances()
5841 { 5862 {
5842 Document::WeakDocumentSet& set = Document::liveDocumentSet(); 5863 Document::WeakDocumentSet& set = Document::liveDocumentSet();
5843 fprintf(stderr, "There are %u documents currently alive:\n", set.size()); 5864 fprintf(stderr, "There are %u documents currently alive:\n", set.size());
5844 for (Document* document : set) 5865 for (Document* document : set)
5845 fprintf(stderr, "- Document %p URL: %s\n", document, document->url().str ing().utf8().data()); 5866 fprintf(stderr, "- Document %p URL: %s\n", document, document->url().str ing().utf8().data());
5846 } 5867 }
5847 #endif 5868 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698