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 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 187 switches::kDisableOverscrollEdgeEffect)), | 187 switches::kDisableOverscrollEdgeEffect)), |
| 188 overscroll_effect_(OverscrollGlow::Create(overscroll_effect_enabled_)), | 188 overscroll_effect_(OverscrollGlow::Create(overscroll_effect_enabled_)), |
| 189 gesture_provider_(CreateGestureProviderConfig(), this), | 189 gesture_provider_(CreateGestureProviderConfig(), this), |
| 190 flush_input_requested_(false), | 190 flush_input_requested_(false), |
| 191 accelerated_surface_route_id_(0), | 191 accelerated_surface_route_id_(0), |
| 192 using_synchronous_compositor_(SynchronousCompositorImpl::FromID( | 192 using_synchronous_compositor_(SynchronousCompositorImpl::FromID( |
| 193 widget_host->GetProcess()->GetID(), | 193 widget_host->GetProcess()->GetID(), |
| 194 widget_host->GetRoutingID()) != NULL), | 194 widget_host->GetRoutingID()) != NULL), |
| 195 frame_evictor_(new DelegatedFrameEvictor(this)), | 195 frame_evictor_(new DelegatedFrameEvictor(this)), |
| 196 locks_on_frame_count_(0), | 196 locks_on_frame_count_(0), |
| 197 observing_root_window_(false) { | 197 observing_root_window_(false), |
| 198 gesture_text_selector_(new GestureTextSelector(this)) { | |
| 198 host_->SetView(this); | 199 host_->SetView(this); |
| 199 SetContentViewCore(content_view_core); | 200 SetContentViewCore(content_view_core); |
| 200 ImageTransportFactoryAndroid::AddObserver(this); | 201 ImageTransportFactoryAndroid::AddObserver(this); |
| 201 } | 202 } |
| 202 | 203 |
| 203 RenderWidgetHostViewAndroid::~RenderWidgetHostViewAndroid() { | 204 RenderWidgetHostViewAndroid::~RenderWidgetHostViewAndroid() { |
| 204 ImageTransportFactoryAndroid::RemoveObserver(this); | 205 ImageTransportFactoryAndroid::RemoveObserver(this); |
| 205 SetContentViewCore(NULL); | 206 SetContentViewCore(NULL); |
| 206 DCHECK(ack_callbacks_.empty()); | 207 DCHECK(ack_callbacks_.empty()); |
| 207 if (resource_collection_.get()) | 208 if (resource_collection_.get()) |
| (...skipping 343 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 551 } | 552 } |
| 552 | 553 |
| 553 bool RenderWidgetHostViewAndroid::OnTouchEvent( | 554 bool RenderWidgetHostViewAndroid::OnTouchEvent( |
| 554 const ui::MotionEvent& event) { | 555 const ui::MotionEvent& event) { |
| 555 if (!host_) | 556 if (!host_) |
| 556 return false; | 557 return false; |
| 557 | 558 |
| 558 if (!gesture_provider_.OnTouchEvent(event)) | 559 if (!gesture_provider_.OnTouchEvent(event)) |
| 559 return false; | 560 return false; |
| 560 | 561 |
| 562 if (gesture_text_selector_->OnTouchEvent(event)) { | |
| 563 gesture_provider_.OnTouchEventAck(false); | |
| 564 return true; | |
| 565 } | |
| 566 | |
| 561 // Short-circuit touch forwarding if no touch handlers exist. | 567 // Short-circuit touch forwarding if no touch handlers exist. |
| 562 if (!host_->ShouldForwardTouchEvent()) { | 568 if (!host_->ShouldForwardTouchEvent()) { |
| 563 const bool event_consumed = false; | 569 const bool event_consumed = false; |
| 564 gesture_provider_.OnTouchEventAck(event_consumed); | 570 gesture_provider_.OnTouchEventAck(event_consumed); |
| 565 return true; | 571 return true; |
| 566 } | 572 } |
| 567 | 573 |
| 568 SendTouchEvent(CreateWebTouchEventFromMotionEvent(event)); | 574 SendTouchEvent(CreateWebTouchEventFromMotionEvent(event)); |
| 569 return true; | 575 return true; |
| 570 } | 576 } |
| (...skipping 709 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1280 | 1286 |
| 1281 void RenderWidgetHostViewAndroid::RunAckCallbacks() { | 1287 void RenderWidgetHostViewAndroid::RunAckCallbacks() { |
| 1282 while (!ack_callbacks_.empty()) { | 1288 while (!ack_callbacks_.empty()) { |
| 1283 ack_callbacks_.front().Run(); | 1289 ack_callbacks_.front().Run(); |
| 1284 ack_callbacks_.pop(); | 1290 ack_callbacks_.pop(); |
| 1285 } | 1291 } |
| 1286 } | 1292 } |
| 1287 | 1293 |
| 1288 void RenderWidgetHostViewAndroid::OnGestureEvent( | 1294 void RenderWidgetHostViewAndroid::OnGestureEvent( |
| 1289 const ui::GestureEventData& gesture) { | 1295 const ui::GestureEventData& gesture) { |
| 1296 if (gesture_text_selector_->OnGestureEvent(gesture)) { | |
|
jdduke (slow)
2014/06/24 15:38:37
Nit: No braces necessary (just add a line break).
Changwan Ryu
2014/06/25 07:26:21
Done.
| |
| 1297 return; | |
| 1298 } | |
| 1290 SendGestureEvent(CreateWebGestureEventFromGestureEventData(gesture)); | 1299 SendGestureEvent(CreateWebGestureEventFromGestureEventData(gesture)); |
| 1291 } | 1300 } |
| 1292 | 1301 |
| 1293 void RenderWidgetHostViewAndroid::OnCompositingDidCommit() { | 1302 void RenderWidgetHostViewAndroid::OnCompositingDidCommit() { |
| 1294 RunAckCallbacks(); | 1303 RunAckCallbacks(); |
| 1295 } | 1304 } |
| 1296 | 1305 |
| 1297 void RenderWidgetHostViewAndroid::OnDetachCompositor() { | 1306 void RenderWidgetHostViewAndroid::OnDetachCompositor() { |
| 1298 DCHECK(content_view_core_); | 1307 DCHECK(content_view_core_); |
| 1299 DCHECK(!using_synchronous_compositor_); | 1308 DCHECK(!using_synchronous_compositor_); |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1427 // Define the criteria here. If say the 16 texture readback is | 1436 // Define the criteria here. If say the 16 texture readback is |
| 1428 // supported we should go with that (this degrades quality) | 1437 // supported we should go with that (this degrades quality) |
| 1429 // or stick back to the default format. | 1438 // or stick back to the default format. |
| 1430 if (base::android::SysUtils::IsLowEndDevice()) { | 1439 if (base::android::SysUtils::IsLowEndDevice()) { |
| 1431 if (IsReadbackConfigSupported(SkBitmap::kRGB_565_Config)) | 1440 if (IsReadbackConfigSupported(SkBitmap::kRGB_565_Config)) |
| 1432 return SkBitmap::kRGB_565_Config; | 1441 return SkBitmap::kRGB_565_Config; |
| 1433 } | 1442 } |
| 1434 return SkBitmap::kARGB_8888_Config; | 1443 return SkBitmap::kARGB_8888_Config; |
| 1435 } | 1444 } |
| 1436 | 1445 |
| 1446 void RenderWidgetHostViewAndroid::ShowSelectionHandlesAutomatically() { | |
| 1447 if (content_view_core_) | |
| 1448 content_view_core_->ShowSelectionHandlesAutomatically(); | |
| 1449 } | |
| 1450 | |
| 1451 void RenderWidgetHostViewAndroid::SelectRange( | |
| 1452 float x1, float y1, float x2, float y2) { | |
| 1453 if (content_view_core_) | |
| 1454 static_cast<WebContentsImpl*>(content_view_core_->GetWebContents())-> | |
|
jdduke (slow)
2014/06/24 15:38:37
We'll want to ask sievers@ or aelias@ about WebCon
Changwan Ryu
2014/06/25 07:26:21
Added a TODO
| |
| 1455 SelectRange(gfx::Point(x1, y1), gfx::Point(x2, y2)); | |
| 1456 } | |
| 1457 | |
| 1458 void RenderWidgetHostViewAndroid::SelectWord(float x, float y) { | |
| 1459 if (host_) { | |
| 1460 host_->MoveCaret(gfx::Point(x, y)); | |
| 1461 RenderViewHost* render_view_host = RenderViewHost::From(host_); | |
| 1462 if (render_view_host) | |
| 1463 render_view_host->SelectWordAroundCaret(); | |
| 1464 } | |
| 1465 } | |
| 1466 | |
| 1467 void RenderWidgetHostViewAndroid::Unselect() { | |
| 1468 if (content_view_core_) | |
| 1469 content_view_core_->GetWebContents()->Unselect(); | |
| 1470 } | |
| 1471 | |
| 1437 // static | 1472 // static |
| 1438 void RenderWidgetHostViewBase::GetDefaultScreenInfo( | 1473 void RenderWidgetHostViewBase::GetDefaultScreenInfo( |
| 1439 blink::WebScreenInfo* results) { | 1474 blink::WebScreenInfo* results) { |
| 1440 const gfx::Display& display = | 1475 const gfx::Display& display = |
| 1441 gfx::Screen::GetNativeScreen()->GetPrimaryDisplay(); | 1476 gfx::Screen::GetNativeScreen()->GetPrimaryDisplay(); |
| 1442 results->rect = display.bounds(); | 1477 results->rect = display.bounds(); |
| 1443 // TODO(husky): Remove any system controls from availableRect. | 1478 // TODO(husky): Remove any system controls from availableRect. |
| 1444 results->availableRect = display.work_area(); | 1479 results->availableRect = display.work_area(); |
| 1445 results->deviceScaleFactor = display.device_scale_factor(); | 1480 results->deviceScaleFactor = display.device_scale_factor(); |
| 1446 results->orientationAngle = display.RotationAsDegree(); | 1481 results->orientationAngle = display.RotationAsDegree(); |
| 1447 gfx::DeviceDisplayInfo info; | 1482 gfx::DeviceDisplayInfo info; |
| 1448 results->depth = info.GetBitsPerPixel(); | 1483 results->depth = info.GetBitsPerPixel(); |
| 1449 results->depthPerComponent = info.GetBitsPerComponent(); | 1484 results->depthPerComponent = info.GetBitsPerComponent(); |
| 1450 results->isMonochrome = (results->depthPerComponent == 0); | 1485 results->isMonochrome = (results->depthPerComponent == 0); |
| 1451 } | 1486 } |
| 1452 | 1487 |
| 1453 } // namespace content | 1488 } // namespace content |
| OLD | NEW |