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

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

Issue 1872973002: Add IntersectionObserverEntry.intersectionRatio attribute. (Closed) Base URL: https://chromium.googlesource.com/chromium/src@master
Patch Set: Fix global-interface-listing-expected.txt Created 4 years, 8 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
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 e5761255ebd4a0fbf6be81dce35e92afd8b39022..94f9b6deb579dd1f04684ad394032e1be2ac631c 100644
--- a/third_party/WebKit/Source/core/dom/IntersectionObservation.cpp
+++ b/third_party/WebKit/Source/core/dom/IntersectionObservation.cpp
@@ -198,6 +198,7 @@ void IntersectionObservation::computeIntersectionObservations(DOMHighResTimeStam
// have a coincident edge or corner), we consider the intersection to have
// "crossed" a zero threshold, but not crossed any non-zero threshold.
unsigned newThresholdIndex;
+ float newVisibleRatio = 0;
if (geometry.targetRect.isEmpty()) {
newThresholdIndex = geometry.doesIntersect ? 1 : 0;
} else if (!geometry.doesIntersect) {
@@ -205,7 +206,7 @@ void IntersectionObservation::computeIntersectionObservations(DOMHighResTimeStam
} else {
float intersectionArea = geometry.intersectionRect.size().width().toFloat() * geometry.intersectionRect.size().height().toFloat();
float targetArea = geometry.targetRect.size().width().toFloat() * geometry.targetRect.size().height().toFloat();
- float newVisibleRatio = intersectionArea / targetArea;
+ newVisibleRatio = intersectionArea / targetArea;
newThresholdIndex = observer().firstThresholdGreaterThan(newVisibleRatio);
}
if (m_lastThresholdIndex != newThresholdIndex) {
@@ -213,6 +214,7 @@ void IntersectionObservation::computeIntersectionObservations(DOMHighResTimeStam
IntRect* rootBoundsPointer = m_shouldReportRootBounds ? &snappedRootBounds : nullptr;
IntersectionObserverEntry* newEntry = new IntersectionObserverEntry(
timestamp,
+ newVisibleRatio,
pixelSnappedIntRect(geometry.targetRect),
rootBoundsPointer,
pixelSnappedIntRect(geometry.intersectionRect),

Powered by Google App Engine
This is Rietveld 408576698