| 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 3034 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3045 // TODO(alexmos): Pass in proper with sourceCapabilities. | 3045 // TODO(alexmos): Pass in proper with sourceCapabilities. |
| 3046 page()->focusController().advanceFocusAcrossFrames( | 3046 page()->focusController().advanceFocusAcrossFrames( |
| 3047 type, toWebRemoteFrameImpl(from)->frame(), toWebLocalFrameImpl(to)->fram
e()); | 3047 type, toWebRemoteFrameImpl(from)->frame(), toWebLocalFrameImpl(to)->fram
e()); |
| 3048 } | 3048 } |
| 3049 | 3049 |
| 3050 double WebViewImpl::zoomLevel() | 3050 double WebViewImpl::zoomLevel() |
| 3051 { | 3051 { |
| 3052 return m_zoomLevel; | 3052 return m_zoomLevel; |
| 3053 } | 3053 } |
| 3054 | 3054 |
| 3055 void WebViewImpl::propagateZoomToLocalFrameRoots(Frame* frame) |
| 3056 { |
| 3057 if (frame->isLocalRoot()) { |
| 3058 LocalFrame* localFrame = toLocalFrame(frame); |
| 3059 |
| 3060 if (!WebLocalFrameImpl::pluginContainerFromFrame(localFrame)) { |
| 3061 float zoomFactor = m_zoomFactorOverride ? m_zoomFactorOverride : sta
tic_cast<float>(zoomLevelToZoomFactor(m_zoomLevel)); |
| 3062 if (m_zoomFactorForDeviceScaleFactor) { |
| 3063 if (m_compositorDeviceScaleFactorOverride) { |
| 3064 // Adjust the page's DSF so that DevicePixelRatio becomes m_
zoomFactorForDeviceScaleFactor. |
| 3065 page()->setDeviceScaleFactor(m_zoomFactorForDeviceScaleFacto
r / m_compositorDeviceScaleFactorOverride); |
| 3066 zoomFactor *= m_compositorDeviceScaleFactorOverride; |
| 3067 } else { |
| 3068 page()->setDeviceScaleFactor(1.f); |
| 3069 zoomFactor *= m_zoomFactorForDeviceScaleFactor; |
| 3070 } |
| 3071 } |
| 3072 localFrame->setPageZoomFactor(zoomFactor); |
| 3073 } |
| 3074 } |
| 3075 |
| 3076 for (Frame* child = frame->tree().firstChild(); child; child = child->tree()
.nextSibling()) |
| 3077 propagateZoomToLocalFrameRoots(child); |
| 3078 } |
| 3079 |
| 3055 double WebViewImpl::setZoomLevel(double zoomLevel) | 3080 double WebViewImpl::setZoomLevel(double zoomLevel) |
| 3056 { | 3081 { |
| 3057 if (zoomLevel < m_minimumZoomLevel) | 3082 if (zoomLevel < m_minimumZoomLevel) |
| 3058 m_zoomLevel = m_minimumZoomLevel; | 3083 m_zoomLevel = m_minimumZoomLevel; |
| 3059 else if (zoomLevel > m_maximumZoomLevel) | 3084 else if (zoomLevel > m_maximumZoomLevel) |
| 3060 m_zoomLevel = m_maximumZoomLevel; | 3085 m_zoomLevel = m_maximumZoomLevel; |
| 3061 else | 3086 else |
| 3062 m_zoomLevel = zoomLevel; | 3087 m_zoomLevel = zoomLevel; |
| 3063 | 3088 |
| 3064 // TODO(nasko): Setting zoom level needs to be refactored to support | 3089 propagateZoomToLocalFrameRoots(m_page->mainFrame()); |
| 3065 // out-of-process iframes. See https://crbug.com/528407. | |
| 3066 if (mainFrame()->isWebRemoteFrame()) | |
| 3067 return m_zoomLevel; | |
| 3068 | |
| 3069 LocalFrame* frame = mainFrameImpl()->frame(); | |
| 3070 if (!WebLocalFrameImpl::pluginContainerFromFrame(frame)) { | |
| 3071 float zoomFactor = m_zoomFactorOverride ? m_zoomFactorOverride : static_
cast<float>(zoomLevelToZoomFactor(m_zoomLevel)); | |
| 3072 if (m_zoomFactorForDeviceScaleFactor) { | |
| 3073 if (m_compositorDeviceScaleFactorOverride) { | |
| 3074 // Adjust the page's DSF so that DevicePixelRatio becomes m_zoom
FactorForDeviceScaleFactor. | |
| 3075 page()->setDeviceScaleFactor(m_zoomFactorForDeviceScaleFactor /
m_compositorDeviceScaleFactorOverride); | |
| 3076 zoomFactor *= m_compositorDeviceScaleFactorOverride; | |
| 3077 } else { | |
| 3078 page()->setDeviceScaleFactor(1.f); | |
| 3079 zoomFactor *= m_zoomFactorForDeviceScaleFactor; | |
| 3080 } | |
| 3081 } | |
| 3082 frame->setPageZoomFactor(zoomFactor); | |
| 3083 } | |
| 3084 | 3090 |
| 3085 return m_zoomLevel; | 3091 return m_zoomLevel; |
| 3086 } | 3092 } |
| 3087 | 3093 |
| 3088 void WebViewImpl::zoomLimitsChanged(double minimumZoomLevel, | 3094 void WebViewImpl::zoomLimitsChanged(double minimumZoomLevel, |
| 3089 double maximumZoomLevel) | 3095 double maximumZoomLevel) |
| 3090 { | 3096 { |
| 3091 m_minimumZoomLevel = minimumZoomLevel; | 3097 m_minimumZoomLevel = minimumZoomLevel; |
| 3092 m_maximumZoomLevel = maximumZoomLevel; | 3098 m_maximumZoomLevel = maximumZoomLevel; |
| 3093 m_client->zoomLimitsChanged(m_minimumZoomLevel, m_maximumZoomLevel); | 3099 m_client->zoomLimitsChanged(m_minimumZoomLevel, m_maximumZoomLevel); |
| (...skipping 1501 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4595 { | 4601 { |
| 4596 // TODO(oshima): Investigate if this should return the ScreenInfo's scale fa
ctor rather than | 4602 // TODO(oshima): Investigate if this should return the ScreenInfo's scale fa
ctor rather than |
| 4597 // page's scale factor, which can be 1 in use-zoom-for-dsf mode. | 4603 // page's scale factor, which can be 1 in use-zoom-for-dsf mode. |
| 4598 if (!page()) | 4604 if (!page()) |
| 4599 return 1; | 4605 return 1; |
| 4600 | 4606 |
| 4601 return page()->deviceScaleFactor(); | 4607 return page()->deviceScaleFactor(); |
| 4602 } | 4608 } |
| 4603 | 4609 |
| 4604 } // namespace blink | 4610 } // namespace blink |
| OLD | NEW |