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

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

Issue 954923005: Make command-zero reset page scale in addition to zoom level (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase again again Created 5 years, 9 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
« 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 642 matching lines...) Expand 10 before | Expand all | Expand 10 after
653 #if defined(OS_WIN) 653 #if defined(OS_WIN)
654 focused_plugin_id_(-1), 654 focused_plugin_id_(-1),
655 #endif 655 #endif
656 #if defined(ENABLE_PLUGINS) 656 #if defined(ENABLE_PLUGINS)
657 plugin_find_handler_(NULL), 657 plugin_find_handler_(NULL),
658 focused_pepper_plugin_(NULL), 658 focused_pepper_plugin_(NULL),
659 pepper_last_mouse_event_target_(NULL), 659 pepper_last_mouse_event_target_(NULL),
660 #endif 660 #endif
661 enumeration_completion_id_(0), 661 enumeration_completion_id_(0),
662 session_storage_namespace_id_(params.session_storage_namespace_id), 662 session_storage_namespace_id_(params.session_storage_namespace_id),
663 next_snapshot_id_(0) { 663 next_snapshot_id_(0),
664 page_scale_factor_is_one_(true) {
664 } 665 }
665 666
666 void RenderViewImpl::Initialize(const ViewMsg_New_Params& params, 667 void RenderViewImpl::Initialize(const ViewMsg_New_Params& params,
667 CompositorDependencies* compositor_deps, 668 CompositorDependencies* compositor_deps,
668 bool was_created_by_renderer) { 669 bool was_created_by_renderer) {
669 routing_id_ = params.view_id; 670 routing_id_ = params.view_id;
670 surface_id_ = params.surface_id; 671 surface_id_ = params.surface_id;
671 if (params.opener_route_id != MSG_ROUTING_NONE && was_created_by_renderer) 672 if (params.opener_route_id != MSG_ROUTING_NONE && was_created_by_renderer)
672 opener_id_ = params.opener_route_id; 673 opener_id_ = params.opener_route_id;
673 674
(...skipping 604 matching lines...) Expand 10 before | Expand all | Expand 10 after
1278 IPC_MESSAGE_HANDLER(InputMsg_ExecuteEditCommand, OnExecuteEditCommand) 1279 IPC_MESSAGE_HANDLER(InputMsg_ExecuteEditCommand, OnExecuteEditCommand)
1279 IPC_MESSAGE_HANDLER(InputMsg_MoveCaret, OnMoveCaret) 1280 IPC_MESSAGE_HANDLER(InputMsg_MoveCaret, OnMoveCaret)
1280 IPC_MESSAGE_HANDLER(InputMsg_ScrollFocusedEditableNodeIntoRect, 1281 IPC_MESSAGE_HANDLER(InputMsg_ScrollFocusedEditableNodeIntoRect,
1281 OnScrollFocusedEditableNodeIntoRect) 1282 OnScrollFocusedEditableNodeIntoRect)
1282 IPC_MESSAGE_HANDLER(InputMsg_SetEditCommandsForNextKeyEvent, 1283 IPC_MESSAGE_HANDLER(InputMsg_SetEditCommandsForNextKeyEvent,
1283 OnSetEditCommandsForNextKeyEvent) 1284 OnSetEditCommandsForNextKeyEvent)
1284 IPC_MESSAGE_HANDLER(ViewMsg_CopyImageAt, OnCopyImageAt) 1285 IPC_MESSAGE_HANDLER(ViewMsg_CopyImageAt, OnCopyImageAt)
1285 IPC_MESSAGE_HANDLER(ViewMsg_SaveImageAt, OnSaveImageAt) 1286 IPC_MESSAGE_HANDLER(ViewMsg_SaveImageAt, OnSaveImageAt)
1286 IPC_MESSAGE_HANDLER(ViewMsg_Find, OnFind) 1287 IPC_MESSAGE_HANDLER(ViewMsg_Find, OnFind)
1287 IPC_MESSAGE_HANDLER(ViewMsg_StopFinding, OnStopFinding) 1288 IPC_MESSAGE_HANDLER(ViewMsg_StopFinding, OnStopFinding)
1289 IPC_MESSAGE_HANDLER(ViewMsg_ResetPageScale, OnResetPageScale)
1288 IPC_MESSAGE_HANDLER(ViewMsg_Zoom, OnZoom) 1290 IPC_MESSAGE_HANDLER(ViewMsg_Zoom, OnZoom)
1289 IPC_MESSAGE_HANDLER(ViewMsg_SetZoomLevelForLoadingURL, 1291 IPC_MESSAGE_HANDLER(ViewMsg_SetZoomLevelForLoadingURL,
1290 OnSetZoomLevelForLoadingURL) 1292 OnSetZoomLevelForLoadingURL)
1291 IPC_MESSAGE_HANDLER(ViewMsg_SetZoomLevelForView, 1293 IPC_MESSAGE_HANDLER(ViewMsg_SetZoomLevelForView,
1292 OnSetZoomLevelForView) 1294 OnSetZoomLevelForView)
1293 IPC_MESSAGE_HANDLER(ViewMsg_SetPageEncoding, OnSetPageEncoding) 1295 IPC_MESSAGE_HANDLER(ViewMsg_SetPageEncoding, OnSetPageEncoding)
1294 IPC_MESSAGE_HANDLER(ViewMsg_ResetPageEncodingToDefault, 1296 IPC_MESSAGE_HANDLER(ViewMsg_ResetPageEncodingToDefault,
1295 OnResetPageEncodingToDefault) 1297 OnResetPageEncodingToDefault)
1296 IPC_MESSAGE_HANDLER(ViewMsg_PostMessageEvent, OnPostMessageEvent) 1298 IPC_MESSAGE_HANDLER(ViewMsg_PostMessageEvent, OnPostMessageEvent)
1297 IPC_MESSAGE_HANDLER(DragMsg_TargetDragEnter, OnDragTargetDragEnter) 1299 IPC_MESSAGE_HANDLER(DragMsg_TargetDragEnter, OnDragTargetDragEnter)
(...skipping 1375 matching lines...) Expand 10 before | Expand all | Expand 10 after
2673 } 2675 }
2674 2676
2675 gfx::RectF active_rect = main_frame->activeFindMatchRect(); 2677 gfx::RectF active_rect = main_frame->activeFindMatchRect();
2676 Send(new ViewHostMsg_FindMatchRects_Reply(routing_id_, 2678 Send(new ViewHostMsg_FindMatchRects_Reply(routing_id_,
2677 rects_version, 2679 rects_version,
2678 match_rects, 2680 match_rects,
2679 active_rect)); 2681 active_rect));
2680 } 2682 }
2681 #endif 2683 #endif
2682 2684
2685 void RenderViewImpl::OnResetPageScale() {
2686 if (!webview())
2687 return;
2688 webview()->setPageScaleFactor(1);
2689 }
2690
2683 void RenderViewImpl::OnZoom(PageZoom zoom) { 2691 void RenderViewImpl::OnZoom(PageZoom zoom) {
2684 if (!webview()) // Not sure if this can happen, but no harm in being safe. 2692 if (!webview()) // Not sure if this can happen, but no harm in being safe.
2685 return; 2693 return;
2686 2694
2687 webview()->hidePopups(); 2695 webview()->hidePopups();
2688 2696
2689 double old_zoom_level = webview()->zoomLevel(); 2697 double old_zoom_level = webview()->zoomLevel();
2690 double zoom_level; 2698 double zoom_level;
2691 if (zoom == PAGE_ZOOM_RESET) { 2699 if (zoom == PAGE_ZOOM_RESET) {
2692 zoom_level = 0; 2700 zoom_level = 0;
(...skipping 982 matching lines...) Expand 10 before | Expand all | Expand 10 after
3675 // zoom level (from RendererPreferences) before the first navigation. 3683 // zoom level (from RendererPreferences) before the first navigation.
3676 if (!webview()->mainFrame()->document().url().isEmpty()) { 3684 if (!webview()->mainFrame()->document().url().isEmpty()) {
3677 // Tell the browser which url got zoomed so it can update the menu and the 3685 // Tell the browser which url got zoomed so it can update the menu and the
3678 // saved values if necessary 3686 // saved values if necessary
3679 Send(new ViewHostMsg_DidZoomURL( 3687 Send(new ViewHostMsg_DidZoomURL(
3680 routing_id_, zoom_level, 3688 routing_id_, zoom_level,
3681 GURL(webview()->mainFrame()->document().url()))); 3689 GURL(webview()->mainFrame()->document().url())));
3682 } 3690 }
3683 } 3691 }
3684 3692
3693 void RenderViewImpl::pageScaleFactorChanged() {
3694 if (!webview())
3695 return;
3696 bool page_scale_factor_is_one = webview()->pageScaleFactor() == 1;
3697 if (page_scale_factor_is_one == page_scale_factor_is_one_)
3698 return;
3699 page_scale_factor_is_one_ = page_scale_factor_is_one;
3700 Send(new ViewHostMsg_PageScaleFactorIsOneChanged(routing_id_,
3701 page_scale_factor_is_one_));
3702 }
3703
3685 double RenderViewImpl::zoomLevelToZoomFactor(double zoom_level) const { 3704 double RenderViewImpl::zoomLevelToZoomFactor(double zoom_level) const {
3686 return ZoomLevelToZoomFactor(zoom_level); 3705 return ZoomLevelToZoomFactor(zoom_level);
3687 } 3706 }
3688 3707
3689 double RenderViewImpl::zoomFactorToZoomLevel(double factor) const { 3708 double RenderViewImpl::zoomFactorToZoomLevel(double factor) const {
3690 return ZoomFactorToZoomLevel(factor); 3709 return ZoomFactorToZoomLevel(factor);
3691 } 3710 }
3692 3711
3693 void RenderViewImpl::registerProtocolHandler(const WebString& scheme, 3712 void RenderViewImpl::registerProtocolHandler(const WebString& scheme,
3694 const WebURL& url, 3713 const WebURL& url,
(...skipping 302 matching lines...) Expand 10 before | Expand all | Expand 10 after
3997 std::vector<gfx::Size> sizes; 4016 std::vector<gfx::Size> sizes;
3998 ConvertToFaviconSizes(icon_urls[i].sizes(), &sizes); 4017 ConvertToFaviconSizes(icon_urls[i].sizes(), &sizes);
3999 if (!url.isEmpty()) 4018 if (!url.isEmpty())
4000 urls.push_back( 4019 urls.push_back(
4001 FaviconURL(url, ToFaviconType(icon_urls[i].iconType()), sizes)); 4020 FaviconURL(url, ToFaviconType(icon_urls[i].iconType()), sizes));
4002 } 4021 }
4003 SendUpdateFaviconURL(urls); 4022 SendUpdateFaviconURL(urls);
4004 } 4023 }
4005 4024
4006 } // namespace content 4025 } // 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