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/renderer/render_view_impl.h" | 5 #include "content/renderer/render_view_impl.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <cmath> | 8 #include <cmath> |
9 | 9 |
10 #include "base/auto_reset.h" | 10 #include "base/auto_reset.h" |
(...skipping 413 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
424 | 424 |
425 static bool ShouldUseCompositedScrollingForFrames( | 425 static bool ShouldUseCompositedScrollingForFrames( |
426 float device_scale_factor) { | 426 float device_scale_factor) { |
427 if (RenderThreadImpl::current() && | 427 if (RenderThreadImpl::current() && |
428 !RenderThreadImpl::current()->is_lcd_text_enabled()) | 428 !RenderThreadImpl::current()->is_lcd_text_enabled()) |
429 return true; | 429 return true; |
430 | 430 |
431 return DeviceScaleEnsuresTextQuality(device_scale_factor); | 431 return DeviceScaleEnsuresTextQuality(device_scale_factor); |
432 } | 432 } |
433 | 433 |
| 434 static bool ShouldUseCompositedSelectionUpdates() { |
| 435 #if defined(OS_ANDROID) |
| 436 return true; |
| 437 #else |
| 438 return false; |
| 439 #endif |
| 440 } |
| 441 |
434 static bool ShouldUseUniversalAcceleratedCompositingForOverflowScroll() { | 442 static bool ShouldUseUniversalAcceleratedCompositingForOverflowScroll() { |
435 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); | 443 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); |
436 | 444 |
437 if (command_line.HasSwitch( | 445 if (command_line.HasSwitch( |
438 switches::kDisableUniversalAcceleratedOverflowScroll)) | 446 switches::kDisableUniversalAcceleratedOverflowScroll)) |
439 return false; | 447 return false; |
440 | 448 |
441 if (command_line.HasSwitch( | 449 if (command_line.HasSwitch( |
442 switches::kEnableUniversalAcceleratedOverflowScroll)) | 450 switches::kEnableUniversalAcceleratedOverflowScroll)) |
443 return true; | 451 return true; |
(...skipping 304 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
748 webview()->settings()->setCompositorDrivenAcceleratedScrollingEnabled( | 756 webview()->settings()->setCompositorDrivenAcceleratedScrollingEnabled( |
749 ShouldUseUniversalAcceleratedCompositingForOverflowScroll()); | 757 ShouldUseUniversalAcceleratedCompositingForOverflowScroll()); |
750 webview()->settings()->setAcceleratedCompositingForTransitionEnabled( | 758 webview()->settings()->setAcceleratedCompositingForTransitionEnabled( |
751 ShouldUseTransitionCompositing(device_scale_factor_)); | 759 ShouldUseTransitionCompositing(device_scale_factor_)); |
752 webview()->settings()->setAcceleratedCompositingForFixedRootBackgroundEnabled( | 760 webview()->settings()->setAcceleratedCompositingForFixedRootBackgroundEnabled( |
753 ShouldUseAcceleratedFixedRootBackground(device_scale_factor_)); | 761 ShouldUseAcceleratedFixedRootBackground(device_scale_factor_)); |
754 webview()->settings()->setCompositedScrollingForFramesEnabled( | 762 webview()->settings()->setCompositedScrollingForFramesEnabled( |
755 ShouldUseCompositedScrollingForFrames(device_scale_factor_)); | 763 ShouldUseCompositedScrollingForFrames(device_scale_factor_)); |
756 webview()->settings()->setUseExpandedHeuristicsForGpuRasterization( | 764 webview()->settings()->setUseExpandedHeuristicsForGpuRasterization( |
757 ShouldUseExpandedHeuristicsForGpuRasterization()); | 765 ShouldUseExpandedHeuristicsForGpuRasterization()); |
| 766 webview()->settings()->setCompositedSelectionUpdatesEnabled( |
| 767 ShouldUseCompositedSelectionUpdates()); |
758 | 768 |
759 ApplyWebPreferences(webkit_preferences_, webview()); | 769 ApplyWebPreferences(webkit_preferences_, webview()); |
760 | 770 |
761 webview()->settings()->setAllowConnectingInsecureWebSocket( | 771 webview()->settings()->setAllowConnectingInsecureWebSocket( |
762 command_line.HasSwitch(switches::kAllowInsecureWebSocketFromHttpsOrigin)); | 772 command_line.HasSwitch(switches::kAllowInsecureWebSocketFromHttpsOrigin)); |
763 | 773 |
764 webview()->setMainFrame(main_render_frame_->GetWebFrame()); | 774 webview()->setMainFrame(main_render_frame_->GetWebFrame()); |
765 main_render_frame_->Initialize(); | 775 main_render_frame_->Initialize(); |
766 | 776 |
767 if (switches::IsTouchDragDropEnabled()) | 777 if (switches::IsTouchDragDropEnabled()) |
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
982 PepperFocusChanged(instance, false); | 992 PepperFocusChanged(instance, false); |
983 } | 993 } |
984 | 994 |
985 void RenderViewImpl::PepperFocusChanged(PepperPluginInstanceImpl* instance, | 995 void RenderViewImpl::PepperFocusChanged(PepperPluginInstanceImpl* instance, |
986 bool focused) { | 996 bool focused) { |
987 if (focused) | 997 if (focused) |
988 focused_pepper_plugin_ = instance; | 998 focused_pepper_plugin_ = instance; |
989 else if (focused_pepper_plugin_ == instance) | 999 else if (focused_pepper_plugin_ == instance) |
990 focused_pepper_plugin_ = NULL; | 1000 focused_pepper_plugin_ = NULL; |
991 | 1001 |
| 1002 if (compositor_) |
| 1003 compositor_->SetIgnoreSelectionUpdates(focused_pepper_plugin_ != NULL); |
| 1004 |
992 UpdateTextInputType(); | 1005 UpdateTextInputType(); |
993 UpdateSelectionBounds(); | 1006 UpdateSelectionBounds(); |
994 } | 1007 } |
995 | 1008 |
996 void RenderViewImpl::RegisterPluginDelegate(WebPluginDelegateProxy* delegate) { | 1009 void RenderViewImpl::RegisterPluginDelegate(WebPluginDelegateProxy* delegate) { |
997 plugin_delegates_.insert(delegate); | 1010 plugin_delegates_.insert(delegate); |
998 // If the renderer is visible, set initial visibility and focus state. | 1011 // If the renderer is visible, set initial visibility and focus state. |
999 if (!is_hidden()) { | 1012 if (!is_hidden()) { |
1000 #if defined(OS_MACOSX) | 1013 #if defined(OS_MACOSX) |
1001 delegate->SetContainerVisibility(true); | 1014 delegate->SetContainerVisibility(true); |
(...skipping 2478 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3480 } | 3493 } |
3481 | 3494 |
3482 ui::TextInputType RenderViewImpl::GetTextInputType() { | 3495 ui::TextInputType RenderViewImpl::GetTextInputType() { |
3483 #if defined(ENABLE_PLUGINS) | 3496 #if defined(ENABLE_PLUGINS) |
3484 if (focused_pepper_plugin_) | 3497 if (focused_pepper_plugin_) |
3485 return focused_pepper_plugin_->text_input_type(); | 3498 return focused_pepper_plugin_->text_input_type(); |
3486 #endif | 3499 #endif |
3487 return RenderWidget::GetTextInputType(); | 3500 return RenderWidget::GetTextInputType(); |
3488 } | 3501 } |
3489 | 3502 |
3490 void RenderViewImpl::GetSelectionBounds(gfx::Rect* start, gfx::Rect* end) { | 3503 bool RenderViewImpl::GetSelectionBounds(gfx::Rect* start, gfx::Rect* end) { |
3491 #if defined(ENABLE_PLUGINS) | 3504 #if defined(ENABLE_PLUGINS) |
3492 if (focused_pepper_plugin_) { | 3505 if (focused_pepper_plugin_) { |
3493 // TODO(kinaba) http://crbug.com/101101 | 3506 // TODO(kinaba) http://crbug.com/101101 |
3494 // Current Pepper IME API does not handle selection bounds. So we simply | 3507 // Current Pepper IME API does not handle selection bounds. So we simply |
3495 // use the caret position as an empty range for now. It will be updated | 3508 // use the caret position as an empty range for now. It will be updated |
3496 // after Pepper API equips features related to surrounding text retrieval. | 3509 // after Pepper API equips features related to surrounding text retrieval. |
3497 gfx::Rect caret = focused_pepper_plugin_->GetCaretBounds(); | 3510 gfx::Rect caret = focused_pepper_plugin_->GetCaretBounds(); |
3498 *start = caret; | 3511 *start = caret; |
3499 *end = caret; | 3512 *end = caret; |
3500 return; | 3513 return true; |
3501 } | 3514 } |
3502 #endif | 3515 #endif |
3503 RenderWidget::GetSelectionBounds(start, end); | 3516 |
| 3517 // With composited selection updates, the selection bounds will be reported |
| 3518 // directly by the compositor, in which case explicit IPC selection |
| 3519 // notifications should be suppressed. |
| 3520 if (compositor_ && webview() && |
| 3521 webview()->settings()->compositedSelectionUpdatesEnabled()) |
| 3522 return false; |
| 3523 |
| 3524 return RenderWidget::GetSelectionBounds(start, end); |
3504 } | 3525 } |
3505 | 3526 |
3506 #if defined(OS_MACOSX) || defined(USE_AURA) | 3527 #if defined(OS_MACOSX) || defined(USE_AURA) |
3507 void RenderViewImpl::GetCompositionCharacterBounds( | 3528 void RenderViewImpl::GetCompositionCharacterBounds( |
3508 std::vector<gfx::Rect>* bounds) { | 3529 std::vector<gfx::Rect>* bounds) { |
3509 DCHECK(bounds); | 3530 DCHECK(bounds); |
3510 bounds->clear(); | 3531 bounds->clear(); |
3511 | 3532 |
3512 #if defined(ENABLE_PLUGINS) | 3533 #if defined(ENABLE_PLUGINS) |
3513 if (focused_pepper_plugin_) { | 3534 if (focused_pepper_plugin_) { |
(...skipping 524 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4038 std::vector<gfx::Size> sizes; | 4059 std::vector<gfx::Size> sizes; |
4039 ConvertToFaviconSizes(icon_urls[i].sizes(), &sizes); | 4060 ConvertToFaviconSizes(icon_urls[i].sizes(), &sizes); |
4040 if (!url.isEmpty()) | 4061 if (!url.isEmpty()) |
4041 urls.push_back( | 4062 urls.push_back( |
4042 FaviconURL(url, ToFaviconType(icon_urls[i].iconType()), sizes)); | 4063 FaviconURL(url, ToFaviconType(icon_urls[i].iconType()), sizes)); |
4043 } | 4064 } |
4044 SendUpdateFaviconURL(urls); | 4065 SendUpdateFaviconURL(urls); |
4045 } | 4066 } |
4046 | 4067 |
4047 } // namespace content | 4068 } // namespace content |
OLD | NEW |