| 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;
|
| +}
|
|
|