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

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

Issue 11415227: Telemtry: hooks "chrome.gpuBenchmarking.smoothScrollBy" with java on android. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Remove inline virtual dtor Created 8 years 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 positionDelta = 10; 29 double position_delta = Tick(
30 if (!last_tick_time_.is_null()) { 30 now, RenderWidgetHostImpl::From(host)->SyntheticScrollMessageInterval());
31 RenderWidgetHostImpl* hostImpl = RenderWidgetHostImpl::From(host);
32 double desiredIntervalMs = hostImpl->SyntheticScrollMessageInterval();
33 double velocity = 10 / desiredIntervalMs;
34 double timeDelta = (now - last_tick_time_).InMillisecondsF();
35 positionDelta = velocity * timeDelta;
36 }
37
38 last_tick_time_ = now;
39 31
40 WebKit::WebMouseWheelEvent event; 32 WebKit::WebMouseWheelEvent event;
41 event.type = WebKit::WebInputEvent::MouseWheel; 33 event.type = WebKit::WebInputEvent::MouseWheel;
42 event.hasPreciseScrollingDeltas = 1; 34 event.hasPreciseScrollingDeltas = 1;
43 event.deltaY = scroll_down_ ? -positionDelta : positionDelta; 35 event.deltaY = scroll_down_ ? -position_delta : position_delta;
44 // TODO(vollick): find a proper way to access 36 // TODO(vollick): find a proper way to access
45 // WebCore::WheelEvent::tickMultiplier. 37 // WebCore::WheelEvent::tickMultiplier.
46 event.wheelTicksY = event.deltaY / 120; 38 event.wheelTicksY = event.deltaY / 120;
47 event.modifiers = 0; 39 event.modifiers = 0;
48 40
49 // TODO(nduca): Figure out plausible x and y values. 41 // TODO(nduca): Figure out plausible x and y values.
50 event.globalX = 0; 42 event.globalX = 0;
51 event.globalY = 0; 43 event.globalY = 0;
52 event.x = mouse_event_x_; 44 event.x = mouse_event_x_;
53 event.y = mouse_event_y_; 45 event.y = mouse_event_y_;
54 event.windowX = event.x; 46 event.windowX = event.x;
55 event.windowY = event.y; 47 event.windowY = event.y;
56 host->ForwardWheelEvent(event); 48 host->ForwardWheelEvent(event);
57 49
58 pixels_scrolled_ += abs(event.deltaY); 50 pixels_scrolled_ += abs(event.deltaY);
59 51
60 TRACE_COUNTER_ID1( 52 TRACE_COUNTER_ID1(
61 "gpu", "smooth_scroll_by_pixels_scrolled", this, pixels_scrolled_); 53 "gpu", "smooth_scroll_by_pixels_scrolled", this, pixels_scrolled_);
62 54
63 return true; 55 return true;
64 } 56 }
65 57
66 } // content 58 } // content
67 59
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698