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

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

Issue 2475643004: Monitor the intersection of video and viewport. (Closed)
Patch Set: Use empty thresholds to indicate observing intersection with viewport. 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 32ef04c78978b5f0856a4812c1ff8499585d1e5d..16dabe16eb5fd8deadc5bec097a0959bdea30ee4 100644
--- a/third_party/WebKit/Source/core/dom/IntersectionObserver.cpp
+++ b/third_party/WebKit/Source/core/dom/IntersectionObserver.cpp
@@ -204,7 +204,8 @@ IntersectionObserver::IntersectionObserver(
m_rightMargin(Fixed),
m_bottomMargin(Fixed),
m_leftMargin(Fixed),
- m_initialState(InitialState::kHidden) {
+ m_initialState(InitialState::kHidden),
+ m_observeViewportIntersection(thresholds.isEmpty()) {
switch (rootMargin.size()) {
case 0:
break;
@@ -269,7 +270,9 @@ void IntersectionObserver::observe(Element* target,
LocalFrame* targetFrame = target->document().frame();
LocalFrame* rootFrame = m_root->document().frame();
- if (target->document() == rootNode()->document()) {
+ if (m_observeViewportIntersection) {
szager1 2016/11/16 21:37:55 Hmm... you're using m_observerViewportIntersection
xjz 2016/11/16 22:57:15 Done.
+ shouldReportRootBounds = true;
+ } else if (target->document() == rootNode()->document()) {
shouldReportRootBounds = true;
isDOMDescendant = rootNode()->isShadowIncludingInclusiveAncestorOf(target);
} else if (targetFrame && rootFrame) {
@@ -279,8 +282,13 @@ void IntersectionObserver::observe(Element* target,
isDOMDescendant = (targetFrame->tree().top() == rootFrame);
}
- IntersectionObservation* observation =
- new IntersectionObservation(*this, *target, shouldReportRootBounds);
+ IntersectionObservation* observation;
+ if (m_observeViewportIntersection) {
+ observation = new ViewportIntersectionObservation(*this, *target);
+ } else {
+ observation =
+ new IntersectionObservation(*this, *target, shouldReportRootBounds);
+ }
target->ensureIntersectionObserverData().addObservation(*observation);
m_observations.add(observation);
« 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