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

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

Issue 2611573004: Remove dead ViewMsg_{Zoom, DidZoomUrl} (Closed)
Patch Set: Created 3 years, 11 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 #include <memory> 9 #include <memory>
10 10
(...skipping 1193 matching lines...) Expand 10 before | Expand all | Expand 10 after
1204 return true; 1204 return true;
1205 } 1205 }
1206 1206
1207 bool handled = true; 1207 bool handled = true;
1208 IPC_BEGIN_MESSAGE_MAP(RenderViewImpl, message) 1208 IPC_BEGIN_MESSAGE_MAP(RenderViewImpl, message)
1209 IPC_MESSAGE_HANDLER(InputMsg_ExecuteEditCommand, OnExecuteEditCommand) 1209 IPC_MESSAGE_HANDLER(InputMsg_ExecuteEditCommand, OnExecuteEditCommand)
1210 IPC_MESSAGE_HANDLER(InputMsg_MoveCaret, OnMoveCaret) 1210 IPC_MESSAGE_HANDLER(InputMsg_MoveCaret, OnMoveCaret)
1211 IPC_MESSAGE_HANDLER(InputMsg_ScrollFocusedEditableNodeIntoRect, 1211 IPC_MESSAGE_HANDLER(InputMsg_ScrollFocusedEditableNodeIntoRect,
1212 OnScrollFocusedEditableNodeIntoRect) 1212 OnScrollFocusedEditableNodeIntoRect)
1213 IPC_MESSAGE_HANDLER(ViewMsg_SetPageScale, OnSetPageScale) 1213 IPC_MESSAGE_HANDLER(ViewMsg_SetPageScale, OnSetPageScale)
1214 IPC_MESSAGE_HANDLER(ViewMsg_Zoom, OnZoom)
1215 IPC_MESSAGE_HANDLER(ViewMsg_AllowBindings, OnAllowBindings) 1214 IPC_MESSAGE_HANDLER(ViewMsg_AllowBindings, OnAllowBindings)
1216 IPC_MESSAGE_HANDLER(ViewMsg_SetInitialFocus, OnSetInitialFocus) 1215 IPC_MESSAGE_HANDLER(ViewMsg_SetInitialFocus, OnSetInitialFocus)
1217 IPC_MESSAGE_HANDLER(ViewMsg_UpdateTargetURL_ACK, OnUpdateTargetURLAck) 1216 IPC_MESSAGE_HANDLER(ViewMsg_UpdateTargetURL_ACK, OnUpdateTargetURLAck)
1218 IPC_MESSAGE_HANDLER(ViewMsg_UpdateWebPreferences, OnUpdateWebPreferences) 1217 IPC_MESSAGE_HANDLER(ViewMsg_UpdateWebPreferences, OnUpdateWebPreferences)
1219 IPC_MESSAGE_HANDLER(ViewMsg_EnumerateDirectoryResponse, 1218 IPC_MESSAGE_HANDLER(ViewMsg_EnumerateDirectoryResponse,
1220 OnEnumerateDirectoryResponse) 1219 OnEnumerateDirectoryResponse)
1221 IPC_MESSAGE_HANDLER(ViewMsg_ClosePage, OnClosePage) 1220 IPC_MESSAGE_HANDLER(ViewMsg_ClosePage, OnClosePage)
1222 IPC_MESSAGE_HANDLER(ViewMsg_MoveOrResizeStarted, OnMoveOrResizeStarted) 1221 IPC_MESSAGE_HANDLER(ViewMsg_MoveOrResizeStarted, OnMoveOrResizeStarted)
1223 IPC_MESSAGE_HANDLER(ViewMsg_SetBackgroundOpaque, OnSetBackgroundOpaque) 1222 IPC_MESSAGE_HANDLER(ViewMsg_SetBackgroundOpaque, OnSetBackgroundOpaque)
1224 IPC_MESSAGE_HANDLER(ViewMsg_EnablePreferredSizeChangedMode, 1223 IPC_MESSAGE_HANDLER(ViewMsg_EnablePreferredSizeChangedMode,
(...skipping 834 matching lines...) Expand 10 before | Expand all | Expand 10 after
2059 bool RenderViewImpl::GetContentStateImmediately() const { 2058 bool RenderViewImpl::GetContentStateImmediately() const {
2060 return send_content_state_immediately_; 2059 return send_content_state_immediately_;
2061 } 2060 }
2062 2061
2063 void RenderViewImpl::OnSetPageScale(float page_scale_factor) { 2062 void RenderViewImpl::OnSetPageScale(float page_scale_factor) {
2064 if (!webview()) 2063 if (!webview())
2065 return; 2064 return;
2066 webview()->setPageScaleFactor(page_scale_factor); 2065 webview()->setPageScaleFactor(page_scale_factor);
2067 } 2066 }
2068 2067
2069 void RenderViewImpl::OnZoom(PageZoom zoom) {
2070 if (!webview()) // Not sure if this can happen, but no harm in being safe.
2071 return;
2072
2073 webview()->hidePopups();
2074
2075 double old_zoom_level = webview()->zoomLevel();
2076 double zoom_level;
2077 if (zoom == PAGE_ZOOM_RESET) {
2078 zoom_level = 0;
2079 } else if (static_cast<int>(old_zoom_level) == old_zoom_level) {
2080 // Previous zoom level is a whole number, so just increment/decrement.
2081 zoom_level = old_zoom_level + zoom;
2082 } else {
2083 // Either the user hit the zoom factor limit and thus the zoom level is now
2084 // not a whole number, or a plugin changed it to a custom value. We want
2085 // to go to the next whole number so that the user can always get back to
2086 // 100% with the keyboard/menu.
2087 if ((old_zoom_level > 1 && zoom > 0) ||
2088 (old_zoom_level < 1 && zoom < 0)) {
2089 zoom_level = static_cast<int>(old_zoom_level + zoom);
2090 } else {
2091 // We're going towards 100%, so first go to the next whole number.
2092 zoom_level = static_cast<int>(old_zoom_level);
2093 }
2094 }
2095 SetZoomLevel(zoom_level);
2096 zoomLevelChanged();
2097 }
2098
2099 void RenderViewImpl::OnSetZoomLevel( 2068 void RenderViewImpl::OnSetZoomLevel(
2100 PageMsg_SetZoomLevel_Command command, 2069 PageMsg_SetZoomLevel_Command command,
2101 double zoom_level) { 2070 double zoom_level) {
2102 switch (command) { 2071 switch (command) {
2103 case PageMsg_SetZoomLevel_Command::CLEAR_TEMPORARY: 2072 case PageMsg_SetZoomLevel_Command::CLEAR_TEMPORARY:
2104 uses_temporary_zoom_level_ = false; 2073 uses_temporary_zoom_level_ = false;
2105 break; 2074 break;
2106 case PageMsg_SetZoomLevel_Command::SET_TEMPORARY: 2075 case PageMsg_SetZoomLevel_Command::SET_TEMPORARY:
2107 uses_temporary_zoom_level_ = true; 2076 uses_temporary_zoom_level_ = true;
2108 break; 2077 break;
(...skipping 340 matching lines...) Expand 10 before | Expand all | Expand 10 after
2449 // percentages. 2418 // percentages.
2450 int minimum_percent = round( 2419 int minimum_percent = round(
2451 ZoomLevelToZoomFactor(minimum_level) * 100); 2420 ZoomLevelToZoomFactor(minimum_level) * 100);
2452 int maximum_percent = round( 2421 int maximum_percent = round(
2453 ZoomLevelToZoomFactor(maximum_level) * 100); 2422 ZoomLevelToZoomFactor(maximum_level) * 100);
2454 2423
2455 Send(new ViewHostMsg_UpdateZoomLimits(GetRoutingID(), minimum_percent, 2424 Send(new ViewHostMsg_UpdateZoomLimits(GetRoutingID(), minimum_percent,
2456 maximum_percent)); 2425 maximum_percent));
2457 } 2426 }
2458 2427
2459 void RenderViewImpl::zoomLevelChanged() {
2460 double zoom_level = webview()->zoomLevel();
2461
2462 // Do not send empty URLs to the browser when we are just setting the default
2463 // zoom level (from RendererPreferences) before the first navigation.
2464 if (!webview()->mainFrame()->document().url().isEmpty()) {
2465 // Tell the browser which url got zoomed so it can update the menu and the
2466 // saved values if necessary
2467 Send(new ViewHostMsg_DidZoomURL(
2468 GetRoutingID(), zoom_level,
2469 GURL(webview()->mainFrame()->document().url())));
2470 }
2471 }
2472
2473 void RenderViewImpl::pageScaleFactorChanged() { 2428 void RenderViewImpl::pageScaleFactorChanged() {
2474 if (!webview()) 2429 if (!webview())
2475 return; 2430 return;
2476 2431
2477 Send(new ViewHostMsg_PageScaleFactorChanged(GetRoutingID(), 2432 Send(new ViewHostMsg_PageScaleFactorChanged(GetRoutingID(),
2478 webview()->pageScaleFactor())); 2433 webview()->pageScaleFactor()));
2479 } 2434 }
2480 2435
2481 double RenderViewImpl::zoomLevelToZoomFactor(double zoom_level) const { 2436 double RenderViewImpl::zoomLevelToZoomFactor(double zoom_level) const {
2482 return ZoomLevelToZoomFactor(zoom_level); 2437 return ZoomLevelToZoomFactor(zoom_level);
(...skipping 308 matching lines...) Expand 10 before | Expand all | Expand 10 after
2791 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); 2746 INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
2792 } 2747 }
2793 2748
2794 std::unique_ptr<InputEventAck> ack( 2749 std::unique_ptr<InputEventAck> ack(
2795 new InputEventAck(InputEventAckSource::MAIN_THREAD, input_event->type, 2750 new InputEventAck(InputEventAckSource::MAIN_THREAD, input_event->type,
2796 INPUT_EVENT_ACK_STATE_NOT_CONSUMED)); 2751 INPUT_EVENT_ACK_STATE_NOT_CONSUMED));
2797 OnInputEventAck(std::move(ack)); 2752 OnInputEventAck(std::move(ack));
2798 } 2753 }
2799 2754
2800 } // namespace content 2755 } // 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