OLD | NEW |
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 Loading... |
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 if (acceleration_ratio == 0.f) |
| 119 return accelerated_delta; |
| 120 return accelerated_delta / acceleration_ratio; |
| 121 } |
| 122 |
| 123 float GetAccelerationRatio(float accelerated_delta, float unaccelerated_delta) { |
| 124 if (unaccelerated_delta == 0.f || accelerated_delta == 0.f) |
| 125 return 1.f; |
| 126 return accelerated_delta / unaccelerated_delta; |
| 127 } |
| 128 |
117 } // namespace | 129 } // namespace |
118 | 130 |
119 | 131 |
120 // static | 132 // static |
121 void RenderWidgetHost::RemoveAllBackingStores() { | 133 void RenderWidgetHost::RemoveAllBackingStores() { |
122 BackingStoreManager::RemoveAllBackingStores(); | 134 BackingStoreManager::RemoveAllBackingStores(); |
123 } | 135 } |
124 | 136 |
125 // static | 137 // static |
126 size_t RenderWidgetHost::BackingStoreMemorySize() { | 138 size_t RenderWidgetHost::BackingStoreMemorySize() { |
(...skipping 832 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
959 // event, as for mouse moves) results in very slow scrolling on the Mac (on | 971 // event, as for mouse moves) results in very slow scrolling on the Mac (on |
960 // which many, very small wheel events are sent). | 972 // which many, very small wheel events are sent). |
961 if (mouse_wheel_pending_) { | 973 if (mouse_wheel_pending_) { |
962 if (coalesced_mouse_wheel_events_.empty() || | 974 if (coalesced_mouse_wheel_events_.empty() || |
963 !ShouldCoalesceMouseWheelEvents(coalesced_mouse_wheel_events_.back(), | 975 !ShouldCoalesceMouseWheelEvents(coalesced_mouse_wheel_events_.back(), |
964 wheel_event)) { | 976 wheel_event)) { |
965 coalesced_mouse_wheel_events_.push_back(wheel_event); | 977 coalesced_mouse_wheel_events_.push_back(wheel_event); |
966 } else { | 978 } else { |
967 WebMouseWheelEvent* last_wheel_event = | 979 WebMouseWheelEvent* last_wheel_event = |
968 &coalesced_mouse_wheel_events_.back(); | 980 &coalesced_mouse_wheel_events_.back(); |
| 981 float unaccelerated_x = |
| 982 GetUnacceleratedDelta(last_wheel_event->deltaX, |
| 983 last_wheel_event->accelerationRatioX) + |
| 984 GetUnacceleratedDelta(wheel_event.deltaX, |
| 985 wheel_event.accelerationRatioX); |
| 986 float unaccelerated_y = |
| 987 GetUnacceleratedDelta(last_wheel_event->deltaY, |
| 988 last_wheel_event->accelerationRatioY) + |
| 989 GetUnacceleratedDelta(wheel_event.deltaY, |
| 990 wheel_event.accelerationRatioY); |
969 last_wheel_event->deltaX += wheel_event.deltaX; | 991 last_wheel_event->deltaX += wheel_event.deltaX; |
970 last_wheel_event->deltaY += wheel_event.deltaY; | 992 last_wheel_event->deltaY += wheel_event.deltaY; |
971 last_wheel_event->wheelTicksX += wheel_event.wheelTicksX; | 993 last_wheel_event->wheelTicksX += wheel_event.wheelTicksX; |
972 last_wheel_event->wheelTicksY += wheel_event.wheelTicksY; | 994 last_wheel_event->wheelTicksY += wheel_event.wheelTicksY; |
| 995 last_wheel_event->accelerationRatioX = |
| 996 GetAccelerationRatio(last_wheel_event->deltaX, unaccelerated_x); |
| 997 last_wheel_event->accelerationRatioY = |
| 998 GetAccelerationRatio(last_wheel_event->deltaY, unaccelerated_y); |
973 DCHECK_GE(wheel_event.timeStampSeconds, | 999 DCHECK_GE(wheel_event.timeStampSeconds, |
974 last_wheel_event->timeStampSeconds); | 1000 last_wheel_event->timeStampSeconds); |
975 last_wheel_event->timeStampSeconds = wheel_event.timeStampSeconds; | 1001 last_wheel_event->timeStampSeconds = wheel_event.timeStampSeconds; |
976 } | 1002 } |
977 return; | 1003 return; |
978 } | 1004 } |
979 mouse_wheel_pending_ = true; | 1005 mouse_wheel_pending_ = true; |
980 current_wheel_event_ = wheel_event; | 1006 current_wheel_event_ = wheel_event; |
981 | 1007 |
982 HISTOGRAM_COUNTS_100("MPArch.RWH_WheelQueueSize", | 1008 HISTOGRAM_COUNTS_100("MPArch.RWH_WheelQueueSize", |
(...skipping 1421 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2404 return; | 2430 return; |
2405 | 2431 |
2406 OnRenderAutoResized(new_size); | 2432 OnRenderAutoResized(new_size); |
2407 } | 2433 } |
2408 | 2434 |
2409 void RenderWidgetHostImpl::DetachDelegate() { | 2435 void RenderWidgetHostImpl::DetachDelegate() { |
2410 delegate_ = NULL; | 2436 delegate_ = NULL; |
2411 } | 2437 } |
2412 | 2438 |
2413 } // namespace content | 2439 } // namespace content |
OLD | NEW |