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

Unified Diff: dashboard/ui/endure_js/dom_utils.js

Issue 12094074: Support Chrome Endure graphs in perf dashboard. (Closed) Base URL: https://git.chromium.org/git/chromium/tools/perf.git@master
Patch Set: updated Created 7 years, 11 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: dashboard/ui/endure_js/dom_utils.js
diff --git a/dashboard/ui/endure_js/dom_utils.js b/dashboard/ui/endure_js/dom_utils.js
new file mode 100644
index 0000000000000000000000000000000000000000..09158c38a9f2c47e58446a8a84fabd2c31e7aa9f
--- /dev/null
+++ b/dashboard/ui/endure_js/dom_utils.js
@@ -0,0 +1,43 @@
+/*
+ Copyright (c) 2012 The Chromium Authors. All rights reserved.
+ Use of this source code is governed by a BSD-style license that can be
+ found in the LICENSE file.
+*/
+
+/**
+ * @fileoverview Collection of functions which operate on DOM.
+ */
+
+var domUtils = window['domUtils'] || {};
+
+/**
+ * Returns pageX and pageY of the given element.
+ *
+ * @param {Element} element An element of which the top-left position is to be
+ * returned in the coordinate system of the document page.
+ * @return {Object} A point object which has {@code x} and {@code y} fields.
+ */
+domUtils.pageXY = function(element) {
+ var x = 0, y = 0;
+ for (; element; element = element.offsetParent) {
+ x += element.offsetLeft;
+ y += element.offsetTop;
+ }
+ return {'x': x, 'y': y};
+};
+
+/**
+ * Returns pageX and pageY of the given event.
+ *
+ * @param {Event} event An event of which the position is to be returned in
+ * the coordinate system of the document page.
+ * @return {Object} A point object which has {@code x} and {@code y} fields.
+ */
+domUtils.pageXYOfEvent = function(event) {
+ return (event.pageX != null && event.pageY != null) ?
+ {'x': event.pageX, 'y': event.pageY} :
+ {'x': event.clientX + document.body.scrollLeft +
+ document.documentElement.scrollLeft,
+ 'y': event.clientY + document.body.scrollTop +
+ document.documentElement.scrollTop};
+};

Powered by Google App Engine
This is Rietveld 408576698