| 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 635 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 646 page_scale_factor_is_one_(true) { | 646 page_scale_factor_is_one_(true) { |
| 647 } | 647 } |
| 648 | 648 |
| 649 void RenderViewImpl::Initialize(const ViewMsg_New_Params& params, | 649 void RenderViewImpl::Initialize(const ViewMsg_New_Params& params, |
| 650 CompositorDependencies* compositor_deps, | 650 CompositorDependencies* compositor_deps, |
| 651 bool was_created_by_renderer) { | 651 bool was_created_by_renderer) { |
| 652 routing_id_ = params.view_id; | 652 routing_id_ = params.view_id; |
| 653 surface_id_ = params.surface_id; | 653 surface_id_ = params.surface_id; |
| 654 if (params.opener_route_id != MSG_ROUTING_NONE && was_created_by_renderer) | 654 if (params.opener_route_id != MSG_ROUTING_NONE && was_created_by_renderer) |
| 655 opener_id_ = params.opener_route_id; | 655 opener_id_ = params.opener_route_id; |
| 656 display_mode_= params.initial_size.display_mode; |
| 656 | 657 |
| 657 // Ensure we start with a valid next_page_id_ from the browser. | 658 // Ensure we start with a valid next_page_id_ from the browser. |
| 658 DCHECK_GE(next_page_id_, 0); | 659 DCHECK_GE(next_page_id_, 0); |
| 659 | 660 |
| 660 main_render_frame_.reset(RenderFrameImpl::Create( | 661 main_render_frame_.reset(RenderFrameImpl::Create( |
| 661 this, params.main_frame_routing_id)); | 662 this, params.main_frame_routing_id)); |
| 662 // The main frame WebLocalFrame object is closed by | 663 // The main frame WebLocalFrame object is closed by |
| 663 // RenderFrameImpl::frameDetached(). | 664 // RenderFrameImpl::frameDetached(). |
| 664 WebLocalFrame* web_frame = WebLocalFrame::create(main_render_frame_.get()); | 665 WebLocalFrame* web_frame = WebLocalFrame::create(main_render_frame_.get()); |
| 665 main_render_frame_->SetWebFrame(web_frame); | 666 main_render_frame_->SetWebFrame(web_frame); |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 700 // If this is a popup, we must wait for the CreatingNew_ACK message before | 701 // If this is a popup, we must wait for the CreatingNew_ACK message before |
| 701 // completing initialization. Otherwise, we can finish it now. | 702 // completing initialization. Otherwise, we can finish it now. |
| 702 if (opener_id_ == MSG_ROUTING_NONE) { | 703 if (opener_id_ == MSG_ROUTING_NONE) { |
| 703 did_show_ = true; | 704 did_show_ = true; |
| 704 CompleteInit(); | 705 CompleteInit(); |
| 705 } | 706 } |
| 706 | 707 |
| 707 g_view_map.Get().insert(std::make_pair(webview(), this)); | 708 g_view_map.Get().insert(std::make_pair(webview(), this)); |
| 708 g_routing_id_view_map.Get().insert(std::make_pair(routing_id_, this)); | 709 g_routing_id_view_map.Get().insert(std::make_pair(routing_id_, this)); |
| 709 webview()->setDeviceScaleFactor(device_scale_factor_); | 710 webview()->setDeviceScaleFactor(device_scale_factor_); |
| 711 webview()->setDisplayMode(display_mode_); |
| 710 webview()->settings()->setPreferCompositingToLCDTextEnabled( | 712 webview()->settings()->setPreferCompositingToLCDTextEnabled( |
| 711 PreferCompositingToLCDText(compositor_deps_, device_scale_factor_)); | 713 PreferCompositingToLCDText(compositor_deps_, device_scale_factor_)); |
| 712 webview()->settings()->setThreadedScrollingEnabled( | 714 webview()->settings()->setThreadedScrollingEnabled( |
| 713 !command_line.HasSwitch(switches::kDisableThreadedScrolling)); | 715 !command_line.HasSwitch(switches::kDisableThreadedScrolling)); |
| 714 webview()->settings()->setRootLayerScrolls( | 716 webview()->settings()->setRootLayerScrolls( |
| 715 command_line.HasSwitch(switches::kRootLayerScrolls)); | 717 command_line.HasSwitch(switches::kRootLayerScrolls)); |
| 716 | 718 |
| 717 ApplyWebPreferences(webkit_preferences_, webview()); | 719 ApplyWebPreferences(webkit_preferences_, webview()); |
| 718 | 720 |
| 719 RenderFrameProxy* proxy = NULL; | 721 RenderFrameProxy* proxy = NULL; |
| (...skipping 1941 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2661 webview()->disableAutoResizeMode(); | 2663 webview()->disableAutoResizeMode(); |
| 2662 | 2664 |
| 2663 if (!new_size.IsEmpty()) { | 2665 if (!new_size.IsEmpty()) { |
| 2664 Resize(new_size, | 2666 Resize(new_size, |
| 2665 physical_backing_size_, | 2667 physical_backing_size_, |
| 2666 top_controls_shrink_blink_size_, | 2668 top_controls_shrink_blink_size_, |
| 2667 top_controls_height_, | 2669 top_controls_height_, |
| 2668 visible_viewport_size_, | 2670 visible_viewport_size_, |
| 2669 resizer_rect_, | 2671 resizer_rect_, |
| 2670 is_fullscreen_, | 2672 is_fullscreen_, |
| 2673 display_mode_, |
| 2671 NO_RESIZE_ACK); | 2674 NO_RESIZE_ACK); |
| 2672 } | 2675 } |
| 2673 } | 2676 } |
| 2674 | 2677 |
| 2675 void RenderViewImpl::OnEnablePreferredSizeChangedMode() { | 2678 void RenderViewImpl::OnEnablePreferredSizeChangedMode() { |
| 2676 if (send_preferred_size_changes_) | 2679 if (send_preferred_size_changes_) |
| 2677 return; | 2680 return; |
| 2678 send_preferred_size_changes_ = true; | 2681 send_preferred_size_changes_ = true; |
| 2679 | 2682 |
| 2680 // Start off with an initial preferred size notification (in case | 2683 // Start off with an initial preferred size notification (in case |
| (...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2848 | 2851 |
| 2849 void RenderViewImpl::OnResize(const ViewMsg_Resize_Params& params) { | 2852 void RenderViewImpl::OnResize(const ViewMsg_Resize_Params& params) { |
| 2850 TRACE_EVENT0("renderer", "RenderViewImpl::OnResize"); | 2853 TRACE_EVENT0("renderer", "RenderViewImpl::OnResize"); |
| 2851 if (webview()) { | 2854 if (webview()) { |
| 2852 webview()->hidePopups(); | 2855 webview()->hidePopups(); |
| 2853 if (send_preferred_size_changes_) { | 2856 if (send_preferred_size_changes_) { |
| 2854 webview()->mainFrame()->setCanHaveScrollbars( | 2857 webview()->mainFrame()->setCanHaveScrollbars( |
| 2855 ShouldDisplayScrollbars(params.new_size.width(), | 2858 ShouldDisplayScrollbars(params.new_size.width(), |
| 2856 params.new_size.height())); | 2859 params.new_size.height())); |
| 2857 } | 2860 } |
| 2861 if (display_mode_ != params.display_mode) { |
| 2862 display_mode_ = params.display_mode; |
| 2863 webview()->setDisplayMode(display_mode_); |
| 2864 } |
| 2858 } | 2865 } |
| 2859 | 2866 |
| 2860 gfx::Size old_visible_viewport_size = visible_viewport_size_; | 2867 gfx::Size old_visible_viewport_size = visible_viewport_size_; |
| 2861 | 2868 |
| 2862 RenderWidget::OnResize(params); | 2869 RenderWidget::OnResize(params); |
| 2863 | 2870 |
| 2864 if (old_visible_viewport_size != visible_viewport_size_) | 2871 if (old_visible_viewport_size != visible_viewport_size_) |
| 2865 has_scrolled_focused_editable_node_into_rect_ = false; | 2872 has_scrolled_focused_editable_node_into_rect_ = false; |
| 2866 } | 2873 } |
| 2867 | 2874 |
| (...skipping 800 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3668 ViewMsg_Resize_Params params; | 3675 ViewMsg_Resize_Params params; |
| 3669 params.screen_info = screen_info_; | 3676 params.screen_info = screen_info_; |
| 3670 params.screen_info.deviceScaleFactor = factor; | 3677 params.screen_info.deviceScaleFactor = factor; |
| 3671 params.new_size = size(); | 3678 params.new_size = size(); |
| 3672 params.visible_viewport_size = visible_viewport_size_; | 3679 params.visible_viewport_size = visible_viewport_size_; |
| 3673 params.physical_backing_size = | 3680 params.physical_backing_size = |
| 3674 gfx::ToCeiledSize(gfx::ScaleSize(size(), factor)); | 3681 gfx::ToCeiledSize(gfx::ScaleSize(size(), factor)); |
| 3675 params.top_controls_shrink_blink_size = false; | 3682 params.top_controls_shrink_blink_size = false; |
| 3676 params.top_controls_height = 0.f; | 3683 params.top_controls_height = 0.f; |
| 3677 params.resizer_rect = WebRect(); | 3684 params.resizer_rect = WebRect(); |
| 3678 params.is_fullscreen = is_fullscreen(); | 3685 params.is_fullscreen = is_fullscreen_; |
| 3686 params.display_mode = display_mode_; |
| 3679 OnResize(params); | 3687 OnResize(params); |
| 3680 } | 3688 } |
| 3681 | 3689 |
| 3682 void RenderViewImpl::SetDeviceColorProfileForTesting( | 3690 void RenderViewImpl::SetDeviceColorProfileForTesting( |
| 3683 const std::vector<char>& color_profile) { | 3691 const std::vector<char>& color_profile) { |
| 3684 SetDeviceColorProfile(color_profile); | 3692 SetDeviceColorProfile(color_profile); |
| 3685 } | 3693 } |
| 3686 | 3694 |
| 3687 void RenderViewImpl::ForceResizeForTesting(const gfx::Size& new_size) { | 3695 void RenderViewImpl::ForceResizeForTesting(const gfx::Size& new_size) { |
| 3688 gfx::Rect new_window_rect(rootWindowRect().x, | 3696 gfx::Rect new_window_rect(rootWindowRect().x, |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3741 std::vector<gfx::Size> sizes; | 3749 std::vector<gfx::Size> sizes; |
| 3742 ConvertToFaviconSizes(icon_urls[i].sizes(), &sizes); | 3750 ConvertToFaviconSizes(icon_urls[i].sizes(), &sizes); |
| 3743 if (!url.isEmpty()) | 3751 if (!url.isEmpty()) |
| 3744 urls.push_back( | 3752 urls.push_back( |
| 3745 FaviconURL(url, ToFaviconType(icon_urls[i].iconType()), sizes)); | 3753 FaviconURL(url, ToFaviconType(icon_urls[i].iconType()), sizes)); |
| 3746 } | 3754 } |
| 3747 SendUpdateFaviconURL(urls); | 3755 SendUpdateFaviconURL(urls); |
| 3748 } | 3756 } |
| 3749 | 3757 |
| 3750 } // namespace content | 3758 } // namespace content |
| OLD | NEW |