| 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 559 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 570 void ContentViewCoreImpl::OnGestureEventAck(const blink::WebGestureEvent& event, | 570 void ContentViewCoreImpl::OnGestureEventAck(const blink::WebGestureEvent& event, |
| 571 InputEventAckState ack_result) { | 571 InputEventAckState ack_result) { |
| 572 JNIEnv* env = AttachCurrentThread(); | 572 JNIEnv* env = AttachCurrentThread(); |
| 573 ScopedJavaLocalRef<jobject> j_obj = java_ref_.get(env); | 573 ScopedJavaLocalRef<jobject> j_obj = java_ref_.get(env); |
| 574 if (j_obj.is_null()) | 574 if (j_obj.is_null()) |
| 575 return; | 575 return; |
| 576 | 576 |
| 577 switch (event.type) { | 577 switch (event.type) { |
| 578 case WebInputEvent::GestureFlingStart: | 578 case WebInputEvent::GestureFlingStart: |
| 579 if (ack_result == INPUT_EVENT_ACK_STATE_CONSUMED) { | 579 if (ack_result == INPUT_EVENT_ACK_STATE_CONSUMED) { |
| 580 // The view expects the fling velocity in pixels/s. |
| 580 Java_ContentViewCore_onFlingStartEventConsumed(env, j_obj.obj(), | 581 Java_ContentViewCore_onFlingStartEventConsumed(env, j_obj.obj(), |
| 581 event.data.flingStart.velocityX, event.data.flingStart.velocityY); | 582 event.data.flingStart.velocityX * GetDpiScale(), |
| 583 event.data.flingStart.velocityY * GetDpiScale()); |
| 582 } else { | 584 } else { |
| 583 // If a scroll ends with a fling, a SCROLL_END event is never sent. | 585 // If a scroll ends with a fling, a SCROLL_END event is never sent. |
| 584 // However, if that fling went unconsumed, we still need to let the | 586 // However, if that fling went unconsumed, we still need to let the |
| 585 // listeners know that scrolling has ended. | 587 // listeners know that scrolling has ended. |
| 586 Java_ContentViewCore_onScrollEndEventAck(env, j_obj.obj()); | 588 Java_ContentViewCore_onScrollEndEventAck(env, j_obj.obj()); |
| 587 } | 589 } |
| 588 | 590 |
| 589 if (ack_result == INPUT_EVENT_ACK_STATE_NO_CONSUMER_EXISTS) { | 591 if (ack_result == INPUT_EVENT_ACK_STATE_NO_CONSUMER_EXISTS) { |
| 592 // The view expects the fling velocity in pixels/s. |
| 590 Java_ContentViewCore_onFlingStartEventHadNoConsumer(env, j_obj.obj(), | 593 Java_ContentViewCore_onFlingStartEventHadNoConsumer(env, j_obj.obj(), |
| 591 event.data.flingStart.velocityX, event.data.flingStart.velocityY); | 594 event.data.flingStart.velocityX * GetDpiScale(), |
| 595 event.data.flingStart.velocityY * GetDpiScale()); |
| 592 } | 596 } |
| 593 break; | 597 break; |
| 594 case WebInputEvent::GestureFlingCancel: | 598 case WebInputEvent::GestureFlingCancel: |
| 595 Java_ContentViewCore_onFlingCancelEventAck(env, j_obj.obj()); | 599 Java_ContentViewCore_onFlingCancelEventAck(env, j_obj.obj()); |
| 596 break; | 600 break; |
| 597 case WebInputEvent::GestureScrollBegin: | 601 case WebInputEvent::GestureScrollBegin: |
| 598 Java_ContentViewCore_onScrollBeginEventAck(env, j_obj.obj()); | 602 Java_ContentViewCore_onScrollBeginEventAck(env, j_obj.obj()); |
| 599 break; | 603 break; |
| 600 case WebInputEvent::GestureScrollUpdate: | 604 case WebInputEvent::GestureScrollUpdate: |
| 601 if (ack_result == INPUT_EVENT_ACK_STATE_CONSUMED) | 605 if (ack_result == INPUT_EVENT_ACK_STATE_CONSUMED) |
| (...skipping 27 matching lines...) Expand all Loading... |
| 629 ScopedJavaLocalRef<jobject> j_obj = java_ref_.get(env); | 633 ScopedJavaLocalRef<jobject> j_obj = java_ref_.get(env); |
| 630 if (j_obj.is_null()) | 634 if (j_obj.is_null()) |
| 631 return false; | 635 return false; |
| 632 | 636 |
| 633 const blink::WebGestureEvent& gesture = | 637 const blink::WebGestureEvent& gesture = |
| 634 static_cast<const blink::WebGestureEvent&>(event); | 638 static_cast<const blink::WebGestureEvent&>(event); |
| 635 int gesture_type = ToContentViewGestureHandlerType(event.type); | 639 int gesture_type = ToContentViewGestureHandlerType(event.type); |
| 636 return Java_ContentViewCore_filterTapOrPressEvent(env, | 640 return Java_ContentViewCore_filterTapOrPressEvent(env, |
| 637 j_obj.obj(), | 641 j_obj.obj(), |
| 638 gesture_type, | 642 gesture_type, |
| 639 gesture.x, | 643 gesture.x * GetDpiScale(), |
| 640 gesture.y); | 644 gesture.y * GetDpiScale()); |
| 641 } | 645 } |
| 642 | 646 |
| 643 bool ContentViewCoreImpl::HasFocus() { | 647 bool ContentViewCoreImpl::HasFocus() { |
| 644 JNIEnv* env = AttachCurrentThread(); | 648 JNIEnv* env = AttachCurrentThread(); |
| 645 ScopedJavaLocalRef<jobject> obj = java_ref_.get(env); | 649 ScopedJavaLocalRef<jobject> obj = java_ref_.get(env); |
| 646 if (obj.is_null()) | 650 if (obj.is_null()) |
| 647 return false; | 651 return false; |
| 648 return Java_ContentViewCore_hasFocus(env, obj.obj()); | 652 return Java_ContentViewCore_hasFocus(env, obj.obj()); |
| 649 } | 653 } |
| 650 | 654 |
| (...skipping 1210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1861 reinterpret_cast<ui::ViewAndroid*>(view_android), | 1865 reinterpret_cast<ui::ViewAndroid*>(view_android), |
| 1862 reinterpret_cast<ui::WindowAndroid*>(window_android)); | 1866 reinterpret_cast<ui::WindowAndroid*>(window_android)); |
| 1863 return reinterpret_cast<intptr_t>(view); | 1867 return reinterpret_cast<intptr_t>(view); |
| 1864 } | 1868 } |
| 1865 | 1869 |
| 1866 bool RegisterContentViewCore(JNIEnv* env) { | 1870 bool RegisterContentViewCore(JNIEnv* env) { |
| 1867 return RegisterNativesImpl(env); | 1871 return RegisterNativesImpl(env); |
| 1868 } | 1872 } |
| 1869 | 1873 |
| 1870 } // namespace content | 1874 } // namespace content |
| OLD | NEW |