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