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 369 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
380 static bool DeviceScaleEnsuresTextQuality(float device_scale_factor) { | 380 static bool DeviceScaleEnsuresTextQuality(float device_scale_factor) { |
381 #if defined(OS_ANDROID) | 381 #if defined(OS_ANDROID) |
382 // On Android, we never have subpixel antialiasing. | 382 // On Android, we never have subpixel antialiasing. |
383 return true; | 383 return true; |
384 #else | 384 #else |
385 return device_scale_factor > 1.5f; | 385 return device_scale_factor > 1.5f; |
386 #endif | 386 #endif |
387 | 387 |
388 } | 388 } |
389 | 389 |
390 static bool PreferCompositingToLCDText(float device_scale_factor) { | 390 static bool PreferCompositingToLCDText(CompositorDependencies* compositor_deps, |
| 391 float device_scale_factor) { |
391 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); | 392 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); |
392 if (command_line.HasSwitch(switches::kDisablePreferCompositingToLCDText)) | 393 if (command_line.HasSwitch(switches::kDisablePreferCompositingToLCDText)) |
393 return false; | 394 return false; |
394 if (command_line.HasSwitch(switches::kEnablePreferCompositingToLCDText)) | 395 if (command_line.HasSwitch(switches::kEnablePreferCompositingToLCDText)) |
395 return true; | 396 return true; |
396 if (RenderThreadImpl::current() && | 397 if (!compositor_deps->IsLcdTextEnabled()) |
397 !RenderThreadImpl::current()->is_lcd_text_enabled()) | |
398 return true; | 398 return true; |
399 return DeviceScaleEnsuresTextQuality(device_scale_factor); | 399 return DeviceScaleEnsuresTextQuality(device_scale_factor); |
400 } | 400 } |
401 | 401 |
402 static FaviconURL::IconType ToFaviconType(blink::WebIconURL::Type type) { | 402 static FaviconURL::IconType ToFaviconType(blink::WebIconURL::Type type) { |
403 switch (type) { | 403 switch (type) { |
404 case blink::WebIconURL::TypeFavicon: | 404 case blink::WebIconURL::TypeFavicon: |
405 return FaviconURL::FAVICON; | 405 return FaviconURL::FAVICON; |
406 case blink::WebIconURL::TypeTouch: | 406 case blink::WebIconURL::TypeTouch: |
407 return FaviconURL::TOUCH_ICON; | 407 return FaviconURL::TOUCH_ICON; |
(...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
665 #if defined(ENABLE_PLUGINS) | 665 #if defined(ENABLE_PLUGINS) |
666 plugin_find_handler_(NULL), | 666 plugin_find_handler_(NULL), |
667 focused_pepper_plugin_(NULL), | 667 focused_pepper_plugin_(NULL), |
668 pepper_last_mouse_event_target_(NULL), | 668 pepper_last_mouse_event_target_(NULL), |
669 #endif | 669 #endif |
670 enumeration_completion_id_(0), | 670 enumeration_completion_id_(0), |
671 session_storage_namespace_id_(params.session_storage_namespace_id), | 671 session_storage_namespace_id_(params.session_storage_namespace_id), |
672 next_snapshot_id_(0) { | 672 next_snapshot_id_(0) { |
673 } | 673 } |
674 | 674 |
675 void RenderViewImpl::Initialize( | 675 void RenderViewImpl::Initialize(const ViewMsg_New_Params& params, |
676 const ViewMsg_New_Params& params, | 676 CompositorDependencies* compositor_deps, |
677 bool was_created_by_renderer) { | 677 bool was_created_by_renderer) { |
678 routing_id_ = params.view_id; | 678 routing_id_ = params.view_id; |
679 surface_id_ = params.surface_id; | 679 surface_id_ = params.surface_id; |
680 if (params.opener_route_id != MSG_ROUTING_NONE && was_created_by_renderer) | 680 if (params.opener_route_id != MSG_ROUTING_NONE && was_created_by_renderer) |
681 opener_id_ = params.opener_route_id; | 681 opener_id_ = params.opener_route_id; |
682 | 682 |
683 // Ensure we start with a valid next_page_id_ from the browser. | 683 // Ensure we start with a valid next_page_id_ from the browser. |
684 DCHECK_GE(next_page_id_, 0); | 684 DCHECK_GE(next_page_id_, 0); |
685 | 685 |
686 main_render_frame_.reset(RenderFrameImpl::Create( | 686 main_render_frame_.reset(RenderFrameImpl::Create( |
687 this, params.main_frame_routing_id)); | 687 this, params.main_frame_routing_id)); |
688 // The main frame WebLocalFrame object is closed by | 688 // The main frame WebLocalFrame object is closed by |
689 // RenderFrameImpl::frameDetached(). | 689 // RenderFrameImpl::frameDetached(). |
690 WebLocalFrame* web_frame = WebLocalFrame::create(main_render_frame_.get()); | 690 WebLocalFrame* web_frame = WebLocalFrame::create(main_render_frame_.get()); |
691 main_render_frame_->SetWebFrame(web_frame); | 691 main_render_frame_->SetWebFrame(web_frame); |
692 | 692 |
| 693 compositor_deps_ = compositor_deps; |
693 webwidget_ = WebView::create(this); | 694 webwidget_ = WebView::create(this); |
694 webwidget_mouse_lock_target_.reset(new WebWidgetLockTarget(webwidget_)); | 695 webwidget_mouse_lock_target_.reset(new WebWidgetLockTarget(webwidget_)); |
695 | 696 |
696 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); | 697 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); |
697 | 698 |
698 if (command_line.HasSwitch(switches::kStatsCollectionController)) | 699 if (command_line.HasSwitch(switches::kStatsCollectionController)) |
699 stats_collection_observer_.reset(new StatsCollectionObserver(this)); | 700 stats_collection_observer_.reset(new StatsCollectionObserver(this)); |
700 | 701 |
701 #if defined(OS_ANDROID) | 702 #if defined(OS_ANDROID) |
702 const std::string region_code = | 703 const std::string region_code = |
(...skipping 24 matching lines...) Expand all Loading... |
727 // completing initialization. Otherwise, we can finish it now. | 728 // completing initialization. Otherwise, we can finish it now. |
728 if (opener_id_ == MSG_ROUTING_NONE) { | 729 if (opener_id_ == MSG_ROUTING_NONE) { |
729 did_show_ = true; | 730 did_show_ = true; |
730 CompleteInit(); | 731 CompleteInit(); |
731 } | 732 } |
732 | 733 |
733 g_view_map.Get().insert(std::make_pair(webview(), this)); | 734 g_view_map.Get().insert(std::make_pair(webview(), this)); |
734 g_routing_id_view_map.Get().insert(std::make_pair(routing_id_, this)); | 735 g_routing_id_view_map.Get().insert(std::make_pair(routing_id_, this)); |
735 webview()->setDeviceScaleFactor(device_scale_factor_); | 736 webview()->setDeviceScaleFactor(device_scale_factor_); |
736 webview()->settings()->setPreferCompositingToLCDTextEnabled( | 737 webview()->settings()->setPreferCompositingToLCDTextEnabled( |
737 PreferCompositingToLCDText(device_scale_factor_)); | 738 PreferCompositingToLCDText(compositor_deps_, device_scale_factor_)); |
738 webview()->settings()->setThreadedScrollingEnabled( | 739 webview()->settings()->setThreadedScrollingEnabled( |
739 !command_line.HasSwitch(switches::kDisableThreadedScrolling)); | 740 !command_line.HasSwitch(switches::kDisableThreadedScrolling)); |
740 webview()->settings()->setRootLayerScrolls( | 741 webview()->settings()->setRootLayerScrolls( |
741 command_line.HasSwitch(switches::kRootLayerScrolls)); | 742 command_line.HasSwitch(switches::kRootLayerScrolls)); |
742 | 743 |
743 ApplyWebPreferences(webkit_preferences_, webview()); | 744 ApplyWebPreferences(webkit_preferences_, webview()); |
744 | 745 |
745 webview()->settings()->setAllowConnectingInsecureWebSocket( | 746 webview()->settings()->setAllowConnectingInsecureWebSocket( |
746 command_line.HasSwitch(switches::kAllowInsecureWebSocketFromHttpsOrigin)); | 747 command_line.HasSwitch(switches::kAllowInsecureWebSocketFromHttpsOrigin)); |
747 | 748 |
748 RenderFrameProxy* proxy = NULL; | 749 RenderFrameProxy* proxy = NULL; |
749 if (params.proxy_routing_id != MSG_ROUTING_NONE) { | 750 if (params.proxy_routing_id != MSG_ROUTING_NONE) { |
750 CHECK(params.swapped_out); | 751 CHECK(params.swapped_out); |
751 proxy = RenderFrameProxy::CreateProxyToReplaceFrame( | 752 proxy = RenderFrameProxy::CreateProxyToReplaceFrame( |
752 main_render_frame_.get(), params.proxy_routing_id); | 753 main_render_frame_.get(), params.proxy_routing_id); |
753 main_render_frame_->set_render_frame_proxy(proxy); | 754 main_render_frame_->set_render_frame_proxy(proxy); |
754 } | 755 } |
755 | 756 |
756 // In --site-per-process, just use the WebRemoteFrame as the main frame. | 757 // In --site-per-process, just use the WebRemoteFrame as the main frame. |
757 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kSitePerProcess) && | 758 if (command_line.HasSwitch(switches::kSitePerProcess) && proxy) { |
758 proxy) { | |
759 webview()->setMainFrame(proxy->web_frame()); | 759 webview()->setMainFrame(proxy->web_frame()); |
760 // Initialize the WebRemoteFrame with information replicated from the | 760 // Initialize the WebRemoteFrame with information replicated from the |
761 // browser process. | 761 // browser process. |
762 proxy->SetReplicatedState(params.replicated_frame_state); | 762 proxy->SetReplicatedState(params.replicated_frame_state); |
763 } else { | 763 } else { |
764 webview()->setMainFrame(main_render_frame_->GetWebFrame()); | 764 webview()->setMainFrame(main_render_frame_->GetWebFrame()); |
765 } | 765 } |
766 main_render_frame_->Initialize(); | 766 main_render_frame_->Initialize(); |
767 | 767 |
768 if (switches::IsTouchDragDropEnabled()) | 768 if (switches::IsTouchDragDropEnabled()) |
(...skipping 357 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1126 settings->setRubberBandingOnCompositorThread( | 1126 settings->setRubberBandingOnCompositorThread( |
1127 prefs.rubber_banding_on_compositor_thread); | 1127 prefs.rubber_banding_on_compositor_thread); |
1128 settings->setUseSolidColorScrollbars(prefs.use_solid_color_scrollbars); | 1128 settings->setUseSolidColorScrollbars(prefs.use_solid_color_scrollbars); |
1129 | 1129 |
1130 #if defined(OS_WIN) | 1130 #if defined(OS_WIN) |
1131 settings->setShowContextMenuOnMouseUp(true); | 1131 settings->setShowContextMenuOnMouseUp(true); |
1132 #endif | 1132 #endif |
1133 } | 1133 } |
1134 | 1134 |
1135 /*static*/ | 1135 /*static*/ |
1136 RenderViewImpl* RenderViewImpl::Create( | 1136 RenderViewImpl* RenderViewImpl::Create(const ViewMsg_New_Params& params, |
1137 const ViewMsg_New_Params& params, | 1137 CompositorDependencies* compositor_deps, |
1138 bool was_created_by_renderer) { | 1138 bool was_created_by_renderer) { |
1139 DCHECK(params.view_id != MSG_ROUTING_NONE); | 1139 DCHECK(params.view_id != MSG_ROUTING_NONE); |
1140 RenderViewImpl* render_view = NULL; | 1140 RenderViewImpl* render_view = NULL; |
1141 if (g_create_render_view_impl) | 1141 if (g_create_render_view_impl) |
1142 render_view = g_create_render_view_impl(params); | 1142 render_view = g_create_render_view_impl(params); |
1143 else | 1143 else |
1144 render_view = new RenderViewImpl(params); | 1144 render_view = new RenderViewImpl(params); |
1145 | 1145 |
1146 render_view->Initialize(params, was_created_by_renderer); | 1146 render_view->Initialize(params, compositor_deps, was_created_by_renderer); |
1147 return render_view; | 1147 return render_view; |
1148 } | 1148 } |
1149 | 1149 |
1150 // static | 1150 // static |
1151 void RenderViewImpl::InstallCreateHook( | 1151 void RenderViewImpl::InstallCreateHook( |
1152 RenderViewImpl* (*create_render_view_impl)(const ViewMsg_New_Params&)) { | 1152 RenderViewImpl* (*create_render_view_impl)(const ViewMsg_New_Params&)) { |
1153 CHECK(!g_create_render_view_impl); | 1153 CHECK(!g_create_render_view_impl); |
1154 g_create_render_view_impl = create_render_view_impl; | 1154 g_create_render_view_impl = create_render_view_impl; |
1155 } | 1155 } |
1156 | 1156 |
(...skipping 418 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1575 params.features = features; | 1575 params.features = features; |
1576 | 1576 |
1577 for (size_t i = 0; i < features.additionalFeatures.size(); ++i) | 1577 for (size_t i = 0; i < features.additionalFeatures.size(); ++i) |
1578 params.additional_features.push_back(features.additionalFeatures[i]); | 1578 params.additional_features.push_back(features.additionalFeatures[i]); |
1579 | 1579 |
1580 int32 routing_id = MSG_ROUTING_NONE; | 1580 int32 routing_id = MSG_ROUTING_NONE; |
1581 int32 main_frame_routing_id = MSG_ROUTING_NONE; | 1581 int32 main_frame_routing_id = MSG_ROUTING_NONE; |
1582 int32 surface_id = 0; | 1582 int32 surface_id = 0; |
1583 int64 cloned_session_storage_namespace_id = 0; | 1583 int64 cloned_session_storage_namespace_id = 0; |
1584 | 1584 |
1585 RenderThread::Get()->Send( | 1585 RenderThread::Get()->Send(new ViewHostMsg_CreateWindow( |
1586 new ViewHostMsg_CreateWindow(params, | 1586 params, &routing_id, &main_frame_routing_id, &surface_id, |
1587 &routing_id, | 1587 &cloned_session_storage_namespace_id)); |
1588 &main_frame_routing_id, | |
1589 &surface_id, | |
1590 &cloned_session_storage_namespace_id)); | |
1591 if (routing_id == MSG_ROUTING_NONE) | 1588 if (routing_id == MSG_ROUTING_NONE) |
1592 return NULL; | 1589 return NULL; |
1593 | 1590 |
1594 WebUserGestureIndicator::consumeUserGesture(); | 1591 WebUserGestureIndicator::consumeUserGesture(); |
1595 | 1592 |
1596 // While this view may be a background extension page, it can spawn a visible | 1593 // While this view may be a background extension page, it can spawn a visible |
1597 // render view. So we just assume that the new one is not another background | 1594 // render view. So we just assume that the new one is not another background |
1598 // page instead of passing on our own value. | 1595 // page instead of passing on our own value. |
1599 // TODO(vangelis): Can we tell if the new view will be a background page? | 1596 // TODO(vangelis): Can we tell if the new view will be a background page? |
1600 bool never_visible = false; | 1597 bool never_visible = false; |
(...skipping 22 matching lines...) Expand all Loading... |
1623 view_params.replicated_frame_state = FrameReplicationState(); | 1620 view_params.replicated_frame_state = FrameReplicationState(); |
1624 view_params.proxy_routing_id = MSG_ROUTING_NONE; | 1621 view_params.proxy_routing_id = MSG_ROUTING_NONE; |
1625 view_params.hidden = (params.disposition == NEW_BACKGROUND_TAB); | 1622 view_params.hidden = (params.disposition == NEW_BACKGROUND_TAB); |
1626 view_params.never_visible = never_visible; | 1623 view_params.never_visible = never_visible; |
1627 view_params.next_page_id = 1; | 1624 view_params.next_page_id = 1; |
1628 view_params.initial_size = initial_size; | 1625 view_params.initial_size = initial_size; |
1629 view_params.enable_auto_resize = false; | 1626 view_params.enable_auto_resize = false; |
1630 view_params.min_size = gfx::Size(); | 1627 view_params.min_size = gfx::Size(); |
1631 view_params.max_size = gfx::Size(); | 1628 view_params.max_size = gfx::Size(); |
1632 | 1629 |
1633 RenderViewImpl* view = RenderViewImpl::Create(view_params, true); | 1630 RenderViewImpl* view = |
| 1631 RenderViewImpl::Create(view_params, compositor_deps_, true); |
1634 view->opened_by_user_gesture_ = params.user_gesture; | 1632 view->opened_by_user_gesture_ = params.user_gesture; |
1635 | 1633 |
1636 // Record whether the creator frame is trying to suppress the opener field. | 1634 // Record whether the creator frame is trying to suppress the opener field. |
1637 view->opener_suppressed_ = params.opener_suppressed; | 1635 view->opener_suppressed_ = params.opener_suppressed; |
1638 | 1636 |
1639 return view->webview(); | 1637 return view->webview(); |
1640 } | 1638 } |
1641 | 1639 |
1642 WebWidget* RenderViewImpl::createPopupMenu(blink::WebPopupType popup_type) { | 1640 WebWidget* RenderViewImpl::createPopupMenu(blink::WebPopupType popup_type) { |
1643 RenderWidget* widget = | 1641 RenderWidget* widget = RenderWidget::Create(routing_id_, compositor_deps_, |
1644 RenderWidget::Create(routing_id_, popup_type, screen_info_); | 1642 popup_type, screen_info_); |
1645 if (!widget) | 1643 if (!widget) |
1646 return NULL; | 1644 return NULL; |
1647 if (screen_metrics_emulator_) { | 1645 if (screen_metrics_emulator_) { |
1648 widget->SetPopupOriginAdjustmentsForEmulation( | 1646 widget->SetPopupOriginAdjustmentsForEmulation( |
1649 screen_metrics_emulator_.get()); | 1647 screen_metrics_emulator_.get()); |
1650 } | 1648 } |
1651 return widget->webwidget(); | 1649 return widget->webwidget(); |
1652 } | 1650 } |
1653 | 1651 |
1654 WebStorageNamespace* RenderViewImpl::createSessionStorageNamespace() { | 1652 WebStorageNamespace* RenderViewImpl::createSessionStorageNamespace() { |
(...skipping 1927 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3582 RenderWidget::OnImeConfirmComposition(text, | 3580 RenderWidget::OnImeConfirmComposition(text, |
3583 replacement_range, | 3581 replacement_range, |
3584 keep_selection); | 3582 keep_selection); |
3585 } | 3583 } |
3586 | 3584 |
3587 void RenderViewImpl::SetDeviceScaleFactor(float device_scale_factor) { | 3585 void RenderViewImpl::SetDeviceScaleFactor(float device_scale_factor) { |
3588 RenderWidget::SetDeviceScaleFactor(device_scale_factor); | 3586 RenderWidget::SetDeviceScaleFactor(device_scale_factor); |
3589 if (webview()) { | 3587 if (webview()) { |
3590 webview()->setDeviceScaleFactor(device_scale_factor); | 3588 webview()->setDeviceScaleFactor(device_scale_factor); |
3591 webview()->settings()->setPreferCompositingToLCDTextEnabled( | 3589 webview()->settings()->setPreferCompositingToLCDTextEnabled( |
3592 PreferCompositingToLCDText(device_scale_factor_)); | 3590 PreferCompositingToLCDText(compositor_deps_, device_scale_factor_)); |
3593 } | 3591 } |
3594 if (auto_resize_mode_) | 3592 if (auto_resize_mode_) |
3595 AutoResizeCompositor(); | 3593 AutoResizeCompositor(); |
3596 | 3594 |
3597 if (browser_plugin_manager_.get()) | 3595 if (browser_plugin_manager_.get()) |
3598 browser_plugin_manager_->UpdateDeviceScaleFactor(); | 3596 browser_plugin_manager_->UpdateDeviceScaleFactor(); |
3599 } | 3597 } |
3600 | 3598 |
3601 bool RenderViewImpl::SetDeviceColorProfile( | 3599 bool RenderViewImpl::SetDeviceColorProfile( |
3602 const std::vector<char>& profile) { | 3600 const std::vector<char>& profile) { |
(...skipping 503 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4106 std::vector<gfx::Size> sizes; | 4104 std::vector<gfx::Size> sizes; |
4107 ConvertToFaviconSizes(icon_urls[i].sizes(), &sizes); | 4105 ConvertToFaviconSizes(icon_urls[i].sizes(), &sizes); |
4108 if (!url.isEmpty()) | 4106 if (!url.isEmpty()) |
4109 urls.push_back( | 4107 urls.push_back( |
4110 FaviconURL(url, ToFaviconType(icon_urls[i].iconType()), sizes)); | 4108 FaviconURL(url, ToFaviconType(icon_urls[i].iconType()), sizes)); |
4111 } | 4109 } |
4112 SendUpdateFaviconURL(urls); | 4110 SendUpdateFaviconURL(urls); |
4113 } | 4111 } |
4114 | 4112 |
4115 } // namespace content | 4113 } // namespace content |
OLD | NEW |