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

Unified Diff: content/browser/renderer_host/render_widget_host_impl.cc

Issue 12223110: aura: Populate and use the newly added acceleration ratio fields in wheel-events. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 7 years, 10 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 side-by-side diff with in-line comments
Download patch
Index: content/browser/renderer_host/render_widget_host_impl.cc
diff --git a/content/browser/renderer_host/render_widget_host_impl.cc b/content/browser/renderer_host/render_widget_host_impl.cc
index 543540725d6e35c214fe0ccfdbeb4740422f9a7a..ff96af2e105b448b97ee239b9b3c170011966807 100644
--- a/content/browser/renderer_host/render_widget_host_impl.cc
+++ b/content/browser/renderer_host/render_widget_host_impl.cc
@@ -114,6 +114,16 @@ bool IsLastTouchEvent(const WebKit::WebTouchEvent& touch) {
touch.touches[0].state == WebKit::WebTouchPoint::StateCancelled);
}
+float GetUnacceleratedDelta(float accelerated_delta, float acceleration_ratio) {
+ return accelerated_delta * acceleration_ratio;
+}
+
+float GetAccelerationRatio(float accelerated_delta, float unaccelerated_delta) {
+ if (unaccelerated_delta == 0.f || accelerated_delta == 0.f)
+ return 1.f;
+ return unaccelerated_delta / accelerated_delta;
+}
+
} // namespace
@@ -966,10 +976,24 @@ void RenderWidgetHostImpl::ForwardWheelEvent(
} else {
WebMouseWheelEvent* last_wheel_event =
&coalesced_mouse_wheel_events_.back();
+ float unaccelerated_x =
+ GetUnacceleratedDelta(last_wheel_event->deltaX,
+ last_wheel_event->accelerationRatioX) +
+ GetUnacceleratedDelta(wheel_event.deltaX,
+ wheel_event.accelerationRatioX);
+ float unaccelerated_y =
+ GetUnacceleratedDelta(last_wheel_event->deltaY,
+ last_wheel_event->accelerationRatioY) +
+ GetUnacceleratedDelta(wheel_event.deltaY,
+ wheel_event.accelerationRatioY);
last_wheel_event->deltaX += wheel_event.deltaX;
last_wheel_event->deltaY += wheel_event.deltaY;
last_wheel_event->wheelTicksX += wheel_event.wheelTicksX;
last_wheel_event->wheelTicksY += wheel_event.wheelTicksY;
+ last_wheel_event->accelerationRatioX =
+ GetAccelerationRatio(last_wheel_event->deltaX, unaccelerated_x);
+ last_wheel_event->accelerationRatioY =
+ GetAccelerationRatio(last_wheel_event->deltaY, unaccelerated_y);
DCHECK_GE(wheel_event.timeStampSeconds,
last_wheel_event->timeStampSeconds);
last_wheel_event->timeStampSeconds = wheel_event.timeStampSeconds;
« no previous file with comments | « content/browser/renderer_host/overscroll_controller.cc ('k') | content/browser/renderer_host/web_input_event_aurax11.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698