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 597 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
608 { | 608 { |
609 if (!m_webView->client()) | 609 if (!m_webView->client()) |
610 return; | 610 return; |
611 WebTextDirection textDirection = (dir == RTL) ? | 611 WebTextDirection textDirection = (dir == RTL) ? |
612 WebTextDirectionRightToLeft : | 612 WebTextDirectionRightToLeft : |
613 WebTextDirectionLeftToRight; | 613 WebTextDirectionLeftToRight; |
614 m_webView->client()->setToolTipText( | 614 m_webView->client()->setToolTipText( |
615 tooltipText, textDirection); | 615 tooltipText, textDirection); |
616 } | 616 } |
617 | 617 |
618 | |
619 static float calculateTargetDensityDPIFactor(const ViewportArguments& arguments,
float deviceScaleFactor) | |
620 { | |
621 if (arguments.deprecatedTargetDensityDPI == ViewportArguments::ValueDeviceDP
I) | |
622 return 1.0f / deviceScaleFactor; | |
623 | |
624 float targetDPI = -1.0f; | |
625 if (arguments.deprecatedTargetDensityDPI == ViewportArguments::ValueLowDPI) | |
626 targetDPI = 120.0f; | |
627 else if (arguments.deprecatedTargetDensityDPI == ViewportArguments::ValueMed
iumDPI) | |
628 targetDPI = 160.0f; | |
629 else if (arguments.deprecatedTargetDensityDPI == ViewportArguments::ValueHig
hDPI) | |
630 targetDPI = 240.0f; | |
631 else if (arguments.deprecatedTargetDensityDPI != ViewportArguments::ValueAut
o) | |
632 targetDPI = arguments.deprecatedTargetDensityDPI; | |
633 return targetDPI > 0 ? (deviceScaleFactor * 120.0f) / targetDPI : 1.0f; | |
634 } | |
635 | |
636 static float getLayoutWidthForNonWideViewport(const ViewportArguments& arguments
, const FloatSize& deviceSize, float initialScale) | |
637 { | |
638 return arguments.zoom == ViewportArguments::ValueAuto ? deviceSize.width() :
deviceSize.width() / initialScale; | |
639 } | |
640 | |
641 void ChromeClientImpl::dispatchViewportPropertiesDidChange(const ViewportArgumen
ts& arguments) const | 618 void ChromeClientImpl::dispatchViewportPropertiesDidChange(const ViewportArgumen
ts& arguments) const |
642 { | 619 { |
643 if (!m_webView->settings()->viewportEnabled() || !m_webView->isFixedLayoutMo
deEnabled() || !m_webView->client() || !m_webView->page()) | 620 m_webView->updatePageDefinedViewportAttributes(arguments); |
644 return; | |
645 | |
646 IntSize viewportSize = m_webView->size(); | |
647 float deviceScaleFactor = m_webView->client()->screenInfo().deviceScaleFacto
r; | |
648 | |
649 // If the window size has not been set yet don't attempt to set the viewport
. | |
650 if (!viewportSize.width() || !viewportSize.height()) | |
651 return; | |
652 | |
653 ViewportAttributes computed = arguments.resolve(viewportSize, viewportSize,
m_webView->page()->settings()->layoutFallbackWidth()); | |
654 restrictScaleFactorToInitialScaleIfNotUserScalable(computed); | |
655 | |
656 if (m_webView->ignoreViewportTagMaximumScale()) { | |
657 computed.maximumScale = max(computed.maximumScale, m_webView->maxPageSca
leFactor); | |
658 computed.userScalable = true; | |
659 } | |
660 float initialScale = computed.initialScale; | |
661 if (arguments.zoom == ViewportArguments::ValueAuto && !m_webView->settingsIm
pl()->initializeAtMinimumPageScale()) { | |
662 if (arguments.width == ViewportArguments::ValueAuto | |
663 || (m_webView->settingsImpl()->useWideViewport() | |
664 && arguments.width != ViewportArguments::ValueAuto && arguments.
width != ViewportArguments::ValueDeviceWidth)) | |
665 computed.initialScale = 1.0f; | |
666 } | |
667 if (m_webView->settingsImpl()->supportDeprecatedTargetDensityDPI()) { | |
668 float targetDensityDPIFactor = calculateTargetDensityDPIFactor(arguments
, deviceScaleFactor); | |
669 computed.initialScale *= targetDensityDPIFactor; | |
670 computed.minimumScale *= targetDensityDPIFactor; | |
671 computed.maximumScale *= targetDensityDPIFactor; | |
672 | |
673 if (m_webView->settingsImpl()->useWideViewport() && arguments.width == V
iewportArguments::ValueAuto && arguments.zoom != 1.0f) | |
674 computed.layoutSize.setWidth(m_webView->page()->settings()->layoutFa
llbackWidth()); | |
675 else { | |
676 if (!m_webView->settingsImpl()->useWideViewport()) | |
677 computed.layoutSize.setWidth(getLayoutWidthForNonWideViewport(ar
guments, viewportSize, initialScale)); | |
678 if (!m_webView->settingsImpl()->useWideViewport() || arguments.width
== ViewportArguments::ValueAuto || arguments.width == ViewportArguments::ValueD
eviceWidth) | |
679 computed.layoutSize.scale(1.0f / targetDensityDPIFactor); | |
680 } | |
681 } | |
682 | |
683 m_webView->setInitialPageScaleFactor(computed.initialScale); | |
684 m_webView->setFixedLayoutSize(flooredIntSize(computed.layoutSize)); | |
685 m_webView->setDeviceScaleFactor(deviceScaleFactor); | |
686 m_webView->setPageScaleFactorLimits(computed.minimumScale, computed.maximumS
cale); | |
687 } | 621 } |
688 | 622 |
689 void ChromeClientImpl::print(Frame* frame) | 623 void ChromeClientImpl::print(Frame* frame) |
690 { | 624 { |
691 if (m_webView->client()) | 625 if (m_webView->client()) |
692 m_webView->client()->printPage(WebFrameImpl::fromFrame(frame)); | 626 m_webView->client()->printPage(WebFrameImpl::fromFrame(frame)); |
693 } | 627 } |
694 | 628 |
695 #if ENABLE(INPUT_TYPE_COLOR) | 629 #if ENABLE(INPUT_TYPE_COLOR) |
696 PassOwnPtr<ColorChooser> ChromeClientImpl::createColorChooser(ColorChooserClient
* chooserClient, const Color&) | 630 PassOwnPtr<ColorChooser> ChromeClientImpl::createColorChooser(ColorChooserClient
* chooserClient, const Color&) |
(...skipping 419 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1116 { | 1050 { |
1117 } | 1051 } |
1118 | 1052 |
1119 void NavigatorContentUtilsClientImpl::registerProtocolHandler(const String& sche
me, const String& baseURL, const String& url, const String& title) | 1053 void NavigatorContentUtilsClientImpl::registerProtocolHandler(const String& sche
me, const String& baseURL, const String& url, const String& title) |
1120 { | 1054 { |
1121 m_webView->client()->registerProtocolHandler(scheme, baseURL, url, title); | 1055 m_webView->client()->registerProtocolHandler(scheme, baseURL, url, title); |
1122 } | 1056 } |
1123 #endif | 1057 #endif |
1124 | 1058 |
1125 } // namespace WebKit | 1059 } // namespace WebKit |
OLD | NEW |