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

Side by Side 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 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/render_widget_host_impl.h" 5 #include "content/browser/renderer_host/render_widget_host_impl.h"
6 6
7 #include <math.h> 7 #include <math.h>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/auto_reset.h" 10 #include "base/auto_reset.h"
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
107 touch.touches[0].state == WebKit::WebTouchPoint::StatePressed; 107 touch.touches[0].state == WebKit::WebTouchPoint::StatePressed;
108 } 108 }
109 109
110 bool IsLastTouchEvent(const WebKit::WebTouchEvent& touch) { 110 bool IsLastTouchEvent(const WebKit::WebTouchEvent& touch) {
111 return touch.touchesLength == 1 && 111 return touch.touchesLength == 1 &&
112 touch.type == WebInputEvent::TouchEnd && 112 touch.type == WebInputEvent::TouchEnd &&
113 (touch.touches[0].state == WebKit::WebTouchPoint::StateReleased || 113 (touch.touches[0].state == WebKit::WebTouchPoint::StateReleased ||
114 touch.touches[0].state == WebKit::WebTouchPoint::StateCancelled); 114 touch.touches[0].state == WebKit::WebTouchPoint::StateCancelled);
115 } 115 }
116 116
117 float GetUnacceleratedDelta(float accelerated_delta, float acceleration_ratio) {
118 return accelerated_delta * acceleration_ratio;
119 }
120
121 float GetAccelerationRatio(float accelerated_delta, float unaccelerated_delta) {
122 if (unaccelerated_delta == 0.f || accelerated_delta == 0.f)
123 return 1.f;
124 return unaccelerated_delta / accelerated_delta;
125 }
126
117 } // namespace 127 } // namespace
118 128
119 129
120 // static 130 // static
121 void RenderWidgetHost::RemoveAllBackingStores() { 131 void RenderWidgetHost::RemoveAllBackingStores() {
122 BackingStoreManager::RemoveAllBackingStores(); 132 BackingStoreManager::RemoveAllBackingStores();
123 } 133 }
124 134
125 // static 135 // static
126 size_t RenderWidgetHost::BackingStoreMemorySize() { 136 size_t RenderWidgetHost::BackingStoreMemorySize() {
(...skipping 832 matching lines...) Expand 10 before | Expand all | Expand 10 after
959 // event, as for mouse moves) results in very slow scrolling on the Mac (on 969 // event, as for mouse moves) results in very slow scrolling on the Mac (on
960 // which many, very small wheel events are sent). 970 // which many, very small wheel events are sent).
961 if (mouse_wheel_pending_) { 971 if (mouse_wheel_pending_) {
962 if (coalesced_mouse_wheel_events_.empty() || 972 if (coalesced_mouse_wheel_events_.empty() ||
963 !ShouldCoalesceMouseWheelEvents(coalesced_mouse_wheel_events_.back(), 973 !ShouldCoalesceMouseWheelEvents(coalesced_mouse_wheel_events_.back(),
964 wheel_event)) { 974 wheel_event)) {
965 coalesced_mouse_wheel_events_.push_back(wheel_event); 975 coalesced_mouse_wheel_events_.push_back(wheel_event);
966 } else { 976 } else {
967 WebMouseWheelEvent* last_wheel_event = 977 WebMouseWheelEvent* last_wheel_event =
968 &coalesced_mouse_wheel_events_.back(); 978 &coalesced_mouse_wheel_events_.back();
979 float unaccelerated_x =
980 GetUnacceleratedDelta(last_wheel_event->deltaX,
981 last_wheel_event->accelerationRatioX) +
982 GetUnacceleratedDelta(wheel_event.deltaX,
983 wheel_event.accelerationRatioX);
984 float unaccelerated_y =
985 GetUnacceleratedDelta(last_wheel_event->deltaY,
986 last_wheel_event->accelerationRatioY) +
987 GetUnacceleratedDelta(wheel_event.deltaY,
988 wheel_event.accelerationRatioY);
969 last_wheel_event->deltaX += wheel_event.deltaX; 989 last_wheel_event->deltaX += wheel_event.deltaX;
970 last_wheel_event->deltaY += wheel_event.deltaY; 990 last_wheel_event->deltaY += wheel_event.deltaY;
971 last_wheel_event->wheelTicksX += wheel_event.wheelTicksX; 991 last_wheel_event->wheelTicksX += wheel_event.wheelTicksX;
972 last_wheel_event->wheelTicksY += wheel_event.wheelTicksY; 992 last_wheel_event->wheelTicksY += wheel_event.wheelTicksY;
993 last_wheel_event->accelerationRatioX =
994 GetAccelerationRatio(last_wheel_event->deltaX, unaccelerated_x);
995 last_wheel_event->accelerationRatioY =
996 GetAccelerationRatio(last_wheel_event->deltaY, unaccelerated_y);
973 DCHECK_GE(wheel_event.timeStampSeconds, 997 DCHECK_GE(wheel_event.timeStampSeconds,
974 last_wheel_event->timeStampSeconds); 998 last_wheel_event->timeStampSeconds);
975 last_wheel_event->timeStampSeconds = wheel_event.timeStampSeconds; 999 last_wheel_event->timeStampSeconds = wheel_event.timeStampSeconds;
976 } 1000 }
977 return; 1001 return;
978 } 1002 }
979 mouse_wheel_pending_ = true; 1003 mouse_wheel_pending_ = true;
980 current_wheel_event_ = wheel_event; 1004 current_wheel_event_ = wheel_event;
981 1005
982 HISTOGRAM_COUNTS_100("MPArch.RWH_WheelQueueSize", 1006 HISTOGRAM_COUNTS_100("MPArch.RWH_WheelQueueSize",
(...skipping 1421 matching lines...) Expand 10 before | Expand all | Expand 10 after
2404 return; 2428 return;
2405 2429
2406 OnRenderAutoResized(new_size); 2430 OnRenderAutoResized(new_size);
2407 } 2431 }
2408 2432
2409 void RenderWidgetHostImpl::DetachDelegate() { 2433 void RenderWidgetHostImpl::DetachDelegate() {
2410 delegate_ = NULL; 2434 delegate_ = NULL;
2411 } 2435 }
2412 2436
2413 } // namespace content 2437 } // namespace content
OLDNEW
« 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