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

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: Remove 'anonymous'. Created 4 years, 7 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
« no previous file with comments | « third_party/WebKit/Source/web/WebViewImpl.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 3046 matching lines...) Expand 10 before | Expand all | Expand 10 after
3057 // TODO(alexmos): Pass in proper with sourceCapabilities. 3057 // TODO(alexmos): Pass in proper with sourceCapabilities.
3058 page()->focusController().advanceFocusAcrossFrames( 3058 page()->focusController().advanceFocusAcrossFrames(
3059 type, toWebRemoteFrameImpl(from)->frame(), toWebLocalFrameImpl(to)->fram e()); 3059 type, toWebRemoteFrameImpl(from)->frame(), toWebLocalFrameImpl(to)->fram e());
3060 } 3060 }
3061 3061
3062 double WebViewImpl::zoomLevel() 3062 double WebViewImpl::zoomLevel()
3063 { 3063 {
3064 return m_zoomLevel; 3064 return m_zoomLevel;
3065 } 3065 }
3066 3066
3067 void WebViewImpl::propagateZoomToLocalFrameRoots(Frame* frame)
3068 {
3069 if (frame->isLocalRoot()) {
3070 LocalFrame* localFrame = toLocalFrame(frame);
3071
3072 if (!WebLocalFrameImpl::pluginContainerFromFrame(localFrame)) {
3073 float zoomFactor = m_zoomFactorOverride ? m_zoomFactorOverride : sta tic_cast<float>(zoomLevelToZoomFactor(m_zoomLevel));
3074 if (m_zoomFactorForDeviceScaleFactor) {
3075 if (m_compositorDeviceScaleFactorOverride) {
3076 // Adjust the page's DSF so that DevicePixelRatio becomes m_ zoomFactorForDeviceScaleFactor.
3077 page()->setDeviceScaleFactor(m_zoomFactorForDeviceScaleFacto r / m_compositorDeviceScaleFactorOverride);
dcheng 2016/04/29 22:49:15 Why do we call the Page methods for each invocatio
3078 zoomFactor *= m_compositorDeviceScaleFactorOverride;
3079 } else {
3080 page()->setDeviceScaleFactor(1.f);
3081 zoomFactor *= m_zoomFactorForDeviceScaleFactor;
3082 }
3083 }
3084 localFrame->setPageZoomFactor(zoomFactor);
3085 }
3086 }
3087
3088 for (Frame* child = frame->tree().firstChild(); child; child = child->tree() .nextSibling())
3089 propagateZoomToLocalFrameRoots(child);
3090 }
3091
3067 double WebViewImpl::setZoomLevel(double zoomLevel) 3092 double WebViewImpl::setZoomLevel(double zoomLevel)
3068 { 3093 {
3069 if (zoomLevel < m_minimumZoomLevel) 3094 if (zoomLevel < m_minimumZoomLevel)
3070 m_zoomLevel = m_minimumZoomLevel; 3095 m_zoomLevel = m_minimumZoomLevel;
3071 else if (zoomLevel > m_maximumZoomLevel) 3096 else if (zoomLevel > m_maximumZoomLevel)
3072 m_zoomLevel = m_maximumZoomLevel; 3097 m_zoomLevel = m_maximumZoomLevel;
3073 else 3098 else
3074 m_zoomLevel = zoomLevel; 3099 m_zoomLevel = zoomLevel;
3075 3100
3076 // TODO(nasko): Setting zoom level needs to be refactored to support 3101 propagateZoomToLocalFrameRoots(m_page->mainFrame());
3077 // out-of-process iframes. See https://crbug.com/528407.
3078 if (mainFrame()->isWebRemoteFrame())
3079 return m_zoomLevel;
3080
3081 LocalFrame* frame = mainFrameImpl()->frame();
3082 if (!WebLocalFrameImpl::pluginContainerFromFrame(frame)) {
3083 float zoomFactor = m_zoomFactorOverride ? m_zoomFactorOverride : static_ cast<float>(zoomLevelToZoomFactor(m_zoomLevel));
3084 if (m_zoomFactorForDeviceScaleFactor) {
3085 if (m_compositorDeviceScaleFactorOverride) {
3086 // Adjust the page's DSF so that DevicePixelRatio becomes m_zoom FactorForDeviceScaleFactor.
3087 page()->setDeviceScaleFactor(m_zoomFactorForDeviceScaleFactor / m_compositorDeviceScaleFactorOverride);
3088 zoomFactor *= m_compositorDeviceScaleFactorOverride;
3089 } else {
3090 page()->setDeviceScaleFactor(1.f);
3091 zoomFactor *= m_zoomFactorForDeviceScaleFactor;
3092 }
3093 }
3094 frame->setPageZoomFactor(zoomFactor);
3095 }
3096 3102
3097 return m_zoomLevel; 3103 return m_zoomLevel;
3098 } 3104 }
3099 3105
3100 void WebViewImpl::zoomLimitsChanged(double minimumZoomLevel, 3106 void WebViewImpl::zoomLimitsChanged(double minimumZoomLevel,
3101 double maximumZoomLevel) 3107 double maximumZoomLevel)
3102 { 3108 {
3103 m_minimumZoomLevel = minimumZoomLevel; 3109 m_minimumZoomLevel = minimumZoomLevel;
3104 m_maximumZoomLevel = maximumZoomLevel; 3110 m_maximumZoomLevel = maximumZoomLevel;
3105 m_client->zoomLimitsChanged(m_minimumZoomLevel, m_maximumZoomLevel); 3111 m_client->zoomLimitsChanged(m_minimumZoomLevel, m_maximumZoomLevel);
(...skipping 1412 matching lines...) Expand 10 before | Expand all | Expand 10 after
4518 { 4524 {
4519 // TODO(oshima): Investigate if this should return the ScreenInfo's scale fa ctor rather than 4525 // TODO(oshima): Investigate if this should return the ScreenInfo's scale fa ctor rather than
4520 // page's scale factor, which can be 1 in use-zoom-for-dsf mode. 4526 // page's scale factor, which can be 1 in use-zoom-for-dsf mode.
4521 if (!page()) 4527 if (!page())
4522 return 1; 4528 return 1;
4523 4529
4524 return page()->deviceScaleFactor(); 4530 return page()->deviceScaleFactor();
4525 } 4531 }
4526 4532
4527 } // namespace blink 4533 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/web/WebViewImpl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698