Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(577)

Side by Side Diff: content/renderer/render_view_impl.cc

Issue 287093002: Remove ViewMsg_SetZoomLevel (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Revised as per comments. Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « content/renderer/render_view_impl.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 922 matching lines...) Expand 10 before | Expand all | Expand 10 after
933 next_page_id, 933 next_page_id,
934 screen_info, 934 screen_info,
935 accessibility_mode); 935 accessibility_mode);
936 RenderViewImpl* render_view = NULL; 936 RenderViewImpl* render_view = NULL;
937 if (g_create_render_view_impl) 937 if (g_create_render_view_impl)
938 render_view = g_create_render_view_impl(&params); 938 render_view = g_create_render_view_impl(&params);
939 else 939 else
940 render_view = new RenderViewImpl(&params); 940 render_view = new RenderViewImpl(&params);
941 941
942 render_view->Initialize(&params); 942 render_view->Initialize(&params);
943 // For now, don't remember plugin zoom values. We don't want to mix them with
944 // normal web content (i.e. a fixed layout plugin would usually want them
945 // different).
946 bool uses_temporary_zoom_level =
947 render_view->webview()->mainFrame()->document().isPluginDocument();
948 render_view->Send(new ViewHostMsg_DidCreateDocument(
fsamuel 2014/05/29 20:28:57 Given you pass this information about plugin docum
wjmaclean 2014/05/29 20:52:29 We can try without ... PDFs don't seem to need it.
949 render_view->GetRoutingID(), uses_temporary_zoom_level));
943 return render_view; 950 return render_view;
944 } 951 }
945 952
946 // static 953 // static
947 void RenderViewImpl::InstallCreateHook( 954 void RenderViewImpl::InstallCreateHook(
948 RenderViewImpl* (*create_render_view_impl)(RenderViewImplParams*)) { 955 RenderViewImpl* (*create_render_view_impl)(RenderViewImplParams*)) {
949 CHECK(!g_create_render_view_impl); 956 CHECK(!g_create_render_view_impl);
950 g_create_render_view_impl = create_render_view_impl; 957 g_create_render_view_impl = create_render_view_impl;
951 } 958 }
952 959
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
1065 OnScrollFocusedEditableNodeIntoRect) 1072 OnScrollFocusedEditableNodeIntoRect)
1066 IPC_MESSAGE_HANDLER(InputMsg_SetEditCommandsForNextKeyEvent, 1073 IPC_MESSAGE_HANDLER(InputMsg_SetEditCommandsForNextKeyEvent,
1067 OnSetEditCommandsForNextKeyEvent) 1074 OnSetEditCommandsForNextKeyEvent)
1068 IPC_MESSAGE_HANDLER(FrameMsg_Navigate, OnNavigate) 1075 IPC_MESSAGE_HANDLER(FrameMsg_Navigate, OnNavigate)
1069 IPC_MESSAGE_HANDLER(ViewMsg_Stop, OnStop) 1076 IPC_MESSAGE_HANDLER(ViewMsg_Stop, OnStop)
1070 IPC_MESSAGE_HANDLER(ViewMsg_CopyImageAt, OnCopyImageAt) 1077 IPC_MESSAGE_HANDLER(ViewMsg_CopyImageAt, OnCopyImageAt)
1071 IPC_MESSAGE_HANDLER(ViewMsg_SaveImageAt, OnSaveImageAt) 1078 IPC_MESSAGE_HANDLER(ViewMsg_SaveImageAt, OnSaveImageAt)
1072 IPC_MESSAGE_HANDLER(ViewMsg_Find, OnFind) 1079 IPC_MESSAGE_HANDLER(ViewMsg_Find, OnFind)
1073 IPC_MESSAGE_HANDLER(ViewMsg_StopFinding, OnStopFinding) 1080 IPC_MESSAGE_HANDLER(ViewMsg_StopFinding, OnStopFinding)
1074 IPC_MESSAGE_HANDLER(ViewMsg_Zoom, OnZoom) 1081 IPC_MESSAGE_HANDLER(ViewMsg_Zoom, OnZoom)
1075 IPC_MESSAGE_HANDLER(ViewMsg_SetZoomLevel, OnSetZoomLevel)
1076 IPC_MESSAGE_HANDLER(ViewMsg_SetZoomLevelForLoadingURL, 1082 IPC_MESSAGE_HANDLER(ViewMsg_SetZoomLevelForLoadingURL,
1077 OnSetZoomLevelForLoadingURL) 1083 OnSetZoomLevelForLoadingURL)
1078 IPC_MESSAGE_HANDLER(ViewMsg_SetPageEncoding, OnSetPageEncoding) 1084 IPC_MESSAGE_HANDLER(ViewMsg_SetPageEncoding, OnSetPageEncoding)
1079 IPC_MESSAGE_HANDLER(ViewMsg_ResetPageEncodingToDefault, 1085 IPC_MESSAGE_HANDLER(ViewMsg_ResetPageEncodingToDefault,
1080 OnResetPageEncodingToDefault) 1086 OnResetPageEncodingToDefault)
1081 IPC_MESSAGE_HANDLER(ViewMsg_PostMessageEvent, OnPostMessageEvent) 1087 IPC_MESSAGE_HANDLER(ViewMsg_PostMessageEvent, OnPostMessageEvent)
1082 IPC_MESSAGE_HANDLER(DragMsg_TargetDragEnter, OnDragTargetDragEnter) 1088 IPC_MESSAGE_HANDLER(DragMsg_TargetDragEnter, OnDragTargetDragEnter)
1083 IPC_MESSAGE_HANDLER(DragMsg_TargetDragOver, OnDragTargetDragOver) 1089 IPC_MESSAGE_HANDLER(DragMsg_TargetDragOver, OnDragTargetDragOver)
1084 IPC_MESSAGE_HANDLER(DragMsg_TargetDragLeave, OnDragTargetDragLeave) 1090 IPC_MESSAGE_HANDLER(DragMsg_TargetDragLeave, OnDragTargetDragLeave)
1085 IPC_MESSAGE_HANDLER(DragMsg_TargetDrop, OnDragTargetDrop) 1091 IPC_MESSAGE_HANDLER(DragMsg_TargetDrop, OnDragTargetDrop)
(...skipping 1559 matching lines...) Expand 10 before | Expand all | Expand 10 after
2645 zoom_level = static_cast<int>(old_zoom_level + zoom); 2651 zoom_level = static_cast<int>(old_zoom_level + zoom);
2646 } else { 2652 } else {
2647 // We're going towards 100%, so first go to the next whole number. 2653 // We're going towards 100%, so first go to the next whole number.
2648 zoom_level = static_cast<int>(old_zoom_level); 2654 zoom_level = static_cast<int>(old_zoom_level);
2649 } 2655 }
2650 } 2656 }
2651 webview()->setZoomLevel(zoom_level); 2657 webview()->setZoomLevel(zoom_level);
2652 zoomLevelChanged(); 2658 zoomLevelChanged();
2653 } 2659 }
2654 2660
2655 void RenderViewImpl::OnSetZoomLevel(double zoom_level) {
2656 webview()->hidePopups();
2657 webview()->setZoomLevel(zoom_level);
2658 zoomLevelChanged();
2659 }
2660
2661 void RenderViewImpl::OnSetZoomLevelForLoadingURL(const GURL& url, 2661 void RenderViewImpl::OnSetZoomLevelForLoadingURL(const GURL& url,
2662 double zoom_level) { 2662 double zoom_level) {
2663 #if !defined(OS_ANDROID) 2663 #if !defined(OS_ANDROID)
2664 // On Android, page zoom isn't used, and in case of WebView, text zoom is used 2664 // On Android, page zoom isn't used, and in case of WebView, text zoom is used
2665 // for legacy WebView text scaling emulation. Thus, the code that resets 2665 // for legacy WebView text scaling emulation. Thus, the code that resets
2666 // the zoom level from this map will be effectively resetting text zoom level. 2666 // the zoom level from this map will be effectively resetting text zoom level.
2667 host_zoom_levels_[url] = zoom_level; 2667 host_zoom_levels_[url] = zoom_level;
2668 #endif 2668 #endif
2669 } 2669 }
2670 2670
(...skipping 979 matching lines...) Expand 10 before | Expand all | Expand 10 after
3650 } 3650 }
3651 3651
3652 blink::WebSpeechRecognizer* RenderViewImpl::speechRecognizer() { 3652 blink::WebSpeechRecognizer* RenderViewImpl::speechRecognizer() {
3653 if (!speech_recognition_dispatcher_) 3653 if (!speech_recognition_dispatcher_)
3654 speech_recognition_dispatcher_ = new SpeechRecognitionDispatcher(this); 3654 speech_recognition_dispatcher_ = new SpeechRecognitionDispatcher(this);
3655 return speech_recognition_dispatcher_; 3655 return speech_recognition_dispatcher_;
3656 } 3656 }
3657 3657
3658 void RenderViewImpl::zoomLimitsChanged(double minimum_level, 3658 void RenderViewImpl::zoomLimitsChanged(double minimum_level,
3659 double maximum_level) { 3659 double maximum_level) {
3660 // For now, don't remember plugin zoom values. We don't want to mix them with
3661 // normal web content (i.e. a fixed layout plugin would usually want them
3662 // different).
3663 bool remember = !webview()->mainFrame()->document().isPluginDocument();
3664
3665 int minimum_percent = static_cast<int>( 3660 int minimum_percent = static_cast<int>(
3666 ZoomLevelToZoomFactor(minimum_level) * 100); 3661 ZoomLevelToZoomFactor(minimum_level) * 100);
3667 int maximum_percent = static_cast<int>( 3662 int maximum_percent = static_cast<int>(
3668 ZoomLevelToZoomFactor(maximum_level) * 100); 3663 ZoomLevelToZoomFactor(maximum_level) * 100);
3669 3664
3670 Send(new ViewHostMsg_UpdateZoomLimits( 3665 Send(new ViewHostMsg_UpdateZoomLimits(
3671 routing_id_, minimum_percent, maximum_percent, remember)); 3666 routing_id_, minimum_percent, maximum_percent));
3672 } 3667 }
3673 3668
3674 void RenderViewImpl::zoomLevelChanged() { 3669 void RenderViewImpl::zoomLevelChanged() {
3675 bool remember = !webview()->mainFrame()->document().isPluginDocument();
3676 double zoom_level = webview()->zoomLevel(); 3670 double zoom_level = webview()->zoomLevel();
3677 3671
3678 FOR_EACH_OBSERVER(RenderViewObserver, observers_, ZoomLevelChanged()); 3672 FOR_EACH_OBSERVER(RenderViewObserver, observers_, ZoomLevelChanged());
3679 3673
3680 // Do not send empty URLs to the browser when we are just setting the default 3674 // Do not send empty URLs to the browser when we are just setting the default
3681 // zoom level (from RendererPreferences) before the first navigation. 3675 // zoom level (from RendererPreferences) before the first navigation.
3682 if (!webview()->mainFrame()->document().url().isEmpty()) { 3676 if (!webview()->mainFrame()->document().url().isEmpty()) {
3683 // Tell the browser which url got zoomed so it can update the menu and the 3677 // Tell the browser which url got zoomed so it can update the menu and the
3684 // saved values if necessary 3678 // saved values if necessary
3685 Send(new ViewHostMsg_DidZoomURL( 3679 Send(new ViewHostMsg_DidZoomURL(
3686 routing_id_, zoom_level, remember, 3680 routing_id_, zoom_level,
3687 GURL(webview()->mainFrame()->document().url()))); 3681 GURL(webview()->mainFrame()->document().url())));
3688 } 3682 }
3689 } 3683 }
3690 3684
3691 double RenderViewImpl::zoomLevelToZoomFactor(double zoom_level) const { 3685 double RenderViewImpl::zoomLevelToZoomFactor(double zoom_level) const {
3692 return ZoomLevelToZoomFactor(zoom_level); 3686 return ZoomLevelToZoomFactor(zoom_level);
3693 } 3687 }
3694 3688
3695 double RenderViewImpl::zoomFactorToZoomLevel(double factor) const { 3689 double RenderViewImpl::zoomFactorToZoomLevel(double factor) const {
3696 return ZoomFactorToZoomLevel(factor); 3690 return ZoomFactorToZoomLevel(factor);
(...skipping 368 matching lines...) Expand 10 before | Expand all | Expand 10 after
4065 std::vector<gfx::Size> sizes; 4059 std::vector<gfx::Size> sizes;
4066 ConvertToFaviconSizes(icon_urls[i].sizes(), &sizes); 4060 ConvertToFaviconSizes(icon_urls[i].sizes(), &sizes);
4067 if (!url.isEmpty()) 4061 if (!url.isEmpty())
4068 urls.push_back( 4062 urls.push_back(
4069 FaviconURL(url, ToFaviconType(icon_urls[i].iconType()), sizes)); 4063 FaviconURL(url, ToFaviconType(icon_urls[i].iconType()), sizes));
4070 } 4064 }
4071 SendUpdateFaviconURL(urls); 4065 SendUpdateFaviconURL(urls);
4072 } 4066 }
4073 4067
4074 } // namespace content 4068 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/render_view_impl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698