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 11416283: Attempt to linearize the scroll deltas created in RenderWidgetHostViewBase (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . 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
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "content/browser/renderer_host/basic_mouse_wheel_smooth_scroll_gesture. h"
6
7 #include "base/debug/trace_event.h"
8 #include "content/browser/renderer_host/render_widget_host_impl.h"
9
10 namespace content {
11
12 BasicMouseWheelSmoothScrollGesture::BasicMouseWheelSmoothScrollGesture(
13 bool scroll_down, int pixels_to_scroll,
14 int mouse_event_x, int mouse_event_y)
15 : scroll_down_(scroll_down),
16 pixels_scrolled_(0),
17 pixels_to_scroll_(pixels_to_scroll),
18 mouse_event_x_(mouse_event_x),
19 mouse_event_y_(mouse_event_y) { }
20
21 BasicMouseWheelSmoothScrollGesture::~BasicMouseWheelSmoothScrollGesture() { }
22
23 bool BasicMouseWheelSmoothScrollGesture::ForwardInputEvents(
24 base::TimeTicks now, RenderWidgetHost* host) {
25
26 if (pixels_scrolled_ >= pixels_to_scroll_)
27 return false;
28
29 double positionDelta = 10;
30 if (!last_tick_time_.is_null()) {
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
40 WebKit::WebMouseWheelEvent event;
41 event.type = WebKit::WebInputEvent::MouseWheel;
42 event.hasPreciseScrollingDeltas = 1;
43 event.deltaY = scroll_down_ ? -positionDelta : positionDelta;
44 // TODO(vollick): find a proper way to access
45 // WebCore::WheelEvent::tickMultiplier.
46 event.wheelTicksY = event.deltaY / 120;
47 event.modifiers = 0;
48
49 // TODO(nduca): Figure out plausible x and y values.
50 event.globalX = 0;
51 event.globalY = 0;
52 event.x = mouse_event_x_;
53 event.y = mouse_event_y_;
54 event.windowX = event.x;
55 event.windowY = event.y;
56 host->ForwardWheelEvent(event);
57
58 pixels_scrolled_ += abs(event.deltaY);
59
60 TRACE_COUNTER_ID1(
61 "gpu", "smooth_scroll_by_pixels_scrolled", this, pixels_scrolled_);
62
63 return true;
64 }
65
66 } // content
67
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698