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

Side by Side Diff: tools/telemetry/telemetry/page/actions/scroll.js

Issue 62443007: Replace old with new synthetic gesture framework. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: opt_mouse_move_event_x/y -> opt_start_x/y Created 7 years, 1 month 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 unified diff | Download patch
« no previous file with comments | « content/renderer/render_widget.cc ('k') | tools/telemetry/telemetry/page/actions/scroll.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // This file provides the ScrollAction object, which scrolls a page 5 // This file provides the ScrollAction object, which scrolls a page
6 // from top to bottom: 6 // from top to bottom:
7 // 1. var action = new __ScrollAction(callback) 7 // 1. var action = new __ScrollAction(callback)
8 // 2. action.start(scroll_options) 8 // 2. action.start(scroll_options)
9 'use strict'; 9 'use strict';
10 10
11 (function() { 11 (function() {
12 var MAX_SCROLL_LENGTH_PIXELS = 5000; 12 var MAX_SCROLL_LENGTH_PIXELS = 5000;
13 13
14 function ScrollGestureOptions(opt_options) { 14 function ScrollGestureOptions(opt_options) {
15 if (opt_options) { 15 if (opt_options) {
16 this.element_ = opt_options.element; 16 this.element_ = opt_options.element;
17 this.left_start_percentage_ = opt_options.left_start_percentage; 17 this.left_start_percentage_ = opt_options.left_start_percentage;
18 this.top_start_percentage_ = opt_options.top_start_percentage; 18 this.top_start_percentage_ = opt_options.top_start_percentage;
19 this.gesture_source_type = opt_options.gesture_source_type;
19 } else { 20 } else {
20 this.element_ = document.body; 21 this.element_ = document.body;
21 this.left_start_percentage_ = 0.5; 22 this.left_start_percentage_ = 0.5;
22 this.top_start_percentage_ = 0.5; 23 this.top_start_percentage_ = 0.5;
24 this.gesture_source_type = chrome.gpuBenchmarking.DEFAULT_INPUT;
23 } 25 }
24 } 26 }
25 27
26 function supportedByBrowser() { 28 function supportedByBrowser() {
27 return !!(window.chrome && 29 return !!(window.chrome &&
28 chrome.gpuBenchmarking && 30 chrome.gpuBenchmarking &&
29 chrome.gpuBenchmarking.smoothScrollBy); 31 chrome.gpuBenchmarking.smoothScrollBy);
30 } 32 }
31 33
32 /** 34 /**
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
66 SmoothScrollDownGesture.prototype.start = function(distance, callback) { 68 SmoothScrollDownGesture.prototype.start = function(distance, callback) {
67 this.callback_ = callback; 69 this.callback_ = callback;
68 70
69 var rect = getBoundingVisibleRect(this.options_.element_); 71 var rect = getBoundingVisibleRect(this.options_.element_);
70 var start_left = 72 var start_left =
71 rect.left + rect.width * this.options_.left_start_percentage_; 73 rect.left + rect.width * this.options_.left_start_percentage_;
72 var start_top = 74 var start_top =
73 rect.top + rect.height * this.options_.top_start_percentage_; 75 rect.top + rect.height * this.options_.top_start_percentage_;
74 chrome.gpuBenchmarking.smoothScrollBy(distance, function() { 76 chrome.gpuBenchmarking.smoothScrollBy(distance, function() {
75 callback(); 77 callback();
76 }, start_left, start_top); 78 }, start_left, start_top, this.options_.gesture_source_type);
77 }; 79 };
78 80
79 // This class scrolls a page from the top to the bottom once. 81 // This class scrolls a page from the top to the bottom once.
80 // 82 //
81 // The page is scrolled down by a single scroll gesture. 83 // The page is scrolled down by a single scroll gesture.
82 function ScrollAction(opt_callback, opt_remaining_distance_func) { 84 function ScrollAction(opt_callback, opt_remaining_distance_func) {
83 var self = this; 85 var self = this;
84 86
85 this.beginMeasuringHook = function() {} 87 this.beginMeasuringHook = function() {}
86 this.endMeasuringHook = function() {} 88 this.endMeasuringHook = function() {}
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
131 133
132 // We're done. 134 // We're done.
133 if (this.callback_) 135 if (this.callback_)
134 this.callback_(); 136 this.callback_();
135 }; 137 };
136 138
137 window.__ScrollAction = ScrollAction; 139 window.__ScrollAction = ScrollAction;
138 window.__ScrollAction_GetBoundingVisibleRect = getBoundingVisibleRect; 140 window.__ScrollAction_GetBoundingVisibleRect = getBoundingVisibleRect;
139 window.__ScrollAction_SupportedByBrowser = supportedByBrowser; 141 window.__ScrollAction_SupportedByBrowser = supportedByBrowser;
140 })(); 142 })();
OLDNEW
« no previous file with comments | « content/renderer/render_widget.cc ('k') | tools/telemetry/telemetry/page/actions/scroll.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698