OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2011, 2012 Google Inc. All rights reserved. | 2 * Copyright (C) 2011, 2012 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 3032 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3043 // TODO(alexmos): Pass in proper with sourceCapabilities. | 3043 // TODO(alexmos): Pass in proper with sourceCapabilities. |
3044 page()->focusController().advanceFocusAcrossFrames( | 3044 page()->focusController().advanceFocusAcrossFrames( |
3045 type, toWebRemoteFrameImpl(from)->frame(), toWebLocalFrameImpl(to)->fram
e()); | 3045 type, toWebRemoteFrameImpl(from)->frame(), toWebLocalFrameImpl(to)->fram
e()); |
3046 } | 3046 } |
3047 | 3047 |
3048 double WebViewImpl::zoomLevel() | 3048 double WebViewImpl::zoomLevel() |
3049 { | 3049 { |
3050 return m_zoomLevel; | 3050 return m_zoomLevel; |
3051 } | 3051 } |
3052 | 3052 |
| 3053 void WebViewImpl::propagateZoomToLocalFrameRoots(Frame* frame) |
| 3054 { |
| 3055 if (frame->isLocalRoot()) { |
| 3056 LocalFrame* localFrame = toLocalFrame(frame); |
| 3057 |
| 3058 if (!WebLocalFrameImpl::pluginContainerFromFrame(localFrame)) { |
| 3059 float zoomFactor = m_zoomFactorOverride ? m_zoomFactorOverride : sta
tic_cast<float>(zoomLevelToZoomFactor(m_zoomLevel)); |
| 3060 if (m_zoomFactorForDeviceScaleFactor) { |
| 3061 if (m_compositorDeviceScaleFactorOverride) { |
| 3062 // Adjust the page's DSF so that DevicePixelRatio becomes m_
zoomFactorForDeviceScaleFactor. |
| 3063 page()->setDeviceScaleFactor(m_zoomFactorForDeviceScaleFacto
r / m_compositorDeviceScaleFactorOverride); |
| 3064 zoomFactor *= m_compositorDeviceScaleFactorOverride; |
| 3065 } else { |
| 3066 page()->setDeviceScaleFactor(1.f); |
| 3067 zoomFactor *= m_zoomFactorForDeviceScaleFactor; |
| 3068 } |
| 3069 } |
| 3070 localFrame->setPageZoomFactor(zoomFactor); |
| 3071 } |
| 3072 } |
| 3073 |
| 3074 for (Frame* child = frame->tree().firstChild(); child; child = child->tree()
.nextSibling()) |
| 3075 propagateZoomToLocalFrameRoots(child); |
| 3076 } |
| 3077 |
3053 double WebViewImpl::setZoomLevel(double zoomLevel) | 3078 double WebViewImpl::setZoomLevel(double zoomLevel) |
3054 { | 3079 { |
3055 if (zoomLevel < m_minimumZoomLevel) | 3080 if (zoomLevel < m_minimumZoomLevel) |
3056 m_zoomLevel = m_minimumZoomLevel; | 3081 m_zoomLevel = m_minimumZoomLevel; |
3057 else if (zoomLevel > m_maximumZoomLevel) | 3082 else if (zoomLevel > m_maximumZoomLevel) |
3058 m_zoomLevel = m_maximumZoomLevel; | 3083 m_zoomLevel = m_maximumZoomLevel; |
3059 else | 3084 else |
3060 m_zoomLevel = zoomLevel; | 3085 m_zoomLevel = zoomLevel; |
3061 | 3086 |
3062 // TODO(nasko): Setting zoom level needs to be refactored to support | 3087 propagateZoomToLocalFrameRoots(m_page->mainFrame()); |
3063 // out-of-process iframes. See https://crbug.com/528407. | |
3064 if (mainFrame()->isWebRemoteFrame()) | |
3065 return m_zoomLevel; | |
3066 | |
3067 LocalFrame* frame = mainFrameImpl()->frame(); | |
3068 if (!WebLocalFrameImpl::pluginContainerFromFrame(frame)) { | |
3069 float zoomFactor = m_zoomFactorOverride ? m_zoomFactorOverride : static_
cast<float>(zoomLevelToZoomFactor(m_zoomLevel)); | |
3070 if (m_zoomFactorForDeviceScaleFactor) { | |
3071 if (m_compositorDeviceScaleFactorOverride) { | |
3072 // Adjust the page's DSF so that DevicePixelRatio becomes m_zoom
FactorForDeviceScaleFactor. | |
3073 page()->setDeviceScaleFactor(m_zoomFactorForDeviceScaleFactor /
m_compositorDeviceScaleFactorOverride); | |
3074 zoomFactor *= m_compositorDeviceScaleFactorOverride; | |
3075 } else { | |
3076 page()->setDeviceScaleFactor(1.f); | |
3077 zoomFactor *= m_zoomFactorForDeviceScaleFactor; | |
3078 } | |
3079 } | |
3080 frame->setPageZoomFactor(zoomFactor); | |
3081 } | |
3082 | 3088 |
3083 return m_zoomLevel; | 3089 return m_zoomLevel; |
3084 } | 3090 } |
3085 | 3091 |
3086 void WebViewImpl::zoomLimitsChanged(double minimumZoomLevel, | 3092 void WebViewImpl::zoomLimitsChanged(double minimumZoomLevel, |
3087 double maximumZoomLevel) | 3093 double maximumZoomLevel) |
3088 { | 3094 { |
3089 m_minimumZoomLevel = minimumZoomLevel; | 3095 m_minimumZoomLevel = minimumZoomLevel; |
3090 m_maximumZoomLevel = maximumZoomLevel; | 3096 m_maximumZoomLevel = maximumZoomLevel; |
3091 m_client->zoomLimitsChanged(m_minimumZoomLevel, m_maximumZoomLevel); | 3097 m_client->zoomLimitsChanged(m_minimumZoomLevel, m_maximumZoomLevel); |
(...skipping 1500 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4592 { | 4598 { |
4593 // TODO(oshima): Investigate if this should return the ScreenInfo's scale fa
ctor rather than | 4599 // TODO(oshima): Investigate if this should return the ScreenInfo's scale fa
ctor rather than |
4594 // page's scale factor, which can be 1 in use-zoom-for-dsf mode. | 4600 // page's scale factor, which can be 1 in use-zoom-for-dsf mode. |
4595 if (!page()) | 4601 if (!page()) |
4596 return 1; | 4602 return 1; |
4597 | 4603 |
4598 return page()->deviceScaleFactor(); | 4604 return page()->deviceScaleFactor(); |
4599 } | 4605 } |
4600 | 4606 |
4601 } // namespace blink | 4607 } // namespace blink |
OLD | NEW |