Changeset 118121 in webkit


Ignore:
Timestamp:
May 22, 2012 10:03:16 PM (12 years ago)
Author:
commit-queue@webkit.org
Message:

[chromium] Apply viewport tag initial-scale only once
https://bugs.webkit.org/show_bug.cgi?id=82949

Patch by Alexandre Elias <aelias@google.com> on 2012-05-22
Reviewed by Adam Barth.

First, check that isPageScaleFactorSet return false before setting
initial-scale. We need to call dispatchViewportPropertiesDidChange()
when the viewport width changes, since that's an input to the viewport
tag calculation. When this happens, we shouldn't pop back to initial
scale.

Second, check that isNewNavigation is true when deciding to clear
isPageScaleFactorIsSet in didCommitLoad. We only want to clear it on
the very first commit, otherwise we'll pop back to initial scale if
the user zooms in before the load is complete.

New test WebFrameTest::FixedLayoutInitializeAtMinimumPageScale.

  • src/ChromeClientImpl.cpp:

(WebKit::ChromeClientImpl::dispatchViewportPropertiesDidChange):

  • src/WebViewImpl.cpp:

(WebKit::WebViewImpl::didCommitLoad):

Location:
trunk/Source/WebKit/chromium
Files:
1 added
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit/chromium/ChangeLog

    r118117 r118121  
     12012-05-22  Alexandre Elias  <aelias@google.com>
     2
     3        [chromium] Apply viewport tag initial-scale only once
     4        https://bugs.webkit.org/show_bug.cgi?id=82949
     5
     6        Reviewed by Adam Barth.
     7
     8        First, check that isPageScaleFactorSet return false before setting
     9        initial-scale. We need to call dispatchViewportPropertiesDidChange()
     10        when the viewport width changes, since that's an input to the viewport
     11        tag calculation. When this happens, we shouldn't pop back to initial
     12        scale.
     13
     14        Second, check that isNewNavigation is true when deciding to clear
     15        isPageScaleFactorIsSet in didCommitLoad. We only want to clear it on
     16        the very first commit, otherwise we'll pop back to initial scale if
     17        the user zooms in before the load is complete.
     18
     19        New test WebFrameTest::FixedLayoutInitializeAtMinimumPageScale.
     20
     21        * src/ChromeClientImpl.cpp:
     22        (WebKit::ChromeClientImpl::dispatchViewportPropertiesDidChange):
     23        * src/WebViewImpl.cpp:
     24        (WebKit::WebViewImpl::didCommitLoad):
     25
    1262012-05-21  Shawn Singh  <shawnsingh@chromium.org>
    227
  • trunk/Source/WebKit/chromium/src/ChromeClientImpl.cpp

    r117170 r118121  
    666666    m_webView->setFixedLayoutSize(IntSize(layoutWidth, layoutHeight));
    667667
    668     // FIXME: Investigate the impact this has on layout/rendering if any.
    669     // This exposes the correct device scale to javascript and media queries.
     668    bool needInitializePageScale = !m_webView->isPageScaleFactorSet();
    670669    if (useDefaultDeviceScaleFactor && settings->defaultDeviceScaleFactor())
    671670        m_webView->setDeviceScaleFactor(settings->defaultDeviceScaleFactor());
     
    673672        m_webView->setDeviceScaleFactor(computed.devicePixelRatio);
    674673    m_webView->setPageScaleFactorLimits(computed.minimumScale, computed.maximumScale);
    675     m_webView->setPageScaleFactorPreservingScrollOffset(computed.initialScale * computed.devicePixelRatio);
     674    if (needInitializePageScale)
     675        m_webView->setPageScaleFactorPreservingScrollOffset(computed.initialScale * computed.devicePixelRatio);
    676676#endif
    677677}
  • trunk/Source/WebKit/chromium/src/WebViewImpl.cpp

    r117915 r118121  
    31033103#endif
    31043104    m_observedNewNavigation = false;
    3105     if (!isNavigationWithinPage)
     3105    if (*isNewNavigation && !isNavigationWithinPage)
    31063106        m_pageScaleFactorIsSet = false;
    31073107
  • trunk/Source/WebKit/chromium/tests/WebFrameTest.cpp

    r117535 r118121  
    3535#include "Frame.h"
    3636#include "FrameTestHelpers.h"
     37#include "FrameView.h"
    3738#include "ResourceError.h"
    3839#include "WebDocument.h"
     
    4041#include "WebFormElement.h"
    4142#include "WebFrameClient.h"
     43#include "WebFrameImpl.h"
    4244#include "WebRange.h"
    4345#include "WebScriptSource.h"
     
    243245    // Force the layout to happen before leaving the test.
    244246    webView->mainFrame()->contentAsText(1024).utf8();
     247}
     248
     249TEST_F(WebFrameTest, FixedLayoutInitializeAtMinimumPageScale)
     250{
     251    registerMockedHttpURLLoad("fixed_layout.html");
     252
     253    FixedLayoutTestWebViewClient client;
     254    client.m_screenInfo.horizontalDPI = 160;
     255    int viewportWidth = 640;
     256    int viewportHeight = 480;
     257    client.m_windowRect = WebRect(0, 0, viewportWidth, viewportHeight);
     258
     259    // Make sure we initialize to minimum scale, even if the window size
     260    // only becomes available after the load begins.
     261    WebViewImpl* webViewImpl = static_cast<WebViewImpl*>(FrameTestHelpers::createWebViewAndLoad(m_baseURL + "fixed_layout.html", true, 0, &client));
     262    webViewImpl->enableFixedLayoutMode(true);
     263    webViewImpl->settings()->setViewportEnabled(true);
     264    webViewImpl->resize(WebSize(viewportWidth, viewportHeight));
     265
     266    int defaultFixedLayoutWidth = 980;
     267    float minimumPageScaleFactor = viewportWidth / (float) defaultFixedLayoutWidth;
     268    EXPECT_EQ(minimumPageScaleFactor, webViewImpl->pageScaleFactor());
     269
     270    // Assume the user has pinch zoomed to page scale factor 2.
     271    float userPinchPageScaleFactor = 2;
     272    webViewImpl->setPageScaleFactorPreservingScrollOffset(userPinchPageScaleFactor);
     273    webViewImpl->mainFrameImpl()->frameView()->layout();
     274
     275    // Make sure we don't reset to initial scale if the page continues to load.
     276    bool isNewNavigation;
     277    webViewImpl->didCommitLoad(&isNewNavigation, false);
     278    webViewImpl->didChangeContentsSize();
     279    EXPECT_EQ(userPinchPageScaleFactor, webViewImpl->pageScaleFactor());
     280
     281    // Make sure we don't reset to initial scale if the viewport size changes.
     282    webViewImpl->resize(WebSize(viewportWidth, viewportHeight + 100));
     283    EXPECT_EQ(userPinchPageScaleFactor, webViewImpl->pageScaleFactor());
    245284}
    246285#endif
Note: See TracChangeset for help on using the changeset viewer.