| OLD | NEW |
| 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 Loading... |
| 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 InputEventAckState ContentViewCoreImpl::FilterInputEvent( | 555 bool ContentViewCoreImpl::FilterInputEvent(const blink::WebInputEvent& event) { |
| 556 const blink::WebInputEvent& event) { | |
| 557 if (event.type != WebInputEvent::GestureTap && | 556 if (event.type != WebInputEvent::GestureTap && |
| 558 event.type != WebInputEvent::GestureDoubleTap && | 557 event.type != WebInputEvent::GestureDoubleTap && |
| 559 event.type != WebInputEvent::GestureLongTap && | 558 event.type != WebInputEvent::GestureLongTap && |
| 560 event.type != WebInputEvent::GestureLongPress && | 559 event.type != WebInputEvent::GestureLongPress) |
| 561 event.type != WebInputEvent::GestureFlingCancel) { | 560 return false; |
| 562 return INPUT_EVENT_ACK_STATE_NOT_CONSUMED; | |
| 563 } | |
| 564 | 561 |
| 565 JNIEnv* env = AttachCurrentThread(); | 562 JNIEnv* env = AttachCurrentThread(); |
| 566 ScopedJavaLocalRef<jobject> j_obj = java_ref_.get(env); | 563 ScopedJavaLocalRef<jobject> j_obj = java_ref_.get(env); |
| 567 if (j_obj.is_null()) | 564 if (j_obj.is_null()) |
| 568 return INPUT_EVENT_ACK_STATE_NOT_CONSUMED; | 565 return false; |
| 569 | |
| 570 if (event.type == WebInputEvent::GestureFlingCancel) { | |
| 571 // If no fling is active, either in the compositor or externally-driven, | |
| 572 // there's no need to explicitly cancel the fling. | |
| 573 bool may_need_fling_cancel = | |
| 574 Java_ContentViewCore_isScrollInProgress(env, j_obj.obj()); | |
| 575 return may_need_fling_cancel ? INPUT_EVENT_ACK_STATE_NOT_CONSUMED | |
| 576 : INPUT_EVENT_ACK_STATE_NO_CONSUMER_EXISTS; | |
| 577 } | |
| 578 | 566 |
| 579 const blink::WebGestureEvent& gesture = | 567 const blink::WebGestureEvent& gesture = |
| 580 static_cast<const blink::WebGestureEvent&>(event); | 568 static_cast<const blink::WebGestureEvent&>(event); |
| 581 int gesture_type = ToGestureEventType(event.type); | 569 int gesture_type = ToGestureEventType(event.type); |
| 582 if (Java_ContentViewCore_filterTapOrPressEvent(env, | 570 return Java_ContentViewCore_filterTapOrPressEvent(env, |
| 583 j_obj.obj(), | 571 j_obj.obj(), |
| 584 gesture_type, | 572 gesture_type, |
| 585 gesture.x * dpi_scale(), | 573 gesture.x * dpi_scale(), |
| 586 gesture.y * dpi_scale())) { | 574 gesture.y * dpi_scale()); |
| 587 return INPUT_EVENT_ACK_STATE_CONSUMED; | |
| 588 } | |
| 589 | 575 |
| 590 return INPUT_EVENT_ACK_STATE_NOT_CONSUMED; | |
| 591 // TODO(jdduke): Also report double-tap UMA, crbug/347568. | 576 // TODO(jdduke): Also report double-tap UMA, crbug/347568. |
| 592 } | 577 } |
| 593 | 578 |
| 594 bool ContentViewCoreImpl::HasFocus() { | 579 bool ContentViewCoreImpl::HasFocus() { |
| 595 JNIEnv* env = AttachCurrentThread(); | 580 JNIEnv* env = AttachCurrentThread(); |
| 596 ScopedJavaLocalRef<jobject> obj = java_ref_.get(env); | 581 ScopedJavaLocalRef<jobject> obj = java_ref_.get(env); |
| 597 if (obj.is_null()) | 582 if (obj.is_null()) |
| 598 return false; | 583 return false; |
| 599 return Java_ContentViewCore_hasFocus(env, obj.obj()); | 584 return Java_ContentViewCore_hasFocus(env, obj.obj()); |
| 600 } | 585 } |
| (...skipping 868 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1469 return NULL; | 1454 return NULL; |
| 1470 | 1455 |
| 1471 return view->GetJavaObject().Release(); | 1456 return view->GetJavaObject().Release(); |
| 1472 } | 1457 } |
| 1473 | 1458 |
| 1474 bool RegisterContentViewCore(JNIEnv* env) { | 1459 bool RegisterContentViewCore(JNIEnv* env) { |
| 1475 return RegisterNativesImpl(env); | 1460 return RegisterNativesImpl(env); |
| 1476 } | 1461 } |
| 1477 | 1462 |
| 1478 } // namespace content | 1463 } // namespace content |
| OLD | NEW |