Changeset 140172 in webkit


Ignore:
Timestamp:
Jan 18, 2013, 10:17:47 AM (12 years ago)
Author:
kerz@chromium.org
Message:

Land two patches for testing

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  
    9797#include "WebPopupType.h"
    9898#include "WebSettings.h"
     99#include "WebSettingsImpl.h"
    99100#include "WebTextDirection.h"
    100101#include "WebViewClient.h"
     
    644645        return;
    645646
    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;
    655655    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());
    658657    } 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    }
    671663    restrictScaleFactorToInitialScaleIfNotUserScalable(computed);
    672664
     
    675667        computed.userScalable = true;
    676668    }
    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;
    681671
    682672    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);
    684678    m_webView->setPageScaleFactorLimits(computed.minimumScale, computed.maximumScale);
    685679    if (needInitializePageScale)
    686         m_webView->setPageScaleFactorPreservingScrollOffset(computed.initialScale * devicePixelRatio);
     680        m_webView->setPageScaleFactorPreservingScrollOffset(computed.initialScale);
    687681#endif
    688682}
  • branches/chromium/1387/Source/WebKit/chromium/src/WebViewImpl.cpp

    r139904 r140172  
    429429    , m_recreatingGraphicsContext(false)
    430430    , m_compositorSurfaceReady(false)
    431     , m_deviceScaleInCompositor(1)
    432431    , m_inputHandlerIdentifier(-1)
    433432#endif
     
    15811580}
    15821581
     1582WebSize WebViewImpl::size()
     1583{
     1584    if (isFixedLayoutModeEnabled() && settingsImpl()->applyPageScaleFactorInCompositor())
     1585        return layoutSize();
     1586
     1587    return m_size;
     1588}
     1589
    15831590void WebViewImpl::resize(const WebSize& newSize)
    15841591{
     
    16081615        WebFrameImpl* webFrame = mainFrameImpl();
    16091616        if (webFrame->frameView())
    1610             webFrame->frameView()->resize(newSize.width, newSize.height);
     1617            webFrame->frameView()->resize(size());
    16111618    }
    16121619
    16131620#if ENABLE(VIEWPORT)
    16141621    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        }
    16181627        computePageScaleFactorLimits();
     1628
    16191629        // When the device rotates:
    16201630        // - If the page width is unchanged, then zoom by new width/old width
     
    16321642        if (scaleMultiplier != 1) {
    16331643            IntSize scrollOffsetAtNewScale = oldScrollOffset;
    1634             scrollOffsetAtNewScale.scale(scaleMultiplier);
     1644            if (!settingsImpl()->applyPageScaleFactorInCompositor())
     1645                scrollOffsetAtNewScale.scale(scaleMultiplier);
    16351646            setPageScaleFactor(oldPageScaleFactor * scaleMultiplier, IntPoint(scrollOffsetAtNewScale));
    16361647        }
     
    29162927        scaleFactor = 1;
    29172928
    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 
    29242929    scaleFactor = clampPageScaleFactorToLimits(scaleFactor);
    29252930    WebPoint scrollOffset;
     
    29552960    page()->setDeviceScaleFactor(scaleFactor);
    29562961
    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);
    29672964}
    29682965
     
    30373034}
    30383035
     3036IntSize 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
    30393049bool WebViewImpl::computePageScaleFactorLimits()
    30403050{
     
    30453055        return false;
    30463056
    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();
    30513069    int unscaledContentsWidth = unscaledContentsSize(page()->mainFrame()).width();
    30523070    if (viewWidthNotIncludingScrollbars && unscaledContentsWidth) {
     
    31473165}
    31483166
    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);
     3167WebCore::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;
    31563173}
    31573174
     
    36983715{
    36993716#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;
    37043721    if (!isPageScaleFactorSet()) {
    37053722        // If the viewport tag failed to be processed earlier, we need
     
    37073724        ViewportArguments viewportArguments = mainFrameImpl()->frame()->document()->viewportArguments();
    37083725        m_page->chrome()->client()->dispatchViewportPropertiesDidChange(viewportArguments);
    3709         didChangeScale = true;
     3726        mayNeedLayout = true;
    37103727    } else
    3711         didChangeScale = computePageScaleFactorLimits();
    3712 
    3713     if (!didChangeScale)
    3714         return;
    3715 
    3716     if (!mainFrameImpl())
    3717         return;
     3728        mayNeedLayout = computePageScaleFactorLimits();
    37183729
    37193730    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())
    37213740        view->layout();
    37223741#endif
     
    40544073        }
    40554074        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());
    40624077
    40634078            bool visible = page()->visibilityState() == PageVisibilityStateVisible;
     
    41984213    m_nonCompositedContentHost->setViewport(visibleRect.size(), view->contentsSize(), scroll, view->scrollOrigin());
    41994214
    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
    42064220    m_layerTreeView->setViewportSize(layoutViewportSize, deviceViewportSize);
    42074221    m_layerTreeView->setPageScaleFactorAndLimits(pageScaleFactor(), m_minimumPageScaleFactor, m_maximumPageScaleFactor);
  • branches/chromium/1387/Source/WebKit/chromium/src/WebViewImpl.h

    r139829 r140172  
    137137    // WebWidget methods:
    138138    virtual void close();
    139     virtual WebSize size() { return m_size; }
     139    virtual WebSize size();
    140140    virtual void willStartLiveResize();
    141141    virtual void resize(const WebSize&);
     
    244244    virtual WebSize fixedLayoutSize() const;
    245245    virtual void setFixedLayoutSize(const WebSize&);
    246     virtual WebCore::FloatSize dipSize() const;
    247246    virtual void enableAutoResizeMode(
    248247        const WebSize& minSize,
     
    461460    }
    462461
     462    WebCore::IntSize dipSize() const;
     463    WebCore::IntSize layoutSize() const;
     464
    463465    // Set the disposition for how this webview is to be initially shown.
    464466    void setInitialNavigationPolicy(WebNavigationPolicy policy)
     
    852854    bool m_recreatingGraphicsContext;
    853855    bool m_compositorSurfaceReady;
    854     float m_deviceScaleInCompositor;
    855856    int m_inputHandlerIdentifier;
    856857#endif
Note: See TracChangeset for help on using the changeset viewer.