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

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

Issue 2475643004: Monitor the intersection of video and viewport. (Closed)
Patch Set: Consolidate two ElementVisibilityObserver in AUtoplayUmaHelper. 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/IntersectionObservation.cpp
diff --git a/third_party/WebKit/Source/core/dom/IntersectionObservation.cpp b/third_party/WebKit/Source/core/dom/IntersectionObservation.cpp
index c9c04457e5ea67c7f176de9f8542466870e0c392..cc44fa1532293b4640b71dacf076addaf603df25 100644
--- a/third_party/WebKit/Source/core/dom/IntersectionObservation.cpp
+++ b/third_party/WebKit/Source/core/dom/IntersectionObservation.cpp
@@ -19,7 +19,7 @@ IntersectionObservation::IntersectionObservation(IntersectionObserver& observer,
bool shouldReportRootBounds)
miu 2016/11/05 02:47:46 Did you intend to remove the 3rd argument to this
xjz 2016/11/09 02:24:28 Now keep this argument for original purpose.
: m_observer(observer),
m_target(&target),
- m_shouldReportRootBounds(shouldReportRootBounds),
+ m_shouldReportRootBounds(true),
m_lastThresholdIndex(0) {}
void IntersectionObservation::applyRootMargin(LayoutRect& rect) const {
@@ -220,9 +220,9 @@ void IntersectionObservation::computeIntersectionObservations(
float intersectionArea =
geometry.intersectionRect.size().width().toFloat() *
geometry.intersectionRect.size().height().toFloat();
- float targetArea = geometry.targetRect.size().width().toFloat() *
- geometry.targetRect.size().height().toFloat();
- newVisibleRatio = intersectionArea / targetArea;
+ float rootArea = geometry.rootRect.size().width().toFloat() *
+ geometry.rootRect.size().height().toFloat();
+ newVisibleRatio = intersectionArea / rootArea;
newThresholdIndex = observer().firstThresholdGreaterThan(newVisibleRatio);
}
if (m_lastThresholdIndex != newThresholdIndex) {

Powered by Google App Engine
This is Rietveld 408576698