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