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: Source/WebKit/chromium/src/ChromeClientImpl.cpp

Issue 13880019: [Android WebView] Update viewport size and scale calculation to match WebView Classic (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Rebased correctly Created 7 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 | Annotate | Revision Log
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2009 Google Inc. All rights reserved. 2 * Copyright (C) 2009 Google Inc. All rights reserved.
3 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). 3 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are 6 * modification, are permitted provided that the following conditions are
7 * met: 7 * met:
8 * 8 *
9 * * Redistributions of source code must retain the above copyright 9 * * Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer. 10 * notice, this list of conditions and the following disclaimer.
(...skipping 638 matching lines...) Expand 10 before | Expand all | Expand 10 after
649 if (!viewportSize.width() || !viewportSize.height()) 649 if (!viewportSize.width() || !viewportSize.height())
650 return; 650 return;
651 651
652 ViewportAttributes computed = arguments.resolve(viewportSize, viewportSize, m_webView->page()->settings()->layoutFallbackWidth()); 652 ViewportAttributes computed = arguments.resolve(viewportSize, viewportSize, m_webView->page()->settings()->layoutFallbackWidth());
653 restrictScaleFactorToInitialScaleIfNotUserScalable(computed); 653 restrictScaleFactorToInitialScaleIfNotUserScalable(computed);
654 654
655 if (m_webView->ignoreViewportTagMaximumScale()) { 655 if (m_webView->ignoreViewportTagMaximumScale()) {
656 computed.maximumScale = max(computed.maximumScale, m_webView->maxPageSca leFactor); 656 computed.maximumScale = max(computed.maximumScale, m_webView->maxPageSca leFactor);
657 computed.userScalable = true; 657 computed.userScalable = true;
658 } 658 }
659 if (arguments.zoom == ViewportArguments::ValueAuto && !m_webView->settingsIm pl()->initializeAtMinimumPageScale()) 659 float initialScale = computed.initialScale;
660 computed.initialScale = 1.0f; 660 if (arguments.zoom == ViewportArguments::ValueAuto && !m_webView->settingsIm pl()->initializeAtMinimumPageScale()) {
661 661 if (arguments.width == ViewportArguments::ValueAuto
662 || (m_webView->settingsImpl()->useWideViewport()
663 && arguments.width != ViewportArguments::ValueAuto && arguments. width != ViewportArguments::ValueDeviceWidth))
664 computed.initialScale = 1.0f;
665 }
662 if (m_webView->settingsImpl()->supportDeprecatedTargetDensityDPI()) { 666 if (m_webView->settingsImpl()->supportDeprecatedTargetDensityDPI()) {
667 bool applyTargetDensityDpiToLayoutSize = true;
abarth-chromium 2013/04/15 23:33:57 Dpi -> DPI
mnaganov (inactive) 2013/04/16 14:41:26 Done.
668 if (!m_webView->settingsImpl()->useWideViewport()) {
669 if (arguments.zoom == ViewportArguments::ValueAuto)
670 computed.layoutSize.setWidth(viewportSize.width());
671 else
672 computed.layoutSize.setWidth(viewportSize.width() / initialScale );
673 } else {
674 if (arguments.width == ViewportArguments::ValueAuto && arguments.zoo m != 1.0f) {
675 computed.layoutSize.setWidth(m_webView->page()->settings()->layo utFallbackWidth());
676 applyTargetDensityDpiToLayoutSize = false;
677 }
678 if (arguments.width != ViewportArguments::ValueAuto && arguments.wid th != ViewportArguments::ValueDeviceWidth)
679 applyTargetDensityDpiToLayoutSize = false;
680 }
abarth-chromium 2013/04/15 23:33:57 Why does this need to be so complicated? Can we s
mnaganov (inactive) 2013/04/16 14:41:26 I compared the resulting scales and widths of old
663 float targetDensityDPIFactor = calculateTargetDensityDPIFactor(arguments , deviceScaleFactor); 681 float targetDensityDPIFactor = calculateTargetDensityDPIFactor(arguments , deviceScaleFactor);
664 computed.initialScale *= targetDensityDPIFactor; 682 computed.initialScale *= targetDensityDPIFactor;
665 computed.minimumScale *= targetDensityDPIFactor; 683 computed.minimumScale *= targetDensityDPIFactor;
666 computed.maximumScale *= targetDensityDPIFactor; 684 computed.maximumScale *= targetDensityDPIFactor;
667 computed.layoutSize.scale(1.0f / targetDensityDPIFactor); 685 if (applyTargetDensityDpiToLayoutSize)
686 computed.layoutSize.scale(1.0f / targetDensityDPIFactor);
668 } 687 }
669 688
670 m_webView->setInitialPageScaleFactor(computed.initialScale); 689 m_webView->setInitialPageScaleFactor(computed.initialScale);
671 m_webView->setFixedLayoutSize(flooredIntSize(computed.layoutSize)); 690 m_webView->setFixedLayoutSize(flooredIntSize(computed.layoutSize));
672 m_webView->setDeviceScaleFactor(deviceScaleFactor); 691 m_webView->setDeviceScaleFactor(deviceScaleFactor);
673 m_webView->setPageScaleFactorLimits(computed.minimumScale, computed.maximumS cale); 692 m_webView->setPageScaleFactorLimits(computed.minimumScale, computed.maximumS cale);
674 #endif 693 #endif
675 } 694 }
676 695
677 void ChromeClientImpl::print(Frame* frame) 696 void ChromeClientImpl::print(Frame* frame)
(...skipping 505 matching lines...) Expand 10 before | Expand all | Expand 10 after
1183 { 1202 {
1184 } 1203 }
1185 1204
1186 void NavigatorContentUtilsClientImpl::registerProtocolHandler(const String& sche me, const String& baseURL, const String& url, const String& title) 1205 void NavigatorContentUtilsClientImpl::registerProtocolHandler(const String& sche me, const String& baseURL, const String& url, const String& title)
1187 { 1206 {
1188 m_webView->client()->registerProtocolHandler(scheme, baseURL, url, title); 1207 m_webView->client()->registerProtocolHandler(scheme, baseURL, url, title);
1189 } 1208 }
1190 #endif 1209 #endif
1191 1210
1192 } // namespace WebKit 1211 } // namespace WebKit
OLDNEW
« no previous file with comments | « Source/WebKit/chromium/public/WebSettings.h ('k') | Source/WebKit/chromium/src/WebSettingsImpl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698