Index: content/browser/renderer_host/render_widget_host_view_android.cc |
diff --git a/content/browser/renderer_host/render_widget_host_view_android.cc b/content/browser/renderer_host/render_widget_host_view_android.cc |
index dc4df92d7e2d28820ae34f3511e6bf558ea618e5..f1315023e3332004010b7cafe6c0e8488c84d030 100644 |
--- a/content/browser/renderer_host/render_widget_host_view_android.cc |
+++ b/content/browser/renderer_host/render_widget_host_view_android.cc |
@@ -782,13 +782,20 @@ bool RenderWidgetHostViewAndroid::OnTouchHandleEvent( |
void RenderWidgetHostViewAndroid::ResetGestureDetection() { |
const ui::MotionEvent* current_down_event = |
gesture_provider_.GetCurrentDownEvent(); |
- if (current_down_event) { |
- scoped_ptr<ui::MotionEvent> cancel_event = current_down_event->Cancel(); |
- OnTouchEvent(*cancel_event); |
+ if (!current_down_event) { |
+ // A hard reset ensures prevention of any timer-based events that might fire |
+ // after a touch sequence has ended. |
+ gesture_provider_.ResetDetection(); |
+ return; |
} |
- // A hard reset ensures prevention of any timer-based events. |
- gesture_provider_.ResetDetection(); |
+ scoped_ptr<ui::MotionEvent> cancel_event = current_down_event->Cancel(); |
+ if (gesture_provider_.OnTouchEvent(*cancel_event).succeeded) { |
+ bool causes_scrolling = false; |
+ host_->ForwardTouchEventWithLatencyInfo( |
+ ui::CreateWebTouchEventFromMotionEvent(*cancel_event, causes_scrolling), |
+ ui::LatencyInfo()); |
+ } |
} |
void RenderWidgetHostViewAndroid::OnDidNavigateMainFrameToNewPage() { |
@@ -1263,12 +1270,12 @@ void RenderWidgetHostViewAndroid::OnSelectionEvent( |
ui::SelectionEventType event) { |
DCHECK(content_view_core_); |
DCHECK(selection_controller_); |
- // Showing the selection action bar can alter the current View coordinates in |
- // such a way that the current MotionEvent stream is suddenly shifted in |
- // space. Avoid the associated scroll jump by pre-emptively cancelling gesture |
- // detection; scrolling after the selection is activated is unnecessary. |
- if (event == ui::SelectionEventType::SELECTION_SHOWN) |
+ // If a selection drag has started, it has taken over the active touch |
+ // sequence. Immediately cancel gesture detection and any downstream touch |
+ // listeners (e.g., web content) to communicate this transfer. |
+ if (event == ui::SELECTION_DRAG_STARTED) |
ResetGestureDetection(); |
+ |
content_view_core_->OnSelectionEvent( |
event, selection_controller_->GetStartPosition(), |
GetSelectionRect(*selection_controller_)); |
@@ -1583,15 +1590,15 @@ void RenderWidgetHostViewAndroid::GestureEventAck( |
InputEventAckState RenderWidgetHostViewAndroid::FilterInputEvent( |
const blink::WebInputEvent& input_event) { |
if (selection_controller_) { |
- switch (input_event.type) { |
- case blink::WebInputEvent::GestureLongPress: |
- selection_controller_->OnLongPressEvent(); |
- break; |
- case blink::WebInputEvent::GestureTap: |
- selection_controller_->OnTapEvent(); |
- break; |
- default: |
- break; |
+ if (input_event.type == blink::WebInputEvent::GestureLongPress) { |
+ const blink::WebGestureEvent& longpress = |
+ static_cast<const blink::WebGestureEvent&>(input_event); |
+ selection_controller_->OnLongPressEvent( |
+ base::TimeTicks() + |
+ base::TimeDelta::FromSecondsD(input_event.timeStampSeconds), |
+ gfx::PointF(longpress.x, longpress.y)); |
+ } else if (input_event.type == blink::WebInputEvent::GestureTap) { |
+ selection_controller_->OnTapEvent(); |
} |
} |