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

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

Issue 1087893003: Support longpress drag selection (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Code review Created 5 years, 7 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
« no previous file with comments | « no previous file | ui/events/test/motion_event_test_utils.h » ('j') | ui/events/test/motion_event_test_utils.h » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 2d41d0879d14ee457bb269722103664aacbb3dad..fc38b2ac61d1ee3a4e6afe40e1c50e5c004addc0 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_SHOWN)
ResetGestureDetection();
+
content_view_core_->OnSelectionEvent(
event, selection_controller_->GetStartPosition(),
GetSelectionRect(*selection_controller_));
@@ -1586,13 +1593,25 @@ InputEventAckState RenderWidgetHostViewAndroid::FilterInputEvent(
blink::WebInputEvent::isGestureEventType(input_event.type)) {
const blink::WebGestureEvent& gesture_event =
static_cast<const blink::WebGestureEvent&>(input_event);
- gfx::PointF gesture_location(gesture_event.x, gesture_event.y);
- if (input_event.type == blink::WebInputEvent::GestureLongPress) {
- if (selection_controller_->WillHandleLongPressEvent(gesture_location))
- return INPUT_EVENT_ACK_STATE_CONSUMED;
- } else if (input_event.type == blink::WebInputEvent::GestureTap) {
- if (selection_controller_->WillHandleTapEvent(gesture_location))
- return INPUT_EVENT_ACK_STATE_CONSUMED;
+ switch (gesture_event.type) {
+ case blink::WebInputEvent::GestureLongPress:
+ if (selection_controller_->WillHandleLongPressEvent(
+ base::TimeTicks() +
+ base::TimeDelta::FromSecondsD(input_event.timeStampSeconds),
+ gfx::PointF(gesture_event.x, gesture_event.y))) {
+ return INPUT_EVENT_ACK_STATE_CONSUMED;
+ }
+ break;
+
+ case blink::WebInputEvent::GestureTap:
+ if (selection_controller_->WillHandleTapEvent(
+ gfx::PointF(gesture_event.x, gesture_event.y))) {
+ return INPUT_EVENT_ACK_STATE_CONSUMED;
+ }
+ break;
+
+ default:
+ break;
}
}
« no previous file with comments | « no previous file | ui/events/test/motion_event_test_utils.h » ('j') | ui/events/test/motion_event_test_utils.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698