Chromium Code Reviews| 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/android/sys_utils.h" | 9 #include "base/android/sys_utils.h" |
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 54 #include "content/public/browser/render_view_host.h" | 54 #include "content/public/browser/render_view_host.h" |
| 55 #include "content/public/common/content_switches.h" | 55 #include "content/public/common/content_switches.h" |
| 56 #include "gpu/command_buffer/client/gles2_interface.h" | 56 #include "gpu/command_buffer/client/gles2_interface.h" |
| 57 #include "gpu/config/gpu_driver_bug_workaround_type.h" | 57 #include "gpu/config/gpu_driver_bug_workaround_type.h" |
| 58 #include "skia/ext/image_operations.h" | 58 #include "skia/ext/image_operations.h" |
| 59 #include "third_party/khronos/GLES2/gl2.h" | 59 #include "third_party/khronos/GLES2/gl2.h" |
| 60 #include "third_party/khronos/GLES2/gl2ext.h" | 60 #include "third_party/khronos/GLES2/gl2ext.h" |
| 61 #include "third_party/skia/include/core/SkCanvas.h" | 61 #include "third_party/skia/include/core/SkCanvas.h" |
| 62 #include "ui/base/android/window_android.h" | 62 #include "ui/base/android/window_android.h" |
| 63 #include "ui/base/android/window_android_compositor.h" | 63 #include "ui/base/android/window_android_compositor.h" |
| 64 #include "ui/events/event_constants.h" | |
| 64 #include "ui/events/gesture_detection/gesture_config_helper.h" | 65 #include "ui/events/gesture_detection/gesture_config_helper.h" |
| 65 #include "ui/events/gesture_detection/motion_event.h" | 66 #include "ui/events/gesture_detection/motion_event.h" |
| 66 #include "ui/gfx/android/device_display_info.h" | 67 #include "ui/gfx/android/device_display_info.h" |
| 67 #include "ui/gfx/android/java_bitmap.h" | 68 #include "ui/gfx/android/java_bitmap.h" |
| 68 #include "ui/gfx/display.h" | 69 #include "ui/gfx/display.h" |
| 69 #include "ui/gfx/screen.h" | 70 #include "ui/gfx/screen.h" |
| 70 #include "ui/gfx/size_conversions.h" | 71 #include "ui/gfx/size_conversions.h" |
| 71 | 72 |
| 72 namespace content { | 73 namespace content { |
| 73 | 74 |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 187 switches::kDisableOverscrollEdgeEffect)), | 188 switches::kDisableOverscrollEdgeEffect)), |
| 188 overscroll_effect_(OverscrollGlow::Create(overscroll_effect_enabled_)), | 189 overscroll_effect_(OverscrollGlow::Create(overscroll_effect_enabled_)), |
| 189 gesture_provider_(CreateGestureProviderConfig(), this), | 190 gesture_provider_(CreateGestureProviderConfig(), this), |
| 190 flush_input_requested_(false), | 191 flush_input_requested_(false), |
| 191 accelerated_surface_route_id_(0), | 192 accelerated_surface_route_id_(0), |
| 192 using_synchronous_compositor_(SynchronousCompositorImpl::FromID( | 193 using_synchronous_compositor_(SynchronousCompositorImpl::FromID( |
| 193 widget_host->GetProcess()->GetID(), | 194 widget_host->GetProcess()->GetID(), |
| 194 widget_host->GetRoutingID()) != NULL), | 195 widget_host->GetRoutingID()) != NULL), |
| 195 frame_evictor_(new DelegatedFrameEvictor(this)), | 196 frame_evictor_(new DelegatedFrameEvictor(this)), |
| 196 locks_on_frame_count_(0), | 197 locks_on_frame_count_(0), |
| 197 observing_root_window_(false) { | 198 observing_root_window_(false), |
| 199 gesture_text_selection_triggered_(false) { | |
| 198 host_->SetView(this); | 200 host_->SetView(this); |
| 199 SetContentViewCore(content_view_core); | 201 SetContentViewCore(content_view_core); |
| 200 ImageTransportFactoryAndroid::AddObserver(this); | 202 ImageTransportFactoryAndroid::AddObserver(this); |
| 201 } | 203 } |
| 202 | 204 |
| 203 RenderWidgetHostViewAndroid::~RenderWidgetHostViewAndroid() { | 205 RenderWidgetHostViewAndroid::~RenderWidgetHostViewAndroid() { |
| 204 ImageTransportFactoryAndroid::RemoveObserver(this); | 206 ImageTransportFactoryAndroid::RemoveObserver(this); |
| 205 SetContentViewCore(NULL); | 207 SetContentViewCore(NULL); |
| 206 DCHECK(ack_callbacks_.empty()); | 208 DCHECK(ack_callbacks_.empty()); |
| 207 if (resource_collection_.get()) | 209 if (resource_collection_.get()) |
| (...skipping 338 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 546 void RenderWidgetHostViewAndroid::OnSmartClipDataExtracted( | 548 void RenderWidgetHostViewAndroid::OnSmartClipDataExtracted( |
| 547 const base::string16& result) { | 549 const base::string16& result) { |
| 548 // Custom serialization over IPC isn't allowed normally for security reasons. | 550 // Custom serialization over IPC isn't allowed normally for security reasons. |
| 549 // Since this feature is only used in (single-process) WebView, there are no | 551 // Since this feature is only used in (single-process) WebView, there are no |
| 550 // security issues. Enforce that it's only called in single process mode. | 552 // security issues. Enforce that it's only called in single process mode. |
| 551 CHECK(RenderProcessHost::run_renderer_in_process()); | 553 CHECK(RenderProcessHost::run_renderer_in_process()); |
| 552 if (content_view_core_) | 554 if (content_view_core_) |
| 553 content_view_core_->OnSmartClipDataExtracted(result); | 555 content_view_core_->OnSmartClipDataExtracted(result); |
| 554 } | 556 } |
| 555 | 557 |
| 558 bool RenderWidgetHostViewAndroid::ShouldTriggerOrUntriggerTextSelection( | |
| 559 const ui::MotionEvent& event) { | |
| 560 // Currently we aren't supporting stylus + touch case. | |
| 561 if (event.GetPointerCount() == 0 || | |
|
jdduke (slow)
2014/06/23 15:09:59
Nit: GetPointerCount() should never be 0, so I wou
Changwan Ryu
2014/06/24 09:29:48
Done.
| |
| 562 event.GetToolType(0) != ui::MotionEvent::TOOL_TYPE_STYLUS) | |
| 563 return false; | |
| 564 const bool is_button_pressed = | |
|
jdduke (slow)
2014/06/23 15:09:59
Maybe rename to |is_secondary_button_pressed|?
Changwan Ryu
2014/06/24 09:29:48
Done.
| |
| 565 (event.GetButtonState() & ui::MotionEvent::BUTTON_SECONDARY) != 0; | |
| 566 const bool is_action_up = event.GetAction() == ui::MotionEvent::ACTION_UP; | |
|
jdduke (slow)
2014/06/23 15:09:59
Hmm, this is a little confusing, why do we check f
Changwan Ryu
2014/06/24 09:29:48
Done.
| |
| 567 return (is_button_pressed && !is_action_up) || | |
| 568 (!is_button_pressed && gesture_text_selection_triggered_ && is_action_up); | |
| 569 } | |
| 570 | |
| 571 bool RenderWidgetHostViewAndroid::IsGestureTextSelectionTriggered() const { | |
| 572 return gesture_text_selection_triggered_; | |
| 573 } | |
| 574 | |
| 556 bool RenderWidgetHostViewAndroid::OnTouchEvent( | 575 bool RenderWidgetHostViewAndroid::OnTouchEvent( |
| 557 const ui::MotionEvent& event) { | 576 const ui::MotionEvent& event) { |
| 558 if (!host_) | 577 if (!host_) |
| 559 return false; | 578 return false; |
| 560 | 579 |
| 561 if (!gesture_provider_.OnTouchEvent(event)) | 580 if (!gesture_provider_.OnTouchEvent(event)) |
| 562 return false; | 581 return false; |
| 563 | 582 |
| 583 if (event.GetAction() == ui::MotionEvent::ACTION_DOWN) { | |
| 584 gesture_text_selection_triggered_ = | |
| 585 ShouldTriggerOrUntriggerTextSelection(event); | |
| 586 } | |
| 587 | |
| 588 if (gesture_text_selection_triggered_) { | |
| 589 const bool event_consumed = false; | |
| 590 gesture_provider_.OnTouchEventAck(event_consumed); | |
| 591 if (event.GetAction() == ui::MotionEvent::ACTION_UP || | |
|
jdduke (slow)
2014/06/23 15:09:59
As I said, we can't reset the state using ACTION_U
Changwan Ryu
2014/06/24 09:29:48
Removed.
| |
| 592 event.GetAction() == ui::MotionEvent::ACTION_CANCEL) | |
| 593 gesture_text_selection_triggered_ = false; | |
| 594 return true; | |
| 595 } | |
| 596 | |
| 564 // Short-circuit touch forwarding if no touch handlers exist. | 597 // Short-circuit touch forwarding if no touch handlers exist. |
| 565 if (!host_->ShouldForwardTouchEvent()) { | 598 if (!host_->ShouldForwardTouchEvent()) { |
| 566 const bool event_consumed = false; | 599 const bool event_consumed = false; |
| 567 gesture_provider_.OnTouchEventAck(event_consumed); | 600 gesture_provider_.OnTouchEventAck(event_consumed); |
| 568 return true; | 601 return true; |
| 569 } | 602 } |
| 570 | 603 |
| 571 SendTouchEvent(CreateWebTouchEventFromMotionEvent(event)); | 604 SendTouchEvent(CreateWebTouchEventFromMotionEvent(event)); |
| 572 return true; | 605 return true; |
| 573 } | 606 } |
| (...skipping 709 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1283 | 1316 |
| 1284 void RenderWidgetHostViewAndroid::RunAckCallbacks() { | 1317 void RenderWidgetHostViewAndroid::RunAckCallbacks() { |
| 1285 while (!ack_callbacks_.empty()) { | 1318 while (!ack_callbacks_.empty()) { |
| 1286 ack_callbacks_.front().Run(); | 1319 ack_callbacks_.front().Run(); |
| 1287 ack_callbacks_.pop(); | 1320 ack_callbacks_.pop(); |
| 1288 } | 1321 } |
| 1289 } | 1322 } |
| 1290 | 1323 |
| 1291 void RenderWidgetHostViewAndroid::OnGestureEvent( | 1324 void RenderWidgetHostViewAndroid::OnGestureEvent( |
| 1292 const ui::GestureEventData& gesture) { | 1325 const ui::GestureEventData& gesture) { |
| 1326 if (gesture_text_selection_triggered_) { | |
| 1327 if (gesture.type() == ui::ET_GESTURE_LONG_PRESS) { | |
| 1328 // Exits the text selection mode until ACTION_DOWN resets it. | |
| 1329 gesture_text_selection_triggered_ = false; | |
|
jdduke (slow)
2014/06/23 15:09:59
Hmm, I don't think we want to reset this here. Can
Changwan Ryu
2014/06/24 09:29:48
Fixed to call SelectWord instead.
But reset is sti
| |
| 1330 } else { | |
| 1331 return; | |
|
jdduke (slow)
2014/06/23 15:09:59
I thought Samsung wanted to be able to highlight a
Changwan Ryu
2014/06/24 09:29:48
Samsung confirmed that it's only for LONG PRESS.
| |
| 1332 } | |
| 1333 } | |
| 1293 SendGestureEvent(CreateWebGestureEventFromGestureEventData(gesture)); | 1334 SendGestureEvent(CreateWebGestureEventFromGestureEventData(gesture)); |
| 1294 } | 1335 } |
| 1295 | 1336 |
| 1296 void RenderWidgetHostViewAndroid::OnCompositingDidCommit() { | 1337 void RenderWidgetHostViewAndroid::OnCompositingDidCommit() { |
| 1297 RunAckCallbacks(); | 1338 RunAckCallbacks(); |
| 1298 } | 1339 } |
| 1299 | 1340 |
| 1300 void RenderWidgetHostViewAndroid::OnDetachCompositor() { | 1341 void RenderWidgetHostViewAndroid::OnDetachCompositor() { |
| 1301 DCHECK(content_view_core_); | 1342 DCHECK(content_view_core_); |
| 1302 DCHECK(!using_synchronous_compositor_); | 1343 DCHECK(!using_synchronous_compositor_); |
| (...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1447 results->availableRect = display.work_area(); | 1488 results->availableRect = display.work_area(); |
| 1448 results->deviceScaleFactor = display.device_scale_factor(); | 1489 results->deviceScaleFactor = display.device_scale_factor(); |
| 1449 results->orientationAngle = display.RotationAsDegree(); | 1490 results->orientationAngle = display.RotationAsDegree(); |
| 1450 gfx::DeviceDisplayInfo info; | 1491 gfx::DeviceDisplayInfo info; |
| 1451 results->depth = info.GetBitsPerPixel(); | 1492 results->depth = info.GetBitsPerPixel(); |
| 1452 results->depthPerComponent = info.GetBitsPerComponent(); | 1493 results->depthPerComponent = info.GetBitsPerComponent(); |
| 1453 results->isMonochrome = (results->depthPerComponent == 0); | 1494 results->isMonochrome = (results->depthPerComponent == 0); |
| 1454 } | 1495 } |
| 1455 | 1496 |
| 1456 } // namespace content | 1497 } // namespace content |
| OLD | NEW |