| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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" |
| 11 #include "base/json/json_writer.h" | 11 #include "base/json/json_writer.h" |
| 12 #include "base/logging.h" | 12 #include "base/logging.h" |
| 13 #include "base/utf_string_conversions.h" | 13 #include "base/utf_string_conversions.h" |
| 14 #include "content/browser/android/load_url_params.h" | 14 #include "content/browser/android/load_url_params.h" |
| 15 #include "content/browser/android/touch_point.h" | 15 #include "content/browser/android/touch_point.h" |
| 16 #include "content/browser/renderer_host/java/java_bound_object.h" | 16 #include "content/browser/renderer_host/java/java_bound_object.h" |
| 17 #include "content/browser/renderer_host/java/java_bridge_dispatcher_host_manager
.h" | 17 #include "content/browser/renderer_host/java/java_bridge_dispatcher_host_manager
.h" |
| 18 #include "content/browser/renderer_host/render_view_host_impl.h" | 18 #include "content/browser/renderer_host/render_view_host_impl.h" |
| 19 #include "content/browser/renderer_host/render_widget_host_impl.h" | 19 #include "content/browser/renderer_host/render_widget_host_impl.h" |
| 20 #include "content/browser/renderer_host/render_widget_host_view_android.h" | 20 #include "content/browser/renderer_host/render_widget_host_view_android.h" |
| 21 #include "content/browser/web_contents/navigation_controller_impl.h" | 21 #include "content/browser/web_contents/navigation_controller_impl.h" |
| 22 #include "content/browser/web_contents/navigation_entry_impl.h" | 22 #include "content/browser/web_contents/navigation_entry_impl.h" |
| 23 #include "content/browser/web_contents/web_contents_view_android.h" | 23 #include "content/browser/web_contents/web_contents_view_android.h" |
| 24 #include "content/common/android/device_info.h" |
| 24 #include "content/common/view_messages.h" | 25 #include "content/common/view_messages.h" |
| 25 #include "content/public/browser/browser_context.h" | 26 #include "content/public/browser/browser_context.h" |
| 26 #include "content/public/browser/favicon_status.h" | 27 #include "content/public/browser/favicon_status.h" |
| 27 #include "content/public/browser/interstitial_page.h" | 28 #include "content/public/browser/interstitial_page.h" |
| 28 #include "content/public/browser/notification_details.h" | 29 #include "content/public/browser/notification_details.h" |
| 29 #include "content/public/browser/notification_service.h" | 30 #include "content/public/browser/notification_service.h" |
| 30 #include "content/public/browser/notification_source.h" | 31 #include "content/public/browser/notification_source.h" |
| 31 #include "content/public/browser/notification_types.h" | 32 #include "content/public/browser/notification_types.h" |
| 32 #include "content/public/browser/web_contents.h" | 33 #include "content/public/browser/web_contents.h" |
| 33 #include "content/public/common/content_client.h" | 34 #include "content/public/common/content_client.h" |
| 34 #include "content/public/common/page_transition_types.h" | 35 #include "content/public/common/page_transition_types.h" |
| 35 #include "jni/ContentViewCore_jni.h" | 36 #include "jni/ContentViewCore_jni.h" |
| 36 #include "third_party/WebKit/Source/WebKit/chromium/public/WebBindings.h" | 37 #include "third_party/WebKit/Source/WebKit/chromium/public/WebBindings.h" |
| 37 #include "third_party/WebKit/Source/WebKit/chromium/public/WebInputEvent.h" | 38 #include "third_party/WebKit/Source/WebKit/chromium/public/WebInputEvent.h" |
| 38 #include "third_party/WebKit/Source/WebKit/chromium/public/android/WebInputEvent
Factory.h" | 39 #include "third_party/WebKit/Source/WebKit/chromium/public/android/WebInputEvent
Factory.h" |
| 39 #include "ui/gfx/android/java_bitmap.h" | 40 #include "ui/gfx/android/java_bitmap.h" |
| 40 #include "ui/gfx/android/window_android.h" | 41 #include "ui/gfx/android/window_android.h" |
| 42 #include "ui/gfx/screen.h" |
| 41 #include "webkit/glue/webmenuitem.h" | 43 #include "webkit/glue/webmenuitem.h" |
| 42 #include "webkit/user_agent/user_agent_util.h" | 44 #include "webkit/user_agent/user_agent_util.h" |
| 43 | 45 |
| 44 using base::android::AttachCurrentThread; | 46 using base::android::AttachCurrentThread; |
| 45 using base::android::ConvertJavaStringToUTF16; | 47 using base::android::ConvertJavaStringToUTF16; |
| 46 using base::android::ConvertJavaStringToUTF8; | 48 using base::android::ConvertJavaStringToUTF8; |
| 47 using base::android::ConvertUTF16ToJavaString; | 49 using base::android::ConvertUTF16ToJavaString; |
| 48 using base::android::ConvertUTF8ToJavaString; | 50 using base::android::ConvertUTF8ToJavaString; |
| 49 using base::android::GetClass; | 51 using base::android::GetClass; |
| 50 using base::android::HasField; | 52 using base::android::HasField; |
| 51 using base::android::JavaByteArrayToByteVector; | 53 using base::android::JavaByteArrayToByteVector; |
| 52 using base::android::ScopedJavaGlobalRef; | 54 using base::android::ScopedJavaGlobalRef; |
| 53 using base::android::ScopedJavaLocalRef; | 55 using base::android::ScopedJavaLocalRef; |
| 56 using WebKit::WebGestureEvent; |
| 54 using WebKit::WebInputEvent; | 57 using WebKit::WebInputEvent; |
| 55 using WebKit::WebInputEventFactory; | 58 using WebKit::WebInputEventFactory; |
| 56 | 59 |
| 57 // Describes the type and enabled state of a select popup item. | 60 // Describes the type and enabled state of a select popup item. |
| 58 // Keep in sync with the value defined in SelectPopupDialog.java | 61 // Keep in sync with the value defined in SelectPopupDialog.java |
| 59 enum PopupItemType { | 62 enum PopupItemType { |
| 60 POPUP_ITEM_TYPE_GROUP = 0, | 63 POPUP_ITEM_TYPE_GROUP = 0, |
| 61 POPUP_ITEM_TYPE_DISABLED, | 64 POPUP_ITEM_TYPE_DISABLED, |
| 62 POPUP_ITEM_TYPE_ENABLED | 65 POPUP_ITEM_TYPE_ENABLED |
| 63 }; | 66 }; |
| (...skipping 23 matching lines...) Expand all Loading... |
| 87 web_contents_(static_cast<WebContentsImpl*>(web_contents)), | 90 web_contents_(static_cast<WebContentsImpl*>(web_contents)), |
| 88 tab_crashed_(false), | 91 tab_crashed_(false), |
| 89 window_android_(window_android) { | 92 window_android_(window_android) { |
| 90 DCHECK(web_contents) << | 93 DCHECK(web_contents) << |
| 91 "A ContentViewCoreImpl should be created with a valid WebContents."; | 94 "A ContentViewCoreImpl should be created with a valid WebContents."; |
| 92 | 95 |
| 93 // TODO(leandrogracia): make use of the hardware_accelerated argument. | 96 // TODO(leandrogracia): make use of the hardware_accelerated argument. |
| 94 | 97 |
| 95 InitJNI(env, obj); | 98 InitJNI(env, obj); |
| 96 | 99 |
| 100 if (!gfx::Screen::IsDIPEnabled()) { |
| 101 dpi_scale_ = 1; |
| 102 } else { |
| 103 scoped_ptr<content::DeviceInfo> device_info(new content::DeviceInfo()); |
| 104 dpi_scale_ = device_info->GetDPIScale(); |
| 105 } |
| 106 |
| 97 notification_registrar_.Add(this, | 107 notification_registrar_.Add(this, |
| 98 NOTIFICATION_EXECUTE_JAVASCRIPT_RESULT, | 108 NOTIFICATION_EXECUTE_JAVASCRIPT_RESULT, |
| 99 NotificationService::AllSources()); | 109 NotificationService::AllSources()); |
| 100 | 110 |
| 101 // Currently, the only use case we have for overriding a user agent involves | 111 // Currently, the only use case we have for overriding a user agent involves |
| 102 // spoofing a desktop Linux user agent for "Request desktop site". | 112 // spoofing a desktop Linux user agent for "Request desktop site". |
| 103 // Automatically set it for all WebContents so that it is available when a | 113 // Automatically set it for all WebContents so that it is available when a |
| 104 // NavigationEntry requires the user agent to be overridden. | 114 // NavigationEntry requires the user agent to be overridden. |
| 105 const char kLinuxInfoStr[] = "X11; Linux x86_64"; | 115 const char kLinuxInfoStr[] = "X11; Linux x86_64"; |
| 106 std::string product = content::GetContentClient()->GetProduct(); | 116 std::string product = content::GetContentClient()->GetProduct(); |
| (...skipping 381 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 488 } | 498 } |
| 489 return false; | 499 return false; |
| 490 } | 500 } |
| 491 | 501 |
| 492 int ContentViewCoreImpl::GetTouchPadding() | 502 int ContentViewCoreImpl::GetTouchPadding() |
| 493 { | 503 { |
| 494 // TODO(trchen): derive a proper padding value from device dpi | 504 // TODO(trchen): derive a proper padding value from device dpi |
| 495 return 48; | 505 return 48; |
| 496 } | 506 } |
| 497 | 507 |
| 508 float ContentViewCoreImpl::DpiScale() const { |
| 509 return dpi_scale_; |
| 510 } |
| 511 |
| 498 jboolean ContentViewCoreImpl::SendMouseMoveEvent(JNIEnv* env, | 512 jboolean ContentViewCoreImpl::SendMouseMoveEvent(JNIEnv* env, |
| 499 jobject obj, | 513 jobject obj, |
| 500 jlong time_ms, | 514 jlong time_ms, |
| 501 jint x, | 515 jint x, |
| 502 jint y) { | 516 jint y) { |
| 503 RenderWidgetHostViewAndroid* rwhv = GetRenderWidgetHostViewAndroid(); | 517 RenderWidgetHostViewAndroid* rwhv = GetRenderWidgetHostViewAndroid(); |
| 504 if (!rwhv) | 518 if (!rwhv) |
| 505 return false; | 519 return false; |
| 506 | 520 |
| 507 WebKit::WebMouseEvent event = WebInputEventFactory::mouseEvent( | 521 WebKit::WebMouseEvent event = WebInputEventFactory::mouseEvent( |
| 508 WebInputEventFactory::MouseEventTypeMove, | 522 WebInputEventFactory::MouseEventTypeMove, |
| 509 WebKit::WebMouseEvent::ButtonNone, | 523 WebKit::WebMouseEvent::ButtonNone, |
| 510 time_ms / 1000.0, x, y, 0, 1); | 524 time_ms / 1000.0, x / DpiScale(), y / DpiScale(), 0, 1); |
| 511 | 525 |
| 512 rwhv->SendMouseEvent(event); | 526 rwhv->SendMouseEvent(event); |
| 513 return true; | 527 return true; |
| 514 } | 528 } |
| 515 | 529 |
| 516 jboolean ContentViewCoreImpl::SendMouseWheelEvent(JNIEnv* env, | 530 jboolean ContentViewCoreImpl::SendMouseWheelEvent(JNIEnv* env, |
| 517 jobject obj, | 531 jobject obj, |
| 518 jlong time_ms, | 532 jlong time_ms, |
| 519 jint x, | 533 jint x, |
| 520 jint y, | 534 jint y, |
| 521 jfloat vertical_axis) { | 535 jfloat vertical_axis) { |
| 522 RenderWidgetHostViewAndroid* rwhv = GetRenderWidgetHostViewAndroid(); | 536 RenderWidgetHostViewAndroid* rwhv = GetRenderWidgetHostViewAndroid(); |
| 523 if (!rwhv) | 537 if (!rwhv) |
| 524 return false; | 538 return false; |
| 525 | 539 |
| 526 WebKit::WebInputEventFactory::MouseWheelDirectionType type; | 540 WebKit::WebInputEventFactory::MouseWheelDirectionType type; |
| 527 if (vertical_axis > 0) { | 541 if (vertical_axis > 0) { |
| 528 type = WebInputEventFactory::MouseWheelDirectionTypeUp; | 542 type = WebInputEventFactory::MouseWheelDirectionTypeUp; |
| 529 } else if (vertical_axis < 0) { | 543 } else if (vertical_axis < 0) { |
| 530 type = WebInputEventFactory::MouseWheelDirectionTypeDown; | 544 type = WebInputEventFactory::MouseWheelDirectionTypeDown; |
| 531 } else { | 545 } else { |
| 532 return false; | 546 return false; |
| 533 } | 547 } |
| 534 WebKit::WebMouseWheelEvent event = WebInputEventFactory::mouseWheelEvent( | 548 WebKit::WebMouseWheelEvent event = WebInputEventFactory::mouseWheelEvent( |
| 535 type, time_ms / 1000.0, x, y); | 549 type, time_ms / 1000.0, x / DpiScale(), y / DpiScale()); |
| 536 | 550 |
| 537 rwhv->SendMouseWheelEvent(event); | 551 rwhv->SendMouseWheelEvent(event); |
| 538 return true; | 552 return true; |
| 539 } | 553 } |
| 540 | 554 |
| 541 void ContentViewCoreImpl::SendGestureEvent(WebInputEvent::Type type, | 555 WebGestureEvent ContentViewCoreImpl::MakeGestureEvent(WebInputEvent::Type type, |
| 542 long time_ms, int x, int y) { | 556 long time_ms, |
| 543 WebKit::WebGestureEvent event = WebInputEventFactory::gestureEvent( | 557 int x, int y) const { |
| 544 type, time_ms / 1000.0, x, y, 0, 0, 0); | 558 WebGestureEvent event; |
| 559 event.type = type; |
| 560 event.x = x / DpiScale(); |
| 561 event.y = y / DpiScale(); |
| 562 event.timeStampSeconds = time_ms / 1000.0; |
| 563 return event; |
| 564 } |
| 545 | 565 |
| 546 if (type == WebInputEvent::GestureFlingStart) | 566 void ContentViewCoreImpl::ScrollBegin(JNIEnv* env, jobject obj, jlong time_ms, |
| 547 event.data.flingStart.sourceDevice = WebKit::WebGestureEvent::Touchscreen; | 567 jint x, jint y) { |
| 548 | 568 WebGestureEvent event = MakeGestureEvent( |
| 569 WebInputEvent::GestureScrollBegin, time_ms, x, y); |
| 549 if (GetRenderWidgetHostViewAndroid()) | 570 if (GetRenderWidgetHostViewAndroid()) |
| 550 GetRenderWidgetHostViewAndroid()->SendGestureEvent(event); | 571 GetRenderWidgetHostViewAndroid()->SendGestureEvent(event); |
| 551 } | 572 } |
| 552 | 573 |
| 553 void ContentViewCoreImpl::ScrollBegin(JNIEnv* env, jobject obj, jlong time_ms, | |
| 554 jint x, jint y) { | |
| 555 SendGestureEvent( | |
| 556 WebInputEvent::GestureScrollBegin, time_ms, x, y); | |
| 557 } | |
| 558 | |
| 559 void ContentViewCoreImpl::ScrollEnd(JNIEnv* env, jobject obj, jlong time_ms) { | 574 void ContentViewCoreImpl::ScrollEnd(JNIEnv* env, jobject obj, jlong time_ms) { |
| 560 SendGestureEvent(WebInputEvent::GestureScrollEnd, time_ms, 0, 0); | 575 WebGestureEvent event = MakeGestureEvent( |
| 576 WebInputEvent::GestureScrollEnd, time_ms, 0, 0); |
| 577 if (GetRenderWidgetHostViewAndroid()) |
| 578 GetRenderWidgetHostViewAndroid()->SendGestureEvent(event); |
| 561 } | 579 } |
| 562 | 580 |
| 563 void ContentViewCoreImpl::ScrollBy(JNIEnv* env, jobject obj, jlong time_ms, | 581 void ContentViewCoreImpl::ScrollBy(JNIEnv* env, jobject obj, jlong time_ms, |
| 564 jint x, jint y, jint dx, jint dy) { | 582 jint x, jint y, jint dx, jint dy) { |
| 565 // TODO(rbyers): Stop setting generic deltaX/deltaY, crbug.com/143237 | 583 WebGestureEvent event = MakeGestureEvent( |
| 566 WebKit::WebGestureEvent event = WebInputEventFactory::gestureEvent( | 584 WebInputEvent::GestureScrollUpdate, time_ms, x, y); |
| 567 WebInputEvent::GestureScrollUpdate, time_ms / 1000.0, x, y, -dx, -dy, 0); | |
| 568 | 585 |
| 569 event.data.scrollUpdate.deltaX = -dx; | 586 event.data.scrollUpdate.deltaX = -dx / DpiScale(); |
| 570 event.data.scrollUpdate.deltaY = -dy; | 587 event.data.scrollUpdate.deltaY = -dy / DpiScale(); |
| 571 | 588 |
| 572 if (GetRenderWidgetHostViewAndroid()) | 589 if (GetRenderWidgetHostViewAndroid()) |
| 573 GetRenderWidgetHostViewAndroid()->SendGestureEvent(event); | 590 GetRenderWidgetHostViewAndroid()->SendGestureEvent(event); |
| 574 } | 591 } |
| 575 | 592 |
| 576 void ContentViewCoreImpl::FlingStart(JNIEnv* env, jobject obj, jlong time_ms, | 593 void ContentViewCoreImpl::FlingStart(JNIEnv* env, jobject obj, jlong time_ms, |
| 577 jint x, jint y, jint vx, jint vy) { | 594 jint x, jint y, jint vx, jint vy) { |
| 578 WebKit::WebGestureEvent event = WebInputEventFactory::gestureEvent( | 595 WebGestureEvent event = MakeGestureEvent( |
| 579 WebInputEvent::GestureFlingStart, time_ms / 1000.0, x, y, vx, vy, 0); | 596 WebInputEvent::GestureFlingStart, time_ms, x, y); |
| 580 event.data.flingStart.velocityX = vx; | 597 event.data.flingStart.velocityX = vx / DpiScale(); |
| 581 event.data.flingStart.velocityY = vy; | 598 event.data.flingStart.velocityY = vy / DpiScale(); |
| 599 event.data.flingStart.sourceDevice = WebGestureEvent::Touchscreen; |
| 582 | 600 |
| 583 if (GetRenderWidgetHostViewAndroid()) | 601 if (GetRenderWidgetHostViewAndroid()) |
| 584 GetRenderWidgetHostViewAndroid()->SendGestureEvent(event); | 602 GetRenderWidgetHostViewAndroid()->SendGestureEvent(event); |
| 585 } | 603 } |
| 586 | 604 |
| 587 void ContentViewCoreImpl::FlingCancel(JNIEnv* env, jobject obj, jlong time_ms) { | 605 void ContentViewCoreImpl::FlingCancel(JNIEnv* env, jobject obj, jlong time_ms) { |
| 588 SendGestureEvent(WebInputEvent::GestureFlingCancel, time_ms, 0, 0); | 606 WebGestureEvent event = MakeGestureEvent( |
| 607 WebInputEvent::GestureFlingCancel, time_ms, 0, 0); |
| 608 if (GetRenderWidgetHostViewAndroid()) |
| 609 GetRenderWidgetHostViewAndroid()->SendGestureEvent(event); |
| 589 } | 610 } |
| 590 | 611 |
| 591 void ContentViewCoreImpl::SingleTap(JNIEnv* env, jobject obj, jlong time_ms, | 612 void ContentViewCoreImpl::SingleTap(JNIEnv* env, jobject obj, jlong time_ms, |
| 592 jint x, jint y, | 613 jint x, jint y, |
| 593 jboolean disambiguation_popup_tap) { | 614 jboolean disambiguation_popup_tap) { |
| 594 WebKit::WebGestureEvent event = WebInputEventFactory::gestureEvent( | 615 WebGestureEvent event = MakeGestureEvent( |
| 595 WebInputEvent::GestureTap, time_ms / 1000.0, x, y, 0, 0, 0); | 616 WebInputEvent::GestureTap, time_ms, x, y); |
| 596 | 617 |
| 597 event.data.tap.tapCount = 1; | 618 event.data.tap.tapCount = 1; |
| 598 if (!disambiguation_popup_tap) { | 619 if (!disambiguation_popup_tap) { |
| 599 int touchPadding = GetTouchPadding(); | 620 int touchPadding = GetTouchPadding(); |
| 600 event.data.tap.width = touchPadding; | 621 event.data.tap.width = touchPadding / DpiScale(); |
| 601 event.data.tap.height = touchPadding; | 622 event.data.tap.height = touchPadding / DpiScale(); |
| 602 } | 623 } |
| 603 | 624 |
| 604 if (GetRenderWidgetHostViewAndroid()) | 625 if (GetRenderWidgetHostViewAndroid()) |
| 605 GetRenderWidgetHostViewAndroid()->SendGestureEvent(event); | 626 GetRenderWidgetHostViewAndroid()->SendGestureEvent(event); |
| 606 } | 627 } |
| 607 | 628 |
| 608 void ContentViewCoreImpl::ShowPressState(JNIEnv* env, jobject obj, | 629 void ContentViewCoreImpl::ShowPressState(JNIEnv* env, jobject obj, |
| 609 jlong time_ms, | 630 jlong time_ms, |
| 610 jint x, jint y) { | 631 jint x, jint y) { |
| 611 SendGestureEvent(WebInputEvent::GestureTapDown, time_ms, x, y); | 632 WebGestureEvent event = MakeGestureEvent( |
| 633 WebInputEvent::GestureTapDown, time_ms, x, y); |
| 634 if (GetRenderWidgetHostViewAndroid()) |
| 635 GetRenderWidgetHostViewAndroid()->SendGestureEvent(event); |
| 612 } | 636 } |
| 613 | 637 |
| 614 void ContentViewCoreImpl::DoubleTap(JNIEnv* env, jobject obj, jlong time_ms, | 638 void ContentViewCoreImpl::DoubleTap(JNIEnv* env, jobject obj, jlong time_ms, |
| 615 jint x, jint y) { | 639 jint x, jint y) { |
| 616 SendGestureEvent(WebInputEvent::GestureDoubleTap, time_ms, x, y); | 640 WebGestureEvent event = MakeGestureEvent( |
| 641 WebInputEvent::GestureDoubleTap, time_ms, x, y); |
| 642 if (GetRenderWidgetHostViewAndroid()) |
| 643 GetRenderWidgetHostViewAndroid()->SendGestureEvent(event); |
| 617 } | 644 } |
| 618 | 645 |
| 619 void ContentViewCoreImpl::LongPress(JNIEnv* env, jobject obj, jlong time_ms, | 646 void ContentViewCoreImpl::LongPress(JNIEnv* env, jobject obj, jlong time_ms, |
| 620 jint x, jint y, | 647 jint x, jint y, |
| 621 jboolean disambiguation_popup_tap) { | 648 jboolean disambiguation_popup_tap) { |
| 622 WebKit::WebGestureEvent event = WebInputEventFactory::gestureEvent( | 649 WebGestureEvent event = MakeGestureEvent( |
| 623 WebInputEvent::GestureLongPress, time_ms / 1000.0, x, y, 0, 0, 0); | 650 WebInputEvent::GestureLongPress, time_ms, x, y); |
| 624 | 651 |
| 625 if (!disambiguation_popup_tap) { | 652 if (!disambiguation_popup_tap) { |
| 626 int touchPadding = GetTouchPadding(); | 653 int touchPadding = GetTouchPadding(); |
| 627 event.data.longPress.width = touchPadding; | 654 event.data.longPress.width = touchPadding / DpiScale(); |
| 628 event.data.longPress.height = touchPadding; | 655 event.data.longPress.height = touchPadding / DpiScale(); |
| 629 } | 656 } |
| 630 | 657 |
| 631 if (GetRenderWidgetHostViewAndroid()) | 658 if (GetRenderWidgetHostViewAndroid()) |
| 632 GetRenderWidgetHostViewAndroid()->SendGestureEvent(event); | 659 GetRenderWidgetHostViewAndroid()->SendGestureEvent(event); |
| 633 } | 660 } |
| 634 | 661 |
| 635 void ContentViewCoreImpl::PinchBegin(JNIEnv* env, jobject obj, jlong time_ms, | 662 void ContentViewCoreImpl::PinchBegin(JNIEnv* env, jobject obj, jlong time_ms, |
| 636 jint x, jint y) { | 663 jint x, jint y) { |
| 637 SendGestureEvent( | 664 WebGestureEvent event = MakeGestureEvent( |
| 638 WebInputEvent::GesturePinchBegin, time_ms, x, y); | 665 WebInputEvent::GesturePinchBegin, time_ms, x, y); |
| 666 if (GetRenderWidgetHostViewAndroid()) |
| 667 GetRenderWidgetHostViewAndroid()->SendGestureEvent(event); |
| 639 } | 668 } |
| 640 | 669 |
| 641 void ContentViewCoreImpl::PinchEnd(JNIEnv* env, jobject obj, jlong time_ms) { | 670 void ContentViewCoreImpl::PinchEnd(JNIEnv* env, jobject obj, jlong time_ms) { |
| 642 SendGestureEvent(WebInputEvent::GesturePinchEnd, time_ms, 0, 0); | 671 WebGestureEvent event = MakeGestureEvent( |
| 672 WebInputEvent::GesturePinchEnd, time_ms, 0, 0); |
| 673 if (GetRenderWidgetHostViewAndroid()) |
| 674 GetRenderWidgetHostViewAndroid()->SendGestureEvent(event); |
| 643 } | 675 } |
| 644 | 676 |
| 645 void ContentViewCoreImpl::PinchBy(JNIEnv* env, jobject obj, jlong time_ms, | 677 void ContentViewCoreImpl::PinchBy(JNIEnv* env, jobject obj, jlong time_ms, |
| 646 jint anchor_x, jint anchor_y, jfloat delta) { | 678 jint anchor_x, jint anchor_y, jfloat delta) { |
| 647 WebKit::WebGestureEvent event = WebInputEventFactory::gestureEvent( | 679 WebGestureEvent event = MakeGestureEvent( |
| 648 WebInputEvent::GesturePinchUpdate, time_ms / 1000.0, anchor_x, anchor_y, | 680 WebInputEvent::GesturePinchUpdate, time_ms, anchor_x, anchor_y); |
| 649 delta, delta, 0); | |
| 650 event.data.pinchUpdate.scale = delta; | 681 event.data.pinchUpdate.scale = delta; |
| 651 | 682 |
| 652 if (GetRenderWidgetHostViewAndroid()) | 683 if (GetRenderWidgetHostViewAndroid()) |
| 653 GetRenderWidgetHostViewAndroid()->SendGestureEvent(event); | 684 GetRenderWidgetHostViewAndroid()->SendGestureEvent(event); |
| 654 } | 685 } |
| 655 | 686 |
| 656 void ContentViewCoreImpl::SelectBetweenCoordinates(JNIEnv* env, jobject obj, | 687 void ContentViewCoreImpl::SelectBetweenCoordinates(JNIEnv* env, jobject obj, |
| 657 jint x1, jint y1, | 688 jint x1, jint y1, |
| 658 jint x2, jint y2) { | 689 jint x2, jint y2) { |
| 659 if (GetRenderWidgetHostViewAndroid()) { | 690 if (GetRenderWidgetHostViewAndroid()) { |
| (...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 880 if (!HasField(env, clazz, "mNativeContentViewCore", "I")) { | 911 if (!HasField(env, clazz, "mNativeContentViewCore", "I")) { |
| 881 DLOG(ERROR) << "Unable to find ContentView.mNativeContentViewCore!"; | 912 DLOG(ERROR) << "Unable to find ContentView.mNativeContentViewCore!"; |
| 882 return false; | 913 return false; |
| 883 } | 914 } |
| 884 g_native_content_view = GetFieldID(env, clazz, "mNativeContentViewCore", "I"); | 915 g_native_content_view = GetFieldID(env, clazz, "mNativeContentViewCore", "I"); |
| 885 | 916 |
| 886 return RegisterNativesImpl(env) >= 0; | 917 return RegisterNativesImpl(env) >= 0; |
| 887 } | 918 } |
| 888 | 919 |
| 889 } // namespace content | 920 } // namespace content |
| OLD | NEW |