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

Unified Diff: third_party/WebKit/Source/core/dom/IntersectionObserverController.cpp

Issue 2322143002: Switch IntersectionObserver to postTask. (Closed)
Patch Set: use weakptr Created 4 years, 3 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/WebKit/Source/core/dom/IntersectionObserverController.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/core/dom/IntersectionObserverController.cpp
diff --git a/third_party/WebKit/Source/core/dom/IntersectionObserverController.cpp b/third_party/WebKit/Source/core/dom/IntersectionObserverController.cpp
index dbdb3f937f598f7f37bb4aad6f082e6f24f0c087..169ec7ceda926e01fce3e84be46eb1d66a4214d2 100644
--- a/third_party/WebKit/Source/core/dom/IntersectionObserverController.cpp
+++ b/third_party/WebKit/Source/core/dom/IntersectionObserverController.cpp
@@ -5,7 +5,7 @@
#include "core/dom/IntersectionObserverController.h"
#include "core/dom/Document.h"
-#include "core/dom/IdleRequestOptions.h"
+#include "core/dom/TaskRunnerHelper.h"
#include "platform/TraceEvent.h"
namespace blink {
@@ -19,7 +19,7 @@ IntersectionObserverController* IntersectionObserverController::create(Document*
IntersectionObserverController::IntersectionObserverController(Document* document)
: ActiveDOMObject(document)
- , m_callbackID(0)
+ , m_weakPtrFactory(this)
, m_callbackFiredWhileSuspended(false)
{
}
@@ -29,15 +29,14 @@ IntersectionObserverController::~IntersectionObserverController() { }
void IntersectionObserverController::scheduleIntersectionObserverForDelivery(IntersectionObserver& observer)
{
m_pendingIntersectionObservers.add(&observer);
- if (m_callbackID)
- return;
- Document* document = toDocument(getExecutionContext());
- if (!document)
- return;
- IdleRequestOptions options;
- // The IntersectionObserver spec mandates that notifications be sent within 100ms.
- options.setTimeout(100);
- m_callbackID = document->requestIdleCallback(this, options);
+ if (!m_weakPtrFactory.hasWeakPtrs()) {
+ // TODO(ojan): These tasks decide whether to throttle a subframe, so they need to
+ // be unthrottled, but we should throttle all the other tasks (e.g. ones coming from
+ // the web page).
+ TaskRunnerHelper::get(TaskType::Unthrottled,
+ getExecutionContext())->postTask(BLINK_FROM_HERE,
+ WTF::bind(&IntersectionObserverController::deliverIntersectionObservations, m_weakPtrFactory.createWeakPtr()));
+ }
}
void IntersectionObserverController::resume()
@@ -50,13 +49,6 @@ void IntersectionObserverController::resume()
}
}
-void IntersectionObserverController::handleEvent(IdleDeadline*)
-{
- DCHECK(m_callbackID);
- m_callbackID = 0;
- deliverIntersectionObservations();
-}
-
void IntersectionObserverController::deliverIntersectionObservations()
{
ExecutionContext* context = getExecutionContext();
@@ -104,7 +96,6 @@ DEFINE_TRACE(IntersectionObserverController)
visitor->trace(m_trackedIntersectionObservers);
visitor->trace(m_pendingIntersectionObservers);
ActiveDOMObject::trace(visitor);
- IdleRequestCallback::trace(visitor);
}
} // namespace blink
« no previous file with comments | « third_party/WebKit/Source/core/dom/IntersectionObserverController.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698