Chromium Code Reviews| 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 3b93544dbc9bd8efccc9bd2e4549160fc561c4dd..8252a5a30215fcbab7c5ba43d401aa2d49b8e1d7 100644 |
| --- a/content/browser/renderer_host/render_widget_host_impl.cc |
| +++ b/content/browser/renderer_host/render_widget_host_impl.cc |
| @@ -102,6 +102,7 @@ bool ShouldCoalesceGestureEvents(const WebKit::WebGestureEvent& last_event, |
| } // namespace |
| + |
| // static |
| void RenderWidgetHost::RemoveAllBackingStores() { |
| BackingStoreManager::RemoveAllBackingStores(); |
| @@ -150,7 +151,8 @@ RenderWidgetHostImpl::RenderWidgetHostImpl(RenderWidgetHostDelegate* delegate, |
| allow_privileged_mouse_lock_(false), |
| has_touch_handler_(false), |
| ALLOW_THIS_IN_INITIALIZER_LIST(weak_factory_(this)), |
| - tap_suppression_controller_(new TapSuppressionController(this)) { |
| + tap_suppression_controller_(new TapSuppressionController(this)), |
| + fling_in_progress_(false) { |
| CHECK(delegate_); |
| if (routing_id_ == MSG_ROUTING_NONE) { |
| routing_id_ = process_->GetNextRoutingID(); |
| @@ -490,6 +492,7 @@ void RenderWidgetHostImpl::ViewDestroyed() { |
| void RenderWidgetHostImpl::SetIsLoading(bool is_loading) { |
| is_loading_ = is_loading; |
| + fling_in_progress_ = false; |
|
sadrul
2012/08/07 17:13:17
Should this be set to false only when is_loading i
rjkroege
2012/08/07 21:00:29
I don't think so. Otherwise, we could send unneces
|
| if (!view_) |
| return; |
| view_->SetIsLoading(is_loading); |
| @@ -830,8 +833,14 @@ void RenderWidgetHostImpl::ForwardGestureEvent( |
| if (ignore_input_events_ || process_->IgnoreInputEvents()) |
| return; |
| + if (ShouldDiscardFlingCancelEvent(gesture_event)) |
| + return; |
| + |
| + if (gesture_event.type == WebInputEvent::GestureFlingCancel) |
| + fling_in_progress_ = false; |
|
sadrul
2012/08/07 17:13:17
Perhaps we can call ShouldDiscardFlingCancelEvent
rjkroege
2012/08/07 21:00:29
Reasonable. Done.
Done.
|
| + |
| if (gesture_event_pending_) { |
| - if (coalesced_gesture_events_.empty() || |
| + if (coalesced_gesture_events_.empty() || |
| !ShouldCoalesceGestureEvents(coalesced_gesture_events_.back(), |
| gesture_event)) { |
| coalesced_gesture_events_.push_back(gesture_event); |
| @@ -848,9 +857,13 @@ void RenderWidgetHostImpl::ForwardGestureEvent( |
| } |
| gesture_event_pending_ = true; |
| - if (gesture_event.type == WebInputEvent::GestureFlingCancel) |
| + if (gesture_event.type == WebInputEvent::GestureFlingCancel) { |
| tap_suppression_controller_->GestureFlingCancel( |
| gesture_event.timeStampSeconds); |
| + } else if (gesture_event.type == WebInputEvent::GestureFlingStart) { |
| + fling_in_progress_ = true; |
| + } |
| + |
| ForwardInputEvent(gesture_event, sizeof(WebGestureEvent), false); |
| } |
| @@ -913,6 +926,8 @@ void RenderWidgetHostImpl::ForwardKeyboardEvent( |
| key_queue_.push_back(key_event); |
| HISTOGRAM_COUNTS_100("Renderer.KeyboardQueueSize", key_queue_.size()); |
| + fling_in_progress_ = false; // Key events always stop flings. |
| + |
| // Only forward the non-native portions of our event. |
| ForwardInputEvent(key_event, sizeof(WebKeyboardEvent), |
| is_keyboard_shortcut); |
| @@ -1513,6 +1528,26 @@ void RenderWidgetHostImpl::TickActiveSmoothScrollGesture() { |
| } |
| } |
| +bool RenderWidgetHostImpl::ShouldDiscardFlingCancelEvent( |
| + const WebKit::WebGestureEvent& gesture_event) { |
| + if (gesture_event.type != WebInputEvent::GestureFlingCancel) { |
| + return false; |
| + } |
| + if (coalesced_gesture_events_.empty() && fling_in_progress_) { |
| + return false; |
|
sadrul
2012/08/07 17:13:17
no braces here
rjkroege
2012/08/07 21:00:29
Done.
|
| + } |
| + GestureEventQueue::reverse_iterator it = |
| + coalesced_gesture_events_.rbegin(); |
| + while (it != coalesced_gesture_events_.rend()) { |
| + if (it->type == WebInputEvent::GestureFlingStart) |
| + return false; |
| + if (it->type == WebInputEvent::GestureFlingCancel) |
| + return true; |
| + it++; |
| + } |
| + return true; |
| +} |
| + |
| void RenderWidgetHostImpl::ProcessWheelAck(bool processed) { |
| mouse_wheel_pending_ = false; |