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

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

Issue 2475643004: Monitor the intersection of video and viewport. (Closed)
Patch Set: Fix trybots failure. Created 4 years, 1 month 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/IntersectionObserver.cpp
diff --git a/third_party/WebKit/Source/core/dom/IntersectionObserver.cpp b/third_party/WebKit/Source/core/dom/IntersectionObserver.cpp
index 60be0837ef1f6001b6cdf4493d28ebe1097ff8b6..2bfda308d700a92cd534e3f25ac579e0f6fc8631 100644
--- a/third_party/WebKit/Source/core/dom/IntersectionObserver.cpp
+++ b/third_party/WebKit/Source/core/dom/IntersectionObserver.cpp
@@ -188,8 +188,13 @@ IntersectionObserver* IntersectionObserver::create(
IntersectionObserverCallbackImpl* intersectionObserverCallback =
new IntersectionObserverCallbackImpl(document, std::move(callback));
- return new IntersectionObserver(*intersectionObserverCallback, *root,
- rootMargin, thresholds);
+ if (thresholds.isEmpty()) {
+ return new ViewportIntersectionObserver(*intersectionObserverCallback,
+ *root, rootMargin);
+ } else {
+ return new IntersectionObserver(*intersectionObserverCallback, *root,
+ rootMargin, thresholds);
+ }
}
IntersectionObserver::IntersectionObserver(
@@ -235,6 +240,8 @@ IntersectionObserver::IntersectionObserver(
*this);
}
+IntersectionObserver::~IntersectionObserver() {}
+
void IntersectionObserver::clearWeakMembers(Visitor* visitor) {
if (ThreadHeap::isHeapObjectAlive(m_root))
return;
@@ -280,7 +287,7 @@ void IntersectionObserver::observe(Element* target,
}
IntersectionObservation* observation =
- new IntersectionObservation(*this, *target, shouldReportRootBounds);
+ createObservation(*target, shouldReportRootBounds);
target->ensureIntersectionObserverData().addObservation(*observation);
m_observations.add(observation);
@@ -445,6 +452,12 @@ void IntersectionObserver::deliver() {
m_callback->handleEvent(entries, *this);
}
+IntersectionObservation* IntersectionObserver::createObservation(
+ Element& target,
+ bool shouldReportRootBounds) {
+ return new IntersectionObservation(*this, target, shouldReportRootBounds);
+}
+
DEFINE_TRACE(IntersectionObserver) {
visitor->template registerWeakMembers<
IntersectionObserver, &IntersectionObserver::clearWeakMembers>(this);
@@ -453,4 +466,18 @@ DEFINE_TRACE(IntersectionObserver) {
visitor->trace(m_entries);
}
+ViewportIntersectionObserver::ViewportIntersectionObserver(
+ IntersectionObserverCallback& callback,
+ Node& node,
+ const Vector<Length>& rootMargin)
+ : IntersectionObserver(callback, node, rootMargin, Vector<float>()) {}
+
+ViewportIntersectionObserver::~ViewportIntersectionObserver() {}
+
+IntersectionObservation* ViewportIntersectionObserver::createObservation(
+ Element& target,
+ bool) {
+ return new ViewportIntersectionObservation(*this, target);
+}
+
} // namespace blink
« no previous file with comments | « third_party/WebKit/Source/core/dom/IntersectionObserver.h ('k') | third_party/WebKit/Source/core/html/AutoplayUmaHelper.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698