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 double WebViewImpl::setZoomLevel(double zoomLevel) | 3053 void WebViewImpl::propagateZoomToLocalFrameRoots(Frame* frame) |
3054 { | 3054 { |
3055 if (zoomLevel < m_minimumZoomLevel) | 3055 if (frame->isRemoteFrame()) { |
3056 m_zoomLevel = m_minimumZoomLevel; | 3056 for (Frame* child = frame->tree().firstChild(); child; child = child->tr ee().nextSibling()) |
3057 else if (zoomLevel > m_maximumZoomLevel) | 3057 propagateZoomToLocalFrameRoots(child); |
alexmos
2016/04/07 23:48:08
Hmm, what if you have a A-B-A scenario, and you se
wjmaclean
2016/04/08 20:13:29
The Zoom update will be sent to both A's and B's p
| |
3058 m_zoomLevel = m_maximumZoomLevel; | 3058 return; |
3059 else | 3059 } |
3060 m_zoomLevel = zoomLevel; | |
3061 | 3060 |
3062 // TODO(nasko): Setting zoom level needs to be refactored to support | 3061 ASSERT(frame->isLocalRoot()); |
bokan
2016/04/07 22:57:12
Blink recently switched ASSERTs to DCHECKs.
wjmaclean
2016/04/08 20:13:29
Done.
| |
3063 // out-of-process iframes. See https://crbug.com/528407. | 3062 LocalFrame* localFrame = toLocalFrame(frame); |
3064 if (mainFrame()->isWebRemoteFrame()) | |
3065 return m_zoomLevel; | |
3066 | 3063 |
3067 LocalFrame* frame = mainFrameImpl()->frame(); | 3064 if (!WebLocalFrameImpl::pluginContainerFromFrame(localFrame)) { |
3068 if (!WebLocalFrameImpl::pluginContainerFromFrame(frame)) { | |
3069 float zoomFactor = m_zoomFactorOverride ? m_zoomFactorOverride : static_ cast<float>(zoomLevelToZoomFactor(m_zoomLevel)); | 3065 float zoomFactor = m_zoomFactorOverride ? m_zoomFactorOverride : static_ cast<float>(zoomLevelToZoomFactor(m_zoomLevel)); |
3070 if (m_zoomFactorForDeviceScaleFactor) { | 3066 if (m_zoomFactorForDeviceScaleFactor) { |
3071 if (m_compositorDeviceScaleFactorOverride) { | 3067 if (m_compositorDeviceScaleFactorOverride) { |
3072 // Adjust the page's DSF so that DevicePixelRatio becomes m_zoom FactorForDeviceScaleFactor. | 3068 // Adjust the page's DSF so that DevicePixelRatio becomes m_zoom FactorForDeviceScaleFactor. |
3073 page()->setDeviceScaleFactor(m_zoomFactorForDeviceScaleFactor / m_compositorDeviceScaleFactorOverride); | 3069 page()->setDeviceScaleFactor(m_zoomFactorForDeviceScaleFactor / m_compositorDeviceScaleFactorOverride); |
3074 zoomFactor *= m_compositorDeviceScaleFactorOverride; | 3070 zoomFactor *= m_compositorDeviceScaleFactorOverride; |
3075 } else { | 3071 } else { |
3076 page()->setDeviceScaleFactor(1.f); | 3072 page()->setDeviceScaleFactor(1.f); |
3077 zoomFactor *= m_zoomFactorForDeviceScaleFactor; | 3073 zoomFactor *= m_zoomFactorForDeviceScaleFactor; |
3078 } | 3074 } |
3079 } | 3075 } |
3080 frame->setPageZoomFactor(zoomFactor); | 3076 localFrame->setPageZoomFactor(zoomFactor); |
3081 } | 3077 } |
3078 } | |
3079 | |
3080 double WebViewImpl::setZoomLevel(double zoomLevel) | |
3081 { | |
3082 if (zoomLevel < m_minimumZoomLevel) | |
3083 m_zoomLevel = m_minimumZoomLevel; | |
3084 else if (zoomLevel > m_maximumZoomLevel) | |
3085 m_zoomLevel = m_maximumZoomLevel; | |
3086 else | |
3087 m_zoomLevel = zoomLevel; | |
3088 | |
3089 propagateZoomToLocalFrameRoots(m_page->mainFrame()); | |
3082 | 3090 |
3083 return m_zoomLevel; | 3091 return m_zoomLevel; |
3084 } | 3092 } |
3085 | 3093 |
3086 void WebViewImpl::zoomLimitsChanged(double minimumZoomLevel, | 3094 void WebViewImpl::zoomLimitsChanged(double minimumZoomLevel, |
3087 double maximumZoomLevel) | 3095 double maximumZoomLevel) |
3088 { | 3096 { |
3089 m_minimumZoomLevel = minimumZoomLevel; | 3097 m_minimumZoomLevel = minimumZoomLevel; |
3090 m_maximumZoomLevel = maximumZoomLevel; | 3098 m_maximumZoomLevel = maximumZoomLevel; |
3091 m_client->zoomLimitsChanged(m_minimumZoomLevel, m_maximumZoomLevel); | 3099 m_client->zoomLimitsChanged(m_minimumZoomLevel, m_maximumZoomLevel); |
(...skipping 1500 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4592 { | 4600 { |
4593 // TODO(oshima): Investigate if this should return the ScreenInfo's scale fa ctor rather than | 4601 // 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. | 4602 // page's scale factor, which can be 1 in use-zoom-for-dsf mode. |
4595 if (!page()) | 4603 if (!page()) |
4596 return 1; | 4604 return 1; |
4597 | 4605 |
4598 return page()->deviceScaleFactor(); | 4606 return page()->deviceScaleFactor(); |
4599 } | 4607 } |
4600 | 4608 |
4601 } // namespace blink | 4609 } // namespace blink |
OLD | NEW |