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