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

Unified Diff: third_party/WebKit/LayoutTests/intersection-observer/helper-functions.js

Issue 1879323003: Add IntersectionObserverEntry.intersectionRatio attribute. (Closed) Base URL: https://chromium.googlesource.com/chromium/src@2704
Patch Set: 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
« no previous file with comments | « no previous file | third_party/WebKit/LayoutTests/intersection-observer/multiple-thresholds.html » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/LayoutTests/intersection-observer/helper-functions.js
diff --git a/third_party/WebKit/LayoutTests/intersection-observer/helper-functions.js b/third_party/WebKit/LayoutTests/intersection-observer/helper-functions.js
index 2aa6ecce92f07bd78915da93bb56ae948c3b19a3..7e2612d49f5806c2244c5d96c295b16c54ef6a02 100644
--- a/third_party/WebKit/LayoutTests/intersection-observer/helper-functions.js
+++ b/third_party/WebKit/LayoutTests/intersection-observer/helper-functions.js
@@ -4,6 +4,10 @@
setPrintTestResultsLazily();
self.jsTestIsAsync = true;
+function rectArea(rect) {
+ return (rect.left - rect.right) * (rect.bottom - rect.top);
+}
+
function rectToString(rect) {
return "[" + rect.left + ", " + rect.right + ", " + rect.top + ", " + rect.bottom + "]";
}
@@ -19,3 +23,10 @@ function entryToString(entry) {
"target=" + entry.target + "\n" +
"time=" + entry.time);
}
+
+function intersectionRatio(entry) {
+ var targetArea = rectArea(entry.boundingClientRect);
+ if (!targetArea)
+ return 0;
+ return rectArea(entry.intersectionRect) / targetArea;
+}
« no previous file with comments | « no previous file | third_party/WebKit/LayoutTests/intersection-observer/multiple-thresholds.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698