| 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 3268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3279 zoom_level = static_cast<int>(old_zoom_level + zoom); | 3279 zoom_level = static_cast<int>(old_zoom_level + zoom); |
| 3280 } else { | 3280 } else { |
| 3281 // We're going towards 100%, so first go to the next whole number. | 3281 // We're going towards 100%, so first go to the next whole number. |
| 3282 zoom_level = static_cast<int>(old_zoom_level); | 3282 zoom_level = static_cast<int>(old_zoom_level); |
| 3283 } | 3283 } |
| 3284 } | 3284 } |
| 3285 webview()->setZoomLevel(zoom_level); | 3285 webview()->setZoomLevel(zoom_level); |
| 3286 zoomLevelChanged(); | 3286 zoomLevelChanged(); |
| 3287 } | 3287 } |
| 3288 | 3288 |
| 3289 void RenderViewImpl::OnSetZoomLevel(double zoom_level) { | 3289 void RenderViewImpl::OnSetZoomLevel(int zoom_id, |
| 3290 double zoom_level, |
| 3291 content::ZoomMode zoom_mode) { |
| 3290 webview()->hidePopups(); | 3292 webview()->hidePopups(); |
| 3291 webview()->setZoomLevel(zoom_level); | 3293 if (zoom_mode != content::kZoomModeManual) { |
| 3292 zoomLevelChanged(); | 3294 webview()->setZoomLevel(zoom_level); |
| 3295 } |
| 3296 zoomLevelChanged(zoom_id, zoom_level, zoom_mode == content::kZoomModeDefault); |
| 3293 } | 3297 } |
| 3294 | 3298 |
| 3295 void RenderViewImpl::OnSetZoomLevelForLoadingURL(const GURL& url, | 3299 void RenderViewImpl::OnSetZoomLevelForLoadingURL(const GURL& url, |
| 3296 double zoom_level) { | 3300 double zoom_level) { |
| 3297 #if !defined(OS_ANDROID) | 3301 #if !defined(OS_ANDROID) |
| 3298 // On Android, page zoom isn't used, and in case of WebView, text zoom is used | 3302 // On Android, page zoom isn't used, and in case of WebView, text zoom is used |
| 3299 // for legacy WebView text scaling emulation. Thus, the code that resets | 3303 // for legacy WebView text scaling emulation. Thus, the code that resets |
| 3300 // the zoom level from this map will be effectively resetting text zoom level. | 3304 // the zoom level from this map will be effectively resetting text zoom level. |
| 3301 host_zoom_levels_[url] = zoom_level; | 3305 host_zoom_levels_[url] = zoom_level; |
| 3302 #endif | 3306 #endif |
| (...skipping 1032 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4335 int minimum_percent = static_cast<int>( | 4339 int minimum_percent = static_cast<int>( |
| 4336 ZoomLevelToZoomFactor(minimum_level) * 100); | 4340 ZoomLevelToZoomFactor(minimum_level) * 100); |
| 4337 int maximum_percent = static_cast<int>( | 4341 int maximum_percent = static_cast<int>( |
| 4338 ZoomLevelToZoomFactor(maximum_level) * 100); | 4342 ZoomLevelToZoomFactor(maximum_level) * 100); |
| 4339 | 4343 |
| 4340 Send(new ViewHostMsg_UpdateZoomLimits( | 4344 Send(new ViewHostMsg_UpdateZoomLimits( |
| 4341 routing_id_, minimum_percent, maximum_percent, remember)); | 4345 routing_id_, minimum_percent, maximum_percent, remember)); |
| 4342 } | 4346 } |
| 4343 | 4347 |
| 4344 void RenderViewImpl::zoomLevelChanged() { | 4348 void RenderViewImpl::zoomLevelChanged() { |
| 4345 bool remember = !webview()->mainFrame()->document().isPluginDocument(); | 4349 zoomLevelChanged(0, webview()->zoomLevel(), false); |
| 4346 float zoom_level = webview()->zoomLevel(); | 4350 } |
| 4351 |
| 4352 void RenderViewImpl::zoomLevelChanged(int zoom_id, double zoom_level, |
| 4353 bool remember) { |
| 4354 remember = remember && !webview()->mainFrame()->document().isPluginDocument(); |
| 4347 | 4355 |
| 4348 FOR_EACH_OBSERVER(RenderViewObserver, observers_, ZoomLevelChanged()); | 4356 FOR_EACH_OBSERVER(RenderViewObserver, observers_, ZoomLevelChanged()); |
| 4349 | 4357 |
| 4350 // Tell the browser which url got zoomed so it can update the menu and the | 4358 // Tell the browser which url got zoomed so it can update the menu and the |
| 4351 // saved values if necessary | 4359 // saved values if necessary |
| 4352 Send(new ViewHostMsg_DidZoomURL( | 4360 Send(new ViewHostMsg_DidZoomURL( |
| 4353 routing_id_, zoom_level, remember, | 4361 routing_id_, zoom_id, zoom_level, remember, |
| 4354 GURL(webview()->mainFrame()->document().url()))); | 4362 GURL(webview()->mainFrame()->document().url()))); |
| 4355 } | 4363 } |
| 4356 | 4364 |
| 4357 double RenderViewImpl::zoomLevelToZoomFactor(double zoom_level) const { | 4365 double RenderViewImpl::zoomLevelToZoomFactor(double zoom_level) const { |
| 4358 return ZoomLevelToZoomFactor(zoom_level); | 4366 return ZoomLevelToZoomFactor(zoom_level); |
| 4359 } | 4367 } |
| 4360 | 4368 |
| 4361 double RenderViewImpl::zoomFactorToZoomLevel(double factor) const { | 4369 double RenderViewImpl::zoomFactorToZoomLevel(double factor) const { |
| 4362 return ZoomFactorToZoomLevel(factor); | 4370 return ZoomFactorToZoomLevel(factor); |
| 4363 } | 4371 } |
| (...skipping 398 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4762 std::vector<gfx::Size> sizes(icon_urls[i].sizes().size()); | 4770 std::vector<gfx::Size> sizes(icon_urls[i].sizes().size()); |
| 4763 ConvertToFaviconSizes(icon_urls[i].sizes(), &sizes); | 4771 ConvertToFaviconSizes(icon_urls[i].sizes(), &sizes); |
| 4764 if (!url.isEmpty()) | 4772 if (!url.isEmpty()) |
| 4765 urls.push_back( | 4773 urls.push_back( |
| 4766 FaviconURL(url, ToFaviconType(icon_urls[i].iconType()), sizes)); | 4774 FaviconURL(url, ToFaviconType(icon_urls[i].iconType()), sizes)); |
| 4767 } | 4775 } |
| 4768 SendUpdateFaviconURL(urls); | 4776 SendUpdateFaviconURL(urls); |
| 4769 } | 4777 } |
| 4770 | 4778 |
| 4771 } // namespace content | 4779 } // namespace content |
| OLD | NEW |