| 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 15 matching lines...) Expand all Loading... |
| 26 #include "content/browser/media/android/browser_media_player_manager.h" | 26 #include "content/browser/media/android/browser_media_player_manager.h" |
| 27 #include "content/browser/renderer_host/compositor_impl_android.h" | 27 #include "content/browser/renderer_host/compositor_impl_android.h" |
| 28 #include "content/browser/renderer_host/input/web_input_event_builders_android.h
" | 28 #include "content/browser/renderer_host/input/web_input_event_builders_android.h
" |
| 29 #include "content/browser/renderer_host/java/java_bound_object.h" | 29 #include "content/browser/renderer_host/java/java_bound_object.h" |
| 30 #include "content/browser/renderer_host/java/java_bridge_dispatcher_host_manager
.h" | 30 #include "content/browser/renderer_host/java/java_bridge_dispatcher_host_manager
.h" |
| 31 #include "content/browser/renderer_host/render_view_host_impl.h" | 31 #include "content/browser/renderer_host/render_view_host_impl.h" |
| 32 #include "content/browser/renderer_host/render_widget_host_impl.h" | 32 #include "content/browser/renderer_host/render_widget_host_impl.h" |
| 33 #include "content/browser/renderer_host/render_widget_host_view_android.h" | 33 #include "content/browser/renderer_host/render_widget_host_view_android.h" |
| 34 #include "content/browser/ssl/ssl_host_state.h" | 34 #include "content/browser/ssl/ssl_host_state.h" |
| 35 #include "content/browser/web_contents/web_contents_view_android.h" | 35 #include "content/browser/web_contents/web_contents_view_android.h" |
| 36 #include "content/common/input/web_input_event_traits.h" |
| 36 #include "content/common/input_messages.h" | 37 #include "content/common/input_messages.h" |
| 37 #include "content/common/view_messages.h" | 38 #include "content/common/view_messages.h" |
| 38 #include "content/public/browser/browser_accessibility_state.h" | 39 #include "content/public/browser/browser_accessibility_state.h" |
| 39 #include "content/public/browser/browser_context.h" | 40 #include "content/public/browser/browser_context.h" |
| 40 #include "content/public/browser/favicon_status.h" | 41 #include "content/public/browser/favicon_status.h" |
| 41 #include "content/public/browser/notification_details.h" | 42 #include "content/public/browser/notification_details.h" |
| 42 #include "content/public/browser/notification_service.h" | 43 #include "content/public/browser/notification_service.h" |
| 43 #include "content/public/browser/notification_source.h" | 44 #include "content/public/browser/notification_source.h" |
| 44 #include "content/public/browser/notification_types.h" | 45 #include "content/public/browser/notification_types.h" |
| 45 #include "content/public/browser/web_contents.h" | 46 #include "content/public/browser/web_contents.h" |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 103 JNIEnv* env, | 104 JNIEnv* env, |
| 104 const gfx::Rect& rect) { | 105 const gfx::Rect& rect) { |
| 105 return ScopedJavaLocalRef<jobject>( | 106 return ScopedJavaLocalRef<jobject>( |
| 106 Java_ContentViewCore_createRect(env, | 107 Java_ContentViewCore_createRect(env, |
| 107 static_cast<int>(rect.x()), | 108 static_cast<int>(rect.x()), |
| 108 static_cast<int>(rect.y()), | 109 static_cast<int>(rect.y()), |
| 109 static_cast<int>(rect.right()), | 110 static_cast<int>(rect.right()), |
| 110 static_cast<int>(rect.bottom()))); | 111 static_cast<int>(rect.bottom()))); |
| 111 } | 112 } |
| 112 | 113 |
| 114 bool PossiblyTriggeredByTimeout(const WebGestureEvent& event) { |
| 115 switch (event.type) { |
| 116 case WebInputEvent::GestureShowPress: |
| 117 case WebInputEvent::GestureLongPress: |
| 118 return true; |
| 119 // On Android, a GestureTap may be sent after a certain timeout window |
| 120 // if there is no GestureDoubleTap follow-up. |
| 121 case WebInputEvent::GestureTap: |
| 122 return true; |
| 123 // On Android, a GestureTapCancel may be triggered by the loss of window |
| 124 // focus (e.g., following a GestureLongPress). |
| 125 case WebInputEvent::GestureTapCancel: |
| 126 return true; |
| 127 default: |
| 128 break; |
| 129 } |
| 130 return false; |
| 131 } |
| 132 |
| 133 GestureEventPacket::GestureSource |
| 134 ToGestureSource(const WebGestureEvent& event) { |
| 135 return PossiblyTriggeredByTimeout(event) ? GestureEventPacket::TOUCH_TIMEOUT |
| 136 : GestureEventPacket::SYNTHETIC; |
| 137 } |
| 138 |
| 139 int ToContentViewGestureHandlerType(WebInputEvent::Type type) { |
| 140 // These values should match exactly those in ContentViewGestureHandler. |
| 141 enum ContentViewGestureHandlerType { |
| 142 GESTURE_SHOW_PRESS = 0, |
| 143 GESTURE_DOUBLE_TAP = 1, |
| 144 GESTURE_SINGLE_TAP_UP = 2, |
| 145 GESTURE_SINGLE_TAP_CONFIRMED = 3, |
| 146 GESTURE_SINGLE_TAP_UNCONFIRMED = 4, |
| 147 GESTURE_LONG_PRESS = 5, |
| 148 GESTURE_SCROLL_START = 6, |
| 149 GESTURE_SCROLL_BY = 7, |
| 150 GESTURE_SCROLL_END = 8, |
| 151 GESTURE_FLING_START = 9, |
| 152 GESTURE_FLING_CANCEL = 10, |
| 153 GESTURE_PINCH_BEGIN = 11, |
| 154 GESTURE_PINCH_BY = 12, |
| 155 GESTURE_PINCH_END = 13, |
| 156 GESTURE_TAP_CANCEL = 14, |
| 157 GESTURE_LONG_TAP = 15, |
| 158 GESTURE_TAP_DOWN = 16 |
| 159 }; |
| 160 switch (type) { |
| 161 case WebInputEvent::GestureScrollBegin: |
| 162 return GESTURE_SCROLL_START; |
| 163 case WebInputEvent::GestureScrollEnd: |
| 164 return GESTURE_SCROLL_END; |
| 165 case WebInputEvent::GestureScrollUpdate: |
| 166 return GESTURE_SCROLL_BY; |
| 167 case WebInputEvent::GestureFlingStart: |
| 168 return GESTURE_FLING_START; |
| 169 case WebInputEvent::GestureFlingCancel: |
| 170 return GESTURE_FLING_CANCEL; |
| 171 case WebInputEvent::GestureShowPress: |
| 172 return GESTURE_SHOW_PRESS; |
| 173 case WebInputEvent::GestureTap: |
| 174 return GESTURE_SINGLE_TAP_CONFIRMED; |
| 175 case WebInputEvent::GestureTapUnconfirmed: |
| 176 return GESTURE_SINGLE_TAP_UNCONFIRMED; |
| 177 case WebInputEvent::GestureTapDown: |
| 178 return GESTURE_TAP_DOWN; |
| 179 case WebInputEvent::GestureTapCancel: |
| 180 return GESTURE_TAP_CANCEL; |
| 181 case WebInputEvent::GestureDoubleTap: |
| 182 return GESTURE_DOUBLE_TAP; |
| 183 case WebInputEvent::GestureLongPress: |
| 184 return GESTURE_LONG_PRESS; |
| 185 case WebInputEvent::GestureLongTap: |
| 186 return GESTURE_LONG_TAP; |
| 187 case WebInputEvent::GesturePinchBegin: |
| 188 return GESTURE_PINCH_BEGIN; |
| 189 case WebInputEvent::GesturePinchEnd: |
| 190 return GESTURE_PINCH_END; |
| 191 case WebInputEvent::GesturePinchUpdate: |
| 192 return GESTURE_PINCH_BY; |
| 193 case WebInputEvent::GestureTwoFingerTap: |
| 194 case WebInputEvent::GestureScrollUpdateWithoutPropagation: |
| 195 default: |
| 196 NOTREACHED() << "Invalid source gesture type: " |
| 197 << WebInputEventTraits::GetName(type); |
| 198 return -1; |
| 199 }; |
| 200 } |
| 201 |
| 113 } // namespace | 202 } // namespace |
| 114 | 203 |
| 115 // Enables a callback when the underlying WebContents is destroyed, to enable | 204 // Enables a callback when the underlying WebContents is destroyed, to enable |
| 116 // nulling the back-pointer. | 205 // nulling the back-pointer. |
| 117 class ContentViewCoreImpl::ContentViewUserData | 206 class ContentViewCoreImpl::ContentViewUserData |
| 118 : public base::SupportsUserData::Data { | 207 : public base::SupportsUserData::Data { |
| 119 public: | 208 public: |
| 120 explicit ContentViewUserData(ContentViewCoreImpl* content_view_core) | 209 explicit ContentViewUserData(ContentViewCoreImpl* content_view_core) |
| 121 : content_view_core_(content_view_core) { | 210 : content_view_core_(content_view_core) { |
| 122 } | 211 } |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 169 java_ref_(env, obj), | 258 java_ref_(env, obj), |
| 170 web_contents_(static_cast<WebContentsImpl*>(web_contents)), | 259 web_contents_(static_cast<WebContentsImpl*>(web_contents)), |
| 171 root_layer_(cc::Layer::Create()), | 260 root_layer_(cc::Layer::Create()), |
| 172 vsync_interval_(base::TimeDelta::FromMicroseconds( | 261 vsync_interval_(base::TimeDelta::FromMicroseconds( |
| 173 kDefaultVSyncIntervalMicros)), | 262 kDefaultVSyncIntervalMicros)), |
| 174 expected_browser_composite_time_(base::TimeDelta::FromMicroseconds( | 263 expected_browser_composite_time_(base::TimeDelta::FromMicroseconds( |
| 175 kDefaultVSyncIntervalMicros * kDefaultBrowserCompositeVSyncFraction)), | 264 kDefaultVSyncIntervalMicros * kDefaultBrowserCompositeVSyncFraction)), |
| 176 view_android_(view_android), | 265 view_android_(view_android), |
| 177 window_android_(window_android), | 266 window_android_(window_android), |
| 178 device_orientation_(0), | 267 device_orientation_(0), |
| 179 geolocation_needs_pause_(false) { | 268 geolocation_needs_pause_(false), |
| 269 gesture_event_queue_(this), |
| 270 handling_touch_event_(false) { |
| 180 CHECK(web_contents) << | 271 CHECK(web_contents) << |
| 181 "A ContentViewCoreImpl should be created with a valid WebContents."; | 272 "A ContentViewCoreImpl should be created with a valid WebContents."; |
| 182 | 273 |
| 183 const gfx::Display& display = | 274 const gfx::Display& display = |
| 184 gfx::Screen::GetNativeScreen()->GetPrimaryDisplay(); | 275 gfx::Screen::GetNativeScreen()->GetPrimaryDisplay(); |
| 185 dpi_scale_ = display.device_scale_factor(); | 276 dpi_scale_ = display.device_scale_factor(); |
| 186 | 277 |
| 187 // Currently, the only use case we have for overriding a user agent involves | 278 // Currently, the only use case we have for overriding a user agent involves |
| 188 // spoofing a desktop Linux user agent for "Request desktop site". | 279 // spoofing a desktop Linux user agent for "Request desktop site". |
| 189 // Automatically set it for all WebContents so that it is available when a | 280 // Automatically set it for all WebContents so that it is available when a |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 295 break; | 386 break; |
| 296 } | 387 } |
| 297 } | 388 } |
| 298 } | 389 } |
| 299 | 390 |
| 300 void ContentViewCoreImpl::RenderViewReady() { | 391 void ContentViewCoreImpl::RenderViewReady() { |
| 301 if (device_orientation_ != 0) | 392 if (device_orientation_ != 0) |
| 302 SendOrientationChangeEventInternal(); | 393 SendOrientationChangeEventInternal(); |
| 303 } | 394 } |
| 304 | 395 |
| 396 void ContentViewCoreImpl::ForwardGestureEvent( |
| 397 const blink::WebGestureEvent& event) { |
| 398 JNIEnv* env = AttachCurrentThread(); |
| 399 ScopedJavaLocalRef<jobject> j_obj = java_ref_.get(env); |
| 400 if (j_obj.is_null()) |
| 401 return; |
| 402 |
| 403 if (!Java_ContentViewCore_onForwardingGestureEvent( |
| 404 env, j_obj.obj(), |
| 405 ToContentViewGestureHandlerType(event.type), event.x, event.y)) |
| 406 return; |
| 407 |
| 408 RenderWidgetHostViewAndroid* rwhv = GetRenderWidgetHostViewAndroid(); |
| 409 if (rwhv) |
| 410 rwhv->SendGestureEvent(event); |
| 411 } |
| 412 |
| 305 RenderWidgetHostViewAndroid* | 413 RenderWidgetHostViewAndroid* |
| 306 ContentViewCoreImpl::GetRenderWidgetHostViewAndroid() { | 414 ContentViewCoreImpl::GetRenderWidgetHostViewAndroid() { |
| 307 RenderWidgetHostView* rwhv = NULL; | 415 RenderWidgetHostView* rwhv = NULL; |
| 308 if (web_contents_) { | 416 if (web_contents_) { |
| 309 rwhv = web_contents_->GetRenderWidgetHostView(); | 417 rwhv = web_contents_->GetRenderWidgetHostView(); |
| 310 if (web_contents_->ShowingInterstitialPage()) { | 418 if (web_contents_->ShowingInterstitialPage()) { |
| 311 rwhv = static_cast<InterstitialPageImpl*>( | 419 rwhv = static_cast<InterstitialPageImpl*>( |
| 312 web_contents_->GetInterstitialPage())-> | 420 web_contents_->GetInterstitialPage())-> |
| 313 GetRenderViewHost()->GetView(); | 421 GetRenderViewHost()->GetView(); |
| 314 } | 422 } |
| (...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 488 env->SetIntArrayRegion(enabled_array.obj(), i, 1, &enabled); | 596 env->SetIntArrayRegion(enabled_array.obj(), i, 1, &enabled); |
| 489 } | 597 } |
| 490 ScopedJavaLocalRef<jobjectArray> items_array( | 598 ScopedJavaLocalRef<jobjectArray> items_array( |
| 491 base::android::ToJavaArrayOfStrings(env, labels)); | 599 base::android::ToJavaArrayOfStrings(env, labels)); |
| 492 Java_ContentViewCore_showSelectPopup(env, j_obj.obj(), | 600 Java_ContentViewCore_showSelectPopup(env, j_obj.obj(), |
| 493 items_array.obj(), enabled_array.obj(), | 601 items_array.obj(), enabled_array.obj(), |
| 494 multiple, selected_array.obj()); | 602 multiple, selected_array.obj()); |
| 495 } | 603 } |
| 496 | 604 |
| 497 void ContentViewCoreImpl::ConfirmTouchEvent(InputEventAckState ack_result) { | 605 void ContentViewCoreImpl::ConfirmTouchEvent(InputEventAckState ack_result) { |
| 606 gesture_event_queue_.OnTouchEventAck(ack_result); |
| 607 } |
| 608 |
| 609 void ContentViewCoreImpl::OnUnhandledFlingStartEventAck(bool had_consumer, |
| 610 float vx, |
| 611 float vy) { |
| 498 JNIEnv* env = AttachCurrentThread(); | 612 JNIEnv* env = AttachCurrentThread(); |
| 499 ScopedJavaLocalRef<jobject> j_obj = java_ref_.get(env); | 613 ScopedJavaLocalRef<jobject> j_obj = java_ref_.get(env); |
| 500 if (j_obj.is_null()) | 614 if (j_obj.is_null()) |
| 501 return; | 615 return; |
| 502 Java_ContentViewCore_confirmTouchEvent(env, j_obj.obj(), | 616 Java_ContentViewCore_onUnhandledFlingStartEventAck(env, j_obj.obj(), |
| 503 static_cast<jint>(ack_result)); | 617 had_consumer, vx, vy); |
| 504 } | |
| 505 | |
| 506 void ContentViewCoreImpl::OnFlingStartEventAck(InputEventAckState ack_result) { | |
| 507 JNIEnv* env = AttachCurrentThread(); | |
| 508 ScopedJavaLocalRef<jobject> j_obj = java_ref_.get(env); | |
| 509 if (j_obj.is_null()) | |
| 510 return; | |
| 511 Java_ContentViewCore_onFlingStartEventAck(env, j_obj.obj(), | |
| 512 static_cast<jint>(ack_result)); | |
| 513 } | 618 } |
| 514 | 619 |
| 515 void ContentViewCoreImpl::OnScrollBeginEventAck() { | 620 void ContentViewCoreImpl::OnScrollBeginEventAck() { |
| 516 JNIEnv* env = AttachCurrentThread(); | 621 JNIEnv* env = AttachCurrentThread(); |
| 517 ScopedJavaLocalRef<jobject> j_obj = java_ref_.get(env); | 622 ScopedJavaLocalRef<jobject> j_obj = java_ref_.get(env); |
| 518 if (j_obj.is_null()) | 623 if (j_obj.is_null()) |
| 519 return; | 624 return; |
| 520 Java_ContentViewCore_onScrollBeginEventAck(env, j_obj.obj()); | 625 Java_ContentViewCore_onScrollBeginEventAck(env, j_obj.obj()); |
| 521 } | 626 } |
| 522 | 627 |
| 523 void ContentViewCoreImpl::OnScrollUpdateGestureConsumed() { | 628 void ContentViewCoreImpl::OnScrollUpdateGestureConsumed() { |
| 524 JNIEnv* env = AttachCurrentThread(); | 629 JNIEnv* env = AttachCurrentThread(); |
| 525 ScopedJavaLocalRef<jobject> j_obj = java_ref_.get(env); | 630 ScopedJavaLocalRef<jobject> j_obj = java_ref_.get(env); |
| 526 if (j_obj.is_null()) | 631 if (j_obj.is_null()) |
| 527 return; | 632 return; |
| 528 Java_ContentViewCore_onScrollUpdateGestureConsumed(env, j_obj.obj()); | 633 Java_ContentViewCore_onScrollUpdateGestureConsumed(env, j_obj.obj()); |
| 529 } | 634 } |
| 530 | 635 |
| 531 void ContentViewCoreImpl::OnScrollEndEventAck() { | 636 void ContentViewCoreImpl::OnScrollEndEventAck() { |
| 532 JNIEnv* env = AttachCurrentThread(); | 637 JNIEnv* env = AttachCurrentThread(); |
| 533 ScopedJavaLocalRef<jobject> j_obj = java_ref_.get(env); | 638 ScopedJavaLocalRef<jobject> j_obj = java_ref_.get(env); |
| 534 if (j_obj.is_null()) | 639 if (j_obj.is_null()) |
| 535 return; | 640 return; |
| 536 Java_ContentViewCore_onScrollEndEventAck(env, j_obj.obj()); | 641 Java_ContentViewCore_onScrollEndEventAck(env, j_obj.obj()); |
| 537 } | 642 } |
| 538 | 643 |
| 539 void ContentViewCoreImpl::HasTouchEventHandlers(bool need_touch_events) { | |
| 540 JNIEnv* env = AttachCurrentThread(); | |
| 541 ScopedJavaLocalRef<jobject> j_obj = java_ref_.get(env); | |
| 542 if (j_obj.is_null()) | |
| 543 return; | |
| 544 Java_ContentViewCore_hasTouchEventHandlers(env, | |
| 545 j_obj.obj(), | |
| 546 need_touch_events); | |
| 547 } | |
| 548 | |
| 549 bool ContentViewCoreImpl::HasFocus() { | 644 bool ContentViewCoreImpl::HasFocus() { |
| 550 JNIEnv* env = AttachCurrentThread(); | 645 JNIEnv* env = AttachCurrentThread(); |
| 551 ScopedJavaLocalRef<jobject> obj = java_ref_.get(env); | 646 ScopedJavaLocalRef<jobject> obj = java_ref_.get(env); |
| 552 if (obj.is_null()) | 647 if (obj.is_null()) |
| 553 return false; | 648 return false; |
| 554 return Java_ContentViewCore_hasFocus(env, obj.obj()); | 649 return Java_ContentViewCore_hasFocus(env, obj.obj()); |
| 555 } | 650 } |
| 556 | 651 |
| 557 void ContentViewCoreImpl::OnSelectionChanged(const std::string& text) { | 652 void ContentViewCoreImpl::OnSelectionChanged(const std::string& text) { |
| 558 JNIEnv* env = AttachCurrentThread(); | 653 JNIEnv* env = AttachCurrentThread(); |
| (...skipping 353 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 912 | 1007 |
| 913 void ContentViewCoreImpl::SendOrientationChangeEvent(JNIEnv* env, | 1008 void ContentViewCoreImpl::SendOrientationChangeEvent(JNIEnv* env, |
| 914 jobject obj, | 1009 jobject obj, |
| 915 jint orientation) { | 1010 jint orientation) { |
| 916 if (device_orientation_ != orientation) { | 1011 if (device_orientation_ != orientation) { |
| 917 device_orientation_ = orientation; | 1012 device_orientation_ = orientation; |
| 918 SendOrientationChangeEventInternal(); | 1013 SendOrientationChangeEventInternal(); |
| 919 } | 1014 } |
| 920 } | 1015 } |
| 921 | 1016 |
| 922 jboolean ContentViewCoreImpl::SendTouchEvent(JNIEnv* env, | 1017 void ContentViewCoreImpl::OnTouchEventHandlingBegin(JNIEnv* env, |
| 923 jobject obj, | 1018 jobject obj, |
| 924 jlong time_ms, | 1019 jlong time_ms, |
| 925 jint type, | 1020 jint type, |
| 926 jobjectArray pts) { | 1021 jobjectArray pts) { |
| 1022 DCHECK(!handling_touch_event_); |
| 1023 handling_touch_event_ = true; |
| 1024 |
| 1025 blink::WebTouchEvent event; |
| 1026 TouchPoint::BuildWebTouchEvent(env, type, time_ms, GetDpiScale(), pts, event); |
| 1027 pending_touch_event_ = event; |
| 1028 |
| 1029 pending_gesture_packet_ = GestureEventPacket::FromTouch(event); |
| 1030 } |
| 1031 |
| 1032 void ContentViewCoreImpl::OnTouchEventHandlingEnd(JNIEnv* env, jobject obj) { |
| 1033 DCHECK(handling_touch_event_); |
| 1034 handling_touch_event_ = false; |
| 1035 |
| 927 RenderWidgetHostViewAndroid* rwhv = GetRenderWidgetHostViewAndroid(); | 1036 RenderWidgetHostViewAndroid* rwhv = GetRenderWidgetHostViewAndroid(); |
| 928 if (rwhv) { | 1037 if (!rwhv) |
| 929 using blink::WebTouchEvent; | 1038 return; |
| 930 blink::WebTouchEvent event; | 1039 |
| 931 TouchPoint::BuildWebTouchEvent(env, type, time_ms, GetDpiScale(), pts, | 1040 // Note: Order is important here, as the touch may be ack'ed synchronously |
| 932 event); | 1041 gesture_event_queue_.OnGestureEventPacket(pending_gesture_packet_); |
| 933 rwhv->SendTouchEvent(event); | 1042 rwhv->SendTouchEvent(pending_touch_event_); |
| 934 return true; | |
| 935 } | |
| 936 return false; | |
| 937 } | 1043 } |
| 938 | 1044 |
| 939 float ContentViewCoreImpl::GetTouchPaddingDip() { | 1045 float ContentViewCoreImpl::GetTouchPaddingDip() { |
| 940 return 48.0f / GetDpiScale(); | 1046 return 48.0f / GetDpiScale(); |
| 941 } | 1047 } |
| 942 | 1048 |
| 943 float ContentViewCoreImpl::GetDpiScale() const { | 1049 float ContentViewCoreImpl::GetDpiScale() const { |
| 944 return dpi_scale_; | 1050 return dpi_scale_; |
| 945 } | 1051 } |
| 946 | 1052 |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 996 } | 1102 } |
| 997 | 1103 |
| 998 WebGestureEvent ContentViewCoreImpl::MakeGestureEvent( | 1104 WebGestureEvent ContentViewCoreImpl::MakeGestureEvent( |
| 999 WebInputEvent::Type type, int64 time_ms, float x, float y) const { | 1105 WebInputEvent::Type type, int64 time_ms, float x, float y) const { |
| 1000 return WebGestureEventBuilder::Build( | 1106 return WebGestureEventBuilder::Build( |
| 1001 type, time_ms / 1000.0, x / GetDpiScale(), y / GetDpiScale()); | 1107 type, time_ms / 1000.0, x / GetDpiScale(), y / GetDpiScale()); |
| 1002 } | 1108 } |
| 1003 | 1109 |
| 1004 void ContentViewCoreImpl::SendGestureEvent( | 1110 void ContentViewCoreImpl::SendGestureEvent( |
| 1005 const blink::WebGestureEvent& event) { | 1111 const blink::WebGestureEvent& event) { |
| 1006 RenderWidgetHostViewAndroid* rwhv = GetRenderWidgetHostViewAndroid(); | 1112 if (handling_touch_event_) { |
| 1007 if (rwhv) | 1113 pending_gesture_packet_.Push(event); |
| 1008 rwhv->SendGestureEvent(event); | 1114 return; |
| 1115 } |
| 1116 gesture_event_queue_.OnGestureEventPacket( |
| 1117 GestureEventPacket::FromGesture(ToGestureSource(event), event)); |
| 1118 } |
| 1119 |
| 1120 void ContentViewCoreImpl::SendSyntheticGestureEvent( |
| 1121 const blink::WebGestureEvent& event) { |
| 1122 gesture_event_queue_.OnGestureEventPacket( |
| 1123 GestureEventPacket::FromGesture(GestureEventPacket::SYNTHETIC, event)); |
| 1009 } | 1124 } |
| 1010 | 1125 |
| 1011 void ContentViewCoreImpl::ScrollBegin(JNIEnv* env, | 1126 void ContentViewCoreImpl::ScrollBegin(JNIEnv* env, |
| 1012 jobject obj, | 1127 jobject obj, |
| 1013 jlong time_ms, | 1128 jlong time_ms, |
| 1014 jfloat x, | 1129 jfloat x, |
| 1015 jfloat y, | 1130 jfloat y, |
| 1016 jfloat hintx, | 1131 jfloat hintx, |
| 1017 jfloat hinty) { | 1132 jfloat hinty) { |
| 1018 WebGestureEvent event = MakeGestureEvent( | 1133 WebGestureEvent event = MakeGestureEvent( |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1058 SendGestureEvent(event); | 1173 SendGestureEvent(event); |
| 1059 } | 1174 } |
| 1060 | 1175 |
| 1061 void ContentViewCoreImpl::SingleTap(JNIEnv* env, jobject obj, jlong time_ms, | 1176 void ContentViewCoreImpl::SingleTap(JNIEnv* env, jobject obj, jlong time_ms, |
| 1062 jfloat x, jfloat y, | 1177 jfloat x, jfloat y, |
| 1063 jboolean disambiguation_popup_tap) { | 1178 jboolean disambiguation_popup_tap) { |
| 1064 WebGestureEvent event = MakeGestureEvent( | 1179 WebGestureEvent event = MakeGestureEvent( |
| 1065 WebInputEvent::GestureTap, time_ms, x, y); | 1180 WebInputEvent::GestureTap, time_ms, x, y); |
| 1066 | 1181 |
| 1067 event.data.tap.tapCount = 1; | 1182 event.data.tap.tapCount = 1; |
| 1068 if (!disambiguation_popup_tap) { | 1183 if (disambiguation_popup_tap) { |
| 1069 const float touch_padding_dip = GetTouchPaddingDip(); | 1184 SendSyntheticGestureEvent(event); |
| 1070 event.data.tap.width = touch_padding_dip; | 1185 return; |
| 1071 event.data.tap.height = touch_padding_dip; | |
| 1072 } | 1186 } |
| 1073 | 1187 |
| 1188 const float touch_padding_dip = GetTouchPaddingDip(); |
| 1189 event.data.tap.width = touch_padding_dip; |
| 1190 event.data.tap.height = touch_padding_dip; |
| 1074 SendGestureEvent(event); | 1191 SendGestureEvent(event); |
| 1075 } | 1192 } |
| 1076 | 1193 |
| 1077 void ContentViewCoreImpl::SingleTapUnconfirmed(JNIEnv* env, jobject obj, | 1194 void ContentViewCoreImpl::SingleTapUnconfirmed(JNIEnv* env, jobject obj, |
| 1078 jlong time_ms, | 1195 jlong time_ms, |
| 1079 jfloat x, jfloat y) { | 1196 jfloat x, jfloat y) { |
| 1080 WebGestureEvent event = MakeGestureEvent( | 1197 WebGestureEvent event = MakeGestureEvent( |
| 1081 WebInputEvent::GestureTapUnconfirmed, time_ms, x, y); | 1198 WebInputEvent::GestureTapUnconfirmed, time_ms, x, y); |
| 1082 | 1199 |
| 1083 event.data.tap.tapCount = 1; | 1200 event.data.tap.tapCount = 1; |
| 1084 | 1201 |
| 1085 const float touch_padding_dip = GetTouchPaddingDip(); | 1202 const float touch_padding_dip = GetTouchPaddingDip(); |
| 1086 event.data.tap.width = touch_padding_dip; | 1203 event.data.tap.width = touch_padding_dip; |
| 1087 event.data.tap.height = touch_padding_dip; | 1204 event.data.tap.height = touch_padding_dip; |
| 1088 | 1205 |
| 1089 SendGestureEvent(event); | 1206 SendGestureEvent(event); |
| 1090 } | 1207 } |
| 1091 | 1208 |
| 1092 void ContentViewCoreImpl::ShowPressState(JNIEnv* env, jobject obj, | 1209 void ContentViewCoreImpl::ShowPress(JNIEnv* env, jobject obj, |
| 1093 jlong time_ms, | 1210 jlong time_ms, |
| 1094 jfloat x, jfloat y) { | 1211 jfloat x, jfloat y) { |
| 1095 WebGestureEvent event = MakeGestureEvent( | 1212 WebGestureEvent event = MakeGestureEvent( |
| 1096 WebInputEvent::GestureShowPress, time_ms, x, y); | 1213 WebInputEvent::GestureShowPress, time_ms, x, y); |
| 1097 SendGestureEvent(event); | 1214 SendGestureEvent(event); |
| 1098 } | 1215 } |
| 1099 | 1216 |
| 1100 void ContentViewCoreImpl::TapCancel(JNIEnv* env, | 1217 void ContentViewCoreImpl::TapCancel(JNIEnv* env, |
| 1101 jobject obj, | 1218 jobject obj, |
| 1102 jlong time_ms, | 1219 jlong time_ms, |
| 1103 jfloat x, | 1220 jfloat x, |
| 1104 jfloat y) { | 1221 jfloat y) { |
| (...skipping 16 matching lines...) Expand all Loading... |
| 1121 WebInputEvent::GestureDoubleTap, time_ms, x, y); | 1238 WebInputEvent::GestureDoubleTap, time_ms, x, y); |
| 1122 SendGestureEvent(event); | 1239 SendGestureEvent(event); |
| 1123 } | 1240 } |
| 1124 | 1241 |
| 1125 void ContentViewCoreImpl::LongPress(JNIEnv* env, jobject obj, jlong time_ms, | 1242 void ContentViewCoreImpl::LongPress(JNIEnv* env, jobject obj, jlong time_ms, |
| 1126 jfloat x, jfloat y, | 1243 jfloat x, jfloat y, |
| 1127 jboolean disambiguation_popup_tap) { | 1244 jboolean disambiguation_popup_tap) { |
| 1128 WebGestureEvent event = MakeGestureEvent( | 1245 WebGestureEvent event = MakeGestureEvent( |
| 1129 WebInputEvent::GestureLongPress, time_ms, x, y); | 1246 WebInputEvent::GestureLongPress, time_ms, x, y); |
| 1130 | 1247 |
| 1131 if (!disambiguation_popup_tap) { | 1248 if (disambiguation_popup_tap) { |
| 1132 const float touch_padding_dip = GetTouchPaddingDip(); | 1249 SendSyntheticGestureEvent(event); |
| 1133 event.data.longPress.width = touch_padding_dip; | 1250 return; |
| 1134 event.data.longPress.height = touch_padding_dip; | |
| 1135 } | 1251 } |
| 1136 | 1252 |
| 1253 const float touch_padding_dip = GetTouchPaddingDip(); |
| 1254 event.data.longPress.width = touch_padding_dip; |
| 1255 event.data.longPress.height = touch_padding_dip; |
| 1137 SendGestureEvent(event); | 1256 SendGestureEvent(event); |
| 1138 } | 1257 } |
| 1139 | 1258 |
| 1140 void ContentViewCoreImpl::LongTap(JNIEnv* env, jobject obj, jlong time_ms, | 1259 void ContentViewCoreImpl::LongTap(JNIEnv* env, jobject obj, jlong time_ms, |
| 1141 jfloat x, jfloat y, | 1260 jfloat x, jfloat y, |
| 1142 jboolean disambiguation_popup_tap) { | 1261 jboolean disambiguation_popup_tap) { |
| 1143 WebGestureEvent event = MakeGestureEvent( | 1262 WebGestureEvent event = MakeGestureEvent( |
| 1144 WebInputEvent::GestureLongTap, time_ms, x, y); | 1263 WebInputEvent::GestureLongTap, time_ms, x, y); |
| 1145 | 1264 |
| 1146 if (!disambiguation_popup_tap) { | 1265 if (disambiguation_popup_tap) { |
| 1147 const float touch_padding_dip = GetTouchPaddingDip(); | 1266 SendSyntheticGestureEvent(event); |
| 1148 event.data.longPress.width = touch_padding_dip; | 1267 return; |
| 1149 event.data.longPress.height = touch_padding_dip; | |
| 1150 } | 1268 } |
| 1151 | 1269 |
| 1270 const float touch_padding_dip = GetTouchPaddingDip(); |
| 1271 event.data.longPress.width = touch_padding_dip; |
| 1272 event.data.longPress.height = touch_padding_dip; |
| 1152 SendGestureEvent(event); | 1273 SendGestureEvent(event); |
| 1153 } | 1274 } |
| 1154 | 1275 |
| 1155 void ContentViewCoreImpl::PinchBegin(JNIEnv* env, jobject obj, jlong time_ms, | 1276 void ContentViewCoreImpl::PinchBegin(JNIEnv* env, jobject obj, jlong time_ms, |
| 1156 jfloat x, jfloat y) { | 1277 jfloat x, jfloat y) { |
| 1157 WebGestureEvent event = MakeGestureEvent( | 1278 WebGestureEvent event = MakeGestureEvent( |
| 1158 WebInputEvent::GesturePinchBegin, time_ms, x, y); | 1279 WebInputEvent::GesturePinchBegin, time_ms, x, y); |
| 1159 SendGestureEvent(event); | 1280 SendGestureEvent(event); |
| 1160 } | 1281 } |
| 1161 | 1282 |
| (...skipping 543 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1705 reinterpret_cast<ui::ViewAndroid*>(view_android), | 1826 reinterpret_cast<ui::ViewAndroid*>(view_android), |
| 1706 reinterpret_cast<ui::WindowAndroid*>(window_android)); | 1827 reinterpret_cast<ui::WindowAndroid*>(window_android)); |
| 1707 return reinterpret_cast<intptr_t>(view); | 1828 return reinterpret_cast<intptr_t>(view); |
| 1708 } | 1829 } |
| 1709 | 1830 |
| 1710 bool RegisterContentViewCore(JNIEnv* env) { | 1831 bool RegisterContentViewCore(JNIEnv* env) { |
| 1711 return RegisterNativesImpl(env); | 1832 return RegisterNativesImpl(env); |
| 1712 } | 1833 } |
| 1713 | 1834 |
| 1714 } // namespace content | 1835 } // namespace content |
| OLD | NEW |