| OLD | NEW |
| 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 625 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 636 targetDPI = 120.0f; | 636 targetDPI = 120.0f; |
| 637 else if (arguments.deprecatedTargetDensityDPI == ViewportArguments::ValueMed
iumDPI) | 637 else if (arguments.deprecatedTargetDensityDPI == ViewportArguments::ValueMed
iumDPI) |
| 638 targetDPI = 160.0f; | 638 targetDPI = 160.0f; |
| 639 else if (arguments.deprecatedTargetDensityDPI == ViewportArguments::ValueHig
hDPI) | 639 else if (arguments.deprecatedTargetDensityDPI == ViewportArguments::ValueHig
hDPI) |
| 640 targetDPI = 240.0f; | 640 targetDPI = 240.0f; |
| 641 else if (arguments.deprecatedTargetDensityDPI != ViewportArguments::ValueAut
o) | 641 else if (arguments.deprecatedTargetDensityDPI != ViewportArguments::ValueAut
o) |
| 642 targetDPI = arguments.deprecatedTargetDensityDPI; | 642 targetDPI = arguments.deprecatedTargetDensityDPI; |
| 643 return targetDPI > 0 ? (deviceScaleFactor * 120.0f) / targetDPI : 1.0f; | 643 return targetDPI > 0 ? (deviceScaleFactor * 120.0f) / targetDPI : 1.0f; |
| 644 } | 644 } |
| 645 | 645 |
| 646 static float getLayoutWidthForNonWideViewport(const ViewportArguments& arguments
, const FloatSize& deviceSize, float initialScale) |
| 647 { |
| 648 return arguments.zoom == ViewportArguments::ValueAuto ? deviceSize.width() :
deviceSize.width() / initialScale; |
| 649 } |
| 650 |
| 646 void ChromeClientImpl::dispatchViewportPropertiesDidChange(const ViewportArgumen
ts& arguments) const | 651 void ChromeClientImpl::dispatchViewportPropertiesDidChange(const ViewportArgumen
ts& arguments) const |
| 647 { | 652 { |
| 648 #if ENABLE(VIEWPORT) | 653 #if ENABLE(VIEWPORT) |
| 649 if (!m_webView->settings()->viewportEnabled() || !m_webView->isFixedLayoutMo
deEnabled() || !m_webView->client() || !m_webView->page()) | 654 if (!m_webView->settings()->viewportEnabled() || !m_webView->isFixedLayoutMo
deEnabled() || !m_webView->client() || !m_webView->page()) |
| 650 return; | 655 return; |
| 651 | 656 |
| 652 IntSize viewportSize = m_webView->size(); | 657 IntSize viewportSize = m_webView->size(); |
| 653 float deviceScaleFactor = m_webView->client()->screenInfo().deviceScaleFacto
r; | 658 float deviceScaleFactor = m_webView->client()->screenInfo().deviceScaleFacto
r; |
| 654 | 659 |
| 655 // If the window size has not been set yet don't attempt to set the viewport
. | 660 // If the window size has not been set yet don't attempt to set the viewport
. |
| 656 if (!viewportSize.width() || !viewportSize.height()) | 661 if (!viewportSize.width() || !viewportSize.height()) |
| 657 return; | 662 return; |
| 658 | 663 |
| 659 ViewportAttributes computed = arguments.resolve(viewportSize, viewportSize,
m_webView->page()->settings()->layoutFallbackWidth()); | 664 ViewportAttributes computed = arguments.resolve(viewportSize, viewportSize,
m_webView->page()->settings()->layoutFallbackWidth()); |
| 660 restrictScaleFactorToInitialScaleIfNotUserScalable(computed); | 665 restrictScaleFactorToInitialScaleIfNotUserScalable(computed); |
| 661 | 666 |
| 662 if (m_webView->ignoreViewportTagMaximumScale()) { | 667 if (m_webView->ignoreViewportTagMaximumScale()) { |
| 663 computed.maximumScale = max(computed.maximumScale, m_webView->maxPageSca
leFactor); | 668 computed.maximumScale = max(computed.maximumScale, m_webView->maxPageSca
leFactor); |
| 664 computed.userScalable = true; | 669 computed.userScalable = true; |
| 665 } | 670 } |
| 666 if (arguments.zoom == ViewportArguments::ValueAuto && !m_webView->settingsIm
pl()->initializeAtMinimumPageScale()) | 671 float initialScale = computed.initialScale; |
| 667 computed.initialScale = 1.0f; | 672 if (arguments.zoom == ViewportArguments::ValueAuto && !m_webView->settingsIm
pl()->initializeAtMinimumPageScale()) { |
| 668 | 673 if (arguments.width == ViewportArguments::ValueAuto |
| 674 || (m_webView->settingsImpl()->useWideViewport() |
| 675 && arguments.width != ViewportArguments::ValueAuto && arguments.
width != ViewportArguments::ValueDeviceWidth)) |
| 676 computed.initialScale = 1.0f; |
| 677 } |
| 669 if (m_webView->settingsImpl()->supportDeprecatedTargetDensityDPI()) { | 678 if (m_webView->settingsImpl()->supportDeprecatedTargetDensityDPI()) { |
| 670 float targetDensityDPIFactor = calculateTargetDensityDPIFactor(arguments
, deviceScaleFactor); | 679 float targetDensityDPIFactor = calculateTargetDensityDPIFactor(arguments
, deviceScaleFactor); |
| 671 computed.initialScale *= targetDensityDPIFactor; | 680 computed.initialScale *= targetDensityDPIFactor; |
| 672 computed.minimumScale *= targetDensityDPIFactor; | 681 computed.minimumScale *= targetDensityDPIFactor; |
| 673 computed.maximumScale *= targetDensityDPIFactor; | 682 computed.maximumScale *= targetDensityDPIFactor; |
| 674 computed.layoutSize.scale(1.0f / targetDensityDPIFactor); | 683 |
| 684 if (m_webView->settingsImpl()->useWideViewport() && arguments.width == V
iewportArguments::ValueAuto && arguments.zoom != 1.0f) |
| 685 computed.layoutSize.setWidth(m_webView->page()->settings()->layoutFa
llbackWidth()); |
| 686 else { |
| 687 if (!m_webView->settingsImpl()->useWideViewport()) |
| 688 computed.layoutSize.setWidth(getLayoutWidthForNonWideViewport(ar
guments, viewportSize, initialScale)); |
| 689 if (!m_webView->settingsImpl()->useWideViewport() || arguments.width
== ViewportArguments::ValueAuto || arguments.width == ViewportArguments::ValueD
eviceWidth) |
| 690 computed.layoutSize.scale(1.0f / targetDensityDPIFactor); |
| 691 } |
| 675 } | 692 } |
| 676 | 693 |
| 677 m_webView->setInitialPageScaleFactor(computed.initialScale); | 694 m_webView->setInitialPageScaleFactor(computed.initialScale); |
| 678 m_webView->setFixedLayoutSize(flooredIntSize(computed.layoutSize)); | 695 m_webView->setFixedLayoutSize(flooredIntSize(computed.layoutSize)); |
| 679 m_webView->setDeviceScaleFactor(deviceScaleFactor); | 696 m_webView->setDeviceScaleFactor(deviceScaleFactor); |
| 680 m_webView->setPageScaleFactorLimits(computed.minimumScale, computed.maximumS
cale); | 697 m_webView->setPageScaleFactorLimits(computed.minimumScale, computed.maximumS
cale); |
| 681 #endif | 698 #endif |
| 682 } | 699 } |
| 683 | 700 |
| 684 void ChromeClientImpl::print(Frame* frame) | 701 void ChromeClientImpl::print(Frame* frame) |
| (...skipping 499 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1184 { | 1201 { |
| 1185 } | 1202 } |
| 1186 | 1203 |
| 1187 void NavigatorContentUtilsClientImpl::registerProtocolHandler(const String& sche
me, const String& baseURL, const String& url, const String& title) | 1204 void NavigatorContentUtilsClientImpl::registerProtocolHandler(const String& sche
me, const String& baseURL, const String& url, const String& title) |
| 1188 { | 1205 { |
| 1189 m_webView->client()->registerProtocolHandler(scheme, baseURL, url, title); | 1206 m_webView->client()->registerProtocolHandler(scheme, baseURL, url, title); |
| 1190 } | 1207 } |
| 1191 #endif | 1208 #endif |
| 1192 | 1209 |
| 1193 } // namespace WebKit | 1210 } // namespace WebKit |
| OLD | NEW |