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 390 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
401 | 401 |
402 static bool PreferCompositingToLCDText(float device_scale_factor) { | 402 static bool PreferCompositingToLCDText(float device_scale_factor) { |
403 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); | 403 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); |
404 if (command_line.HasSwitch(switches::kDisablePreferCompositingToLCDText)) | 404 if (command_line.HasSwitch(switches::kDisablePreferCompositingToLCDText)) |
405 return false; | 405 return false; |
406 if (command_line.HasSwitch(switches::kEnablePreferCompositingToLCDText)) | 406 if (command_line.HasSwitch(switches::kEnablePreferCompositingToLCDText)) |
407 return true; | 407 return true; |
408 return DeviceScaleEnsuresTextQuality(device_scale_factor); | 408 return DeviceScaleEnsuresTextQuality(device_scale_factor); |
409 } | 409 } |
410 | 410 |
| 411 static bool ShouldUseAcceleratedCompositingForOverflowScroll( |
| 412 float device_scale_factor) { |
| 413 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); |
| 414 |
| 415 if (command_line.HasSwitch(switches::kDisableAcceleratedOverflowScroll)) |
| 416 return false; |
| 417 |
| 418 if (command_line.HasSwitch(switches::kEnableAcceleratedOverflowScroll)) |
| 419 return true; |
| 420 |
| 421 return DeviceScaleEnsuresTextQuality(device_scale_factor); |
| 422 } |
| 423 |
411 static bool ShouldUseCompositedScrollingForFrames( | 424 static bool ShouldUseCompositedScrollingForFrames( |
412 float device_scale_factor) { | 425 float device_scale_factor) { |
413 if (RenderThreadImpl::current() && | 426 if (RenderThreadImpl::current() && |
414 !RenderThreadImpl::current()->is_lcd_text_enabled()) | 427 !RenderThreadImpl::current()->is_lcd_text_enabled()) |
415 return true; | 428 return true; |
416 | 429 |
417 return DeviceScaleEnsuresTextQuality(device_scale_factor); | 430 return DeviceScaleEnsuresTextQuality(device_scale_factor); |
418 } | 431 } |
419 | 432 |
420 static bool ShouldUseTransitionCompositing(float device_scale_factor) { | 433 static bool ShouldUseTransitionCompositing(float device_scale_factor) { |
421 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); | 434 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); |
422 | 435 |
423 if (command_line.HasSwitch(switches::kDisableCompositingForTransition)) | 436 if (command_line.HasSwitch(switches::kDisableCompositingForTransition)) |
424 return false; | 437 return false; |
425 | 438 |
426 if (command_line.HasSwitch(switches::kEnableCompositingForTransition)) | 439 if (command_line.HasSwitch(switches::kEnableCompositingForTransition)) |
427 return true; | 440 return true; |
428 | 441 |
429 // TODO(ajuma): Re-enable this by default for high-DPI once the problem | 442 // TODO(ajuma): Re-enable this by default for high-DPI once the problem |
430 // of excessive layer promotion caused by overlap has been addressed. | 443 // of excessive layer promotion caused by overlap has been addressed. |
431 // http://crbug.com/178119. | 444 // http://crbug.com/178119. |
432 return false; | 445 return false; |
433 } | 446 } |
434 | 447 |
| 448 static bool ShouldUseAcceleratedFixedRootBackground(float device_scale_factor) { |
| 449 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); |
| 450 |
| 451 if (command_line.HasSwitch(switches::kDisableAcceleratedFixedRootBackground)) |
| 452 return false; |
| 453 |
| 454 if (command_line.HasSwitch(switches::kEnableAcceleratedFixedRootBackground)) |
| 455 return true; |
| 456 |
| 457 return DeviceScaleEnsuresTextQuality(device_scale_factor); |
| 458 } |
| 459 |
435 static FaviconURL::IconType ToFaviconType(blink::WebIconURL::Type type) { | 460 static FaviconURL::IconType ToFaviconType(blink::WebIconURL::Type type) { |
436 switch (type) { | 461 switch (type) { |
437 case blink::WebIconURL::TypeFavicon: | 462 case blink::WebIconURL::TypeFavicon: |
438 return FaviconURL::FAVICON; | 463 return FaviconURL::FAVICON; |
439 case blink::WebIconURL::TypeTouch: | 464 case blink::WebIconURL::TypeTouch: |
440 return FaviconURL::TOUCH_ICON; | 465 return FaviconURL::TOUCH_ICON; |
441 case blink::WebIconURL::TypeTouchPrecomposed: | 466 case blink::WebIconURL::TypeTouchPrecomposed: |
442 return FaviconURL::TOUCH_PRECOMPOSED_ICON; | 467 return FaviconURL::TOUCH_PRECOMPOSED_ICON; |
443 case blink::WebIconURL::TypeInvalid: | 468 case blink::WebIconURL::TypeInvalid: |
444 return FaviconURL::INVALID_ICON; | 469 return FaviconURL::INVALID_ICON; |
(...skipping 317 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
762 did_show_ = true; | 787 did_show_ = true; |
763 CompleteInit(); | 788 CompleteInit(); |
764 } | 789 } |
765 | 790 |
766 g_view_map.Get().insert(std::make_pair(webview(), this)); | 791 g_view_map.Get().insert(std::make_pair(webview(), this)); |
767 g_routing_id_view_map.Get().insert(std::make_pair(routing_id_, this)); | 792 g_routing_id_view_map.Get().insert(std::make_pair(routing_id_, this)); |
768 webview()->setDeviceScaleFactor(device_scale_factor_); | 793 webview()->setDeviceScaleFactor(device_scale_factor_); |
769 webview()->settings()->setPreferCompositingToLCDTextEnabled( | 794 webview()->settings()->setPreferCompositingToLCDTextEnabled( |
770 PreferCompositingToLCDText(device_scale_factor_)); | 795 PreferCompositingToLCDText(device_scale_factor_)); |
771 webview()->settings()->setAcceleratedCompositingForOverflowScrollEnabled( | 796 webview()->settings()->setAcceleratedCompositingForOverflowScrollEnabled( |
772 PreferCompositingToLCDText(device_scale_factor_)); | 797 ShouldUseAcceleratedCompositingForOverflowScroll(device_scale_factor_)); |
773 webview()->settings()->setAcceleratedCompositingForTransitionEnabled( | 798 webview()->settings()->setAcceleratedCompositingForTransitionEnabled( |
774 ShouldUseTransitionCompositing(device_scale_factor_)); | 799 ShouldUseTransitionCompositing(device_scale_factor_)); |
775 webview()->settings()->setAcceleratedCompositingForFixedRootBackgroundEnabled( | 800 webview()->settings()->setAcceleratedCompositingForFixedRootBackgroundEnabled( |
776 PreferCompositingToLCDText(device_scale_factor_)); | 801 ShouldUseAcceleratedFixedRootBackground(device_scale_factor_)); |
777 webview()->settings()->setCompositedScrollingForFramesEnabled( | 802 webview()->settings()->setCompositedScrollingForFramesEnabled( |
778 ShouldUseCompositedScrollingForFrames(device_scale_factor_)); | 803 ShouldUseCompositedScrollingForFrames(device_scale_factor_)); |
779 | 804 |
780 ApplyWebPreferences(webkit_preferences_, webview()); | 805 ApplyWebPreferences(webkit_preferences_, webview()); |
781 | 806 |
782 webview()->settings()->setAllowConnectingInsecureWebSocket( | 807 webview()->settings()->setAllowConnectingInsecureWebSocket( |
783 command_line.HasSwitch(switches::kAllowInsecureWebSocketFromHttpsOrigin)); | 808 command_line.HasSwitch(switches::kAllowInsecureWebSocketFromHttpsOrigin)); |
784 | 809 |
785 RenderFrameProxy* proxy = NULL; | 810 RenderFrameProxy* proxy = NULL; |
786 if (params->proxy_routing_id != MSG_ROUTING_NONE) { | 811 if (params->proxy_routing_id != MSG_ROUTING_NONE) { |
(...skipping 2947 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3734 keep_selection); | 3759 keep_selection); |
3735 } | 3760 } |
3736 | 3761 |
3737 void RenderViewImpl::SetDeviceScaleFactor(float device_scale_factor) { | 3762 void RenderViewImpl::SetDeviceScaleFactor(float device_scale_factor) { |
3738 RenderWidget::SetDeviceScaleFactor(device_scale_factor); | 3763 RenderWidget::SetDeviceScaleFactor(device_scale_factor); |
3739 if (webview()) { | 3764 if (webview()) { |
3740 webview()->setDeviceScaleFactor(device_scale_factor); | 3765 webview()->setDeviceScaleFactor(device_scale_factor); |
3741 webview()->settings()->setPreferCompositingToLCDTextEnabled( | 3766 webview()->settings()->setPreferCompositingToLCDTextEnabled( |
3742 PreferCompositingToLCDText(device_scale_factor_)); | 3767 PreferCompositingToLCDText(device_scale_factor_)); |
3743 webview()->settings()->setAcceleratedCompositingForOverflowScrollEnabled( | 3768 webview()->settings()->setAcceleratedCompositingForOverflowScrollEnabled( |
3744 PreferCompositingToLCDText(device_scale_factor_)); | 3769 ShouldUseAcceleratedCompositingForOverflowScroll(device_scale_factor_)); |
3745 webview()->settings()->setAcceleratedCompositingForTransitionEnabled( | 3770 webview()->settings()->setAcceleratedCompositingForTransitionEnabled( |
3746 ShouldUseTransitionCompositing(device_scale_factor_)); | 3771 ShouldUseTransitionCompositing(device_scale_factor_)); |
3747 webview() | 3772 webview()->settings()-> |
3748 ->settings() | 3773 setAcceleratedCompositingForFixedRootBackgroundEnabled( |
3749 ->setAcceleratedCompositingForFixedRootBackgroundEnabled( | 3774 ShouldUseAcceleratedFixedRootBackground(device_scale_factor_)); |
3750 PreferCompositingToLCDText(device_scale_factor_)); | |
3751 webview()->settings()->setCompositedScrollingForFramesEnabled( | 3775 webview()->settings()->setCompositedScrollingForFramesEnabled( |
3752 ShouldUseCompositedScrollingForFrames(device_scale_factor_)); | 3776 ShouldUseCompositedScrollingForFrames(device_scale_factor_)); |
3753 } | 3777 } |
3754 if (auto_resize_mode_) | 3778 if (auto_resize_mode_) |
3755 AutoResizeCompositor(); | 3779 AutoResizeCompositor(); |
3756 | 3780 |
3757 if (browser_plugin_manager_.get()) | 3781 if (browser_plugin_manager_.get()) |
3758 browser_plugin_manager_->UpdateDeviceScaleFactor(device_scale_factor_); | 3782 browser_plugin_manager_->UpdateDeviceScaleFactor(device_scale_factor_); |
3759 } | 3783 } |
3760 | 3784 |
(...skipping 547 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4308 std::vector<gfx::Size> sizes; | 4332 std::vector<gfx::Size> sizes; |
4309 ConvertToFaviconSizes(icon_urls[i].sizes(), &sizes); | 4333 ConvertToFaviconSizes(icon_urls[i].sizes(), &sizes); |
4310 if (!url.isEmpty()) | 4334 if (!url.isEmpty()) |
4311 urls.push_back( | 4335 urls.push_back( |
4312 FaviconURL(url, ToFaviconType(icon_urls[i].iconType()), sizes)); | 4336 FaviconURL(url, ToFaviconType(icon_urls[i].iconType()), sizes)); |
4313 } | 4337 } |
4314 SendUpdateFaviconURL(urls); | 4338 SendUpdateFaviconURL(urls); |
4315 } | 4339 } |
4316 | 4340 |
4317 } // namespace content | 4341 } // namespace content |
OLD | NEW |