Changeset 141450 in webkit


Ignore:
Timestamp:
Jan 31, 2013 11:25:41 AM (11 years ago)
Author:
aelias@chromium.org
Message:

Call FrameView::contentsResized() when setting fixed layout size
https://bugs.webkit.org/show_bug.cgi?id=107922

Reviewed by James Robinson.

In fixed layout mode, we should be calling contentsResized() when the
fixed layout size is changed, but not laying out when the visible
content rect changes.

Previously landed as r140869 but was reverted due to a bug in bundled
Chromium-specific code. This patch includes just the minimum needed in
WebCore.

New WebFrameTest: FrameViewNeedsLayoutOnFixedLayoutResize. Some
flaky and obsolete tests for the old page scale mode are also deleted.

Source/WebCore:

  • page/FrameView.cpp:

(WebCore::FrameView::visibleContentsResized):

  • platform/ScrollView.cpp:

(WebCore::ScrollView::setFixedLayoutSize):
(WebCore::ScrollView::setUseFixedLayout):

Source/WebKit/chromium:

  • tests/WebFrameTest.cpp:
Location:
trunk/Source
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r141446 r141450  
     12013-01-31  Alexandre Elias  <aelias@chromium.org>
     2
     3        Call FrameView::contentsResized() when setting fixed layout size
     4        https://bugs.webkit.org/show_bug.cgi?id=107922
     5
     6        Reviewed by James Robinson.
     7
     8        In fixed layout mode, we should be calling contentsResized() when the
     9        fixed layout size is changed, but not laying out when the visible
     10        content rect changes.
     11
     12        Previously landed as r140869 but was reverted due to a bug in bundled
     13        Chromium-specific code. This patch includes just the minimum needed in
     14        WebCore.
     15
     16        New WebFrameTest: FrameViewNeedsLayoutOnFixedLayoutResize.  Some
     17        flaky and obsolete tests for the old page scale mode are also deleted.
     18
     19        * page/FrameView.cpp:
     20        (WebCore::FrameView::visibleContentsResized):
     21        * platform/ScrollView.cpp:
     22        (WebCore::ScrollView::setFixedLayoutSize):
     23        (WebCore::ScrollView::setUseFixedLayout):
     24
    1252013-01-31  Otto Derek Cheung  <otcheung@rim.com>
    226
  • trunk/Source/WebCore/page/FrameView.cpp

    r141053 r141450  
    20232023        return;
    20242024
    2025     if (needsLayout())
     2025    if (!useFixedLayout() && needsLayout())
    20262026        layout();
    20272027
  • trunk/Source/WebCore/platform/ScrollView.cpp

    r141226 r141450  
    279279    m_fixedLayoutSize = newSize;
    280280    updateScrollbars(scrollOffset());
     281    if (m_useFixedLayout)
     282        contentsResized();
    281283}
    282284
     
    292294    m_useFixedLayout = enable;
    293295    updateScrollbars(scrollOffset());
     296    contentsResized();
    294297}
    295298
  • trunk/Source/WebKit/chromium/ChangeLog

    r141444 r141450  
     12013-01-31  Alexandre Elias  <aelias@chromium.org>
     2
     3        Call FrameView::contentsResized() when setting fixed layout size
     4        https://bugs.webkit.org/show_bug.cgi?id=107922
     5
     6        Reviewed by James Robinson.
     7
     8        In fixed layout mode, we should be calling contentsResized() when the
     9        fixed layout size is changed, but not laying out when the visible
     10        content rect changes.
     11
     12        Previously landed as r140869 but was reverted due to a bug in bundled
     13        Chromium-specific code. This patch includes just the minimum needed in
     14        WebCore.
     15
     16        New WebFrameTest: FrameViewNeedsLayoutOnFixedLayoutResize.  Some
     17        flaky and obsolete tests for the old page scale mode are also deleted.
     18
     19        * tests/WebFrameTest.cpp:
     20
    1212013-01-31  Tommy Widenflycht  <tommyw@google.com>
    222
  • trunk/Source/WebKit/chromium/tests/WebFrameTest.cpp

    r141297 r141450  
    228228};
    229229
    230 TEST_F(WebFrameTest, DeviceScaleFactorUsesDefaultWithoutViewportTag)
    231 {
    232     registerMockedHttpURLLoad("no_viewport_tag.html");
    233 
     230TEST_F(WebFrameTest, FrameViewNeedsLayoutOnFixedLayoutResize)
     231{
     232    registerMockedHttpURLLoad("fixed_layout.html");
     233
     234    FixedLayoutTestWebViewClient client;
    234235    int viewportWidth = 640;
    235236    int viewportHeight = 480;
    236237
    237     FixedLayoutTestWebViewClient client;
    238     client.m_screenInfo.deviceScaleFactor = 2;
    239 
    240     WebView* webView = static_cast<WebView*>(FrameTestHelpers::createWebViewAndLoad(m_baseURL + "no_viewport_tag.html", true, 0, &client));
    241 
    242     webView->settings()->setViewportEnabled(true);
    243     webView->enableFixedLayoutMode(true);
    244     webView->resize(WebSize(viewportWidth, viewportHeight));
    245     webView->layout();
    246 
    247     EXPECT_EQ(2, webView->deviceScaleFactor());
    248 
    249     // Device scale factor should be a component of page scale factor in fixed-layout, so a scale of 1 becomes 2.
    250     webView->setPageScaleFactorLimits(1, 2);
    251     EXPECT_EQ(2, webView->pageScaleFactor());
    252 
    253     // Force the layout to happen before leaving the test.
    254     webView->mainFrame()->contentAsText(1024).utf8();
    255 }
    256 
    257 // Test is disabled because it started failing after r140025.
    258 // See bug for details: webkit.org/b/107206.
    259 TEST_F(WebFrameTest, DISABLED_FixedLayoutInitializeAtMinimumPageScale)
    260 {
    261     registerMockedHttpURLLoad("fixed_layout.html");
    262 
    263     FixedLayoutTestWebViewClient client;
    264     client.m_screenInfo.deviceScaleFactor = 1;
    265     int viewportWidth = 640;
    266     int viewportHeight = 480;
    267 
    268238    // Make sure we initialize to minimum scale, even if the window size
    269239    // only becomes available after the load begins.
    270     WebViewImpl* webViewImpl = static_cast<WebViewImpl*>(FrameTestHelpers::createWebViewAndLoad(m_baseURL + "fixed_layout.html", true, 0, &client));
    271     webViewImpl->enableFixedLayoutMode(true);
    272     webViewImpl->settings()->setViewportEnabled(true);
    273     webViewImpl->resize(WebSize(viewportWidth, viewportHeight));
    274 
    275     int defaultFixedLayoutWidth = 980;
    276     float minimumPageScaleFactor = viewportWidth / (float) defaultFixedLayoutWidth;
    277     EXPECT_EQ(minimumPageScaleFactor, webViewImpl->pageScaleFactor());
    278 
    279     // Assume the user has pinch zoomed to page scale factor 2.
    280     float userPinchPageScaleFactor = 2;
    281     webViewImpl->setPageScaleFactorPreservingScrollOffset(userPinchPageScaleFactor);
    282     webViewImpl->mainFrameImpl()->frameView()->layout();
    283 
    284     // Make sure we don't reset to initial scale if the page continues to load.
    285     bool isNewNavigation;
    286     webViewImpl->didCommitLoad(&isNewNavigation, false);
    287     webViewImpl->didChangeContentsSize();
    288     EXPECT_EQ(userPinchPageScaleFactor, webViewImpl->pageScaleFactor());
    289 
    290     // Make sure we don't reset to initial scale if the viewport size changes.
    291     webViewImpl->resize(WebSize(viewportWidth, viewportHeight + 100));
    292     EXPECT_EQ(userPinchPageScaleFactor, webViewImpl->pageScaleFactor());
    293 }
    294 
    295 TEST_F(WebFrameTest, ScaleFactorShouldNotOscillate)
    296 {
    297     registerMockedHttpURLLoad("scale_oscillate.html");
    298 
    299     FixedLayoutTestWebViewClient client;
    300     client.m_screenInfo.deviceScaleFactor = static_cast<float>(1.325);
    301     int viewportWidth = 800;
    302     int viewportHeight = 1057;
    303 
    304     WebViewImpl* webViewImpl = static_cast<WebViewImpl*>(FrameTestHelpers::createWebViewAndLoad(m_baseURL + "scale_oscillate.html", true, 0, &client));
    305     webViewImpl->enableFixedLayoutMode(true);
    306     webViewImpl->settings()->setViewportEnabled(true);
    307     webViewImpl->resize(WebSize(viewportWidth, viewportHeight));
    308     webViewImpl->layout();
    309 }
    310 
    311 TEST_F(WebFrameTest, setPageScaleFactorDoesNotLayout)
    312 {
    313     registerMockedHttpURLLoad("fixed_layout.html");
    314 
    315     FixedLayoutTestWebViewClient client;
    316     client.m_screenInfo.deviceScaleFactor = 1;
    317     int viewportWidth = 640;
    318     int viewportHeight = 480;
    319 
    320240    WebViewImpl* webViewImpl = static_cast<WebViewImpl*>(FrameTestHelpers::createWebViewAndLoad(m_baseURL + "fixed_layout.html", true, 0, &client));
    321241    webViewImpl->settings()->setApplyDeviceScaleFactorInCompositor(true);
     
    326246    webViewImpl->layout();
    327247
     248    webViewImpl->mainFrameImpl()->frameView()->setFixedLayoutSize(WebCore::IntSize(100, 100));
     249    EXPECT_TRUE(webViewImpl->mainFrameImpl()->frameView()->needsLayout());
     250
    328251    int prevLayoutCount = webViewImpl->mainFrameImpl()->frameView()->layoutCount();
    329     webViewImpl->setPageScaleFactor(3, WebPoint());
    330     EXPECT_FALSE(webViewImpl->mainFrameImpl()->frameView()->needsLayout());
     252    webViewImpl->mainFrameImpl()->frameView()->setFrameRect(WebCore::IntRect(0, 0, 641, 481));
    331253    EXPECT_EQ(prevLayoutCount, webViewImpl->mainFrameImpl()->frameView()->layoutCount());
    332 }
    333 
    334 TEST_F(WebFrameTest, pageScaleFactorWrittenToHistoryItem)
     254
     255    webViewImpl->layout();
     256}
     257
     258TEST_F(WebFrameTest, DeviceScaleFactorUsesDefaultWithoutViewportTag)
     259{
     260    registerMockedHttpURLLoad("no_viewport_tag.html");
     261
     262    int viewportWidth = 640;
     263    int viewportHeight = 480;
     264
     265    FixedLayoutTestWebViewClient client;
     266    client.m_screenInfo.deviceScaleFactor = 2;
     267
     268    WebView* webView = static_cast<WebView*>(FrameTestHelpers::createWebViewAndLoad(m_baseURL + "no_viewport_tag.html", true, 0, &client));
     269
     270    webView->settings()->setApplyDeviceScaleFactorInCompositor(true);
     271    webView->settings()->setApplyPageScaleFactorInCompositor(true);
     272    webView->settings()->setViewportEnabled(true);
     273    webView->enableFixedLayoutMode(true);
     274    webView->resize(WebSize(viewportWidth, viewportHeight));
     275    webView->layout();
     276
     277    EXPECT_EQ(2, webView->deviceScaleFactor());
     278
     279    // Device scale factor should be independent of page scale.
     280    webView->setPageScaleFactorLimits(1, 2);
     281    webView->setPageScaleFactorPreservingScrollOffset(0.5);
     282    webView->layout();
     283    EXPECT_EQ(1, webView->pageScaleFactor());
     284
     285    // Force the layout to happen before leaving the test.
     286    webView->mainFrame()->contentAsText(1024).utf8();
     287}
     288
     289// Test is disabled because it started failing after r140025.
     290// See bug for details: webkit.org/b/107206.
     291TEST_F(WebFrameTest, DISABLED_FixedLayoutInitializeAtMinimumPageScale)
     292{
     293    registerMockedHttpURLLoad("fixed_layout.html");
     294
     295    FixedLayoutTestWebViewClient client;
     296    client.m_screenInfo.deviceScaleFactor = 1;
     297    int viewportWidth = 640;
     298    int viewportHeight = 480;
     299
     300    // Make sure we initialize to minimum scale, even if the window size
     301    // only becomes available after the load begins.
     302    WebViewImpl* webViewImpl = static_cast<WebViewImpl*>(FrameTestHelpers::createWebViewAndLoad(m_baseURL + "fixed_layout.html", true, 0, &client));
     303    webViewImpl->enableFixedLayoutMode(true);
     304    webViewImpl->settings()->setViewportEnabled(true);
     305    webViewImpl->resize(WebSize(viewportWidth, viewportHeight));
     306
     307    int defaultFixedLayoutWidth = 980;
     308    float minimumPageScaleFactor = viewportWidth / (float) defaultFixedLayoutWidth;
     309    EXPECT_EQ(minimumPageScaleFactor, webViewImpl->pageScaleFactor());
     310
     311    // Assume the user has pinch zoomed to page scale factor 2.
     312    float userPinchPageScaleFactor = 2;
     313    webViewImpl->setPageScaleFactorPreservingScrollOffset(userPinchPageScaleFactor);
     314    webViewImpl->mainFrameImpl()->frameView()->layout();
     315
     316    // Make sure we don't reset to initial scale if the page continues to load.
     317    bool isNewNavigation;
     318    webViewImpl->didCommitLoad(&isNewNavigation, false);
     319    webViewImpl->didChangeContentsSize();
     320    EXPECT_EQ(userPinchPageScaleFactor, webViewImpl->pageScaleFactor());
     321
     322    // Make sure we don't reset to initial scale if the viewport size changes.
     323    webViewImpl->resize(WebSize(viewportWidth, viewportHeight + 100));
     324    EXPECT_EQ(userPinchPageScaleFactor, webViewImpl->pageScaleFactor());
     325}
     326
     327TEST_F(WebFrameTest, ScaleFactorShouldNotOscillate)
     328{
     329    registerMockedHttpURLLoad("scale_oscillate.html");
     330
     331    FixedLayoutTestWebViewClient client;
     332    client.m_screenInfo.deviceScaleFactor = static_cast<float>(1.325);
     333    int viewportWidth = 800;
     334    int viewportHeight = 1057;
     335
     336    WebViewImpl* webViewImpl = static_cast<WebViewImpl*>(FrameTestHelpers::createWebViewAndLoad(m_baseURL + "scale_oscillate.html", true, 0, &client));
     337    webViewImpl->enableFixedLayoutMode(true);
     338    webViewImpl->settings()->setViewportEnabled(true);
     339    webViewImpl->resize(WebSize(viewportWidth, viewportHeight));
     340    webViewImpl->layout();
     341}
     342
     343TEST_F(WebFrameTest, setPageScaleFactorDoesNotLayout)
    335344{
    336345    registerMockedHttpURLLoad("fixed_layout.html");
     
    349358    webViewImpl->layout();
    350359
     360    int prevLayoutCount = webViewImpl->mainFrameImpl()->frameView()->layoutCount();
    351361    webViewImpl->setPageScaleFactor(3, WebPoint());
    352     webViewImpl->page()->mainFrame()->loader()->history()->saveDocumentAndScrollState();
    353     webViewImpl->setPageScaleFactor(1, WebPoint());
    354     webViewImpl->page()->mainFrame()->loader()->history()->restoreScrollPositionAndViewState();
    355     EXPECT_EQ(3, webViewImpl->pageScaleFactor());
    356 }
    357 
    358 // Disabled, pending investigation after http://trac.webkit.org/changeset/141053
    359 TEST_F(WebFrameTest, DISABLED_pageScaleFactorShrinksViewport)
     362    EXPECT_FALSE(webViewImpl->mainFrameImpl()->frameView()->needsLayout());
     363    EXPECT_EQ(prevLayoutCount, webViewImpl->mainFrameImpl()->frameView()->layoutCount());
     364}
     365
     366TEST_F(WebFrameTest, pageScaleFactorWrittenToHistoryItem)
    360367{
    361368    registerMockedHttpURLLoad("fixed_layout.html");
     
    365372    int viewportWidth = 640;
    366373    int viewportHeight = 480;
    367     int viewportWidthMinusScrollbar = 640 - 15;
    368     int viewportHeightMinusScrollbar = 480 - 15;
    369374
    370375    WebViewImpl* webViewImpl = static_cast<WebViewImpl*>(FrameTestHelpers::createWebViewAndLoad(m_baseURL + "fixed_layout.html", true, 0, &client));
     
    376381    webViewImpl->layout();
    377382
    378     webViewImpl->setPageScaleFactor(2, WebPoint());
    379 
    380     WebCore::IntSize unscaledSize = webViewImpl->mainFrameImpl()->frameView()->unscaledVisibleContentSize(true);
    381     EXPECT_EQ(viewportWidth, unscaledSize.width());
    382     EXPECT_EQ(viewportHeight, unscaledSize.height());
    383 
    384     WebCore::IntSize unscaledSizeMinusScrollbar = webViewImpl->mainFrameImpl()->frameView()->unscaledVisibleContentSize(false);
    385     EXPECT_EQ(viewportWidthMinusScrollbar, unscaledSizeMinusScrollbar.width());
    386     EXPECT_EQ(viewportHeightMinusScrollbar, unscaledSizeMinusScrollbar.height());
    387 
    388     WebCore::IntSize scaledSize = webViewImpl->mainFrameImpl()->frameView()->visibleContentRect().size();
    389     EXPECT_EQ(ceil(viewportWidthMinusScrollbar / 2.0), scaledSize.width());
    390     EXPECT_EQ(ceil(viewportHeightMinusScrollbar / 2.0), scaledSize.height());
    391 }
    392 
    393 TEST_F(WebFrameTest, pageScaleFactorDoesNotApplyCssTransform)
     383    webViewImpl->setPageScaleFactor(3, WebPoint());
     384    webViewImpl->page()->mainFrame()->loader()->history()->saveDocumentAndScrollState();
     385    webViewImpl->setPageScaleFactor(1, WebPoint());
     386    webViewImpl->page()->mainFrame()->loader()->history()->restoreScrollPositionAndViewState();
     387    EXPECT_EQ(3, webViewImpl->pageScaleFactor());
     388}
     389
     390// Disabled, pending investigation after http://trac.webkit.org/changeset/141053
     391TEST_F(WebFrameTest, DISABLED_pageScaleFactorShrinksViewport)
    394392{
    395393    registerMockedHttpURLLoad("fixed_layout.html");
     
    399397    int viewportWidth = 640;
    400398    int viewportHeight = 480;
     399    int viewportWidthMinusScrollbar = 640 - 15;
     400    int viewportHeightMinusScrollbar = 480 - 15;
    401401
    402402    WebViewImpl* webViewImpl = static_cast<WebViewImpl*>(FrameTestHelpers::createWebViewAndLoad(m_baseURL + "fixed_layout.html", true, 0, &client));
     
    410410    webViewImpl->setPageScaleFactor(2, WebPoint());
    411411
    412     EXPECT_EQ(1, webViewImpl->page()->mainFrame()->frameScaleFactor());
    413     EXPECT_EQ(980, webViewImpl->page()->mainFrame()->contentRenderer()->unscaledDocumentRect().width());
    414     EXPECT_EQ(980, webViewImpl->mainFrameImpl()->frameView()->contentsSize().width());
    415 }
    416 #endif
    417 
    418 TEST_F(WebFrameTest, CanOverrideMaximumScaleFactor)
    419 {
    420     registerMockedHttpURLLoad("no_scale_for_you.html");
     412    WebCore::IntSize unscaledSize = webViewImpl->mainFrameImpl()->frameView()->unscaledVisibleContentSize(true);
     413    EXPECT_EQ(viewportWidth, unscaledSize.width());
     414    EXPECT_EQ(viewportHeight, unscaledSize.height());
     415
     416    WebCore::IntSize unscaledSizeMinusScrollbar = webViewImpl->mainFrameImpl()->frameView()->unscaledVisibleContentSize(false);
     417    EXPECT_EQ(viewportWidthMinusScrollbar, unscaledSizeMinusScrollbar.width());
     418    EXPECT_EQ(viewportHeightMinusScrollbar, unscaledSizeMinusScrollbar.height());
     419
     420    WebCore::IntSize scaledSize = webViewImpl->mainFrameImpl()->frameView()->visibleContentRect().size();
     421    EXPECT_EQ(ceil(viewportWidthMinusScrollbar / 2.0), scaledSize.width());
     422    EXPECT_EQ(ceil(viewportHeightMinusScrollbar / 2.0), scaledSize.height());
     423}
     424
     425TEST_F(WebFrameTest, pageScaleFactorDoesNotApplyCssTransform)
     426{
     427    registerMockedHttpURLLoad("fixed_layout.html");
    421428
    422429    FixedLayoutTestWebViewClient client;
     
    425432    int viewportHeight = 480;
    426433
     434    WebViewImpl* webViewImpl = static_cast<WebViewImpl*>(FrameTestHelpers::createWebViewAndLoad(m_baseURL + "fixed_layout.html", true, 0, &client));
     435    webViewImpl->settings()->setApplyDeviceScaleFactorInCompositor(true);
     436    webViewImpl->settings()->setApplyPageScaleFactorInCompositor(true);
     437    webViewImpl->enableFixedLayoutMode(true);
     438    webViewImpl->settings()->setViewportEnabled(true);
     439    webViewImpl->resize(WebSize(viewportWidth, viewportHeight));
     440    webViewImpl->layout();
     441
     442    webViewImpl->setPageScaleFactor(2, WebPoint());
     443
     444    EXPECT_EQ(1, webViewImpl->page()->mainFrame()->frameScaleFactor());
     445    EXPECT_EQ(980, webViewImpl->page()->mainFrame()->contentRenderer()->unscaledDocumentRect().width());
     446    EXPECT_EQ(980, webViewImpl->mainFrameImpl()->frameView()->contentsSize().width());
     447}
     448#endif
     449
     450TEST_F(WebFrameTest, CanOverrideMaximumScaleFactor)
     451{
     452    registerMockedHttpURLLoad("no_scale_for_you.html");
     453
     454    FixedLayoutTestWebViewClient client;
     455    client.m_screenInfo.deviceScaleFactor = 1;
     456    int viewportWidth = 640;
     457    int viewportHeight = 480;
     458
    427459    WebViewImpl* webViewImpl = static_cast<WebViewImpl*>(FrameTestHelpers::createWebViewAndLoad(m_baseURL + "no_scale_for_you.html", true, 0, &client));
    428460    webViewImpl->enableFixedLayoutMode(true);
     
    442474    webView->setPageScaleFactor(scale, WebPoint(scroll.x, scroll.y));
    443475    webView->layout();
    444 }
    445 
    446 TEST_F(WebFrameTest, DivAutoZoomParamsTestWebKitScaling)
    447 {
    448     registerMockedHttpURLLoad("get_scale_for_auto_zoom_into_div_test.html");
    449 
    450     int viewportWidth = 640;
    451     int viewportHeight = 480;
    452     WebKit::WebView* webView = FrameTestHelpers::createWebViewAndLoad(m_baseURL + "get_scale_for_auto_zoom_into_div_test.html");
    453     webView->settings()->setApplyDeviceScaleFactorInCompositor(false);
    454     webView->settings()->setApplyPageScaleFactorInCompositor(false);
    455     webView->setDeviceScaleFactor(2.0f);
    456     webView->resize(WebSize(viewportWidth, viewportHeight));
    457     webView->setPageScaleFactorLimits(0.01f, 4);
    458     webView->enableFixedLayoutMode(true);
    459     webView->layout();
    460 
    461     WebRect wideDiv(200, 100, 400, 150);
    462     WebRect tallDiv(200, 300, 400, 800);
    463     WebRect doubleTapPointWide((wideDiv.x + 50) * webView->pageScaleFactor(),
    464         (wideDiv.y + 50) * webView->pageScaleFactor(), 0, 0);
    465     WebRect doubleTapPointTall((tallDiv.x + 50) * webView->pageScaleFactor(),
    466         (tallDiv.y + 50) * webView->pageScaleFactor(), 0, 0);
    467     float scale;
    468     WebPoint scroll;
    469     bool isAnchor;
    470 
    471     WebViewImpl* webViewImpl = static_cast<WebViewImpl*>(webView);
    472     // Test double-tap zooming into wide div.
    473     webViewImpl->computeScaleAndScrollForHitRect(doubleTapPointWide, WebViewImpl::DoubleTap, scale, scroll, isAnchor);
    474     // The div should horizontally fill the screen (modulo margins), and
    475     // vertically centered (modulo integer rounding).
    476     EXPECT_NEAR(viewportWidth / (float) wideDiv.width, scale, 0.1);
    477     EXPECT_NEAR(wideDiv.x * scale, scroll.x, 20);
    478     int vScroll = (wideDiv.y + wideDiv.height / 2) * scale - (viewportHeight / 2);
    479     EXPECT_NEAR(vScroll, scroll.y, 1);
    480     EXPECT_FALSE(isAnchor);
    481 
    482     setScaleAndScrollAndLayout(webViewImpl, scroll, scale);
    483 
    484     // Test zoom out back to minimum scale.
    485     webViewImpl->computeScaleAndScrollForHitRect(doubleTapPointWide, WebViewImpl::DoubleTap, scale, scroll, isAnchor);
    486     EXPECT_FLOAT_EQ(webViewImpl->minimumPageScaleFactor(), scale);
    487     EXPECT_TRUE(isAnchor);
    488 
    489     setScaleAndScrollAndLayout(webViewImpl, WebPoint(0, 0), scale);
    490 
    491     // Test double-tap zooming into tall div.
    492     webViewImpl->computeScaleAndScrollForHitRect(doubleTapPointTall, WebViewImpl::DoubleTap, scale, scroll, isAnchor);
    493     // The div should start at the top left of the viewport.
    494     EXPECT_NEAR(viewportWidth / (float) tallDiv.width, scale, 0.1);
    495     EXPECT_NEAR(tallDiv.x * scale, scroll.x, 20);
    496     EXPECT_NEAR(tallDiv.y * scale, scroll.y, 20);
    497     EXPECT_FALSE(isAnchor);
    498 
    499     // Test for Non-doubletap scaling
    500     // Test zooming into div.
    501     webViewImpl->computeScaleAndScrollForHitRect(WebRect(250, 250, 10, 10), WebViewImpl::FindInPage, scale, scroll, isAnchor);
    502     EXPECT_NEAR(viewportWidth / (float) wideDiv.width, scale, 0.1);
    503476}
    504477
     
    568541    webViewImpl->mainFrameImpl()->frameView()->layout();
    569542    scale = webViewImpl->pageScaleFactor();
    570 }
    571 
    572 TEST_F(WebFrameTest, DivAutoZoomMultipleDivsTestWebKitScaling)
    573 {
    574     registerMockedHttpURLLoad("get_multiple_divs_for_auto_zoom_test.html");
    575 
    576     int viewportWidth = 640;
    577     int viewportHeight = 480;
    578     float doubleTapZoomAlreadyLegibleRatio = 1.2f;
    579     WebKit::WebView* webView = FrameTestHelpers::createWebViewAndLoad(m_baseURL + "get_multiple_divs_for_auto_zoom_test.html");
    580     webView->settings()->setApplyDeviceScaleFactorInCompositor(false);
    581     webView->settings()->setApplyPageScaleFactorInCompositor(false);
    582     webView->enableFixedLayoutMode(true);
    583     webView->resize(WebSize(viewportWidth, viewportHeight));
    584     webView->setPageScaleFactorLimits(1, 4);
    585     webView->layout();
    586     webView->setDeviceScaleFactor(1.5f);
    587 
    588     WebViewImpl* webViewImpl = static_cast<WebViewImpl*>(webView);
    589     webViewImpl->shouldUseAnimateDoubleTapTimeZeroForTesting(true);
    590 
    591     WebRect topDiv(200, 100, 200, 150);
    592     WebRect bottomDiv(200, 300, 200, 150);
    593     WebPoint topPoint(topDiv.x + 50, topDiv.y + 50);
    594     WebPoint bottomPoint(bottomDiv.x + 50, bottomDiv.y + 50);
    595     float scale;
    596     setScaleAndScrollAndLayout(webViewImpl, WebPoint(0, 0), (webViewImpl->minimumPageScaleFactor()) * (1 + doubleTapZoomAlreadyLegibleRatio) / 2);
    597 
    598     // Test double tap on two different divs
    599     // After first zoom, we should go back to minimum page scale with a second double tap.
    600     simulateDoubleTap(webViewImpl, topPoint, scale);
    601     EXPECT_FLOAT_EQ(webViewImpl->deviceScaleFactor(), scale);
    602     simulateDoubleTap(webViewImpl, bottomPoint, scale);
    603     EXPECT_FLOAT_EQ(webViewImpl->minimumPageScaleFactor(), scale);
    604 
    605     // If the user pinch zooms after double tap, a second double tap should zoom back to the div.
    606     simulateDoubleTap(webViewImpl, topPoint, scale);
    607     EXPECT_FLOAT_EQ(webViewImpl->deviceScaleFactor(), scale);
    608     webViewImpl->applyScrollAndScale(WebSize(), 0.6f);
    609     simulateDoubleTap(webViewImpl, bottomPoint, scale);
    610     EXPECT_FLOAT_EQ(webView->deviceScaleFactor(), scale);
    611543}
    612544
     
    654586}
    655587
    656 TEST_F(WebFrameTest, DivAutoZoomScaleBoundsTestWebKitScaling)
    657 {
    658     registerMockedHttpURLLoad("get_scale_bounds_check_for_auto_zoom_test.html");
    659 
    660     int viewportWidth = 640;
    661     int viewportHeight = 480;
    662     float doubleTapZoomAlreadyLegibleRatio = 1.2f;
    663     WebKit::WebView* webView = FrameTestHelpers::createWebViewAndLoad(m_baseURL + "get_scale_bounds_check_for_auto_zoom_test.html");
    664     webView->settings()->setApplyDeviceScaleFactorInCompositor(false);
    665     webView->settings()->setApplyPageScaleFactorInCompositor(false);
    666     webView->enableFixedLayoutMode(true);
    667     webView->resize(WebSize(viewportWidth, viewportHeight));
    668     webView->setPageScaleFactorLimits(1, 4);
    669     webView->layout();
    670 
    671     WebViewImpl* webViewImpl = static_cast<WebViewImpl*>(webView);
    672     webViewImpl->shouldUseAnimateDoubleTapTimeZeroForTesting(true);
    673     float doubleTapZoomAlreadyLegibleScale = webViewImpl->minimumPageScaleFactor() * doubleTapZoomAlreadyLegibleRatio;
    674 
    675     WebRect div(200, 100, 200, 150);
    676     WebPoint doubleTapPoint(div.x + 50, div.y + 50);
    677     float scale;
    678 
    679     // Test double tap scale bounds.
    680     // minimumPageScale < doubleTapZoomAlreadyLegibleScale < deviceDpiScale
    681     webViewImpl->setDeviceScaleFactor(1.5f);
    682     setScaleAndScrollAndLayout(webViewImpl, WebPoint(0, 0), (webViewImpl->minimumPageScaleFactor()) * (1 + doubleTapZoomAlreadyLegibleRatio) / 2);
    683     simulateDoubleTap(webViewImpl, doubleTapPoint, scale);
    684     EXPECT_FLOAT_EQ(webViewImpl->deviceScaleFactor(), scale);
    685     simulateDoubleTap(webViewImpl, doubleTapPoint, scale);
    686     EXPECT_FLOAT_EQ(webViewImpl->minimumPageScaleFactor(), scale);
    687     simulateDoubleTap(webViewImpl, doubleTapPoint, scale);
    688     EXPECT_FLOAT_EQ(webViewImpl->deviceScaleFactor(), scale);
    689 
    690     // Zoom in to reset double_tap_zoom_in_effect flag.
    691     webViewImpl->applyScrollAndScale(WebSize(), 1.1f);
    692     // deviceDpiScale < minimumPageScale < doubleTapZoomAlreadyLegibleScale
    693     webViewImpl->setDeviceScaleFactor(0.5f);
    694     setScaleAndScrollAndLayout(webViewImpl, WebPoint(0, 0), (webViewImpl->minimumPageScaleFactor()) * (1 + doubleTapZoomAlreadyLegibleRatio) / 2);
    695     simulateDoubleTap(webViewImpl, doubleTapPoint, scale);
    696     EXPECT_FLOAT_EQ(webViewImpl->minimumPageScaleFactor(), scale);
    697     simulateDoubleTap(webViewImpl, doubleTapPoint, scale);
    698     EXPECT_FLOAT_EQ(doubleTapZoomAlreadyLegibleScale, scale);
    699     simulateDoubleTap(webViewImpl, doubleTapPoint, scale);
    700     EXPECT_FLOAT_EQ(webViewImpl->minimumPageScaleFactor(), scale);
    701 
    702     // Zoom in to reset double_tap_zoom_in_effect flag.
    703     webViewImpl->applyScrollAndScale(WebSize(), 1.1f);
    704     // minimumPageScale < deviceDpiScale < doubleTapZoomAlreadyLegibleScale
    705     webViewImpl->setDeviceScaleFactor(1.1f);
    706     setScaleAndScrollAndLayout(webViewImpl, WebPoint(0, 0), (webViewImpl->minimumPageScaleFactor()) * (1 + doubleTapZoomAlreadyLegibleRatio) / 2);
    707     simulateDoubleTap(webViewImpl, doubleTapPoint, scale);
    708     EXPECT_FLOAT_EQ(webViewImpl->minimumPageScaleFactor(), scale);
    709     simulateDoubleTap(webViewImpl, doubleTapPoint, scale);
    710     EXPECT_FLOAT_EQ(doubleTapZoomAlreadyLegibleScale, scale);
    711     simulateDoubleTap(webViewImpl, doubleTapPoint, scale);
    712     EXPECT_FLOAT_EQ(webViewImpl->minimumPageScaleFactor(), scale);
    713 }
    714 
    715588TEST_F(WebFrameTest, DivAutoZoomScaleBoundsTestCompositorScaling)
    716589{
     
    775648
    776649#if ENABLE(TEXT_AUTOSIZING)
    777 TEST_F(WebFrameTest, DivAutoZoomScaleFontScaleFactorTestWebKitScaling)
    778 {
    779     registerMockedHttpURLLoad("get_scale_bounds_check_for_auto_zoom_test.html");
    780 
    781     int viewportWidth = 640;
    782     int viewportHeight = 480;
    783     float doubleTapZoomAlreadyLegibleRatio = 1.2f;
    784     float textAutosizingFontScaleFactor = 1.13f;
    785     WebKit::WebView* webView = FrameTestHelpers::createWebViewAndLoad(m_baseURL + "get_scale_bounds_check_for_auto_zoom_test.html");
    786     webView->settings()->setApplyDeviceScaleFactorInCompositor(false);
    787     webView->settings()->setApplyPageScaleFactorInCompositor(false);
    788     webView->enableFixedLayoutMode(true);
    789     webView->resize(WebSize(viewportWidth, viewportHeight));
    790     webView->setPageScaleFactorLimits(1, 4);
    791     webView->layout();
    792 
    793     WebViewImpl* webViewImpl = static_cast<WebViewImpl*>(webView);
    794     webViewImpl->shouldUseAnimateDoubleTapTimeZeroForTesting(true);
    795     webViewImpl->page()->settings()->setTextAutosizingFontScaleFactor(textAutosizingFontScaleFactor);
    796     float doubleTapZoomAlreadyLegibleScale = webViewImpl->minimumPageScaleFactor() * doubleTapZoomAlreadyLegibleRatio;
    797 
    798     WebRect div(200, 100, 200, 150);
    799     WebPoint doubleTapPoint(div.x + 50, div.y + 50);
    800     float scale;
    801 
    802     // Test double tap scale bounds.
    803     // minimumPageScale < doubleTapZoomAlreadyLegibleScale < deviceDpiScale < deviceDpiScale * textAutosizingFontScaleFactor
    804     webViewImpl->setDeviceScaleFactor(1.5f);
    805     float legibleScale = webViewImpl->deviceScaleFactor() * textAutosizingFontScaleFactor;
    806     setScaleAndScrollAndLayout(webViewImpl, WebPoint(0, 0), (webViewImpl->minimumPageScaleFactor()) * (1 + doubleTapZoomAlreadyLegibleRatio) / 2);
    807     simulateDoubleTap(webViewImpl, doubleTapPoint, scale);
    808     EXPECT_FLOAT_EQ(legibleScale, scale);
    809     simulateDoubleTap(webViewImpl, doubleTapPoint, scale);
    810     EXPECT_FLOAT_EQ(webViewImpl->minimumPageScaleFactor(), scale);
    811     simulateDoubleTap(webViewImpl, doubleTapPoint, scale);
    812     EXPECT_FLOAT_EQ(legibleScale, scale);
    813 
    814     // Zoom in to reset double_tap_zoom_in_effect flag.
    815     webViewImpl->applyScrollAndScale(WebSize(), 1.1f);
    816     // deviceDpiScale < deviceDpiScale * textAutosizingFontScaleFactor < minimumPageScale < doubleTapZoomAlreadyLegibleScale
    817     webViewImpl->setDeviceScaleFactor(0.5f);
    818     legibleScale = webViewImpl->deviceScaleFactor() * textAutosizingFontScaleFactor;
    819     setScaleAndScrollAndLayout(webViewImpl, WebPoint(0, 0), (webViewImpl->minimumPageScaleFactor()) * (1 + doubleTapZoomAlreadyLegibleRatio) / 2);
    820     simulateDoubleTap(webViewImpl, doubleTapPoint, scale);
    821     EXPECT_FLOAT_EQ(webViewImpl->minimumPageScaleFactor(), scale);
    822     simulateDoubleTap(webViewImpl, doubleTapPoint, scale);
    823     EXPECT_FLOAT_EQ(doubleTapZoomAlreadyLegibleScale, scale);
    824     simulateDoubleTap(webViewImpl, doubleTapPoint, scale);
    825     EXPECT_FLOAT_EQ(webViewImpl->minimumPageScaleFactor(), scale);
    826 
    827     // Zoom in to reset double_tap_zoom_in_effect flag.
    828     webViewImpl->applyScrollAndScale(WebSize(), 1.1f);
    829     // minimumPageScale < deviceDpiScale < deviceDpiScale * textAutosizingFontScaleFactor < doubleTapZoomAlreadyLegibleScale
    830     webViewImpl->setDeviceScaleFactor(1.05f);
    831     legibleScale = webViewImpl->deviceScaleFactor() * textAutosizingFontScaleFactor;
    832     setScaleAndScrollAndLayout(webViewImpl, WebPoint(0, 0), (webViewImpl->minimumPageScaleFactor()) * (1 + doubleTapZoomAlreadyLegibleRatio) / 2);
    833     simulateDoubleTap(webViewImpl, doubleTapPoint, scale);
    834     EXPECT_FLOAT_EQ(webViewImpl->minimumPageScaleFactor(), scale);
    835     simulateDoubleTap(webViewImpl, doubleTapPoint, scale);
    836     EXPECT_FLOAT_EQ(doubleTapZoomAlreadyLegibleScale, scale);
    837     simulateDoubleTap(webViewImpl, doubleTapPoint, scale);
    838     EXPECT_FLOAT_EQ(webViewImpl->minimumPageScaleFactor(), scale);
    839 
    840     // Zoom in to reset double_tap_zoom_in_effect flag.
    841     webViewImpl->applyScrollAndScale(WebSize(), 1.1f);
    842     // minimumPageScale < deviceDpiScale < doubleTapZoomAlreadyLegibleScale < deviceDpiScale * textAutosizingFontScaleFactor
    843     webViewImpl->setDeviceScaleFactor(1.1f);
    844     legibleScale = webViewImpl->deviceScaleFactor() * textAutosizingFontScaleFactor;
    845     setScaleAndScrollAndLayout(webViewImpl, WebPoint(0, 0), (webViewImpl->minimumPageScaleFactor()) * (1 + doubleTapZoomAlreadyLegibleRatio) / 2);
    846     simulateDoubleTap(webViewImpl, doubleTapPoint, scale);
    847     EXPECT_FLOAT_EQ(legibleScale, scale);
    848     simulateDoubleTap(webViewImpl, doubleTapPoint, scale);
    849     EXPECT_FLOAT_EQ(webViewImpl->minimumPageScaleFactor(), scale);
    850     simulateDoubleTap(webViewImpl, doubleTapPoint, scale);
    851     EXPECT_FLOAT_EQ(legibleScale, scale);
    852 }
    853 
    854650TEST_F(WebFrameTest, DivAutoZoomScaleFontScaleFactorTestCompositorScaling)
    855651{
Note: See TracChangeset for help on using the changeset viewer.