Chromium Code Reviews| 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..3a5389bfcefe74570f5978470c696fef55d64e6d 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/IntersectionObserverRegistry.h" |
| #include "core/dom/LayoutTreeBuilderTraversal.h" |
| #include "core/dom/MainThreadTaskRunner.h" |
| #include "core/dom/Microtask.h" |
| @@ -433,6 +434,7 @@ Document::Document(const DocumentInit& initializer, DocumentClassFlags documentC |
| , m_loadEventDelayCount(0) |
| , m_loadEventDelayTimer(this, &Document::loadEventDelayTimerFired) |
| , m_pluginLoadingTimer(this, &Document::pluginLoadingTimerFired) |
| + , m_deliverIntersectionObservationsTimer(this, &Document::deliverIntersectionObservationsTimerFired) |
| , m_documentTiming(*this) |
| , m_writeRecursionIsTooDeep(false) |
| , m_writeRecursionDepth(0) |
| @@ -602,6 +604,8 @@ void Document::dispose() |
| if (svgExtensions()) |
| accessSVGExtensions().pauseAnimations(); |
| + m_deliverIntersectionObservationsTimer.stop(); |
| + |
| m_lifecycle.advanceTo(DocumentLifecycle::Disposed); |
| DocumentLifecycleNotifier::notifyDocumentWasDisposed(); |
| @@ -4492,11 +4496,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 +4972,29 @@ void Document::parseDNSPrefetchControlHeader(const String& dnsPrefetchControl) |
| m_haveExplicitlyDisabledDNSPrefetch = true; |
| } |
| +WeakPtrWillBeRawPtr<Document> Document::createWeakPtr() |
| +{ |
| +#if ENABLE(OILPAN) |
| + return this; |
| +#else |
| + return m_weakFactory.createWeakPtr(); |
| +#endif |
| +} |
| + |
| +IntersectionObserverRegistry* Document::intersectionObserverRegistry() |
| +{ |
| + if (!m_intersectionObserverRegistry) |
| + m_intersectionObserverRegistry = new IntersectionObserverRegistry(m_deliverIntersectionObservationsTimer); |
|
esprehn
2015/12/12 00:14:13
put the timer in the registry, it doesn't need to
szager1
2015/12/16 19:15:34
Done.
|
| + return m_intersectionObserverRegistry.get(); |
| +} |
| + |
| +void Document::deliverIntersectionObservationsTimerFired(Timer<Document>*) |
| +{ |
| + ASSERT(isMainThread()); |
|
esprehn
2015/12/12 00:14:13
no need for the main thread assert, the whole DOM
szager1
2015/12/16 19:15:34
Done.
|
| + ASSERT(m_intersectionObserverRegistry); |
| + m_intersectionObserverRegistry->deliverIntersectionObservations(); |
|
esprehn
2015/12/12 00:14:13
remove this, move it into the registry
szager1
2015/12/16 19:15:34
Done.
|
| +} |
| + |
| void Document::reportBlockedScriptExecutionToInspector(const String& directiveText) |
| { |
| InspectorInstrumentation::scriptExecutionBlockedByCSP(this, directiveText); |
| @@ -5029,6 +5052,8 @@ void Document::tasksWereResumed() |
| m_scriptedAnimationController->resume(); |
| MutationObserver::resumeSuspendedObservers(); |
| + if (m_intersectionObserverRegistry) |
| + m_intersectionObserverRegistry->resumeSuspendedIntersectionObservers(); |
| if (m_domWindow) |
| DOMWindowPerformance::performance(*m_domWindow)->resumeSuspendedObservers(); |
| } |
| @@ -5822,6 +5847,7 @@ DEFINE_TRACE(Document) |
| visitor->trace(m_compositorPendingAnimations); |
| visitor->trace(m_contextDocument); |
| visitor->trace(m_canvasFontCache); |
| + visitor->trace(m_intersectionObserverRegistry); |
| WillBeHeapSupplementable<Document>::trace(visitor); |
| #endif |
| TreeScope::trace(visitor); |