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 3004 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3015 // TODO(alexmos): Pass in proper with sourceCapabilities. | 3015 // TODO(alexmos): Pass in proper with sourceCapabilities. |
3016 page()->focusController().advanceFocusAcrossFrames( | 3016 page()->focusController().advanceFocusAcrossFrames( |
3017 type, toWebRemoteFrameImpl(from)->frame(), toWebLocalFrameImpl(to)->fram e()); | 3017 type, toWebRemoteFrameImpl(from)->frame(), toWebLocalFrameImpl(to)->fram e()); |
3018 } | 3018 } |
3019 | 3019 |
3020 double WebViewImpl::zoomLevel() | 3020 double WebViewImpl::zoomLevel() |
3021 { | 3021 { |
3022 return m_zoomLevel; | 3022 return m_zoomLevel; |
3023 } | 3023 } |
3024 | 3024 |
3025 double WebViewImpl::setZoomLevel(double zoomLevel) | 3025 double WebViewImpl::setZoomLevelForFrame(WebLocalFrame* frame, double zoomLevel) |
3026 { | |
3027 LocalFrame* localFrame = static_cast<WebLocalFrameImpl*>(frame)->frame(); | |
3028 return setZoomLevelForFrame(localFrame, zoomLevel); | |
3029 } | |
3030 | |
3031 double WebViewImpl::setZoomLevelForFrame(LocalFrame* frame, double zoomLevel) | |
alexmos
2016/04/05 18:00:54
Why is the LocalFrame version of the function need
wjmaclean
2016/04/05 20:22:00
Because there are callers who have WebLocalFrame*
| |
3026 { | 3032 { |
3027 if (zoomLevel < m_minimumZoomLevel) | 3033 if (zoomLevel < m_minimumZoomLevel) |
3028 m_zoomLevel = m_minimumZoomLevel; | 3034 m_zoomLevel = m_minimumZoomLevel; |
3029 else if (zoomLevel > m_maximumZoomLevel) | 3035 else if (zoomLevel > m_maximumZoomLevel) |
3030 m_zoomLevel = m_maximumZoomLevel; | 3036 m_zoomLevel = m_maximumZoomLevel; |
3031 else | 3037 else |
3032 m_zoomLevel = zoomLevel; | 3038 m_zoomLevel = zoomLevel; |
3033 | 3039 |
3034 // TODO(nasko): Setting zoom level needs to be refactored to support | |
3035 // out-of-process iframes. See https://crbug.com/528407. | |
3036 if (mainFrame()->isWebRemoteFrame()) | |
3037 return m_zoomLevel; | |
3038 | |
3039 LocalFrame* frame = mainFrameImpl()->frame(); | |
3040 if (!WebLocalFrameImpl::pluginContainerFromFrame(frame)) { | 3040 if (!WebLocalFrameImpl::pluginContainerFromFrame(frame)) { |
3041 float zoomFactor = m_zoomFactorOverride ? m_zoomFactorOverride : static_ cast<float>(zoomLevelToZoomFactor(m_zoomLevel)); | 3041 float zoomFactor = m_zoomFactorOverride ? m_zoomFactorOverride : static_ cast<float>(zoomLevelToZoomFactor(m_zoomLevel)); |
3042 if (m_zoomFactorForDeviceScaleFactor) { | 3042 if (m_zoomFactorForDeviceScaleFactor) { |
3043 if (m_compositorDeviceScaleFactorOverride) { | 3043 if (m_compositorDeviceScaleFactorOverride) { |
3044 // Adjust the page's DSF so that DevicePixelRatio becomes m_zoom FactorForDeviceScaleFactor. | 3044 // Adjust the page's DSF so that DevicePixelRatio becomes m_zoom FactorForDeviceScaleFactor. |
3045 page()->setDeviceScaleFactor(m_zoomFactorForDeviceScaleFactor / m_compositorDeviceScaleFactorOverride); | 3045 page()->setDeviceScaleFactor(m_zoomFactorForDeviceScaleFactor / m_compositorDeviceScaleFactorOverride); |
3046 zoomFactor *= m_compositorDeviceScaleFactorOverride; | 3046 zoomFactor *= m_compositorDeviceScaleFactorOverride; |
3047 } else { | 3047 } else { |
3048 page()->setDeviceScaleFactor(1.f); | 3048 page()->setDeviceScaleFactor(1.f); |
3049 zoomFactor *= m_zoomFactorForDeviceScaleFactor; | 3049 zoomFactor *= m_zoomFactorForDeviceScaleFactor; |
3050 } | 3050 } |
3051 } | 3051 } |
3052 frame->setPageZoomFactor(zoomFactor); | 3052 frame->setPageZoomFactor(zoomFactor); |
alexmos
2016/04/05 18:00:54
This calls LocalFrame::setPageAndTextZoomFactors,
wjmaclean
2016/04/05 20:22:00
Yes, I suppose there is some redundancy. This coul
| |
3053 } | 3053 } |
3054 | 3054 |
3055 return m_zoomLevel; | 3055 return m_zoomLevel; |
3056 } | 3056 } |
3057 | 3057 |
3058 double WebViewImpl::setZoomLevel(double zoomLevel) | |
alexmos
2016/04/05 18:00:54
There seem to be some existing renderer-initiated
wjmaclean
2016/04/05 20:22:00
They might, if it has to be done for something oth
| |
3059 { | |
3060 if (zoomLevel < m_minimumZoomLevel) | |
3061 m_zoomLevel = m_minimumZoomLevel; | |
3062 else if (zoomLevel > m_maximumZoomLevel) | |
3063 m_zoomLevel = m_maximumZoomLevel; | |
3064 else | |
3065 m_zoomLevel = zoomLevel; | |
alexmos
2016/04/05 18:00:54
Is it necessary to have this duplicated here in ad
wjmaclean
2016/04/05 20:22:00
m_zoomLevel is accessed elsewhere in WebViewImpl,
alexmos
2016/04/07 01:20:56
Sorry, I just meant that this work (clamping the z
wjmaclean
2016/04/07 12:55:36
I'd be happy to do that in a follow-on if I can, b
alexmos
2016/04/07 23:48:08
Yes, that's ok, though it doesn't look like this i
| |
3066 | |
3067 // Code that wishes to set zoom level on local frames when the main frame is | |
3068 // remote should call setZoomLevelForFrame() instead. | |
3069 if (mainFrame()->isWebRemoteFrame()) | |
alexmos
2016/04/05 18:00:54
How much would break if we ASSERT that mainFrame()
wjmaclean
2016/04/05 20:22:00
I'm not sure. I'll see if it passes the bots on a
| |
3070 return m_zoomLevel; | |
3071 | |
3072 return setZoomLevelForFrame(mainFrameImpl()->frame(), m_zoomLevel); | |
3073 } | |
3074 | |
3058 void WebViewImpl::zoomLimitsChanged(double minimumZoomLevel, | 3075 void WebViewImpl::zoomLimitsChanged(double minimumZoomLevel, |
3059 double maximumZoomLevel) | 3076 double maximumZoomLevel) |
3060 { | 3077 { |
3061 m_minimumZoomLevel = minimumZoomLevel; | 3078 m_minimumZoomLevel = minimumZoomLevel; |
3062 m_maximumZoomLevel = maximumZoomLevel; | 3079 m_maximumZoomLevel = maximumZoomLevel; |
3063 m_client->zoomLimitsChanged(m_minimumZoomLevel, m_maximumZoomLevel); | 3080 m_client->zoomLimitsChanged(m_minimumZoomLevel, m_maximumZoomLevel); |
3064 } | 3081 } |
3065 | 3082 |
3066 float WebViewImpl::textZoomFactor() | 3083 float WebViewImpl::textZoomFactor() |
3067 { | 3084 { |
(...skipping 1496 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4564 { | 4581 { |
4565 // TODO(oshima): Investigate if this should return the ScreenInfo's scale fa ctor rather than | 4582 // TODO(oshima): Investigate if this should return the ScreenInfo's scale fa ctor rather than |
4566 // page's scale factor, which can be 1 in use-zoom-for-dsf mode. | 4583 // page's scale factor, which can be 1 in use-zoom-for-dsf mode. |
4567 if (!page()) | 4584 if (!page()) |
4568 return 1; | 4585 return 1; |
4569 | 4586 |
4570 return page()->deviceScaleFactor(); | 4587 return page()->deviceScaleFactor(); |
4571 } | 4588 } |
4572 | 4589 |
4573 } // namespace blink | 4590 } // namespace blink |
OLD | NEW |