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

Side by Side Diff: content/browser/android/content_view_core_impl.cc

Issue 1074553002: [Android] Properly filter GestureFlingCancel events (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 8 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
OLDNEW
1 // Copyright 2012 The Chromium Authors. All rights reserved. 1 // Copyright 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/android/content_view_core_impl.h" 5 #include "content/browser/android/content_view_core_impl.h"
6 6
7 #include "base/android/jni_android.h" 7 #include "base/android/jni_android.h"
8 #include "base/android/jni_array.h" 8 #include "base/android/jni_array.h"
9 #include "base/android/jni_string.h" 9 #include "base/android/jni_string.h"
10 #include "base/android/scoped_java_ref.h" 10 #include "base/android/scoped_java_ref.h"
(...skipping 534 matching lines...) Expand 10 before | Expand all | Expand 10 after
545 j_obj.obj(), 545 j_obj.obj(),
546 ack_result == INPUT_EVENT_ACK_STATE_CONSUMED, 546 ack_result == INPUT_EVENT_ACK_STATE_CONSUMED,
547 event.x * dpi_scale(), 547 event.x * dpi_scale(),
548 event.y * dpi_scale()); 548 event.y * dpi_scale());
549 break; 549 break;
550 default: 550 default:
551 break; 551 break;
552 } 552 }
553 } 553 }
554 554
555 bool ContentViewCoreImpl::FilterInputEvent(const blink::WebInputEvent& event) { 555 InputEventAckState ContentViewCoreImpl::FilterInputEvent(
556 const blink::WebInputEvent& event) {
556 if (event.type != WebInputEvent::GestureTap && 557 if (event.type != WebInputEvent::GestureTap &&
557 event.type != WebInputEvent::GestureDoubleTap && 558 event.type != WebInputEvent::GestureDoubleTap &&
558 event.type != WebInputEvent::GestureLongTap && 559 event.type != WebInputEvent::GestureLongTap &&
559 event.type != WebInputEvent::GestureLongPress && 560 event.type != WebInputEvent::GestureLongPress &&
560 event.type != WebInputEvent::GestureFlingCancel) 561 event.type != WebInputEvent::GestureFlingCancel) {
561 return false; 562 return INPUT_EVENT_ACK_STATE_NOT_CONSUMED;
563 }
562 564
563 JNIEnv* env = AttachCurrentThread(); 565 JNIEnv* env = AttachCurrentThread();
564 ScopedJavaLocalRef<jobject> j_obj = java_ref_.get(env); 566 ScopedJavaLocalRef<jobject> j_obj = java_ref_.get(env);
565 if (j_obj.is_null()) 567 if (j_obj.is_null())
566 return false; 568 return INPUT_EVENT_ACK_STATE_NOT_CONSUMED;
567 569
568 if (event.type == WebInputEvent::GestureFlingCancel) { 570 if (event.type == WebInputEvent::GestureFlingCancel) {
569 // If no fling is active, either in the compositor or externally-driven, 571 // If no fling is active, either in the compositor or externally-driven,
570 // there's no need to explicitly cancel the fling. 572 // there's no need to explicitly cancel the fling.
571 bool may_need_fling_cancel = 573 bool may_need_fling_cancel =
572 Java_ContentViewCore_isScrollInProgress(env, j_obj.obj()); 574 Java_ContentViewCore_isScrollInProgress(env, j_obj.obj());
573 return !may_need_fling_cancel; 575 return may_need_fling_cancel ? INPUT_EVENT_ACK_STATE_NOT_CONSUMED
576 : INPUT_EVENT_ACK_STATE_NO_CONSUMER_EXISTS;
574 } 577 }
575 578
576 const blink::WebGestureEvent& gesture = 579 const blink::WebGestureEvent& gesture =
577 static_cast<const blink::WebGestureEvent&>(event); 580 static_cast<const blink::WebGestureEvent&>(event);
578 int gesture_type = ToGestureEventType(event.type); 581 int gesture_type = ToGestureEventType(event.type);
579 return Java_ContentViewCore_filterTapOrPressEvent(env, 582 if (Java_ContentViewCore_filterTapOrPressEvent(env,
580 j_obj.obj(), 583 j_obj.obj(),
581 gesture_type, 584 gesture_type,
582 gesture.x * dpi_scale(), 585 gesture.x * dpi_scale(),
583 gesture.y * dpi_scale()); 586 gesture.y * dpi_scale())) {
587 return INPUT_EVENT_ACK_STATE_CONSUMED;
588 }
584 589
590 return INPUT_EVENT_ACK_STATE_NOT_CONSUMED;
585 // TODO(jdduke): Also report double-tap UMA, crbug/347568. 591 // TODO(jdduke): Also report double-tap UMA, crbug/347568.
586 } 592 }
587 593
588 bool ContentViewCoreImpl::HasFocus() { 594 bool ContentViewCoreImpl::HasFocus() {
589 JNIEnv* env = AttachCurrentThread(); 595 JNIEnv* env = AttachCurrentThread();
590 ScopedJavaLocalRef<jobject> obj = java_ref_.get(env); 596 ScopedJavaLocalRef<jobject> obj = java_ref_.get(env);
591 if (obj.is_null()) 597 if (obj.is_null())
592 return false; 598 return false;
593 return Java_ContentViewCore_hasFocus(env, obj.obj()); 599 return Java_ContentViewCore_hasFocus(env, obj.obj());
594 } 600 }
(...skipping 830 matching lines...) Expand 10 before | Expand all | Expand 10 after
1425 return NULL; 1431 return NULL;
1426 1432
1427 return view->GetJavaObject().Release(); 1433 return view->GetJavaObject().Release();
1428 } 1434 }
1429 1435
1430 bool RegisterContentViewCore(JNIEnv* env) { 1436 bool RegisterContentViewCore(JNIEnv* env) {
1431 return RegisterNativesImpl(env); 1437 return RegisterNativesImpl(env);
1432 } 1438 }
1433 1439
1434 } // namespace content 1440 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/android/content_view_core_impl.h ('k') | content/browser/renderer_host/render_widget_host_view_android.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698