Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(434)

Side by Side Diff: third_party/WebKit/Source/web/WebViewImpl.cpp

Issue 1804023002: Fix page zoom to be frame-centric for out-of-process frames. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address alexmos@ comments, run two experiments. Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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 double WebViewImpl::setZoomLevelForFrame(WebLocalFrame* frame, double zoomLevel)
3054 {
3055 LocalFrame* localFrame = static_cast<WebLocalFrameImpl*>(frame)->frame();
3056 return setZoomLevelForFrame(localFrame, zoomLevel);
3057 }
3058
3059 double WebViewImpl::setZoomLevelForFrame(LocalFrame* frame, double zoomLevel)
3054 { 3060 {
3055 if (zoomLevel < m_minimumZoomLevel) 3061 if (zoomLevel < m_minimumZoomLevel)
3056 m_zoomLevel = m_minimumZoomLevel; 3062 m_zoomLevel = m_minimumZoomLevel;
3057 else if (zoomLevel > m_maximumZoomLevel) 3063 else if (zoomLevel > m_maximumZoomLevel)
3058 m_zoomLevel = m_maximumZoomLevel; 3064 m_zoomLevel = m_maximumZoomLevel;
3059 else 3065 else
3060 m_zoomLevel = zoomLevel; 3066 m_zoomLevel = zoomLevel;
3061 3067
3062 // TODO(nasko): Setting zoom level needs to be refactored to support
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)) { 3068 if (!WebLocalFrameImpl::pluginContainerFromFrame(frame)) {
3069 float zoomFactor = m_zoomFactorOverride ? m_zoomFactorOverride : static_ cast<float>(zoomLevelToZoomFactor(m_zoomLevel)); 3069 float zoomFactor = m_zoomFactorOverride ? m_zoomFactorOverride : static_ cast<float>(zoomLevelToZoomFactor(m_zoomLevel));
3070 if (m_zoomFactorForDeviceScaleFactor) { 3070 if (m_zoomFactorForDeviceScaleFactor) {
3071 if (m_compositorDeviceScaleFactorOverride) { 3071 if (m_compositorDeviceScaleFactorOverride) {
3072 // Adjust the page's DSF so that DevicePixelRatio becomes m_zoom FactorForDeviceScaleFactor. 3072 // Adjust the page's DSF so that DevicePixelRatio becomes m_zoom FactorForDeviceScaleFactor.
3073 page()->setDeviceScaleFactor(m_zoomFactorForDeviceScaleFactor / m_compositorDeviceScaleFactorOverride); 3073 page()->setDeviceScaleFactor(m_zoomFactorForDeviceScaleFactor / m_compositorDeviceScaleFactorOverride);
3074 zoomFactor *= m_compositorDeviceScaleFactorOverride; 3074 zoomFactor *= m_compositorDeviceScaleFactorOverride;
3075 } else { 3075 } else {
3076 page()->setDeviceScaleFactor(1.f); 3076 page()->setDeviceScaleFactor(1.f);
3077 zoomFactor *= m_zoomFactorForDeviceScaleFactor; 3077 zoomFactor *= m_zoomFactorForDeviceScaleFactor;
3078 } 3078 }
3079 } 3079 }
3080 frame->setPageZoomFactor(zoomFactor); 3080 frame->setPageZoomFactor(zoomFactor);
3081 } 3081 }
3082 3082
3083 return m_zoomLevel; 3083 return m_zoomLevel;
3084 } 3084 }
3085 3085
3086 double WebViewImpl::setZoomLevel(double zoomLevel)
3087 {
3088 // Code that wishes to set zoom level on local frames when the main frame is
3089 // remote should call setZoomLevelForFrame() instead.
3090 ASSERT(mainFrame()->isWebLocalFrame());
3091
3092 if (zoomLevel < m_minimumZoomLevel)
3093 m_zoomLevel = m_minimumZoomLevel;
3094 else if (zoomLevel > m_maximumZoomLevel)
3095 m_zoomLevel = m_maximumZoomLevel;
3096 else
3097 m_zoomLevel = zoomLevel;
3098
3099 return setZoomLevelForFrame(mainFrameImpl()->frame(), m_zoomLevel);
3100 }
3101
3086 void WebViewImpl::zoomLimitsChanged(double minimumZoomLevel, 3102 void WebViewImpl::zoomLimitsChanged(double minimumZoomLevel,
3087 double maximumZoomLevel) 3103 double maximumZoomLevel)
3088 { 3104 {
3089 m_minimumZoomLevel = minimumZoomLevel; 3105 m_minimumZoomLevel = minimumZoomLevel;
3090 m_maximumZoomLevel = maximumZoomLevel; 3106 m_maximumZoomLevel = maximumZoomLevel;
3091 m_client->zoomLimitsChanged(m_minimumZoomLevel, m_maximumZoomLevel); 3107 m_client->zoomLimitsChanged(m_minimumZoomLevel, m_maximumZoomLevel);
3092 } 3108 }
3093 3109
3094 float WebViewImpl::textZoomFactor() 3110 float WebViewImpl::textZoomFactor()
3095 { 3111 {
(...skipping 1496 matching lines...) Expand 10 before | Expand all | Expand 10 after
4592 { 4608 {
4593 // TODO(oshima): Investigate if this should return the ScreenInfo's scale fa ctor rather than 4609 // 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. 4610 // page's scale factor, which can be 1 in use-zoom-for-dsf mode.
4595 if (!page()) 4611 if (!page())
4596 return 1; 4612 return 1;
4597 4613
4598 return page()->deviceScaleFactor(); 4614 return page()->deviceScaleFactor();
4599 } 4615 }
4600 4616
4601 } // namespace blink 4617 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698