| 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/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 Loading... |
| 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 // TODO(jdduke): Unify gesture ack dispatch into a single |
| 1107 if (gesture_event_type == blink::WebInputEvent::GestureScrollBegin) { | 1107 // |ContentViewCore.onGestureEventAck()| method. |
| 1108 if (event.type == blink::WebInputEvent::GestureScrollBegin) { |
| 1108 content_view_core_->OnScrollBeginEventAck(); | 1109 content_view_core_->OnScrollBeginEventAck(); |
| 1109 } | 1110 } else if (event.type == blink::WebInputEvent::GestureScrollUpdate) { |
| 1110 if (gesture_event_type == blink::WebInputEvent::GestureScrollUpdate && | 1111 if (ack_result == INPUT_EVENT_ACK_STATE_CONSUMED) |
| 1111 ack_result == INPUT_EVENT_ACK_STATE_CONSUMED) { | 1112 content_view_core_->OnScrollUpdateGestureConsumed(); |
| 1112 content_view_core_->OnScrollUpdateGestureConsumed(); | 1113 } else if (event.type == blink::WebInputEvent::GestureScrollEnd) { |
| 1113 } | |
| 1114 if (gesture_event_type == blink::WebInputEvent::GestureScrollEnd) { | |
| 1115 content_view_core_->OnScrollEndEventAck(); | 1114 content_view_core_->OnScrollEndEventAck(); |
| 1116 } | 1115 } else if (event.type == blink::WebInputEvent::GestureFlingStart) { |
| 1117 | 1116 content_view_core_->OnFlingStartEventAck(ack_result, |
| 1118 // Fling events. | 1117 event.data.flingStart.velocityX, |
| 1119 if (gesture_event_type == blink::WebInputEvent::GestureFlingStart) { | 1118 event.data.flingStart.velocityY); |
| 1120 content_view_core_->OnFlingStartEventAck(ack_result); | |
| 1121 } | 1119 } |
| 1122 } | 1120 } |
| 1123 | 1121 |
| 1124 InputEventAckState RenderWidgetHostViewAndroid::FilterInputEvent( | 1122 InputEventAckState RenderWidgetHostViewAndroid::FilterInputEvent( |
| 1125 const blink::WebInputEvent& input_event) { | 1123 const blink::WebInputEvent& input_event) { |
| 1126 if (!host_) | 1124 if (!host_) |
| 1127 return INPUT_EVENT_ACK_STATE_NOT_CONSUMED; | 1125 return INPUT_EVENT_ACK_STATE_NOT_CONSUMED; |
| 1128 | 1126 |
| 1129 if (input_event.type == blink::WebInputEvent::GestureTapDown || | 1127 if (input_event.type == blink::WebInputEvent::GestureTapDown || |
| 1130 input_event.type == blink::WebInputEvent::TouchStart) { | 1128 input_event.type == blink::WebInputEvent::TouchStart) { |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1234 if (host_) | 1232 if (host_) |
| 1235 host_->ForwardKeyboardEvent(event); | 1233 host_->ForwardKeyboardEvent(event); |
| 1236 } | 1234 } |
| 1237 | 1235 |
| 1238 void RenderWidgetHostViewAndroid::SendTouchEvent( | 1236 void RenderWidgetHostViewAndroid::SendTouchEvent( |
| 1239 const blink::WebTouchEvent& event) { | 1237 const blink::WebTouchEvent& event) { |
| 1240 if (host_) | 1238 if (host_) |
| 1241 host_->ForwardTouchEventWithLatencyInfo(event, CreateLatencyInfo(event)); | 1239 host_->ForwardTouchEventWithLatencyInfo(event, CreateLatencyInfo(event)); |
| 1242 } | 1240 } |
| 1243 | 1241 |
| 1244 | |
| 1245 void RenderWidgetHostViewAndroid::SendMouseEvent( | 1242 void RenderWidgetHostViewAndroid::SendMouseEvent( |
| 1246 const blink::WebMouseEvent& event) { | 1243 const blink::WebMouseEvent& event) { |
| 1247 if (host_) | 1244 if (host_) |
| 1248 host_->ForwardMouseEvent(event); | 1245 host_->ForwardMouseEvent(event); |
| 1249 } | 1246 } |
| 1250 | 1247 |
| 1251 void RenderWidgetHostViewAndroid::SendMouseWheelEvent( | 1248 void RenderWidgetHostViewAndroid::SendMouseWheelEvent( |
| 1252 const blink::WebMouseWheelEvent& event) { | 1249 const blink::WebMouseWheelEvent& event) { |
| 1253 if (host_) | 1250 if (host_) |
| 1254 host_->ForwardWheelEvent(event); | 1251 host_->ForwardWheelEvent(event); |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1360 obj = content_view_core_->GetJavaObject(); | 1357 obj = content_view_core_->GetJavaObject(); |
| 1361 GetBrowserAccessibilityManager()->ToBrowserAccessibilityManagerAndroid()-> | 1358 GetBrowserAccessibilityManager()->ToBrowserAccessibilityManagerAndroid()-> |
| 1362 SetContentViewCore(obj); | 1359 SetContentViewCore(obj); |
| 1363 } | 1360 } |
| 1364 | 1361 |
| 1365 if (are_layers_attached_) { | 1362 if (are_layers_attached_) { |
| 1366 AttachLayers(); | 1363 AttachLayers(); |
| 1367 if (content_view_core_ && !using_synchronous_compositor_) | 1364 if (content_view_core_ && !using_synchronous_compositor_) |
| 1368 content_view_core_->GetWindowAndroid()->AddObserver(this); | 1365 content_view_core_->GetWindowAndroid()->AddObserver(this); |
| 1369 } | 1366 } |
| 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 } | 1367 } |
| 1376 | 1368 |
| 1377 void RenderWidgetHostViewAndroid::RunAckCallbacks() { | 1369 void RenderWidgetHostViewAndroid::RunAckCallbacks() { |
| 1378 while (!ack_callbacks_.empty()) { | 1370 while (!ack_callbacks_.empty()) { |
| 1379 ack_callbacks_.front().Run(); | 1371 ack_callbacks_.front().Run(); |
| 1380 ack_callbacks_.pop(); | 1372 ack_callbacks_.pop(); |
| 1381 } | 1373 } |
| 1382 } | 1374 } |
| 1383 | 1375 |
| 1384 void RenderWidgetHostViewAndroid::HasTouchEventHandlers( | 1376 void RenderWidgetHostViewAndroid::HasTouchEventHandlers( |
| 1385 bool need_touch_events) { | 1377 bool need_touch_events) { |
| 1386 if (content_view_core_) | |
| 1387 content_view_core_->HasTouchEventHandlers(need_touch_events); | |
| 1388 } | 1378 } |
| 1389 | 1379 |
| 1390 void RenderWidgetHostViewAndroid::OnCompositingDidCommit() { | 1380 void RenderWidgetHostViewAndroid::OnCompositingDidCommit() { |
| 1391 RunAckCallbacks(); | 1381 RunAckCallbacks(); |
| 1392 } | 1382 } |
| 1393 | 1383 |
| 1394 void RenderWidgetHostViewAndroid::OnDetachCompositor() { | 1384 void RenderWidgetHostViewAndroid::OnDetachCompositor() { |
| 1395 DCHECK(content_view_core_); | 1385 DCHECK(content_view_core_); |
| 1396 DCHECK(!using_synchronous_compositor_); | 1386 DCHECK(!using_synchronous_compositor_); |
| 1397 RunAckCallbacks(); | 1387 RunAckCallbacks(); |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1510 // RenderWidgetHostView, public: | 1500 // RenderWidgetHostView, public: |
| 1511 | 1501 |
| 1512 // static | 1502 // static |
| 1513 RenderWidgetHostView* | 1503 RenderWidgetHostView* |
| 1514 RenderWidgetHostView::CreateViewForWidget(RenderWidgetHost* widget) { | 1504 RenderWidgetHostView::CreateViewForWidget(RenderWidgetHost* widget) { |
| 1515 RenderWidgetHostImpl* rwhi = RenderWidgetHostImpl::From(widget); | 1505 RenderWidgetHostImpl* rwhi = RenderWidgetHostImpl::From(widget); |
| 1516 return new RenderWidgetHostViewAndroid(rwhi, NULL); | 1506 return new RenderWidgetHostViewAndroid(rwhi, NULL); |
| 1517 } | 1507 } |
| 1518 | 1508 |
| 1519 } // namespace content | 1509 } // namespace content |
| OLD | NEW |