Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(78)

Side by Side Diff: content/browser/android/content_view_core_impl.cc

Issue 120513005: [Android] Perform eager gesture recognition on MotionEvents (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Undo some changes Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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
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 PossiblyTriggeredByTouchTimeout(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 int ToContentViewGestureHandlerType(WebInputEvent::Type type) {
134 // These values should match exactly those in ContentViewGestureHandler.
135 enum ContentViewGestureHandlerType {
136 GESTURE_SHOW_PRESS = 0,
137 GESTURE_DOUBLE_TAP = 1,
138 GESTURE_SINGLE_TAP_UP = 2,
139 GESTURE_SINGLE_TAP_CONFIRMED = 3,
140 GESTURE_SINGLE_TAP_UNCONFIRMED = 4,
141 GESTURE_LONG_PRESS = 5,
142 GESTURE_SCROLL_START = 6,
143 GESTURE_SCROLL_BY = 7,
144 GESTURE_SCROLL_END = 8,
145 GESTURE_FLING_START = 9,
146 GESTURE_FLING_CANCEL = 10,
147 GESTURE_PINCH_BEGIN = 11,
148 GESTURE_PINCH_BY = 12,
149 GESTURE_PINCH_END = 13,
150 GESTURE_TAP_CANCEL = 14,
151 GESTURE_LONG_TAP = 15,
152 GESTURE_TAP_DOWN = 16
153 };
154 switch (type) {
155 case WebInputEvent::GestureScrollBegin:
156 return GESTURE_SCROLL_START;
157 case WebInputEvent::GestureScrollEnd:
158 return GESTURE_SCROLL_END;
159 case WebInputEvent::GestureScrollUpdate:
160 return GESTURE_SCROLL_BY;
161 case WebInputEvent::GestureFlingStart:
162 return GESTURE_FLING_START;
163 case WebInputEvent::GestureFlingCancel:
164 return GESTURE_FLING_CANCEL;
165 case WebInputEvent::GestureShowPress:
166 return GESTURE_SHOW_PRESS;
167 case WebInputEvent::GestureTap:
168 return GESTURE_SINGLE_TAP_CONFIRMED;
169 case WebInputEvent::GestureTapUnconfirmed:
170 return GESTURE_SINGLE_TAP_UNCONFIRMED;
171 case WebInputEvent::GestureTapDown:
172 return GESTURE_TAP_DOWN;
173 case WebInputEvent::GestureTapCancel:
174 return GESTURE_TAP_CANCEL;
175 case WebInputEvent::GestureDoubleTap:
176 return GESTURE_DOUBLE_TAP;
177 case WebInputEvent::GestureLongPress:
178 return GESTURE_LONG_PRESS;
179 case WebInputEvent::GestureLongTap:
180 return GESTURE_LONG_TAP;
181 case WebInputEvent::GesturePinchBegin:
182 return GESTURE_PINCH_BEGIN;
183 case WebInputEvent::GesturePinchEnd:
184 return GESTURE_PINCH_END;
185 case WebInputEvent::GesturePinchUpdate:
186 return GESTURE_PINCH_BY;
187 case WebInputEvent::GestureTwoFingerTap:
188 case WebInputEvent::GestureScrollUpdateWithoutPropagation:
189 default:
190 NOTREACHED() << "Invalid source gesture type: "
191 << WebInputEventTraits::GetName(type);
192 return -1;
193 };
194 }
195
113 } // namespace 196 } // namespace
114 197
115 // Enables a callback when the underlying WebContents is destroyed, to enable 198 // Enables a callback when the underlying WebContents is destroyed, to enable
116 // nulling the back-pointer. 199 // nulling the back-pointer.
117 class ContentViewCoreImpl::ContentViewUserData 200 class ContentViewCoreImpl::ContentViewUserData
118 : public base::SupportsUserData::Data { 201 : public base::SupportsUserData::Data {
119 public: 202 public:
120 explicit ContentViewUserData(ContentViewCoreImpl* content_view_core) 203 explicit ContentViewUserData(ContentViewCoreImpl* content_view_core)
121 : content_view_core_(content_view_core) { 204 : content_view_core_(content_view_core) {
122 } 205 }
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
169 java_ref_(env, obj), 252 java_ref_(env, obj),
170 web_contents_(static_cast<WebContentsImpl*>(web_contents)), 253 web_contents_(static_cast<WebContentsImpl*>(web_contents)),
171 root_layer_(cc::Layer::Create()), 254 root_layer_(cc::Layer::Create()),
172 vsync_interval_(base::TimeDelta::FromMicroseconds( 255 vsync_interval_(base::TimeDelta::FromMicroseconds(
173 kDefaultVSyncIntervalMicros)), 256 kDefaultVSyncIntervalMicros)),
174 expected_browser_composite_time_(base::TimeDelta::FromMicroseconds( 257 expected_browser_composite_time_(base::TimeDelta::FromMicroseconds(
175 kDefaultVSyncIntervalMicros * kDefaultBrowserCompositeVSyncFraction)), 258 kDefaultVSyncIntervalMicros * kDefaultBrowserCompositeVSyncFraction)),
176 view_android_(view_android), 259 view_android_(view_android),
177 window_android_(window_android), 260 window_android_(window_android),
178 device_orientation_(0), 261 device_orientation_(0),
179 geolocation_needs_pause_(false) { 262 geolocation_needs_pause_(false),
263 gesture_event_queue_(this),
264 handling_touch_event_(false) {
180 CHECK(web_contents) << 265 CHECK(web_contents) <<
181 "A ContentViewCoreImpl should be created with a valid WebContents."; 266 "A ContentViewCoreImpl should be created with a valid WebContents.";
182 267
183 const gfx::Display& display = 268 const gfx::Display& display =
184 gfx::Screen::GetNativeScreen()->GetPrimaryDisplay(); 269 gfx::Screen::GetNativeScreen()->GetPrimaryDisplay();
185 dpi_scale_ = display.device_scale_factor(); 270 dpi_scale_ = display.device_scale_factor();
186 271
187 // Currently, the only use case we have for overriding a user agent involves 272 // Currently, the only use case we have for overriding a user agent involves
188 // spoofing a desktop Linux user agent for "Request desktop site". 273 // spoofing a desktop Linux user agent for "Request desktop site".
189 // Automatically set it for all WebContents so that it is available when a 274 // 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
295 break; 380 break;
296 } 381 }
297 } 382 }
298 } 383 }
299 384
300 void ContentViewCoreImpl::RenderViewReady() { 385 void ContentViewCoreImpl::RenderViewReady() {
301 if (device_orientation_ != 0) 386 if (device_orientation_ != 0)
302 SendOrientationChangeEventInternal(); 387 SendOrientationChangeEventInternal();
303 } 388 }
304 389
390 void ContentViewCoreImpl::ForwardGestureEvent(
391 const blink::WebGestureEvent& event) {
392 JNIEnv* env = AttachCurrentThread();
393 ScopedJavaLocalRef<jobject> j_obj = java_ref_.get(env);
394 if (j_obj.is_null())
395 return;
396
397 if (!Java_ContentViewCore_onForwardingGestureEvent(
398 env, j_obj.obj(),
Ted C 2014/01/30 02:29:48 should only be indented 4 right?
jdduke (slow) 2014/01/30 18:46:24 Done.
399 ToContentViewGestureHandlerType(event.type), event.x, event.y))
400 return;
401
402 RenderWidgetHostViewAndroid* rwhv = GetRenderWidgetHostViewAndroid();
403 if (rwhv)
404 rwhv->SendGestureEvent(event);
405 }
406
305 RenderWidgetHostViewAndroid* 407 RenderWidgetHostViewAndroid*
306 ContentViewCoreImpl::GetRenderWidgetHostViewAndroid() { 408 ContentViewCoreImpl::GetRenderWidgetHostViewAndroid() {
307 RenderWidgetHostView* rwhv = NULL; 409 RenderWidgetHostView* rwhv = NULL;
308 if (web_contents_) { 410 if (web_contents_) {
309 rwhv = web_contents_->GetRenderWidgetHostView(); 411 rwhv = web_contents_->GetRenderWidgetHostView();
310 if (web_contents_->ShowingInterstitialPage()) { 412 if (web_contents_->ShowingInterstitialPage()) {
311 rwhv = static_cast<InterstitialPageImpl*>( 413 rwhv = static_cast<InterstitialPageImpl*>(
312 web_contents_->GetInterstitialPage())-> 414 web_contents_->GetInterstitialPage())->
313 GetRenderViewHost()->GetView(); 415 GetRenderViewHost()->GetView();
314 } 416 }
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after
488 env->SetIntArrayRegion(enabled_array.obj(), i, 1, &enabled); 590 env->SetIntArrayRegion(enabled_array.obj(), i, 1, &enabled);
489 } 591 }
490 ScopedJavaLocalRef<jobjectArray> items_array( 592 ScopedJavaLocalRef<jobjectArray> items_array(
491 base::android::ToJavaArrayOfStrings(env, labels)); 593 base::android::ToJavaArrayOfStrings(env, labels));
492 Java_ContentViewCore_showSelectPopup(env, j_obj.obj(), 594 Java_ContentViewCore_showSelectPopup(env, j_obj.obj(),
493 items_array.obj(), enabled_array.obj(), 595 items_array.obj(), enabled_array.obj(),
494 multiple, selected_array.obj()); 596 multiple, selected_array.obj());
495 } 597 }
496 598
497 void ContentViewCoreImpl::ConfirmTouchEvent(InputEventAckState ack_result) { 599 void ContentViewCoreImpl::ConfirmTouchEvent(InputEventAckState ack_result) {
498 JNIEnv* env = AttachCurrentThread(); 600 gesture_event_queue_.OnTouchEventAck(ack_result);
499 ScopedJavaLocalRef<jobject> j_obj = java_ref_.get(env);
500 if (j_obj.is_null())
501 return;
502 Java_ContentViewCore_confirmTouchEvent(env, j_obj.obj(),
503 static_cast<jint>(ack_result));
504 } 601 }
505 602
506 void ContentViewCoreImpl::OnFlingStartEventAck(InputEventAckState ack_result) { 603 void ContentViewCoreImpl::OnFlingStartEventAck(InputEventAckState ack_result,
604 float vx,
605 float vy) {
507 JNIEnv* env = AttachCurrentThread(); 606 JNIEnv* env = AttachCurrentThread();
508 ScopedJavaLocalRef<jobject> j_obj = java_ref_.get(env); 607 ScopedJavaLocalRef<jobject> j_obj = java_ref_.get(env);
509 if (j_obj.is_null()) 608 if (j_obj.is_null())
510 return; 609 return;
511 Java_ContentViewCore_onFlingStartEventAck(env, j_obj.obj(), 610 Java_ContentViewCore_onFlingStartEventAck(env, j_obj.obj(),
512 static_cast<jint>(ack_result)); 611 static_cast<int>(ack_result),
612 vx, vy);
513 } 613 }
514 614
515 void ContentViewCoreImpl::OnScrollBeginEventAck() { 615 void ContentViewCoreImpl::OnScrollBeginEventAck() {
516 JNIEnv* env = AttachCurrentThread(); 616 JNIEnv* env = AttachCurrentThread();
517 ScopedJavaLocalRef<jobject> j_obj = java_ref_.get(env); 617 ScopedJavaLocalRef<jobject> j_obj = java_ref_.get(env);
518 if (j_obj.is_null()) 618 if (j_obj.is_null())
519 return; 619 return;
520 Java_ContentViewCore_onScrollBeginEventAck(env, j_obj.obj()); 620 Java_ContentViewCore_onScrollBeginEventAck(env, j_obj.obj());
521 } 621 }
522 622
523 void ContentViewCoreImpl::OnScrollUpdateGestureConsumed() { 623 void ContentViewCoreImpl::OnScrollUpdateGestureConsumed() {
524 JNIEnv* env = AttachCurrentThread(); 624 JNIEnv* env = AttachCurrentThread();
525 ScopedJavaLocalRef<jobject> j_obj = java_ref_.get(env); 625 ScopedJavaLocalRef<jobject> j_obj = java_ref_.get(env);
526 if (j_obj.is_null()) 626 if (j_obj.is_null())
527 return; 627 return;
528 Java_ContentViewCore_onScrollUpdateGestureConsumed(env, j_obj.obj()); 628 Java_ContentViewCore_onScrollUpdateGestureConsumed(env, j_obj.obj());
529 } 629 }
530 630
531 void ContentViewCoreImpl::OnScrollEndEventAck() { 631 void ContentViewCoreImpl::OnScrollEndEventAck() {
532 JNIEnv* env = AttachCurrentThread(); 632 JNIEnv* env = AttachCurrentThread();
533 ScopedJavaLocalRef<jobject> j_obj = java_ref_.get(env); 633 ScopedJavaLocalRef<jobject> j_obj = java_ref_.get(env);
534 if (j_obj.is_null()) 634 if (j_obj.is_null())
535 return; 635 return;
536 Java_ContentViewCore_onScrollEndEventAck(env, j_obj.obj()); 636 Java_ContentViewCore_onScrollEndEventAck(env, j_obj.obj());
537 } 637 }
538 638
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() { 639 bool ContentViewCoreImpl::HasFocus() {
550 JNIEnv* env = AttachCurrentThread(); 640 JNIEnv* env = AttachCurrentThread();
551 ScopedJavaLocalRef<jobject> obj = java_ref_.get(env); 641 ScopedJavaLocalRef<jobject> obj = java_ref_.get(env);
552 if (obj.is_null()) 642 if (obj.is_null())
553 return false; 643 return false;
554 return Java_ContentViewCore_hasFocus(env, obj.obj()); 644 return Java_ContentViewCore_hasFocus(env, obj.obj());
555 } 645 }
556 646
557 void ContentViewCoreImpl::OnSelectionChanged(const std::string& text) { 647 void ContentViewCoreImpl::OnSelectionChanged(const std::string& text) {
558 JNIEnv* env = AttachCurrentThread(); 648 JNIEnv* env = AttachCurrentThread();
(...skipping 353 matching lines...) Expand 10 before | Expand all | Expand 10 after
912 1002
913 void ContentViewCoreImpl::SendOrientationChangeEvent(JNIEnv* env, 1003 void ContentViewCoreImpl::SendOrientationChangeEvent(JNIEnv* env,
914 jobject obj, 1004 jobject obj,
915 jint orientation) { 1005 jint orientation) {
916 if (device_orientation_ != orientation) { 1006 if (device_orientation_ != orientation) {
917 device_orientation_ = orientation; 1007 device_orientation_ = orientation;
918 SendOrientationChangeEventInternal(); 1008 SendOrientationChangeEventInternal();
919 } 1009 }
920 } 1010 }
921 1011
922 jboolean ContentViewCoreImpl::SendTouchEvent(JNIEnv* env, 1012 void ContentViewCoreImpl::OnTouchEventHandlingBegin(JNIEnv* env,
923 jobject obj, 1013 jobject obj,
924 jlong time_ms, 1014 jlong time_ms,
925 jint type, 1015 jint type,
926 jobjectArray pts) { 1016 jobjectArray pts) {
1017 DCHECK(!handling_touch_event_);
1018 handling_touch_event_ = true;
1019
1020 blink::WebTouchEvent event;
1021 TouchPoint::BuildWebTouchEvent(env, type, time_ms, GetDpiScale(), pts, event);
1022 pending_touch_event_ = event;
1023
1024 pending_gesture_packet_ = GestureEventPacket::FromTouch(event);
1025 }
1026
1027 void ContentViewCoreImpl::OnTouchEventHandlingEnd(JNIEnv* env, jobject obj) {
1028 DCHECK(handling_touch_event_);
1029 handling_touch_event_ = false;
1030
927 RenderWidgetHostViewAndroid* rwhv = GetRenderWidgetHostViewAndroid(); 1031 RenderWidgetHostViewAndroid* rwhv = GetRenderWidgetHostViewAndroid();
928 if (rwhv) { 1032 if (!rwhv)
929 using blink::WebTouchEvent; 1033 return;
930 blink::WebTouchEvent event; 1034
931 TouchPoint::BuildWebTouchEvent(env, type, time_ms, GetDpiScale(), pts, 1035 // Note: Order is important here, as the touch may be ack'ed synchronously
932 event); 1036 gesture_event_queue_.OnGestureEventPacket(pending_gesture_packet_);
933 rwhv->SendTouchEvent(event); 1037 rwhv->SendTouchEvent(pending_touch_event_);
934 return true;
935 }
936 return false;
937 } 1038 }
938 1039
939 float ContentViewCoreImpl::GetTouchPaddingDip() { 1040 float ContentViewCoreImpl::GetTouchPaddingDip() {
940 return 48.0f / GetDpiScale(); 1041 return 48.0f / GetDpiScale();
941 } 1042 }
942 1043
943 float ContentViewCoreImpl::GetDpiScale() const { 1044 float ContentViewCoreImpl::GetDpiScale() const {
944 return dpi_scale_; 1045 return dpi_scale_;
945 } 1046 }
946 1047
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
996 } 1097 }
997 1098
998 WebGestureEvent ContentViewCoreImpl::MakeGestureEvent( 1099 WebGestureEvent ContentViewCoreImpl::MakeGestureEvent(
999 WebInputEvent::Type type, int64 time_ms, float x, float y) const { 1100 WebInputEvent::Type type, int64 time_ms, float x, float y) const {
1000 return WebGestureEventBuilder::Build( 1101 return WebGestureEventBuilder::Build(
1001 type, time_ms / 1000.0, x / GetDpiScale(), y / GetDpiScale()); 1102 type, time_ms / 1000.0, x / GetDpiScale(), y / GetDpiScale());
1002 } 1103 }
1003 1104
1004 void ContentViewCoreImpl::SendGestureEvent( 1105 void ContentViewCoreImpl::SendGestureEvent(
1005 const blink::WebGestureEvent& event) { 1106 const blink::WebGestureEvent& event) {
1006 RenderWidgetHostViewAndroid* rwhv = GetRenderWidgetHostViewAndroid(); 1107 // Gestures received while |handling_touch_event_| will accumulate until
1007 if (rwhv) 1108 // touch handling finishes, at which point the gestures will be pushed to the
1008 rwhv->SendGestureEvent(event); 1109 // |gesture_event_queue_|.
1110 if (handling_touch_event_) {
1111 pending_gesture_packet_.Push(event);
1112 return;
1113 }
1114
1115 // TODO(jdduke): In general, timeout-based gestures *should* have the same
1116 // timestamp as the initial TouchStart of the current sequence. We should
1117 // verify that this is true, and use that as another timeout check.
1118 if (PossiblyTriggeredByTouchTimeout(event)) {
1119 gesture_event_queue_.OnGestureEventPacket(
1120 GestureEventPacket::FromTouchTimeout(event));
1121 return;
1122 }
1123
1124 // If |event| was not (directly or indirectly) touch-derived, treat it as
1125 // a synthetic gesture event.
1126 SendSyntheticGestureEvent(event);
1127 }
1128
1129 void ContentViewCoreImpl::SendSyntheticGestureEvent(
1130 const blink::WebGestureEvent& event) {
1131 // Synthetic gestures (e.g., those not generated directly by touches
1132 // for which we expect an ack), should be forwarded directly.
1133 ForwardGestureEvent(event);
1009 } 1134 }
1010 1135
1011 void ContentViewCoreImpl::ScrollBegin(JNIEnv* env, 1136 void ContentViewCoreImpl::ScrollBegin(JNIEnv* env,
1012 jobject obj, 1137 jobject obj,
1013 jlong time_ms, 1138 jlong time_ms,
1014 jfloat x, 1139 jfloat x,
1015 jfloat y, 1140 jfloat y,
1016 jfloat hintx, 1141 jfloat hintx,
1017 jfloat hinty) { 1142 jfloat hinty) {
1018 WebGestureEvent event = MakeGestureEvent( 1143 WebGestureEvent event = MakeGestureEvent(
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
1058 SendGestureEvent(event); 1183 SendGestureEvent(event);
1059 } 1184 }
1060 1185
1061 void ContentViewCoreImpl::SingleTap(JNIEnv* env, jobject obj, jlong time_ms, 1186 void ContentViewCoreImpl::SingleTap(JNIEnv* env, jobject obj, jlong time_ms,
1062 jfloat x, jfloat y, 1187 jfloat x, jfloat y,
1063 jboolean disambiguation_popup_tap) { 1188 jboolean disambiguation_popup_tap) {
1064 WebGestureEvent event = MakeGestureEvent( 1189 WebGestureEvent event = MakeGestureEvent(
1065 WebInputEvent::GestureTap, time_ms, x, y); 1190 WebInputEvent::GestureTap, time_ms, x, y);
1066 1191
1067 event.data.tap.tapCount = 1; 1192 event.data.tap.tapCount = 1;
1068 if (!disambiguation_popup_tap) { 1193
1069 const float touch_padding_dip = GetTouchPaddingDip(); 1194 // Disambiguation popup gestures are treated as synthetic because their
1070 event.data.tap.width = touch_padding_dip; 1195 // generating touches were never forwarded to the renderer.
1071 event.data.tap.height = touch_padding_dip; 1196 if (disambiguation_popup_tap) {
1197 SendSyntheticGestureEvent(event);
1198 return;
1072 } 1199 }
1073 1200
1201 const float touch_padding_dip = GetTouchPaddingDip();
1202 event.data.tap.width = touch_padding_dip;
1203 event.data.tap.height = touch_padding_dip;
1074 SendGestureEvent(event); 1204 SendGestureEvent(event);
1075 } 1205 }
1076 1206
1077 void ContentViewCoreImpl::SingleTapUnconfirmed(JNIEnv* env, jobject obj, 1207 void ContentViewCoreImpl::SingleTapUnconfirmed(JNIEnv* env, jobject obj,
1078 jlong time_ms, 1208 jlong time_ms,
1079 jfloat x, jfloat y) { 1209 jfloat x, jfloat y) {
1080 WebGestureEvent event = MakeGestureEvent( 1210 WebGestureEvent event = MakeGestureEvent(
1081 WebInputEvent::GestureTapUnconfirmed, time_ms, x, y); 1211 WebInputEvent::GestureTapUnconfirmed, time_ms, x, y);
1082 1212
1083 event.data.tap.tapCount = 1; 1213 event.data.tap.tapCount = 1;
1084 1214
1085 const float touch_padding_dip = GetTouchPaddingDip(); 1215 const float touch_padding_dip = GetTouchPaddingDip();
1086 event.data.tap.width = touch_padding_dip; 1216 event.data.tap.width = touch_padding_dip;
1087 event.data.tap.height = touch_padding_dip; 1217 event.data.tap.height = touch_padding_dip;
1088 1218
1089 SendGestureEvent(event); 1219 SendGestureEvent(event);
1090 } 1220 }
1091 1221
1092 void ContentViewCoreImpl::ShowPressState(JNIEnv* env, jobject obj, 1222 void ContentViewCoreImpl::ShowPress(JNIEnv* env, jobject obj,
1093 jlong time_ms, 1223 jlong time_ms,
1094 jfloat x, jfloat y) { 1224 jfloat x, jfloat y) {
1095 WebGestureEvent event = MakeGestureEvent( 1225 WebGestureEvent event = MakeGestureEvent(
1096 WebInputEvent::GestureShowPress, time_ms, x, y); 1226 WebInputEvent::GestureShowPress, time_ms, x, y);
1097 SendGestureEvent(event); 1227 SendGestureEvent(event);
1098 } 1228 }
1099 1229
1100 void ContentViewCoreImpl::TapCancel(JNIEnv* env, 1230 void ContentViewCoreImpl::TapCancel(JNIEnv* env,
1101 jobject obj, 1231 jobject obj,
1102 jlong time_ms, 1232 jlong time_ms,
1103 jfloat x, 1233 jfloat x,
1104 jfloat y) { 1234 jfloat y) {
(...skipping 16 matching lines...) Expand all
1121 WebInputEvent::GestureDoubleTap, time_ms, x, y); 1251 WebInputEvent::GestureDoubleTap, time_ms, x, y);
1122 SendGestureEvent(event); 1252 SendGestureEvent(event);
1123 } 1253 }
1124 1254
1125 void ContentViewCoreImpl::LongPress(JNIEnv* env, jobject obj, jlong time_ms, 1255 void ContentViewCoreImpl::LongPress(JNIEnv* env, jobject obj, jlong time_ms,
1126 jfloat x, jfloat y, 1256 jfloat x, jfloat y,
1127 jboolean disambiguation_popup_tap) { 1257 jboolean disambiguation_popup_tap) {
1128 WebGestureEvent event = MakeGestureEvent( 1258 WebGestureEvent event = MakeGestureEvent(
1129 WebInputEvent::GestureLongPress, time_ms, x, y); 1259 WebInputEvent::GestureLongPress, time_ms, x, y);
1130 1260
1131 if (!disambiguation_popup_tap) { 1261 // Disambiguation popup gestures are treated as synthetic because their
1132 const float touch_padding_dip = GetTouchPaddingDip(); 1262 // generating touches were never forwarded to the renderer.
1133 event.data.longPress.width = touch_padding_dip; 1263 if (disambiguation_popup_tap) {
1134 event.data.longPress.height = touch_padding_dip; 1264 SendSyntheticGestureEvent(event);
1265 return;
1135 } 1266 }
1136 1267
1268 const float touch_padding_dip = GetTouchPaddingDip();
1269 event.data.longPress.width = touch_padding_dip;
1270 event.data.longPress.height = touch_padding_dip;
1137 SendGestureEvent(event); 1271 SendGestureEvent(event);
1138 } 1272 }
1139 1273
1140 void ContentViewCoreImpl::LongTap(JNIEnv* env, jobject obj, jlong time_ms, 1274 void ContentViewCoreImpl::LongTap(JNIEnv* env, jobject obj, jlong time_ms,
1141 jfloat x, jfloat y, 1275 jfloat x, jfloat y,
1142 jboolean disambiguation_popup_tap) { 1276 jboolean disambiguation_popup_tap) {
1143 WebGestureEvent event = MakeGestureEvent( 1277 WebGestureEvent event = MakeGestureEvent(
1144 WebInputEvent::GestureLongTap, time_ms, x, y); 1278 WebInputEvent::GestureLongTap, time_ms, x, y);
1145 1279
1146 if (!disambiguation_popup_tap) { 1280 // Disambiguation popup gestures are treated as synthetic because their
1147 const float touch_padding_dip = GetTouchPaddingDip(); 1281 // generating touches were never forwarded to the renderer.
1148 event.data.longPress.width = touch_padding_dip; 1282 if (disambiguation_popup_tap) {
1149 event.data.longPress.height = touch_padding_dip; 1283 SendSyntheticGestureEvent(event);
1284 return;
1150 } 1285 }
1151 1286
1287 const float touch_padding_dip = GetTouchPaddingDip();
1288 event.data.longPress.width = touch_padding_dip;
1289 event.data.longPress.height = touch_padding_dip;
1152 SendGestureEvent(event); 1290 SendGestureEvent(event);
1153 } 1291 }
1154 1292
1155 void ContentViewCoreImpl::PinchBegin(JNIEnv* env, jobject obj, jlong time_ms, 1293 void ContentViewCoreImpl::PinchBegin(JNIEnv* env, jobject obj, jlong time_ms,
1156 jfloat x, jfloat y) { 1294 jfloat x, jfloat y) {
1157 WebGestureEvent event = MakeGestureEvent( 1295 WebGestureEvent event = MakeGestureEvent(
1158 WebInputEvent::GesturePinchBegin, time_ms, x, y); 1296 WebInputEvent::GesturePinchBegin, time_ms, x, y);
1159 SendGestureEvent(event); 1297 SendGestureEvent(event);
1160 } 1298 }
1161 1299
(...skipping 543 matching lines...) Expand 10 before | Expand all | Expand 10 after
1705 reinterpret_cast<ui::ViewAndroid*>(view_android), 1843 reinterpret_cast<ui::ViewAndroid*>(view_android),
1706 reinterpret_cast<ui::WindowAndroid*>(window_android)); 1844 reinterpret_cast<ui::WindowAndroid*>(window_android));
1707 return reinterpret_cast<intptr_t>(view); 1845 return reinterpret_cast<intptr_t>(view);
1708 } 1846 }
1709 1847
1710 bool RegisterContentViewCore(JNIEnv* env) { 1848 bool RegisterContentViewCore(JNIEnv* env) {
1711 return RegisterNativesImpl(env); 1849 return RegisterNativesImpl(env);
1712 } 1850 }
1713 1851
1714 } // namespace content 1852 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698