Changeset 140172 in webkit
- Timestamp:
- Jan 18, 2013, 10:17:47 AM (12 years ago)
- Location:
- branches/chromium/1387/Source/WebKit/chromium/src
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/chromium/1387/Source/WebKit/chromium/src/ChromeClientImpl.cpp
r139829 r140172 97 97 #include "WebPopupType.h" 98 98 #include "WebSettings.h" 99 #include "WebSettingsImpl.h" 99 100 #include "WebTextDirection.h" 100 101 #include "WebViewClient.h" … … 644 645 return; 645 646 646 WebViewClient* client = m_webView->client(); 647 WebSize deviceSize = m_webView->size(); 648 // If the window size has not been set yet don't attempt to set the viewport 649 if (!deviceSize.width || !deviceSize.height) 650 return; 651 652 int viewportWidthInDIPs = m_webView->dipSize().width(); 653 ViewportArguments effectiveViewportArguments; 654 int effectiveFallbackWidth; 647 IntSize viewportSize = m_webView->dipSize(); 648 float deviceScaleFactor = m_webView->client()->screenInfo().deviceScaleFactor; 649 650 // If the window size has not been set yet don't attempt to set the viewport. 651 if (!viewportSize.width() || !viewportSize.height()) 652 return; 653 654 ViewportAttributes computed; 655 655 if (m_webView->settings()->viewportEnabled()) { 656 effectiveViewportArguments = arguments; 657 effectiveFallbackWidth = std::max(m_webView->page()->settings()->layoutFallbackWidth(), viewportWidthInDIPs); 656 computed = arguments.resolve(viewportSize, viewportSize, m_webView->page()->settings()->layoutFallbackWidth()); 658 657 } else { 659 // This is for Android WebView to use layout width in device-independent pixels. 660 // Once WebViewImpl on Android will start using DIP pixels size, 661 // dispatchViewportPropertiesDidChange can bail out when viewport is disabled. 662 effectiveViewportArguments = ViewportArguments(); 663 effectiveFallbackWidth = viewportWidthInDIPs; 664 } 665 float devicePixelRatio = client->screenInfo().deviceScaleFactor; 666 // Call the common viewport computing logic in ViewportArguments.cpp. 667 ViewportAttributes computed = computeViewportAttributes( 668 effectiveViewportArguments, effectiveFallbackWidth, deviceSize.width, deviceSize.height, 669 devicePixelRatio, IntSize(deviceSize.width, deviceSize.height)); 670 658 // If viewport tag is disabled but fixed layout is still enabled, (for 659 // example, on Android WebView with UseWideViewport false), compute 660 // based on the default viewport arguments. 661 computed = ViewportArguments().resolve(viewportSize, viewportSize, viewportSize.width()); 662 } 671 663 restrictScaleFactorToInitialScaleIfNotUserScalable(computed); 672 664 … … 675 667 computed.userScalable = true; 676 668 } 677 678 int layoutWidth = computed.layoutSize.width(); 679 int layoutHeight = computed.layoutSize.height(); 680 m_webView->setFixedLayoutSize(IntSize(layoutWidth, layoutHeight)); 669 if (!m_webView->settingsImpl()->applyDeviceScaleFactorInCompositor()) 670 computed.initialScale *= deviceScaleFactor; 681 671 682 672 bool needInitializePageScale = !m_webView->isPageScaleFactorSet(); 683 m_webView->setDeviceScaleFactor(devicePixelRatio); 673 IntSize fixedLayoutSize = flooredIntSize(computed.layoutSize); 674 if (viewportSize.width() > fixedLayoutSize.width()) 675 fixedLayoutSize = viewportSize; 676 m_webView->setFixedLayoutSize(fixedLayoutSize); 677 m_webView->setDeviceScaleFactor(deviceScaleFactor); 684 678 m_webView->setPageScaleFactorLimits(computed.minimumScale, computed.maximumScale); 685 679 if (needInitializePageScale) 686 m_webView->setPageScaleFactorPreservingScrollOffset(computed.initialScale * devicePixelRatio);680 m_webView->setPageScaleFactorPreservingScrollOffset(computed.initialScale); 687 681 #endif 688 682 } -
branches/chromium/1387/Source/WebKit/chromium/src/WebViewImpl.cpp
r139904 r140172 429 429 , m_recreatingGraphicsContext(false) 430 430 , m_compositorSurfaceReady(false) 431 , m_deviceScaleInCompositor(1)432 431 , m_inputHandlerIdentifier(-1) 433 432 #endif … … 1581 1580 } 1582 1581 1582 WebSize WebViewImpl::size() 1583 { 1584 if (isFixedLayoutModeEnabled() && settingsImpl()->applyPageScaleFactorInCompositor()) 1585 return layoutSize(); 1586 1587 return m_size; 1588 } 1589 1583 1590 void WebViewImpl::resize(const WebSize& newSize) 1584 1591 { … … 1608 1615 WebFrameImpl* webFrame = mainFrameImpl(); 1609 1616 if (webFrame->frameView()) 1610 webFrame->frameView()->resize( newSize.width, newSize.height);1617 webFrame->frameView()->resize(size()); 1611 1618 } 1612 1619 1613 1620 #if ENABLE(VIEWPORT) 1614 1621 if (settings()->viewportEnabled()) { 1615 // Relayout immediately to obtain the new content width, which is needed 1616 // to calculate the minimum scale limit. 1617 view->layout(); 1622 if (!settingsImpl()->applyPageScaleFactorInCompositor()) { 1623 // Relayout immediately to obtain the new content width, which is needed 1624 // to calculate the minimum scale limit. 1625 view->layout(); 1626 } 1618 1627 computePageScaleFactorLimits(); 1628 1619 1629 // When the device rotates: 1620 1630 // - If the page width is unchanged, then zoom by new width/old width … … 1632 1642 if (scaleMultiplier != 1) { 1633 1643 IntSize scrollOffsetAtNewScale = oldScrollOffset; 1634 scrollOffsetAtNewScale.scale(scaleMultiplier); 1644 if (!settingsImpl()->applyPageScaleFactorInCompositor()) 1645 scrollOffsetAtNewScale.scale(scaleMultiplier); 1635 1646 setPageScaleFactor(oldPageScaleFactor * scaleMultiplier, IntPoint(scrollOffsetAtNewScale)); 1636 1647 } … … 2916 2927 scaleFactor = 1; 2917 2928 2918 if (m_deviceScaleInCompositor != 1) {2919 // Don't allow page scaling when compositor scaling is being used,2920 // as they are currently incompatible.2921 ASSERT(scaleFactor == 1);2922 }2923 2924 2929 scaleFactor = clampPageScaleFactorToLimits(scaleFactor); 2925 2930 WebPoint scrollOffset; … … 2955 2960 page()->setDeviceScaleFactor(scaleFactor); 2956 2961 2957 if (m_layerTreeView && m_webSettings->applyDeviceScaleFactorInCompositor()) { 2958 m_deviceScaleInCompositor = page()->deviceScaleFactor(); 2959 m_layerTreeView->setDeviceScaleFactor(m_deviceScaleInCompositor); 2960 } 2961 if (m_deviceScaleInCompositor != 1) { 2962 // Don't allow page scaling when compositor scaling is being used, 2963 // as they are currently incompatible. This means the deviceScale 2964 // needs to match the one in the compositor. 2965 ASSERT(scaleFactor == m_deviceScaleInCompositor); 2966 } 2962 if (m_layerTreeView && m_webSettings->applyDeviceScaleFactorInCompositor()) 2963 m_layerTreeView->setDeviceScaleFactor(scaleFactor); 2967 2964 } 2968 2965 … … 3037 3034 } 3038 3035 3036 IntSize WebViewImpl::layoutSize() const 3037 { 3038 if (!isFixedLayoutModeEnabled()) 3039 return m_size; 3040 3041 IntSize contentSize = unscaledContentsSize(page()->mainFrame()); 3042 if (fixedLayoutSize().width >= contentSize.width()) 3043 return fixedLayoutSize(); 3044 3045 float aspectRatio = static_cast<float>(m_size.height) / m_size.width; 3046 return IntSize(contentSize.width(), contentSize.width() * aspectRatio); 3047 } 3048 3039 3049 bool WebViewImpl::computePageScaleFactorLimits() 3040 3050 { … … 3045 3055 return false; 3046 3056 3047 m_minimumPageScaleFactor = min(max(m_pageDefinedMinimumPageScaleFactor, minPageScaleFactor), maxPageScaleFactor) * (deviceScaleFactor() / m_deviceScaleInCompositor); 3048 m_maximumPageScaleFactor = max(min(m_pageDefinedMaximumPageScaleFactor, maxPageScaleFactor), minPageScaleFactor) * (deviceScaleFactor() / m_deviceScaleInCompositor); 3049 3050 int viewWidthNotIncludingScrollbars = page()->mainFrame()->view()->visibleContentRect(false).width(); 3057 FrameView* view = page()->mainFrame()->view(); 3058 3059 m_minimumPageScaleFactor = min(max(m_pageDefinedMinimumPageScaleFactor, minPageScaleFactor), maxPageScaleFactor); 3060 m_maximumPageScaleFactor = max(min(m_pageDefinedMaximumPageScaleFactor, maxPageScaleFactor), minPageScaleFactor); 3061 if (!m_webSettings->applyDeviceScaleFactorInCompositor()) { 3062 m_minimumPageScaleFactor *= deviceScaleFactor(); 3063 m_maximumPageScaleFactor *= deviceScaleFactor(); 3064 } 3065 3066 int viewWidthNotIncludingScrollbars = m_size.width; 3067 if (viewWidthNotIncludingScrollbars && view->verticalScrollbar() && !view->verticalScrollbar()->isOverlayScrollbar()) 3068 viewWidthNotIncludingScrollbars -= view->verticalScrollbar()->width(); 3051 3069 int unscaledContentsWidth = unscaledContentsSize(page()->mainFrame()).width(); 3052 3070 if (viewWidthNotIncludingScrollbars && unscaledContentsWidth) { … … 3147 3165 } 3148 3166 3149 WebCore::FloatSize WebViewImpl::dipSize() const 3150 { 3151 if (!page() || m_webSettings->applyDeviceScaleFactorInCompositor()) 3152 return FloatSize(m_size.width, m_size.height); 3153 3154 float deviceScaleFactor = page()->deviceScaleFactor(); 3155 return FloatSize(m_size.width / deviceScaleFactor, m_size.height / deviceScaleFactor); 3167 WebCore::IntSize WebViewImpl::dipSize() const 3168 { 3169 IntSize dipSize = m_size; 3170 if (!m_webSettings->applyDeviceScaleFactorInCompositor()) 3171 dipSize.scale(1 / m_client->screenInfo().deviceScaleFactor); 3172 return dipSize; 3156 3173 } 3157 3174 … … 3698 3715 { 3699 3716 #if ENABLE(VIEWPORT) 3700 if (!settings()->viewportEnabled() )3701 return; 3702 3703 bool didChangeScale= false;3717 if (!settings()->viewportEnabled() || !mainFrameImpl()) 3718 return; 3719 3720 bool mayNeedLayout = false; 3704 3721 if (!isPageScaleFactorSet()) { 3705 3722 // If the viewport tag failed to be processed earlier, we need … … 3707 3724 ViewportArguments viewportArguments = mainFrameImpl()->frame()->document()->viewportArguments(); 3708 3725 m_page->chrome()->client()->dispatchViewportPropertiesDidChange(viewportArguments); 3709 didChangeScale= true;3726 mayNeedLayout = true; 3710 3727 } else 3711 didChangeScale = computePageScaleFactorLimits(); 3712 3713 if (!didChangeScale) 3714 return; 3715 3716 if (!mainFrameImpl()) 3717 return; 3728 mayNeedLayout = computePageScaleFactorLimits(); 3718 3729 3719 3730 FrameView* view = mainFrameImpl()->frameView(); 3720 if (view && view->needsLayout()) 3731 if (settingsImpl()->applyPageScaleFactorInCompositor() && view && view->visibleContentRect(true).width() != layoutSize().width()) { 3732 view->resize(layoutSize()); 3733 mayNeedLayout = true; 3734 } 3735 3736 // didChangeContentsSize() may be called from FrameView::layout; we need to 3737 // relayout to avoid triggering the assertion that needsLayout() isn't set 3738 // at the end of a layout. 3739 if (mayNeedLayout && view && view->needsLayout()) 3721 3740 view->layout(); 3722 3741 #endif … … 4054 4073 } 4055 4074 if (m_layerTreeView) { 4056 if (m_webSettings->applyDeviceScaleFactorInCompositor() && page()->deviceScaleFactor() != 1) { 4057 ASSERT(page()->deviceScaleFactor()); 4058 4059 m_deviceScaleInCompositor = page()->deviceScaleFactor(); 4060 setDeviceScaleFactor(m_deviceScaleInCompositor); 4061 } 4075 if (m_webSettings->applyDeviceScaleFactorInCompositor() && page()->deviceScaleFactor() != 1) 4076 setDeviceScaleFactor(page()->deviceScaleFactor()); 4062 4077 4063 4078 bool visible = page()->visibilityState() == PageVisibilityStateVisible; … … 4198 4213 m_nonCompositedContentHost->setViewport(visibleRect.size(), view->contentsSize(), scroll, view->scrollOrigin()); 4199 4214 4200 IntSize layoutViewportSize = size(); 4201 IntSize deviceViewportSize = size(); 4202 4203 // This part of the deviceScale will be used to scale the contents of 4204 // the NCCH's GraphicsLayer. 4205 deviceViewportSize.scale(m_deviceScaleInCompositor); 4215 IntSize layoutViewportSize = visibleRect.size(); 4216 IntSize deviceViewportSize = m_size; 4217 if (m_webSettings->applyDeviceScaleFactorInCompositor()) 4218 deviceViewportSize.scale(deviceScaleFactor()); 4219 4206 4220 m_layerTreeView->setViewportSize(layoutViewportSize, deviceViewportSize); 4207 4221 m_layerTreeView->setPageScaleFactorAndLimits(pageScaleFactor(), m_minimumPageScaleFactor, m_maximumPageScaleFactor); -
branches/chromium/1387/Source/WebKit/chromium/src/WebViewImpl.h
r139829 r140172 137 137 // WebWidget methods: 138 138 virtual void close(); 139 virtual WebSize size() { return m_size; }139 virtual WebSize size(); 140 140 virtual void willStartLiveResize(); 141 141 virtual void resize(const WebSize&); … … 244 244 virtual WebSize fixedLayoutSize() const; 245 245 virtual void setFixedLayoutSize(const WebSize&); 246 virtual WebCore::FloatSize dipSize() const;247 246 virtual void enableAutoResizeMode( 248 247 const WebSize& minSize, … … 461 460 } 462 461 462 WebCore::IntSize dipSize() const; 463 WebCore::IntSize layoutSize() const; 464 463 465 // Set the disposition for how this webview is to be initially shown. 464 466 void setInitialNavigationPolicy(WebNavigationPolicy policy) … … 852 854 bool m_recreatingGraphicsContext; 853 855 bool m_compositorSurfaceReady; 854 float m_deviceScaleInCompositor;855 856 int m_inputHandlerIdentifier; 856 857 #endif
Note:
See TracChangeset
for help on using the changeset viewer.