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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/core/dom/Document.cpp
diff --git a/third_party/WebKit/Source/core/dom/Document.cpp b/third_party/WebKit/Source/core/dom/Document.cpp
index 1e47f442157510b83b9c9d82cd55cf388366721c..9eab14d099bf31c2a2d1a0d8989757fab9b51a2a 100644
--- a/third_party/WebKit/Source/core/dom/Document.cpp
+++ b/third_party/WebKit/Source/core/dom/Document.cpp
@@ -76,6 +76,7 @@
#include "core/dom/ExceptionCode.h"
#include "core/dom/ExecutionContextTask.h"
#include "core/dom/FrameRequestCallback.h"
+#include "core/dom/IntersectionObserverController.h"
#include "core/dom/LayoutTreeBuilderTraversal.h"
#include "core/dom/MainThreadTaskRunner.h"
#include "core/dom/Microtask.h"
@@ -602,6 +603,11 @@ void Document::dispose()
if (svgExtensions())
accessSVGExtensions().pauseAnimations();
+ if (m_intersectionObserverController) {
+ m_intersectionObserverController->dispose();
+ m_intersectionObserverController.clear();
+ }
+
m_lifecycle.advanceTo(DocumentLifecycle::Disposed);
DocumentLifecycleNotifier::notifyDocumentWasDisposed();
@@ -4492,11 +4498,7 @@ WeakPtrWillBeRawPtr<Document> Document::contextDocument()
if (m_contextDocument)
return m_contextDocument;
if (m_frame) {
-#if ENABLE(OILPAN)
- return this;
-#else
- return m_weakFactory.createWeakPtr();
-#endif
+ return createWeakPtr();
}
return nullptr;
}
@@ -4972,6 +4974,22 @@ void Document::parseDNSPrefetchControlHeader(const String& dnsPrefetchControl)
m_haveExplicitlyDisabledDNSPrefetch = true;
}
+WeakPtrWillBeRawPtr<Document> Document::createWeakPtr()
+{
+#if ENABLE(OILPAN)
+ return this;
+#else
+ return m_weakFactory.createWeakPtr();
+#endif
+}
+
+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.
+{
+ if (!m_intersectionObserverController)
+ m_intersectionObserverController = new IntersectionObserverController();
+ return m_intersectionObserverController.get();
+}
+
void Document::reportBlockedScriptExecutionToInspector(const String& directiveText)
{
InspectorInstrumentation::scriptExecutionBlockedByCSP(this, directiveText);
@@ -5029,6 +5047,8 @@ void Document::tasksWereResumed()
m_scriptedAnimationController->resume();
MutationObserver::resumeSuspendedObservers();
+ if (m_intersectionObserverController)
+ m_intersectionObserverController->resumeSuspendedIntersectionObservers();
if (m_domWindow)
DOMWindowPerformance::performance(*m_domWindow)->resumeSuspendedObservers();
}
@@ -5822,6 +5842,7 @@ DEFINE_TRACE(Document)
visitor->trace(m_compositorPendingAnimations);
visitor->trace(m_contextDocument);
visitor->trace(m_canvasFontCache);
+ visitor->trace(m_intersectionObserverController);
WillBeHeapSupplementable<Document>::trace(visitor);
#endif
TreeScope::trace(visitor);

Powered by Google App Engine
This is Rietveld 408576698