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

Side by Side Diff: content/browser/renderer_host/render_widget_host_view_android.cc

Issue 120513005: [Android] Perform eager gesture recognition on MotionEvents (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Allow scrolling after longpress Created 6 years, 11 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 (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/renderer_host/render_widget_host_view_android.h" 5 #include "content/browser/renderer_host/render_widget_host_view_android.h"
6 6
7 #include <android/bitmap.h> 7 #include <android/bitmap.h>
8 8
9 #include "base/basictypes.h" 9 #include "base/basictypes.h"
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 1083 matching lines...) Expand 10 before | Expand all | Expand 10 after
1094 bool is_pinned_to_left, bool is_pinned_to_right) { 1094 bool is_pinned_to_left, bool is_pinned_to_right) {
1095 // intentionally empty, like RenderWidgetHostViewViews 1095 // intentionally empty, like RenderWidgetHostViewViews
1096 } 1096 }
1097 1097
1098 void RenderWidgetHostViewAndroid::UnhandledWheelEvent( 1098 void RenderWidgetHostViewAndroid::UnhandledWheelEvent(
1099 const blink::WebMouseWheelEvent& event) { 1099 const blink::WebMouseWheelEvent& event) {
1100 // intentionally empty, like RenderWidgetHostViewViews 1100 // intentionally empty, like RenderWidgetHostViewViews
1101 } 1101 }
1102 1102
1103 void RenderWidgetHostViewAndroid::GestureEventAck( 1103 void RenderWidgetHostViewAndroid::GestureEventAck(
1104 int gesture_event_type, 1104 const blink::WebGestureEvent& event,
1105 InputEventAckState ack_result) { 1105 InputEventAckState ack_result) {
1106 // Scroll events. 1106 if (event.type == blink::WebInputEvent::GestureScrollBegin) {
1107 if (gesture_event_type == blink::WebInputEvent::GestureScrollBegin) {
1108 content_view_core_->OnScrollBeginEventAck(); 1107 content_view_core_->OnScrollBeginEventAck();
1109 } 1108 } else if (event.type == blink::WebInputEvent::GestureScrollUpdate) {
1110 if (gesture_event_type == blink::WebInputEvent::GestureScrollUpdate && 1109 if (ack_result == INPUT_EVENT_ACK_STATE_CONSUMED)
1111 ack_result == INPUT_EVENT_ACK_STATE_CONSUMED) { 1110 content_view_core_->OnScrollUpdateGestureConsumed();
1112 content_view_core_->OnScrollUpdateGestureConsumed(); 1111 } else if (event.type == blink::WebInputEvent::GestureScrollEnd) {
1113 }
1114 if (gesture_event_type == blink::WebInputEvent::GestureScrollEnd) {
1115 content_view_core_->OnScrollEndEventAck(); 1112 content_view_core_->OnScrollEndEventAck();
1116 } 1113 } else if (event.type == blink::WebInputEvent::GestureFlingStart) {
1117 1114 if (ack_result == INPUT_EVENT_ACK_STATE_NOT_CONSUMED ||
1118 // Fling events. 1115 ack_result == INPUT_EVENT_ACK_STATE_NO_CONSUMER_EXISTS) {
1119 if (gesture_event_type == blink::WebInputEvent::GestureFlingStart) { 1116 const bool had_consumer =
1120 content_view_core_->OnFlingStartEventAck(ack_result); 1117 ack_result == INPUT_EVENT_ACK_STATE_NOT_CONSUMED;
1118 content_view_core_->OnUnhandledFlingStartEventAck(
1119 had_consumer,
1120 event.data.flingStart.velocityX,
1121 event.data.flingStart.velocityY);
1122 }
1121 } 1123 }
1122 } 1124 }
1123 1125
1124 InputEventAckState RenderWidgetHostViewAndroid::FilterInputEvent( 1126 InputEventAckState RenderWidgetHostViewAndroid::FilterInputEvent(
1125 const blink::WebInputEvent& input_event) { 1127 const blink::WebInputEvent& input_event) {
1126 if (!host_) 1128 if (!host_)
1127 return INPUT_EVENT_ACK_STATE_NOT_CONSUMED; 1129 return INPUT_EVENT_ACK_STATE_NOT_CONSUMED;
1128 1130
1129 if (input_event.type == blink::WebInputEvent::GestureTapDown || 1131 if (input_event.type == blink::WebInputEvent::GestureTapDown ||
1130 input_event.type == blink::WebInputEvent::TouchStart) { 1132 input_event.type == blink::WebInputEvent::TouchStart) {
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
1234 if (host_) 1236 if (host_)
1235 host_->ForwardKeyboardEvent(event); 1237 host_->ForwardKeyboardEvent(event);
1236 } 1238 }
1237 1239
1238 void RenderWidgetHostViewAndroid::SendTouchEvent( 1240 void RenderWidgetHostViewAndroid::SendTouchEvent(
1239 const blink::WebTouchEvent& event) { 1241 const blink::WebTouchEvent& event) {
1240 if (host_) 1242 if (host_)
1241 host_->ForwardTouchEventWithLatencyInfo(event, CreateLatencyInfo(event)); 1243 host_->ForwardTouchEventWithLatencyInfo(event, CreateLatencyInfo(event));
1242 } 1244 }
1243 1245
1244
1245 void RenderWidgetHostViewAndroid::SendMouseEvent( 1246 void RenderWidgetHostViewAndroid::SendMouseEvent(
1246 const blink::WebMouseEvent& event) { 1247 const blink::WebMouseEvent& event) {
1247 if (host_) 1248 if (host_)
1248 host_->ForwardMouseEvent(event); 1249 host_->ForwardMouseEvent(event);
1249 } 1250 }
1250 1251
1251 void RenderWidgetHostViewAndroid::SendMouseWheelEvent( 1252 void RenderWidgetHostViewAndroid::SendMouseWheelEvent(
1252 const blink::WebMouseWheelEvent& event) { 1253 const blink::WebMouseWheelEvent& event) {
1253 if (host_) 1254 if (host_)
1254 host_->ForwardWheelEvent(event); 1255 host_->ForwardWheelEvent(event);
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
1360 obj = content_view_core_->GetJavaObject(); 1361 obj = content_view_core_->GetJavaObject();
1361 GetBrowserAccessibilityManager()->ToBrowserAccessibilityManagerAndroid()-> 1362 GetBrowserAccessibilityManager()->ToBrowserAccessibilityManagerAndroid()->
1362 SetContentViewCore(obj); 1363 SetContentViewCore(obj);
1363 } 1364 }
1364 1365
1365 if (are_layers_attached_) { 1366 if (are_layers_attached_) {
1366 AttachLayers(); 1367 AttachLayers();
1367 if (content_view_core_ && !using_synchronous_compositor_) 1368 if (content_view_core_ && !using_synchronous_compositor_)
1368 content_view_core_->GetWindowAndroid()->AddObserver(this); 1369 content_view_core_->GetWindowAndroid()->AddObserver(this);
1369 } 1370 }
1370
1371 // Ensure ContentsViewCore is aware of the current touch handling state, eg.
1372 // in case we've already been running JS for the page as part of preload.
1373 if (content_view_core_ && host_)
1374 content_view_core_->HasTouchEventHandlers(host_->has_touch_handler());
1375 } 1371 }
1376 1372
1377 void RenderWidgetHostViewAndroid::RunAckCallbacks() { 1373 void RenderWidgetHostViewAndroid::RunAckCallbacks() {
1378 while (!ack_callbacks_.empty()) { 1374 while (!ack_callbacks_.empty()) {
1379 ack_callbacks_.front().Run(); 1375 ack_callbacks_.front().Run();
1380 ack_callbacks_.pop(); 1376 ack_callbacks_.pop();
1381 } 1377 }
1382 } 1378 }
1383 1379
1384 void RenderWidgetHostViewAndroid::HasTouchEventHandlers( 1380 void RenderWidgetHostViewAndroid::HasTouchEventHandlers(
1385 bool need_touch_events) { 1381 bool need_touch_events) {
1386 if (content_view_core_)
1387 content_view_core_->HasTouchEventHandlers(need_touch_events);
1388 } 1382 }
1389 1383
1390 void RenderWidgetHostViewAndroid::OnCompositingDidCommit() { 1384 void RenderWidgetHostViewAndroid::OnCompositingDidCommit() {
1391 RunAckCallbacks(); 1385 RunAckCallbacks();
1392 } 1386 }
1393 1387
1394 void RenderWidgetHostViewAndroid::OnDetachCompositor() { 1388 void RenderWidgetHostViewAndroid::OnDetachCompositor() {
1395 DCHECK(content_view_core_); 1389 DCHECK(content_view_core_);
1396 DCHECK(!using_synchronous_compositor_); 1390 DCHECK(!using_synchronous_compositor_);
1397 RunAckCallbacks(); 1391 RunAckCallbacks();
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
1510 // RenderWidgetHostView, public: 1504 // RenderWidgetHostView, public:
1511 1505
1512 // static 1506 // static
1513 RenderWidgetHostView* 1507 RenderWidgetHostView*
1514 RenderWidgetHostView::CreateViewForWidget(RenderWidgetHost* widget) { 1508 RenderWidgetHostView::CreateViewForWidget(RenderWidgetHost* widget) {
1515 RenderWidgetHostImpl* rwhi = RenderWidgetHostImpl::From(widget); 1509 RenderWidgetHostImpl* rwhi = RenderWidgetHostImpl::From(widget);
1516 return new RenderWidgetHostViewAndroid(rwhi, NULL); 1510 return new RenderWidgetHostViewAndroid(rwhi, NULL);
1517 } 1511 }
1518 1512
1519 } // namespace content 1513 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698