| 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 <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include "base/android/jni_android.h" | 9 #include "base/android/jni_android.h" |
| 10 #include "base/android/jni_array.h" | 10 #include "base/android/jni_array.h" |
| (...skipping 517 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 528 select_popup_.Reset(); | 528 select_popup_.Reset(); |
| 529 } | 529 } |
| 530 | 530 |
| 531 void ContentViewCoreImpl::OnGestureEventAck(const blink::WebGestureEvent& event, | 531 void ContentViewCoreImpl::OnGestureEventAck(const blink::WebGestureEvent& event, |
| 532 InputEventAckState ack_result) { | 532 InputEventAckState ack_result) { |
| 533 JNIEnv* env = AttachCurrentThread(); | 533 JNIEnv* env = AttachCurrentThread(); |
| 534 ScopedJavaLocalRef<jobject> j_obj = java_ref_.get(env); | 534 ScopedJavaLocalRef<jobject> j_obj = java_ref_.get(env); |
| 535 if (j_obj.is_null()) | 535 if (j_obj.is_null()) |
| 536 return; | 536 return; |
| 537 | 537 |
| 538 switch (event.type) { | 538 switch (event.type()) { |
| 539 case WebInputEvent::GestureFlingStart: | 539 case WebInputEvent::GestureFlingStart: |
| 540 if (ack_result == INPUT_EVENT_ACK_STATE_CONSUMED) { | 540 if (ack_result == INPUT_EVENT_ACK_STATE_CONSUMED) { |
| 541 // The view expects the fling velocity in pixels/s. | 541 // The view expects the fling velocity in pixels/s. |
| 542 Java_ContentViewCore_onFlingStartEventConsumed(env, j_obj); | 542 Java_ContentViewCore_onFlingStartEventConsumed(env, j_obj); |
| 543 } else { | 543 } else { |
| 544 // If a scroll ends with a fling, a SCROLL_END event is never sent. | 544 // If a scroll ends with a fling, a SCROLL_END event is never sent. |
| 545 // However, if that fling went unconsumed, we still need to let the | 545 // However, if that fling went unconsumed, we still need to let the |
| 546 // listeners know that scrolling has ended. | 546 // listeners know that scrolling has ended. |
| 547 Java_ContentViewCore_onScrollEndEventAck(env, j_obj); | 547 Java_ContentViewCore_onScrollEndEventAck(env, j_obj); |
| 548 } | 548 } |
| (...skipping 24 matching lines...) Expand all Loading... |
| 573 case WebInputEvent::GestureLongPress: | 573 case WebInputEvent::GestureLongPress: |
| 574 if (ack_result == INPUT_EVENT_ACK_STATE_CONSUMED) | 574 if (ack_result == INPUT_EVENT_ACK_STATE_CONSUMED) |
| 575 Java_ContentViewCore_performLongPressHapticFeedback(env, j_obj); | 575 Java_ContentViewCore_performLongPressHapticFeedback(env, j_obj); |
| 576 break; | 576 break; |
| 577 default: | 577 default: |
| 578 break; | 578 break; |
| 579 } | 579 } |
| 580 } | 580 } |
| 581 | 581 |
| 582 bool ContentViewCoreImpl::FilterInputEvent(const blink::WebInputEvent& event) { | 582 bool ContentViewCoreImpl::FilterInputEvent(const blink::WebInputEvent& event) { |
| 583 if (event.type != WebInputEvent::GestureTap && | 583 if (event.type() != WebInputEvent::GestureTap && |
| 584 event.type != WebInputEvent::GestureDoubleTap && | 584 event.type() != WebInputEvent::GestureDoubleTap && |
| 585 event.type != WebInputEvent::GestureLongTap && | 585 event.type() != WebInputEvent::GestureLongTap && |
| 586 event.type != WebInputEvent::GestureLongPress) | 586 event.type() != WebInputEvent::GestureLongPress) |
| 587 return false; | 587 return false; |
| 588 | 588 |
| 589 JNIEnv* env = AttachCurrentThread(); | 589 JNIEnv* env = AttachCurrentThread(); |
| 590 ScopedJavaLocalRef<jobject> j_obj = java_ref_.get(env); | 590 ScopedJavaLocalRef<jobject> j_obj = java_ref_.get(env); |
| 591 if (j_obj.is_null()) | 591 if (j_obj.is_null()) |
| 592 return false; | 592 return false; |
| 593 | 593 |
| 594 const blink::WebGestureEvent& gesture = | 594 const blink::WebGestureEvent& gesture = |
| 595 static_cast<const blink::WebGestureEvent&>(event); | 595 static_cast<const blink::WebGestureEvent&>(event); |
| 596 int gesture_type = ToGestureEventType(event.type); | 596 int gesture_type = ToGestureEventType(event.type()); |
| 597 return Java_ContentViewCore_filterTapOrPressEvent(env, j_obj, gesture_type, | 597 return Java_ContentViewCore_filterTapOrPressEvent(env, j_obj, gesture_type, |
| 598 gesture.x * dpi_scale(), | 598 gesture.x * dpi_scale(), |
| 599 gesture.y * dpi_scale()); | 599 gesture.y * dpi_scale()); |
| 600 } | 600 } |
| 601 | 601 |
| 602 bool ContentViewCoreImpl::HasFocus() { | 602 bool ContentViewCoreImpl::HasFocus() { |
| 603 JNIEnv* env = AttachCurrentThread(); | 603 JNIEnv* env = AttachCurrentThread(); |
| 604 ScopedJavaLocalRef<jobject> obj = java_ref_.get(env); | 604 ScopedJavaLocalRef<jobject> obj = java_ref_.get(env); |
| 605 if (obj.is_null()) | 605 if (obj.is_null()) |
| 606 return false; | 606 return false; |
| (...skipping 977 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1584 return ScopedJavaLocalRef<jobject>(); | 1584 return ScopedJavaLocalRef<jobject>(); |
| 1585 | 1585 |
| 1586 return view->GetJavaObject(); | 1586 return view->GetJavaObject(); |
| 1587 } | 1587 } |
| 1588 | 1588 |
| 1589 bool RegisterContentViewCore(JNIEnv* env) { | 1589 bool RegisterContentViewCore(JNIEnv* env) { |
| 1590 return RegisterNativesImpl(env); | 1590 return RegisterNativesImpl(env); |
| 1591 } | 1591 } |
| 1592 | 1592 |
| 1593 } // namespace content | 1593 } // namespace content |
| OLD | NEW |