| 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 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); |
| 436 |
| 437 if (command_line.HasSwitch(switches::kDisableCompositedSelectionUpdates)) |
| 438 return false; |
| 439 |
| 440 if (command_line.HasSwitch(switches::kEnableCompositedSelectionUpdates)) |
| 441 return true; |
| 442 |
| 443 return false; |
| 444 } |
| 445 |
| 434 static bool ShouldUseUniversalAcceleratedCompositingForOverflowScroll() { | 446 static bool ShouldUseUniversalAcceleratedCompositingForOverflowScroll() { |
| 435 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); | 447 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); |
| 436 | 448 |
| 437 if (command_line.HasSwitch( | 449 if (command_line.HasSwitch( |
| 438 switches::kDisableUniversalAcceleratedOverflowScroll)) | 450 switches::kDisableUniversalAcceleratedOverflowScroll)) |
| 439 return false; | 451 return false; |
| 440 | 452 |
| 441 if (command_line.HasSwitch( | 453 if (command_line.HasSwitch( |
| 442 switches::kEnableUniversalAcceleratedOverflowScroll)) | 454 switches::kEnableUniversalAcceleratedOverflowScroll)) |
| 443 return true; | 455 return true; |
| (...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 744 webview()->settings()->setAcceleratedCompositingForOverflowScrollEnabled( | 756 webview()->settings()->setAcceleratedCompositingForOverflowScrollEnabled( |
| 745 ShouldUseAcceleratedCompositingForOverflowScroll(device_scale_factor_)); | 757 ShouldUseAcceleratedCompositingForOverflowScroll(device_scale_factor_)); |
| 746 webview()->settings()->setCompositorDrivenAcceleratedScrollingEnabled( | 758 webview()->settings()->setCompositorDrivenAcceleratedScrollingEnabled( |
| 747 ShouldUseUniversalAcceleratedCompositingForOverflowScroll()); | 759 ShouldUseUniversalAcceleratedCompositingForOverflowScroll()); |
| 748 webview()->settings()->setAcceleratedCompositingForTransitionEnabled( | 760 webview()->settings()->setAcceleratedCompositingForTransitionEnabled( |
| 749 ShouldUseTransitionCompositing(device_scale_factor_)); | 761 ShouldUseTransitionCompositing(device_scale_factor_)); |
| 750 webview()->settings()->setAcceleratedCompositingForFixedRootBackgroundEnabled( | 762 webview()->settings()->setAcceleratedCompositingForFixedRootBackgroundEnabled( |
| 751 ShouldUseAcceleratedFixedRootBackground(device_scale_factor_)); | 763 ShouldUseAcceleratedFixedRootBackground(device_scale_factor_)); |
| 752 webview()->settings()->setCompositedScrollingForFramesEnabled( | 764 webview()->settings()->setCompositedScrollingForFramesEnabled( |
| 753 ShouldUseCompositedScrollingForFrames(device_scale_factor_)); | 765 ShouldUseCompositedScrollingForFrames(device_scale_factor_)); |
| 766 webview()->settings()->setCompositedSelectionUpdatesEnabled( |
| 767 ShouldUseCompositedSelectionUpdates()); |
| 754 | 768 |
| 755 ApplyWebPreferences(webkit_preferences_, webview()); | 769 ApplyWebPreferences(webkit_preferences_, webview()); |
| 756 | 770 |
| 757 webview()->settings()->setAllowConnectingInsecureWebSocket( | 771 webview()->settings()->setAllowConnectingInsecureWebSocket( |
| 758 command_line.HasSwitch(switches::kAllowInsecureWebSocketFromHttpsOrigin)); | 772 command_line.HasSwitch(switches::kAllowInsecureWebSocketFromHttpsOrigin)); |
| 759 | 773 |
| 760 main_render_frame_.reset(main_render_frame); | 774 main_render_frame_.reset(main_render_frame); |
| 761 webview()->setMainFrame(main_render_frame_->GetWebFrame()); | 775 webview()->setMainFrame(main_render_frame_->GetWebFrame()); |
| 762 main_render_frame_->Initialize(); | 776 main_render_frame_->Initialize(); |
| 763 | 777 |
| (...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 979 PepperFocusChanged(instance, false); | 993 PepperFocusChanged(instance, false); |
| 980 } | 994 } |
| 981 | 995 |
| 982 void RenderViewImpl::PepperFocusChanged(PepperPluginInstanceImpl* instance, | 996 void RenderViewImpl::PepperFocusChanged(PepperPluginInstanceImpl* instance, |
| 983 bool focused) { | 997 bool focused) { |
| 984 if (focused) | 998 if (focused) |
| 985 focused_pepper_plugin_ = instance; | 999 focused_pepper_plugin_ = instance; |
| 986 else if (focused_pepper_plugin_ == instance) | 1000 else if (focused_pepper_plugin_ == instance) |
| 987 focused_pepper_plugin_ = NULL; | 1001 focused_pepper_plugin_ = NULL; |
| 988 | 1002 |
| 1003 if (compositor_) |
| 1004 compositor_->SetIgnoreSelectionUpdates(focused_pepper_plugin_ != NULL); |
| 1005 |
| 989 UpdateTextInputType(); | 1006 UpdateTextInputType(); |
| 990 UpdateSelectionBounds(); | 1007 UpdateSelectionBounds(); |
| 991 } | 1008 } |
| 992 | 1009 |
| 993 void RenderViewImpl::RegisterPluginDelegate(WebPluginDelegateProxy* delegate) { | 1010 void RenderViewImpl::RegisterPluginDelegate(WebPluginDelegateProxy* delegate) { |
| 994 plugin_delegates_.insert(delegate); | 1011 plugin_delegates_.insert(delegate); |
| 995 // If the renderer is visible, set initial visibility and focus state. | 1012 // If the renderer is visible, set initial visibility and focus state. |
| 996 if (!is_hidden()) { | 1013 if (!is_hidden()) { |
| 997 #if defined(OS_MACOSX) | 1014 #if defined(OS_MACOSX) |
| 998 delegate->SetContainerVisibility(true); | 1015 delegate->SetContainerVisibility(true); |
| (...skipping 2488 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3487 } | 3504 } |
| 3488 | 3505 |
| 3489 ui::TextInputType RenderViewImpl::GetTextInputType() { | 3506 ui::TextInputType RenderViewImpl::GetTextInputType() { |
| 3490 #if defined(ENABLE_PLUGINS) | 3507 #if defined(ENABLE_PLUGINS) |
| 3491 if (focused_pepper_plugin_) | 3508 if (focused_pepper_plugin_) |
| 3492 return focused_pepper_plugin_->text_input_type(); | 3509 return focused_pepper_plugin_->text_input_type(); |
| 3493 #endif | 3510 #endif |
| 3494 return RenderWidget::GetTextInputType(); | 3511 return RenderWidget::GetTextInputType(); |
| 3495 } | 3512 } |
| 3496 | 3513 |
| 3497 void RenderViewImpl::GetSelectionBounds(gfx::Rect* start, gfx::Rect* end) { | 3514 bool RenderViewImpl::GetSelectionBounds(gfx::Rect* start, gfx::Rect* end) { |
| 3498 #if defined(ENABLE_PLUGINS) | 3515 #if defined(ENABLE_PLUGINS) |
| 3499 if (focused_pepper_plugin_) { | 3516 if (focused_pepper_plugin_) { |
| 3500 // TODO(kinaba) http://crbug.com/101101 | 3517 // TODO(kinaba) http://crbug.com/101101 |
| 3501 // Current Pepper IME API does not handle selection bounds. So we simply | 3518 // Current Pepper IME API does not handle selection bounds. So we simply |
| 3502 // use the caret position as an empty range for now. It will be updated | 3519 // use the caret position as an empty range for now. It will be updated |
| 3503 // after Pepper API equips features related to surrounding text retrieval. | 3520 // after Pepper API equips features related to surrounding text retrieval. |
| 3504 gfx::Rect caret = focused_pepper_plugin_->GetCaretBounds(); | 3521 gfx::Rect caret = focused_pepper_plugin_->GetCaretBounds(); |
| 3505 *start = caret; | 3522 *start = caret; |
| 3506 *end = caret; | 3523 *end = caret; |
| 3507 return; | 3524 return true; |
| 3508 } | 3525 } |
| 3509 #endif | 3526 #endif |
| 3510 RenderWidget::GetSelectionBounds(start, end); | 3527 |
| 3528 if (compositor_ && webview() && |
| 3529 webview()->settings()->compositedSelectionUpdatesEnabled()) |
| 3530 return false; |
| 3531 |
| 3532 return RenderWidget::GetSelectionBounds(start, end); |
| 3511 } | 3533 } |
| 3512 | 3534 |
| 3513 #if defined(OS_MACOSX) || defined(USE_AURA) | 3535 #if defined(OS_MACOSX) || defined(USE_AURA) |
| 3514 void RenderViewImpl::GetCompositionCharacterBounds( | 3536 void RenderViewImpl::GetCompositionCharacterBounds( |
| 3515 std::vector<gfx::Rect>* bounds) { | 3537 std::vector<gfx::Rect>* bounds) { |
| 3516 DCHECK(bounds); | 3538 DCHECK(bounds); |
| 3517 bounds->clear(); | 3539 bounds->clear(); |
| 3518 | 3540 |
| 3519 #if defined(ENABLE_PLUGINS) | 3541 #if defined(ENABLE_PLUGINS) |
| 3520 if (focused_pepper_plugin_) { | 3542 if (focused_pepper_plugin_) { |
| (...skipping 530 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4051 std::vector<gfx::Size> sizes; | 4073 std::vector<gfx::Size> sizes; |
| 4052 ConvertToFaviconSizes(icon_urls[i].sizes(), &sizes); | 4074 ConvertToFaviconSizes(icon_urls[i].sizes(), &sizes); |
| 4053 if (!url.isEmpty()) | 4075 if (!url.isEmpty()) |
| 4054 urls.push_back( | 4076 urls.push_back( |
| 4055 FaviconURL(url, ToFaviconType(icon_urls[i].iconType()), sizes)); | 4077 FaviconURL(url, ToFaviconType(icon_urls[i].iconType()), sizes)); |
| 4056 } | 4078 } |
| 4057 SendUpdateFaviconURL(urls); | 4079 SendUpdateFaviconURL(urls); |
| 4058 } | 4080 } |
| 4059 | 4081 |
| 4060 } // namespace content | 4082 } // namespace content |
| OLD | NEW |