| OLD | NEW |
| (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 float position_delta = synthetic_gesture_calculator_.GetDelta( | |
| 30 now, | |
| 31 RenderWidgetHostImpl::From(host)->GetSyntheticGestureMessageInterval()); | |
| 32 | |
| 33 | |
| 34 blink::WebMouseWheelEvent event; | |
| 35 event.type = blink::WebInputEvent::MouseWheel; | |
| 36 event.hasPreciseScrollingDeltas = 0; | |
| 37 event.deltaY = scroll_down_ ? -position_delta : position_delta; | |
| 38 // TODO(vollick): find a proper way to access | |
| 39 // WebCore::WheelEvent::tickMultiplier. | |
| 40 event.wheelTicksY = event.deltaY / 120; | |
| 41 event.modifiers = 0; | |
| 42 | |
| 43 // TODO(nduca): Figure out plausible x and y values. | |
| 44 event.globalX = 0; | |
| 45 event.globalY = 0; | |
| 46 event.x = mouse_event_x_; | |
| 47 event.y = mouse_event_y_; | |
| 48 event.windowX = event.x; | |
| 49 event.windowY = event.y; | |
| 50 host->ForwardWheelEvent(event); | |
| 51 | |
| 52 pixels_scrolled_ += abs(event.deltaY); | |
| 53 | |
| 54 TRACE_COUNTER_ID1( | |
| 55 "gpu", "smooth_scroll_by_pixels_scrolled", this, pixels_scrolled_); | |
| 56 | |
| 57 return true; | |
| 58 } | |
| 59 | |
| 60 } // content | |
| 61 | |
| OLD | NEW |