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

Side by Side Diff: content/browser/renderer_host/basic_mouse_wheel_smooth_scroll_gesture.cc

Issue 11793003: Relands: Telemetry: hooks "chrome.gpuBenchmarking.smoothScrollBy" with java on android. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: nits Created 7 years, 7 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 unified diff | Download patch | Annotate | Revision Log
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 #include "content/browser/renderer_host/basic_mouse_wheel_smooth_scroll_gesture. h" 5 #include "content/browser/renderer_host/basic_mouse_wheel_smooth_scroll_gesture. h"
6 6
7 #include "base/debug/trace_event.h" 7 #include "base/debug/trace_event.h"
8 #include "content/browser/renderer_host/render_widget_host_impl.h" 8 #include "content/browser/renderer_host/render_widget_host_impl.h"
9 9
10 namespace content { 10 namespace content {
11 11
12 BasicMouseWheelSmoothScrollGesture::BasicMouseWheelSmoothScrollGesture( 12 BasicMouseWheelSmoothScrollGesture::BasicMouseWheelSmoothScrollGesture(
13 bool scroll_down, int pixels_to_scroll, 13 bool scroll_down, int pixels_to_scroll,
14 int mouse_event_x, int mouse_event_y) 14 int mouse_event_x, int mouse_event_y)
15 : scroll_down_(scroll_down), 15 : scroll_down_(scroll_down),
16 pixels_scrolled_(0), 16 pixels_scrolled_(0),
17 pixels_to_scroll_(pixels_to_scroll), 17 pixels_to_scroll_(pixels_to_scroll),
18 mouse_event_x_(mouse_event_x), 18 mouse_event_x_(mouse_event_x),
19 mouse_event_y_(mouse_event_y) { } 19 mouse_event_y_(mouse_event_y) { }
20 20
21 BasicMouseWheelSmoothScrollGesture::~BasicMouseWheelSmoothScrollGesture() { } 21 BasicMouseWheelSmoothScrollGesture::~BasicMouseWheelSmoothScrollGesture() { }
22 22
23 bool BasicMouseWheelSmoothScrollGesture::ForwardInputEvents( 23 bool BasicMouseWheelSmoothScrollGesture::ForwardInputEvents(
24 base::TimeTicks now, RenderWidgetHost* host) { 24 base::TimeTicks now, RenderWidgetHost* host) {
25 25
26 if (pixels_scrolled_ >= pixels_to_scroll_) 26 if (pixels_scrolled_ >= pixels_to_scroll_)
27 return false; 27 return false;
28 28
29 double position_delta = 10; 29 double position_delta = smooth_scroll_calculator_.GetScrollDelta(
30 if (!last_tick_time_.is_null()) { 30 now,
31 RenderWidgetHostImpl* rwhi = RenderWidgetHostImpl::From(host); 31 RenderWidgetHostImpl::From(host)->GetSyntheticScrollMessageInterval());
32 base::TimeDelta desired_interval =
33 rwhi->GetSyntheticScrollMessageInterval();
34 double velocity = 10 / desired_interval.InMillisecondsF();
35 double time_delta = (now - last_tick_time_).InMillisecondsF();
36 position_delta = velocity * time_delta;
37 }
38 32
39 last_tick_time_ = now;
40 33
41 WebKit::WebMouseWheelEvent event; 34 WebKit::WebMouseWheelEvent event;
42 event.type = WebKit::WebInputEvent::MouseWheel; 35 event.type = WebKit::WebInputEvent::MouseWheel;
43 event.hasPreciseScrollingDeltas = 0; 36 event.hasPreciseScrollingDeltas = 0;
44 event.deltaY = scroll_down_ ? -position_delta : position_delta; 37 event.deltaY = scroll_down_ ? -position_delta : position_delta;
45 // TODO(vollick): find a proper way to access 38 // TODO(vollick): find a proper way to access
46 // WebCore::WheelEvent::tickMultiplier. 39 // WebCore::WheelEvent::tickMultiplier.
47 event.wheelTicksY = event.deltaY / 120; 40 event.wheelTicksY = event.deltaY / 120;
48 event.modifiers = 0; 41 event.modifiers = 0;
49 42
50 // TODO(nduca): Figure out plausible x and y values. 43 // TODO(nduca): Figure out plausible x and y values.
51 event.globalX = 0; 44 event.globalX = 0;
52 event.globalY = 0; 45 event.globalY = 0;
53 event.x = mouse_event_x_; 46 event.x = mouse_event_x_;
54 event.y = mouse_event_y_; 47 event.y = mouse_event_y_;
55 event.windowX = event.x; 48 event.windowX = event.x;
56 event.windowY = event.y; 49 event.windowY = event.y;
57 host->ForwardWheelEvent(event); 50 host->ForwardWheelEvent(event);
58 51
59 pixels_scrolled_ += abs(event.deltaY); 52 pixels_scrolled_ += abs(event.deltaY);
60 53
61 TRACE_COUNTER_ID1( 54 TRACE_COUNTER_ID1(
62 "gpu", "smooth_scroll_by_pixels_scrolled", this, pixels_scrolled_); 55 "gpu", "smooth_scroll_by_pixels_scrolled", this, pixels_scrolled_);
63 56
64 return true; 57 return true;
65 } 58 }
66 59
67 } // content 60 } // content
68 61
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698