summaryrefslogtreecommitdiffstats
path: root/tools/perf
diff options
context:
space:
mode:
authorhartmanng@chromium.org <hartmanng@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-10-09 14:44:29 +0000
committerhartmanng@chromium.org <hartmanng@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-10-09 14:44:29 +0000
commitebd8b5647ee0db5a3a7fae6447c28aa0d8cb148b (patch)
tree9513534921227e260f3d270c82566e82c40a5d44 /tools/perf
parentf3eb6aea8ae82cb90b1cd10fcb0ef46ae36415c1 (diff)
downloadchromium_src-ebd8b5647ee0db5a3a7fae6447c28aa0d8cb148b.zip
chromium_src-ebd8b5647ee0db5a3a7fae6447c28aa0d8cb148b.tar.gz
chromium_src-ebd8b5647ee0db5a3a7fae6447c28aa0d8cb148b.tar.bz2
Dynamically set mouse event coordinates in gpu_benchmarking_extension.cc based
on the bounding rect of the scrollable element. BUG=152469 Review URL: https://chromiumcodereview.appspot.com/11053014 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@160842 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'tools/perf')
-rw-r--r--tools/perf/perf_tools/scroll.js46
1 files changed, 41 insertions, 5 deletions
diff --git a/tools/perf/perf_tools/scroll.js b/tools/perf/perf_tools/scroll.js
index 48c6e0e..6863cee 100644
--- a/tools/perf/perf_tools/scroll.js
+++ b/tools/perf/perf_tools/scroll.js
@@ -43,21 +43,57 @@
this.element_ = opt_element || document.body;
};
+ function min(a, b) {
+ if (a > b) {
+ return b;
+ }
+ return a;
+ };
+
+ function getBoundingVisibleRect(el) {
+ r = el.getBoundingClientRect();
+ cur = el;
+ while (cur && cur.parentElement) {
+ r.top += cur.parentElement.offsetTop;
+ r.left += cur.parentElement.offsetLeft;
+ r.height = min(r.height, cur.parentElement.offsetHeight);
+ r.width = min(r.width, cur.parentElement.offsetWidth);
+ cur = cur.parentElement;
+ }
+ return r;
+ };
+
+ function rectsDoIntersect(r1, r2) {
+ return (r1.right >= r2.left &&
+ r1.left <= r2.right &&
+ r1.bottom >= r2.top &&
+ r1.top <= r2.bottom);
+ };
+
SmoothScrollDownGesture.prototype.start = function(callback) {
this.callback_ = callback;
if (chrome &&
chrome.gpuBenchmarking &&
chrome.gpuBenchmarking.beginSmoothScrollDown) {
- chrome.gpuBenchmarking.beginSmoothScrollDown(true, function() {
- callback();
- });
- return;
+ rect = getBoundingVisibleRect(this.element_);
+ if (chrome.gpuBenchmarking.beginSmoothScrollSupportsPositioning ||
+ rectsDoIntersect(rect, {left: 0,
+ top: 0,
+ right: 1,
+ bottom: 1,
+ height: 1,
+ width: 1})) {
+ chrome.gpuBenchmarking.beginSmoothScrollDown(true, function() {
+ callback();
+ }, rect.left + rect.width / 2, rect.top + rect.height / 2);
+ return;
+ }
}
var SCROLL_DELTA = 100;
this.element_.scrollTop += SCROLL_DELTA;
requestAnimationFrame(callback);
- }
+ };
/**
* Tracks rendering performance using the gpuBenchmarking.renderingStats API.