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