diff options
author | dominikg@chromium.org <dominikg@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-10-15 21:33:08 +0000 |
---|---|---|
committer | dominikg@chromium.org <dominikg@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-10-15 21:33:08 +0000 |
commit | 67b194950b1197c0ca2d8626b3f3e0db65bcabfa (patch) | |
tree | bb6744d10099ae9e08e8b0e84a40341ad51d7eb4 /tools | |
parent | 802899181271df799926644a1bd7c0ff4fe9dae9 (diff) | |
download | chromium_src-67b194950b1197c0ca2d8626b3f3e0db65bcabfa.zip chromium_src-67b194950b1197c0ca2d8626b3f3e0db65bcabfa.tar.gz chromium_src-67b194950b1197c0ca2d8626b3f3e0db65bcabfa.tar.bz2 |
Telemetry: Remove rAF-based fallback for scroll action.
The smoothness measurement, which is the only one using the scroll action, is
only used for Chrome. Chrome always provides some synthetic scrolling support,
so we don't need the fallback option any more.
This patch also checks if synthetic gestures (currently scroll and pinch) are supported by the browser and raises an error if that's not the case.
BUG=305347
Review URL: https://codereview.chromium.org/26877002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@228766 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'tools')
-rw-r--r-- | tools/telemetry/telemetry/page/actions/pinch.js | 33 | ||||
-rw-r--r-- | tools/telemetry/telemetry/page/actions/pinch.py | 4 | ||||
-rw-r--r-- | tools/telemetry/telemetry/page/actions/scroll.js | 31 | ||||
-rw-r--r-- | tools/telemetry/telemetry/page/actions/scroll.py | 5 |
4 files changed, 41 insertions, 32 deletions
diff --git a/tools/telemetry/telemetry/page/actions/pinch.js b/tools/telemetry/telemetry/page/actions/pinch.js index df0dc73..f0dccdb 100644 --- a/tools/telemetry/telemetry/page/actions/pinch.js +++ b/tools/telemetry/telemetry/page/actions/pinch.js @@ -10,6 +10,12 @@ (function() { + function supportedByBrowser() { + return !!(window.chrome && + chrome.gpuBenchmarking && + chrome.gpuBenchmarking.pinchBy); + } + /** * Performs a single vertical pinch gesture to zoom in or out, anchored * in the center of the window. @@ -22,22 +28,16 @@ PinchGesture.prototype.start = function(pixels_to_move, callback) { this.callback_ = callback; - if (window.chrome && - chrome.gpuBenchmarking && - chrome.gpuBenchmarking.pinchBy) { - - // The anchor point of the gesture is the center of the window. - // Use 'outerWidth/Height' (in DIPs) instead of 'innerWidth/Height' - // (in CSS pixels) because they are independent of the zoom factor. - var anchor_x = window.outerWidth / 2; - var anchor_y = window.outerHeight / 2; - - chrome.gpuBenchmarking.pinchBy(this.zoom_in_, pixels_to_move, - anchor_x, anchor_y, - function() { callback(); }); - return; - } - callback(); + + // The anchor point of the gesture is the center of the window. + // Use 'outerWidth/Height' (in DIPs) instead of 'innerWidth/Height' + // (in CSS pixels) because they are independent of the zoom factor. + var anchor_x = window.outerWidth / 2; + var anchor_y = window.outerHeight / 2; + + chrome.gpuBenchmarking.pinchBy(this.zoom_in_, pixels_to_move, + anchor_x, anchor_y, + function() { callback(); }); }; // This class zooms into or out of a page, given a number of pixels for @@ -78,4 +78,5 @@ }; window.__PinchAction = PinchAction; + window.__PinchAction_SupportedByBrowser = supportedByBrowser; })(); diff --git a/tools/telemetry/telemetry/page/actions/pinch.py b/tools/telemetry/telemetry/page/actions/pinch.py index 532717b..ff67594 100644 --- a/tools/telemetry/telemetry/page/actions/pinch.py +++ b/tools/telemetry/telemetry/page/actions/pinch.py @@ -16,6 +16,10 @@ class PinchAction(page_action.PageAction): js = f.read() tab.ExecuteJavaScript(js) + # Fail if browser doesn't support synthetic pinch gestures. + if not tab.EvaluateJavaScript('window.__PinchAction_SupportedByBrowser()'): + raise page_action.PageActionNotSupported( + 'Synthetic pinch not supported for this browser') done_callback = 'function() { window.__pinchActionDone = true; }' tab.ExecuteJavaScript(""" diff --git a/tools/telemetry/telemetry/page/actions/scroll.js b/tools/telemetry/telemetry/page/actions/scroll.js index 498b60f..2addddf 100644 --- a/tools/telemetry/telemetry/page/actions/scroll.js +++ b/tools/telemetry/telemetry/page/actions/scroll.js @@ -23,6 +23,12 @@ } } + function supportedByBrowser() { + return !!(window.chrome && + chrome.gpuBenchmarking && + chrome.gpuBenchmarking.smoothScrollBy); + } + /** * Scrolls a given element down a certain amount to emulate user scroll. * Uses smooth scroll capabilities provided by the platform, if available. @@ -59,23 +65,15 @@ SmoothScrollDownGesture.prototype.start = function(distance, callback) { this.callback_ = callback; - if (window.chrome && - chrome.gpuBenchmarking && - chrome.gpuBenchmarking.smoothScrollBy) { - var rect = getBoundingVisibleRect(this.options_.element_); - var start_left = - rect.left + rect.width * this.options_.left_start_percentage_; - var start_top = - rect.top + rect.height * this.options_.top_start_percentage_; - chrome.gpuBenchmarking.smoothScrollBy(distance, function() { - callback(); - }, start_left, start_top); - return; - } - var SCROLL_DELTA = 100; - this.options_.element_.scrollTop += SCROLL_DELTA; - requestAnimationFrame(callback); + var rect = getBoundingVisibleRect(this.options_.element_); + var start_left = + rect.left + rect.width * this.options_.left_start_percentage_; + var start_top = + rect.top + rect.height * this.options_.top_start_percentage_; + chrome.gpuBenchmarking.smoothScrollBy(distance, function() { + callback(); + }, start_left, start_top); }; // This class scrolls a page from the top to the bottom once. @@ -142,4 +140,5 @@ window.__ScrollAction = ScrollAction; window.__ScrollAction_GetBoundingVisibleRect = getBoundingVisibleRect; + window.__ScrollAction_SupportedByBrowser = supportedByBrowser; })(); diff --git a/tools/telemetry/telemetry/page/actions/scroll.py b/tools/telemetry/telemetry/page/actions/scroll.py index db795bb..8c9e105 100644 --- a/tools/telemetry/telemetry/page/actions/scroll.py +++ b/tools/telemetry/telemetry/page/actions/scroll.py @@ -16,6 +16,11 @@ class ScrollAction(page_action.PageAction): js = f.read() tab.ExecuteJavaScript(js) + # Fail if browser doesn't support synthetic scroll gestures. + if not tab.EvaluateJavaScript('window.__ScrollAction_SupportedByBrowser()'): + raise page_action.PageActionNotSupported( + 'Synthetic scroll not supported for this browser') + # Fail if this action requires touch and we can't send touch events. if (hasattr(self, 'scroll_requires_touch') and self.scroll_requires_touch and not |