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 #include <memory> | 9 #include <memory> |
10 | 10 |
(...skipping 1340 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1351 IPC_MESSAGE_HANDLER(ViewMsg_ReleaseDisambiguationPopupBitmap, | 1351 IPC_MESSAGE_HANDLER(ViewMsg_ReleaseDisambiguationPopupBitmap, |
1352 OnReleaseDisambiguationPopupBitmap) | 1352 OnReleaseDisambiguationPopupBitmap) |
1353 IPC_MESSAGE_HANDLER(ViewMsg_ForceRedraw, OnForceRedraw) | 1353 IPC_MESSAGE_HANDLER(ViewMsg_ForceRedraw, OnForceRedraw) |
1354 IPC_MESSAGE_HANDLER(ViewMsg_SelectWordAroundCaret, OnSelectWordAroundCaret) | 1354 IPC_MESSAGE_HANDLER(ViewMsg_SelectWordAroundCaret, OnSelectWordAroundCaret) |
1355 | 1355 |
1356 // Page messages. | 1356 // Page messages. |
1357 IPC_MESSAGE_HANDLER(PageMsg_UpdateWindowScreenRect, | 1357 IPC_MESSAGE_HANDLER(PageMsg_UpdateWindowScreenRect, |
1358 OnUpdateWindowScreenRect) | 1358 OnUpdateWindowScreenRect) |
1359 IPC_MESSAGE_HANDLER(PageMsg_SetZoomLevel, OnSetZoomLevel) | 1359 IPC_MESSAGE_HANDLER(PageMsg_SetZoomLevel, OnSetZoomLevel) |
1360 IPC_MESSAGE_HANDLER(PageMsg_SetDeviceScaleFactor, OnSetDeviceScaleFactor); | 1360 IPC_MESSAGE_HANDLER(PageMsg_SetDeviceScaleFactor, OnSetDeviceScaleFactor); |
| 1361 IPC_MESSAGE_HANDLER(PageMsg_SetPageScaleFactor, OnSetPageScaleFactor); |
1361 IPC_MESSAGE_HANDLER(PageMsg_WasHidden, OnPageWasHidden) | 1362 IPC_MESSAGE_HANDLER(PageMsg_WasHidden, OnPageWasHidden) |
1362 IPC_MESSAGE_HANDLER(PageMsg_WasShown, OnPageWasShown) | 1363 IPC_MESSAGE_HANDLER(PageMsg_WasShown, OnPageWasShown) |
1363 IPC_MESSAGE_HANDLER(PageMsg_SetHistoryOffsetAndLength, | 1364 IPC_MESSAGE_HANDLER(PageMsg_SetHistoryOffsetAndLength, |
1364 OnSetHistoryOffsetAndLength) | 1365 OnSetHistoryOffsetAndLength) |
1365 | 1366 |
1366 #if defined(OS_ANDROID) | 1367 #if defined(OS_ANDROID) |
1367 IPC_MESSAGE_HANDLER(ViewMsg_UpdateTopControlsState, | 1368 IPC_MESSAGE_HANDLER(ViewMsg_UpdateTopControlsState, |
1368 OnUpdateTopControlsState) | 1369 OnUpdateTopControlsState) |
1369 IPC_MESSAGE_HANDLER(ViewMsg_ExtractSmartClipData, OnExtractSmartClipData) | 1370 IPC_MESSAGE_HANDLER(ViewMsg_ExtractSmartClipData, OnExtractSmartClipData) |
1370 #elif defined(OS_MACOSX) | 1371 #elif defined(OS_MACOSX) |
(...skipping 1298 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2669 GetWidget()->FocusChangeComplete(); | 2670 GetWidget()->FocusChangeComplete(); |
2670 } | 2671 } |
2671 | 2672 |
2672 void RenderViewImpl::OnDeviceScaleFactorChanged() { | 2673 void RenderViewImpl::OnDeviceScaleFactorChanged() { |
2673 RenderWidget::OnDeviceScaleFactorChanged(); | 2674 RenderWidget::OnDeviceScaleFactorChanged(); |
2674 UpdateWebViewWithDeviceScaleFactor(); | 2675 UpdateWebViewWithDeviceScaleFactor(); |
2675 if (auto_resize_mode_) | 2676 if (auto_resize_mode_) |
2676 AutoResizeCompositor(); | 2677 AutoResizeCompositor(); |
2677 } | 2678 } |
2678 | 2679 |
| 2680 void RenderViewImpl::OnSetPageScaleFactor(double page_scale_delta) { |
| 2681 static float scale = 1.f; |
| 2682 if (webview() && webview()->mainFrame() && |
| 2683 !webview()->mainFrame()->isWebLocalFrame()) { |
| 2684 scale = webview()->clampPageScaleFactorToLimits(page_scale_delta * scale); |
| 2685 // TODO(wjmaclean): find something better than walking the frame tree to |
| 2686 // find the local roots? |
| 2687 for (WebFrame* frame = webview()->mainFrame(); frame; |
| 2688 frame = frame->traverseNext(false)) { |
| 2689 if (frame->isWebLocalFrame() && !frame->parent()->isWebLocalFrame()) { |
| 2690 RenderFrameImpl* rfi = RenderFrameImpl::FromWebFrame(frame); |
| 2691 RenderWidgetCompositor* widget_compositor = |
| 2692 rfi->GetRenderWidget()->compositor(); |
| 2693 // TODO(wjmaclean): It would likely be better if we could send deltas, |
| 2694 // but for now this works. |
| 2695 widget_compositor->setPageScaleFactorAndLimits(scale, 1.f, 4.f); |
| 2696 } |
| 2697 } |
| 2698 } |
| 2699 } |
| 2700 |
2679 void RenderViewImpl::SetScreenMetricsEmulationParameters( | 2701 void RenderViewImpl::SetScreenMetricsEmulationParameters( |
2680 bool enabled, | 2702 bool enabled, |
2681 const blink::WebDeviceEmulationParams& params) { | 2703 const blink::WebDeviceEmulationParams& params) { |
2682 if (webview() && compositor()) { | 2704 if (webview() && compositor()) { |
2683 if (enabled) | 2705 if (enabled) |
2684 webview()->enableDeviceEmulation(params); | 2706 webview()->enableDeviceEmulation(params); |
2685 else | 2707 else |
2686 webview()->disableDeviceEmulation(); | 2708 webview()->disableDeviceEmulation(); |
2687 } | 2709 } |
2688 } | 2710 } |
(...skipping 327 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3016 if (IsUseZoomForDSFEnabled()) { | 3038 if (IsUseZoomForDSFEnabled()) { |
3017 webview()->setZoomFactorForDeviceScaleFactor(device_scale_factor_); | 3039 webview()->setZoomFactorForDeviceScaleFactor(device_scale_factor_); |
3018 } else { | 3040 } else { |
3019 webview()->setDeviceScaleFactor(device_scale_factor_); | 3041 webview()->setDeviceScaleFactor(device_scale_factor_); |
3020 } | 3042 } |
3021 webview()->settings()->setPreferCompositingToLCDTextEnabled( | 3043 webview()->settings()->setPreferCompositingToLCDTextEnabled( |
3022 PreferCompositingToLCDText(compositor_deps_, device_scale_factor_)); | 3044 PreferCompositingToLCDText(compositor_deps_, device_scale_factor_)); |
3023 } | 3045 } |
3024 | 3046 |
3025 } // namespace content | 3047 } // namespace content |
OLD | NEW |