Index: third_party/WebKit/LayoutTests/http/tests/intersection-observer/resources/helper-functions.js |
diff --git a/third_party/WebKit/LayoutTests/http/tests/intersection-observer/resources/helper-functions.js b/third_party/WebKit/LayoutTests/http/tests/intersection-observer/resources/helper-functions.js |
new file mode 100644 |
index 0000000000000000000000000000000000000000..733a01dd0ba88ed341427f93a1a8760a3384ab83 |
--- /dev/null |
+++ b/third_party/WebKit/LayoutTests/http/tests/intersection-observer/resources/helper-functions.js |
@@ -0,0 +1,33 @@ |
+function clientRectToJson(rect) { |
+ if (!rect) |
+ return null; |
+ return { |
+ top: rect.top, |
+ right: rect.right, |
+ bottom: rect.bottom, |
+ left: rect.left, |
+ width: rect.width, |
+ height: rect.height |
+ }; |
+} |
+ |
+function coordinatesToClientRectJson(top, right, bottom, left) { |
+ return { |
+ top: top, |
+ right: right, |
+ bottom: bottom, |
+ left: left, |
+ width: right - left, |
+ height: bottom - top |
+ }; |
+} |
+ |
+function entryToJson(entry) { |
+ return { |
+ boundingClientRect: clientRectToJson(entry.boundingClientRect), |
+ intersectionRect: clientRectToJson(entry.intersectionRect), |
+ rootBounds: clientRectToJson(entry.rootBounds), |
+ time: entry.time, |
+ target: entry.target.id |
+ }; |
+} |