| 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 641 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 652 page_scale_factor_is_one_(true) { | 652 page_scale_factor_is_one_(true) { |
| 653 } | 653 } |
| 654 | 654 |
| 655 void RenderViewImpl::Initialize(const ViewMsg_New_Params& params, | 655 void RenderViewImpl::Initialize(const ViewMsg_New_Params& params, |
| 656 CompositorDependencies* compositor_deps, | 656 CompositorDependencies* compositor_deps, |
| 657 bool was_created_by_renderer) { | 657 bool was_created_by_renderer) { |
| 658 routing_id_ = params.view_id; | 658 routing_id_ = params.view_id; |
| 659 surface_id_ = params.surface_id; | 659 surface_id_ = params.surface_id; |
| 660 if (params.opener_route_id != MSG_ROUTING_NONE && was_created_by_renderer) | 660 if (params.opener_route_id != MSG_ROUTING_NONE && was_created_by_renderer) |
| 661 opener_id_ = params.opener_route_id; | 661 opener_id_ = params.opener_route_id; |
| 662 display_mode_= params.initial_size.display_mode; |
| 662 | 663 |
| 663 // Ensure we start with a valid next_page_id_ from the browser. | 664 // Ensure we start with a valid next_page_id_ from the browser. |
| 664 DCHECK_GE(next_page_id_, 0); | 665 DCHECK_GE(next_page_id_, 0); |
| 665 | 666 |
| 666 main_render_frame_.reset(RenderFrameImpl::Create( | 667 main_render_frame_.reset(RenderFrameImpl::Create( |
| 667 this, params.main_frame_routing_id)); | 668 this, params.main_frame_routing_id)); |
| 668 // The main frame WebLocalFrame object is closed by | 669 // The main frame WebLocalFrame object is closed by |
| 669 // RenderFrameImpl::frameDetached(). | 670 // RenderFrameImpl::frameDetached(). |
| 670 WebLocalFrame* web_frame = WebLocalFrame::create(main_render_frame_.get()); | 671 WebLocalFrame* web_frame = WebLocalFrame::create(main_render_frame_.get()); |
| 671 main_render_frame_->SetWebFrame(web_frame); | 672 main_render_frame_->SetWebFrame(web_frame); |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 708 // If this is a popup, we must wait for the CreatingNew_ACK message before | 709 // If this is a popup, we must wait for the CreatingNew_ACK message before |
| 709 // completing initialization. Otherwise, we can finish it now. | 710 // completing initialization. Otherwise, we can finish it now. |
| 710 if (opener_id_ == MSG_ROUTING_NONE) { | 711 if (opener_id_ == MSG_ROUTING_NONE) { |
| 711 did_show_ = true; | 712 did_show_ = true; |
| 712 CompleteInit(); | 713 CompleteInit(); |
| 713 } | 714 } |
| 714 | 715 |
| 715 g_view_map.Get().insert(std::make_pair(webview(), this)); | 716 g_view_map.Get().insert(std::make_pair(webview(), this)); |
| 716 g_routing_id_view_map.Get().insert(std::make_pair(routing_id_, this)); | 717 g_routing_id_view_map.Get().insert(std::make_pair(routing_id_, this)); |
| 717 webview()->setDeviceScaleFactor(device_scale_factor_); | 718 webview()->setDeviceScaleFactor(device_scale_factor_); |
| 719 webview()->setDisplayMode(display_mode_); |
| 718 webview()->settings()->setPreferCompositingToLCDTextEnabled( | 720 webview()->settings()->setPreferCompositingToLCDTextEnabled( |
| 719 PreferCompositingToLCDText(compositor_deps_, device_scale_factor_)); | 721 PreferCompositingToLCDText(compositor_deps_, device_scale_factor_)); |
| 720 webview()->settings()->setThreadedScrollingEnabled( | 722 webview()->settings()->setThreadedScrollingEnabled( |
| 721 !command_line.HasSwitch(switches::kDisableThreadedScrolling)); | 723 !command_line.HasSwitch(switches::kDisableThreadedScrolling)); |
| 722 webview()->settings()->setRootLayerScrolls( | 724 webview()->settings()->setRootLayerScrolls( |
| 723 command_line.HasSwitch(switches::kRootLayerScrolls)); | 725 command_line.HasSwitch(switches::kRootLayerScrolls)); |
| 724 | 726 |
| 725 ApplyWebPreferences(webkit_preferences_, webview()); | 727 ApplyWebPreferences(webkit_preferences_, webview()); |
| 726 | 728 |
| 727 webview()->settings()->setAllowConnectingInsecureWebSocket( | 729 webview()->settings()->setAllowConnectingInsecureWebSocket( |
| (...skipping 2000 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2728 webview()->disableAutoResizeMode(); | 2730 webview()->disableAutoResizeMode(); |
| 2729 | 2731 |
| 2730 if (!new_size.IsEmpty()) { | 2732 if (!new_size.IsEmpty()) { |
| 2731 Resize(new_size, | 2733 Resize(new_size, |
| 2732 physical_backing_size_, | 2734 physical_backing_size_, |
| 2733 top_controls_shrink_blink_size_, | 2735 top_controls_shrink_blink_size_, |
| 2734 top_controls_height_, | 2736 top_controls_height_, |
| 2735 visible_viewport_size_, | 2737 visible_viewport_size_, |
| 2736 resizer_rect_, | 2738 resizer_rect_, |
| 2737 is_fullscreen_, | 2739 is_fullscreen_, |
| 2740 display_mode_, |
| 2738 NO_RESIZE_ACK); | 2741 NO_RESIZE_ACK); |
| 2739 } | 2742 } |
| 2740 } | 2743 } |
| 2741 | 2744 |
| 2742 void RenderViewImpl::OnEnablePreferredSizeChangedMode() { | 2745 void RenderViewImpl::OnEnablePreferredSizeChangedMode() { |
| 2743 if (send_preferred_size_changes_) | 2746 if (send_preferred_size_changes_) |
| 2744 return; | 2747 return; |
| 2745 send_preferred_size_changes_ = true; | 2748 send_preferred_size_changes_ = true; |
| 2746 | 2749 |
| 2747 // Start off with an initial preferred size notification (in case | 2750 // Start off with an initial preferred size notification (in case |
| (...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2913 | 2916 |
| 2914 void RenderViewImpl::OnResize(const ViewMsg_Resize_Params& params) { | 2917 void RenderViewImpl::OnResize(const ViewMsg_Resize_Params& params) { |
| 2915 TRACE_EVENT0("renderer", "RenderViewImpl::OnResize"); | 2918 TRACE_EVENT0("renderer", "RenderViewImpl::OnResize"); |
| 2916 if (webview()) { | 2919 if (webview()) { |
| 2917 webview()->hidePopups(); | 2920 webview()->hidePopups(); |
| 2918 if (send_preferred_size_changes_) { | 2921 if (send_preferred_size_changes_) { |
| 2919 webview()->mainFrame()->setCanHaveScrollbars( | 2922 webview()->mainFrame()->setCanHaveScrollbars( |
| 2920 ShouldDisplayScrollbars(params.new_size.width(), | 2923 ShouldDisplayScrollbars(params.new_size.width(), |
| 2921 params.new_size.height())); | 2924 params.new_size.height())); |
| 2922 } | 2925 } |
| 2926 if (display_mode_ != params.display_mode) { |
| 2927 display_mode_ = params.display_mode; |
| 2928 webview()->setDisplayMode(display_mode_); |
| 2929 } |
| 2923 } | 2930 } |
| 2924 | 2931 |
| 2925 gfx::Size old_visible_viewport_size = visible_viewport_size_; | 2932 gfx::Size old_visible_viewport_size = visible_viewport_size_; |
| 2926 | 2933 |
| 2927 RenderWidget::OnResize(params); | 2934 RenderWidget::OnResize(params); |
| 2928 | 2935 |
| 2929 if (old_visible_viewport_size != visible_viewport_size_) | 2936 if (old_visible_viewport_size != visible_viewport_size_) |
| 2930 has_scrolled_focused_editable_node_into_rect_ = false; | 2937 has_scrolled_focused_editable_node_into_rect_ = false; |
| 2931 } | 2938 } |
| 2932 | 2939 |
| (...skipping 800 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3733 ViewMsg_Resize_Params params; | 3740 ViewMsg_Resize_Params params; |
| 3734 params.screen_info = screen_info_; | 3741 params.screen_info = screen_info_; |
| 3735 params.screen_info.deviceScaleFactor = factor; | 3742 params.screen_info.deviceScaleFactor = factor; |
| 3736 params.new_size = size(); | 3743 params.new_size = size(); |
| 3737 params.visible_viewport_size = visible_viewport_size_; | 3744 params.visible_viewport_size = visible_viewport_size_; |
| 3738 params.physical_backing_size = | 3745 params.physical_backing_size = |
| 3739 gfx::ToCeiledSize(gfx::ScaleSize(size(), factor)); | 3746 gfx::ToCeiledSize(gfx::ScaleSize(size(), factor)); |
| 3740 params.top_controls_shrink_blink_size = false; | 3747 params.top_controls_shrink_blink_size = false; |
| 3741 params.top_controls_height = 0.f; | 3748 params.top_controls_height = 0.f; |
| 3742 params.resizer_rect = WebRect(); | 3749 params.resizer_rect = WebRect(); |
| 3743 params.is_fullscreen = is_fullscreen(); | 3750 params.is_fullscreen = is_fullscreen_; |
| 3751 params.display_mode = display_mode_; |
| 3744 OnResize(params); | 3752 OnResize(params); |
| 3745 } | 3753 } |
| 3746 | 3754 |
| 3747 void RenderViewImpl::SetDeviceColorProfileForTesting( | 3755 void RenderViewImpl::SetDeviceColorProfileForTesting( |
| 3748 const std::vector<char>& color_profile) { | 3756 const std::vector<char>& color_profile) { |
| 3749 SetDeviceColorProfile(color_profile); | 3757 SetDeviceColorProfile(color_profile); |
| 3750 } | 3758 } |
| 3751 | 3759 |
| 3752 void RenderViewImpl::ForceResizeForTesting(const gfx::Size& new_size) { | 3760 void RenderViewImpl::ForceResizeForTesting(const gfx::Size& new_size) { |
| 3753 gfx::Rect new_window_rect(rootWindowRect().x, | 3761 gfx::Rect new_window_rect(rootWindowRect().x, |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3806 std::vector<gfx::Size> sizes; | 3814 std::vector<gfx::Size> sizes; |
| 3807 ConvertToFaviconSizes(icon_urls[i].sizes(), &sizes); | 3815 ConvertToFaviconSizes(icon_urls[i].sizes(), &sizes); |
| 3808 if (!url.isEmpty()) | 3816 if (!url.isEmpty()) |
| 3809 urls.push_back( | 3817 urls.push_back( |
| 3810 FaviconURL(url, ToFaviconType(icon_urls[i].iconType()), sizes)); | 3818 FaviconURL(url, ToFaviconType(icon_urls[i].iconType()), sizes)); |
| 3811 } | 3819 } |
| 3812 SendUpdateFaviconURL(urls); | 3820 SendUpdateFaviconURL(urls); |
| 3813 } | 3821 } |
| 3814 | 3822 |
| 3815 } // namespace content | 3823 } // namespace content |
| OLD | NEW |