| 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 1064 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1075 bool is_pinned_to_left, bool is_pinned_to_right) { | 1075 bool is_pinned_to_left, bool is_pinned_to_right) { |
| 1076 // intentionally empty, like RenderWidgetHostViewViews | 1076 // intentionally empty, like RenderWidgetHostViewViews |
| 1077 } | 1077 } |
| 1078 | 1078 |
| 1079 void RenderWidgetHostViewAndroid::UnhandledWheelEvent( | 1079 void RenderWidgetHostViewAndroid::UnhandledWheelEvent( |
| 1080 const blink::WebMouseWheelEvent& event) { | 1080 const blink::WebMouseWheelEvent& event) { |
| 1081 // intentionally empty, like RenderWidgetHostViewViews | 1081 // intentionally empty, like RenderWidgetHostViewViews |
| 1082 } | 1082 } |
| 1083 | 1083 |
| 1084 void RenderWidgetHostViewAndroid::GestureEventAck( | 1084 void RenderWidgetHostViewAndroid::GestureEventAck( |
| 1085 int gesture_event_type, | 1085 const blink::WebGestureEvent& event, |
| 1086 InputEventAckState ack_result) { | 1086 InputEventAckState ack_result) { |
| 1087 // Scroll events. | 1087 if (event.type == blink::WebInputEvent::GestureScrollBegin) { |
| 1088 if (gesture_event_type == blink::WebInputEvent::GestureScrollBegin) { | |
| 1089 content_view_core_->OnScrollBeginEventAck(); | 1088 content_view_core_->OnScrollBeginEventAck(); |
| 1090 } | 1089 } else if (event.type == blink::WebInputEvent::GestureScrollUpdate) { |
| 1091 if (gesture_event_type == blink::WebInputEvent::GestureScrollUpdate && | 1090 if (ack_result == INPUT_EVENT_ACK_STATE_CONSUMED) |
| 1092 ack_result == INPUT_EVENT_ACK_STATE_CONSUMED) { | 1091 content_view_core_->OnScrollUpdateGestureConsumed(); |
| 1093 content_view_core_->OnScrollUpdateGestureConsumed(); | 1092 } else if (event.type == blink::WebInputEvent::GestureScrollEnd) { |
| 1094 } | |
| 1095 if (gesture_event_type == blink::WebInputEvent::GestureScrollEnd) { | |
| 1096 content_view_core_->OnScrollEndEventAck(); | 1093 content_view_core_->OnScrollEndEventAck(); |
| 1097 } | 1094 } else if (event.type == blink::WebInputEvent::GestureFlingStart) { |
| 1098 | 1095 if (ack_result == INPUT_EVENT_ACK_STATE_NOT_CONSUMED || |
| 1099 // Fling events. | 1096 ack_result == INPUT_EVENT_ACK_STATE_NO_CONSUMER_EXISTS) { |
| 1100 if (gesture_event_type == blink::WebInputEvent::GestureFlingStart) { | 1097 const bool had_consumer = |
| 1101 content_view_core_->OnFlingStartEventAck(ack_result); | 1098 ack_result == INPUT_EVENT_ACK_STATE_NOT_CONSUMED; |
| 1099 content_view_core_->OnUnhandledFlingStartEventAck( |
| 1100 had_consumer, |
| 1101 event.data.flingStart.velocityX, |
| 1102 event.data.flingStart.velocityY); |
| 1103 } |
| 1102 } | 1104 } |
| 1103 } | 1105 } |
| 1104 | 1106 |
| 1105 InputEventAckState RenderWidgetHostViewAndroid::FilterInputEvent( | 1107 InputEventAckState RenderWidgetHostViewAndroid::FilterInputEvent( |
| 1106 const blink::WebInputEvent& input_event) { | 1108 const blink::WebInputEvent& input_event) { |
| 1107 if (!host_) | 1109 if (!host_) |
| 1108 return INPUT_EVENT_ACK_STATE_NOT_CONSUMED; | 1110 return INPUT_EVENT_ACK_STATE_NOT_CONSUMED; |
| 1109 | 1111 |
| 1110 if (input_event.type == blink::WebInputEvent::GestureTapDown || | 1112 if (input_event.type == blink::WebInputEvent::GestureTapDown || |
| 1111 input_event.type == blink::WebInputEvent::TouchStart) { | 1113 input_event.type == blink::WebInputEvent::TouchStart) { |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1215 if (host_) | 1217 if (host_) |
| 1216 host_->ForwardKeyboardEvent(event); | 1218 host_->ForwardKeyboardEvent(event); |
| 1217 } | 1219 } |
| 1218 | 1220 |
| 1219 void RenderWidgetHostViewAndroid::SendTouchEvent( | 1221 void RenderWidgetHostViewAndroid::SendTouchEvent( |
| 1220 const blink::WebTouchEvent& event) { | 1222 const blink::WebTouchEvent& event) { |
| 1221 if (host_) | 1223 if (host_) |
| 1222 host_->ForwardTouchEventWithLatencyInfo(event, CreateLatencyInfo(event)); | 1224 host_->ForwardTouchEventWithLatencyInfo(event, CreateLatencyInfo(event)); |
| 1223 } | 1225 } |
| 1224 | 1226 |
| 1225 | |
| 1226 void RenderWidgetHostViewAndroid::SendMouseEvent( | 1227 void RenderWidgetHostViewAndroid::SendMouseEvent( |
| 1227 const blink::WebMouseEvent& event) { | 1228 const blink::WebMouseEvent& event) { |
| 1228 if (host_) | 1229 if (host_) |
| 1229 host_->ForwardMouseEvent(event); | 1230 host_->ForwardMouseEvent(event); |
| 1230 } | 1231 } |
| 1231 | 1232 |
| 1232 void RenderWidgetHostViewAndroid::SendMouseWheelEvent( | 1233 void RenderWidgetHostViewAndroid::SendMouseWheelEvent( |
| 1233 const blink::WebMouseWheelEvent& event) { | 1234 const blink::WebMouseWheelEvent& event) { |
| 1234 if (host_) | 1235 if (host_) |
| 1235 host_->ForwardWheelEvent(event); | 1236 host_->ForwardWheelEvent(event); |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1341 obj = content_view_core_->GetJavaObject(); | 1342 obj = content_view_core_->GetJavaObject(); |
| 1342 GetBrowserAccessibilityManager()->ToBrowserAccessibilityManagerAndroid()-> | 1343 GetBrowserAccessibilityManager()->ToBrowserAccessibilityManagerAndroid()-> |
| 1343 SetContentViewCore(obj); | 1344 SetContentViewCore(obj); |
| 1344 } | 1345 } |
| 1345 | 1346 |
| 1346 if (are_layers_attached_) { | 1347 if (are_layers_attached_) { |
| 1347 AttachLayers(); | 1348 AttachLayers(); |
| 1348 if (content_view_core_ && !using_synchronous_compositor_) | 1349 if (content_view_core_ && !using_synchronous_compositor_) |
| 1349 content_view_core_->GetWindowAndroid()->AddObserver(this); | 1350 content_view_core_->GetWindowAndroid()->AddObserver(this); |
| 1350 } | 1351 } |
| 1351 | |
| 1352 // Ensure ContentsViewCore is aware of the current touch handling state, eg. | |
| 1353 // in case we've already been running JS for the page as part of preload. | |
| 1354 if (content_view_core_ && host_) | |
| 1355 content_view_core_->HasTouchEventHandlers(host_->has_touch_handler()); | |
| 1356 } | 1352 } |
| 1357 | 1353 |
| 1358 void RenderWidgetHostViewAndroid::RunAckCallbacks() { | 1354 void RenderWidgetHostViewAndroid::RunAckCallbacks() { |
| 1359 while (!ack_callbacks_.empty()) { | 1355 while (!ack_callbacks_.empty()) { |
| 1360 ack_callbacks_.front().Run(); | 1356 ack_callbacks_.front().Run(); |
| 1361 ack_callbacks_.pop(); | 1357 ack_callbacks_.pop(); |
| 1362 } | 1358 } |
| 1363 } | 1359 } |
| 1364 | 1360 |
| 1365 void RenderWidgetHostViewAndroid::HasTouchEventHandlers( | 1361 void RenderWidgetHostViewAndroid::HasTouchEventHandlers( |
| 1366 bool need_touch_events) { | 1362 bool need_touch_events) { |
| 1367 if (content_view_core_) | |
| 1368 content_view_core_->HasTouchEventHandlers(need_touch_events); | |
| 1369 } | 1363 } |
| 1370 | 1364 |
| 1371 void RenderWidgetHostViewAndroid::OnCompositingDidCommit() { | 1365 void RenderWidgetHostViewAndroid::OnCompositingDidCommit() { |
| 1372 RunAckCallbacks(); | 1366 RunAckCallbacks(); |
| 1373 } | 1367 } |
| 1374 | 1368 |
| 1375 void RenderWidgetHostViewAndroid::OnDetachCompositor() { | 1369 void RenderWidgetHostViewAndroid::OnDetachCompositor() { |
| 1376 DCHECK(content_view_core_); | 1370 DCHECK(content_view_core_); |
| 1377 DCHECK(!using_synchronous_compositor_); | 1371 DCHECK(!using_synchronous_compositor_); |
| 1378 RunAckCallbacks(); | 1372 RunAckCallbacks(); |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1488 // RenderWidgetHostView, public: | 1482 // RenderWidgetHostView, public: |
| 1489 | 1483 |
| 1490 // static | 1484 // static |
| 1491 RenderWidgetHostView* | 1485 RenderWidgetHostView* |
| 1492 RenderWidgetHostView::CreateViewForWidget(RenderWidgetHost* widget) { | 1486 RenderWidgetHostView::CreateViewForWidget(RenderWidgetHost* widget) { |
| 1493 RenderWidgetHostImpl* rwhi = RenderWidgetHostImpl::From(widget); | 1487 RenderWidgetHostImpl* rwhi = RenderWidgetHostImpl::From(widget); |
| 1494 return new RenderWidgetHostViewAndroid(rwhi, NULL); | 1488 return new RenderWidgetHostViewAndroid(rwhi, NULL); |
| 1495 } | 1489 } |
| 1496 | 1490 |
| 1497 } // namespace content | 1491 } // namespace content |
| OLD | NEW |