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