Modified: trunk/Source/WebKit/chromium/tests/WebFrameTest.cpp (141449 => 141450)
--- trunk/Source/WebKit/chromium/tests/WebFrameTest.cpp 2013-01-31 19:16:07 UTC (rev 141449)
+++ trunk/Source/WebKit/chromium/tests/WebFrameTest.cpp 2013-01-31 19:25:41 UTC (rev 141450)
@@ -227,6 +227,34 @@
WebScreenInfo m_screenInfo;
};
+TEST_F(WebFrameTest, FrameViewNeedsLayoutOnFixedLayoutResize)
+{
+ registerMockedHttpURLLoad("fixed_layout.html");
+
+ FixedLayoutTestWebViewClient client;
+ int viewportWidth = 640;
+ int viewportHeight = 480;
+
+ // Make sure we initialize to minimum scale, even if the window size
+ // only becomes available after the load begins.
+ WebViewImpl* webViewImpl = static_cast<WebViewImpl*>(FrameTestHelpers::createWebViewAndLoad(m_baseURL + "fixed_layout.html", true, 0, &client));
+ webViewImpl->settings()->setApplyDeviceScaleFactorInCompositor(true);
+ webViewImpl->settings()->setApplyPageScaleFactorInCompositor(true);
+ webViewImpl->enableFixedLayoutMode(true);
+ webViewImpl->settings()->setViewportEnabled(true);
+ webViewImpl->resize(WebSize(viewportWidth, viewportHeight));
+ webViewImpl->layout();
+
+ webViewImpl->mainFrameImpl()->frameView()->setFixedLayoutSize(WebCore::IntSize(100, 100));
+ EXPECT_TRUE(webViewImpl->mainFrameImpl()->frameView()->needsLayout());
+
+ int prevLayoutCount = webViewImpl->mainFrameImpl()->frameView()->layoutCount();
+ webViewImpl->mainFrameImpl()->frameView()->setFrameRect(WebCore::IntRect(0, 0, 641, 481));
+ EXPECT_EQ(prevLayoutCount, webViewImpl->mainFrameImpl()->frameView()->layoutCount());
+
+ webViewImpl->layout();
+}
+
TEST_F(WebFrameTest, DeviceScaleFactorUsesDefaultWithoutViewportTag)
{
registerMockedHttpURLLoad("no_viewport_tag.html");
@@ -239,6 +267,8 @@
WebView* webView = static_cast<WebView*>(FrameTestHelpers::createWebViewAndLoad(m_baseURL + "no_viewport_tag.html", true, 0, &client));
+ webView->settings()->setApplyDeviceScaleFactorInCompositor(true);
+ webView->settings()->setApplyPageScaleFactorInCompositor(true);
webView->settings()->setViewportEnabled(true);
webView->enableFixedLayoutMode(true);
webView->resize(WebSize(viewportWidth, viewportHeight));
@@ -246,9 +276,11 @@
EXPECT_EQ(2, webView->deviceScaleFactor());
- // Device scale factor should be a component of page scale factor in fixed-layout, so a scale of 1 becomes 2.
+ // Device scale factor should be independent of page scale.
webView->setPageScaleFactorLimits(1, 2);
- EXPECT_EQ(2, webView->pageScaleFactor());
+ webView->setPageScaleFactorPreservingScrollOffset(0.5);
+ webView->layout();
+ EXPECT_EQ(1, webView->pageScaleFactor());
// Force the layout to happen before leaving the test.
webView->mainFrame()->contentAsText(1024).utf8();
@@ -443,65 +475,6 @@
webView->layout();
}
-TEST_F(WebFrameTest, DivAutoZoomParamsTestWebKitScaling)
-{
- registerMockedHttpURLLoad("get_scale_for_auto_zoom_into_div_test.html");
-
- int viewportWidth = 640;
- int viewportHeight = 480;
- WebKit::WebView* webView = FrameTestHelpers::createWebViewAndLoad(m_baseURL + "get_scale_for_auto_zoom_into_div_test.html");
- webView->settings()->setApplyDeviceScaleFactorInCompositor(false);
- webView->settings()->setApplyPageScaleFactorInCompositor(false);
- webView->setDeviceScaleFactor(2.0f);
- webView->resize(WebSize(viewportWidth, viewportHeight));
- webView->setPageScaleFactorLimits(0.01f, 4);
- webView->enableFixedLayoutMode(true);
- webView->layout();
-
- WebRect wideDiv(200, 100, 400, 150);
- WebRect tallDiv(200, 300, 400, 800);
- WebRect doubleTapPointWide((wideDiv.x + 50) * webView->pageScaleFactor(),
- (wideDiv.y + 50) * webView->pageScaleFactor(), 0, 0);
- WebRect doubleTapPointTall((tallDiv.x + 50) * webView->pageScaleFactor(),
- (tallDiv.y + 50) * webView->pageScaleFactor(), 0, 0);
- float scale;
- WebPoint scroll;
- bool isAnchor;
-
- WebViewImpl* webViewImpl = static_cast<WebViewImpl*>(webView);
- // Test double-tap zooming into wide div.
- webViewImpl->computeScaleAndScrollForHitRect(doubleTapPointWide, WebViewImpl::DoubleTap, scale, scroll, isAnchor);
- // The div should horizontally fill the screen (modulo margins), and
- // vertically centered (modulo integer rounding).
- EXPECT_NEAR(viewportWidth / (float) wideDiv.width, scale, 0.1);
- EXPECT_NEAR(wideDiv.x * scale, scroll.x, 20);
- int vScroll = (wideDiv.y + wideDiv.height / 2) * scale - (viewportHeight / 2);
- EXPECT_NEAR(vScroll, scroll.y, 1);
- EXPECT_FALSE(isAnchor);
-
- setScaleAndScrollAndLayout(webViewImpl, scroll, scale);
-
- // Test zoom out back to minimum scale.
- webViewImpl->computeScaleAndScrollForHitRect(doubleTapPointWide, WebViewImpl::DoubleTap, scale, scroll, isAnchor);
- EXPECT_FLOAT_EQ(webViewImpl->minimumPageScaleFactor(), scale);
- EXPECT_TRUE(isAnchor);
-
- setScaleAndScrollAndLayout(webViewImpl, WebPoint(0, 0), scale);
-
- // Test double-tap zooming into tall div.
- webViewImpl->computeScaleAndScrollForHitRect(doubleTapPointTall, WebViewImpl::DoubleTap, scale, scroll, isAnchor);
- // The div should start at the top left of the viewport.
- EXPECT_NEAR(viewportWidth / (float) tallDiv.width, scale, 0.1);
- EXPECT_NEAR(tallDiv.x * scale, scroll.x, 20);
- EXPECT_NEAR(tallDiv.y * scale, scroll.y, 20);
- EXPECT_FALSE(isAnchor);
-
- // Test for Non-doubletap scaling
- // Test zooming into div.
- webViewImpl->computeScaleAndScrollForHitRect(WebRect(250, 250, 10, 10), WebViewImpl::FindInPage, scale, scroll, isAnchor);
- EXPECT_NEAR(viewportWidth / (float) wideDiv.width, scale, 0.1);
-}
-
TEST_F(WebFrameTest, DivAutoZoomParamsTestCompositorScaling)
{
registerMockedHttpURLLoad("get_scale_for_auto_zoom_into_div_test.html");
@@ -569,47 +542,6 @@
scale = webViewImpl->pageScaleFactor();
}
-TEST_F(WebFrameTest, DivAutoZoomMultipleDivsTestWebKitScaling)
-{
- registerMockedHttpURLLoad("get_multiple_divs_for_auto_zoom_test.html");
-
- int viewportWidth = 640;
- int viewportHeight = 480;
- float doubleTapZoomAlreadyLegibleRatio = 1.2f;
- WebKit::WebView* webView = FrameTestHelpers::createWebViewAndLoad(m_baseURL + "get_multiple_divs_for_auto_zoom_test.html");
- webView->settings()->setApplyDeviceScaleFactorInCompositor(false);
- webView->settings()->setApplyPageScaleFactorInCompositor(false);
- webView->enableFixedLayoutMode(true);
- webView->resize(WebSize(viewportWidth, viewportHeight));
- webView->setPageScaleFactorLimits(1, 4);
- webView->layout();
- webView->setDeviceScaleFactor(1.5f);
-
- WebViewImpl* webViewImpl = static_cast<WebViewImpl*>(webView);
- webViewImpl->shouldUseAnimateDoubleTapTimeZeroForTesting(true);
-
- WebRect topDiv(200, 100, 200, 150);
- WebRect bottomDiv(200, 300, 200, 150);
- WebPoint topPoint(topDiv.x + 50, topDiv.y + 50);
- WebPoint bottomPoint(bottomDiv.x + 50, bottomDiv.y + 50);
- float scale;
- setScaleAndScrollAndLayout(webViewImpl, WebPoint(0, 0), (webViewImpl->minimumPageScaleFactor()) * (1 + doubleTapZoomAlreadyLegibleRatio) / 2);
-
- // Test double tap on two different divs
- // After first zoom, we should go back to minimum page scale with a second double tap.
- simulateDoubleTap(webViewImpl, topPoint, scale);
- EXPECT_FLOAT_EQ(webViewImpl->deviceScaleFactor(), scale);
- simulateDoubleTap(webViewImpl, bottomPoint, scale);
- EXPECT_FLOAT_EQ(webViewImpl->minimumPageScaleFactor(), scale);
-
- // If the user pinch zooms after double tap, a second double tap should zoom back to the div.
- simulateDoubleTap(webViewImpl, topPoint, scale);
- EXPECT_FLOAT_EQ(webViewImpl->deviceScaleFactor(), scale);
- webViewImpl->applyScrollAndScale(WebSize(), 0.6f);
- simulateDoubleTap(webViewImpl, bottomPoint, scale);
- EXPECT_FLOAT_EQ(webView->deviceScaleFactor(), scale);
-}
-
TEST_F(WebFrameTest, DivAutoZoomMultipleDivsTestCompositorScaling)
{
registerMockedHttpURLLoad("get_multiple_divs_for_auto_zoom_test.html");
@@ -653,65 +585,6 @@
EXPECT_FLOAT_EQ(1, scale);
}
-TEST_F(WebFrameTest, DivAutoZoomScaleBoundsTestWebKitScaling)
-{
- registerMockedHttpURLLoad("get_scale_bounds_check_for_auto_zoom_test.html");
-
- int viewportWidth = 640;
- int viewportHeight = 480;
- float doubleTapZoomAlreadyLegibleRatio = 1.2f;
- WebKit::WebView* webView = FrameTestHelpers::createWebViewAndLoad(m_baseURL + "get_scale_bounds_check_for_auto_zoom_test.html");
- webView->settings()->setApplyDeviceScaleFactorInCompositor(false);
- webView->settings()->setApplyPageScaleFactorInCompositor(false);
- webView->enableFixedLayoutMode(true);
- webView->resize(WebSize(viewportWidth, viewportHeight));
- webView->setPageScaleFactorLimits(1, 4);
- webView->layout();
-
- WebViewImpl* webViewImpl = static_cast<WebViewImpl*>(webView);
- webViewImpl->shouldUseAnimateDoubleTapTimeZeroForTesting(true);
- float doubleTapZoomAlreadyLegibleScale = webViewImpl->minimumPageScaleFactor() * doubleTapZoomAlreadyLegibleRatio;
-
- WebRect div(200, 100, 200, 150);
- WebPoint doubleTapPoint(div.x + 50, div.y + 50);
- float scale;
-
- // Test double tap scale bounds.
- // minimumPageScale < doubleTapZoomAlreadyLegibleScale < deviceDpiScale
- webViewImpl->setDeviceScaleFactor(1.5f);
- setScaleAndScrollAndLayout(webViewImpl, WebPoint(0, 0), (webViewImpl->minimumPageScaleFactor()) * (1 + doubleTapZoomAlreadyLegibleRatio) / 2);
- simulateDoubleTap(webViewImpl, doubleTapPoint, scale);
- EXPECT_FLOAT_EQ(webViewImpl->deviceScaleFactor(), scale);
- simulateDoubleTap(webViewImpl, doubleTapPoint, scale);
- EXPECT_FLOAT_EQ(webViewImpl->minimumPageScaleFactor(), scale);
- simulateDoubleTap(webViewImpl, doubleTapPoint, scale);
- EXPECT_FLOAT_EQ(webViewImpl->deviceScaleFactor(), scale);
-
- // Zoom in to reset double_tap_zoom_in_effect flag.
- webViewImpl->applyScrollAndScale(WebSize(), 1.1f);
- // deviceDpiScale < minimumPageScale < doubleTapZoomAlreadyLegibleScale
- webViewImpl->setDeviceScaleFactor(0.5f);
- setScaleAndScrollAndLayout(webViewImpl, WebPoint(0, 0), (webViewImpl->minimumPageScaleFactor()) * (1 + doubleTapZoomAlreadyLegibleRatio) / 2);
- simulateDoubleTap(webViewImpl, doubleTapPoint, scale);
- EXPECT_FLOAT_EQ(webViewImpl->minimumPageScaleFactor(), scale);
- simulateDoubleTap(webViewImpl, doubleTapPoint, scale);
- EXPECT_FLOAT_EQ(doubleTapZoomAlreadyLegibleScale, scale);
- simulateDoubleTap(webViewImpl, doubleTapPoint, scale);
- EXPECT_FLOAT_EQ(webViewImpl->minimumPageScaleFactor(), scale);
-
- // Zoom in to reset double_tap_zoom_in_effect flag.
- webViewImpl->applyScrollAndScale(WebSize(), 1.1f);
- // minimumPageScale < deviceDpiScale < doubleTapZoomAlreadyLegibleScale
- webViewImpl->setDeviceScaleFactor(1.1f);
- setScaleAndScrollAndLayout(webViewImpl, WebPoint(0, 0), (webViewImpl->minimumPageScaleFactor()) * (1 + doubleTapZoomAlreadyLegibleRatio) / 2);
- simulateDoubleTap(webViewImpl, doubleTapPoint, scale);
- EXPECT_FLOAT_EQ(webViewImpl->minimumPageScaleFactor(), scale);
- simulateDoubleTap(webViewImpl, doubleTapPoint, scale);
- EXPECT_FLOAT_EQ(doubleTapZoomAlreadyLegibleScale, scale);
- simulateDoubleTap(webViewImpl, doubleTapPoint, scale);
- EXPECT_FLOAT_EQ(webViewImpl->minimumPageScaleFactor(), scale);
-}
-
TEST_F(WebFrameTest, DivAutoZoomScaleBoundsTestCompositorScaling)
{
registerMockedHttpURLLoad("get_scale_bounds_check_for_auto_zoom_test.html");
@@ -774,83 +647,6 @@
}
#if ENABLE(TEXT_AUTOSIZING)
-TEST_F(WebFrameTest, DivAutoZoomScaleFontScaleFactorTestWebKitScaling)
-{
- registerMockedHttpURLLoad("get_scale_bounds_check_for_auto_zoom_test.html");
-
- int viewportWidth = 640;
- int viewportHeight = 480;
- float doubleTapZoomAlreadyLegibleRatio = 1.2f;
- float textAutosizingFontScaleFactor = 1.13f;
- WebKit::WebView* webView = FrameTestHelpers::createWebViewAndLoad(m_baseURL + "get_scale_bounds_check_for_auto_zoom_test.html");
- webView->settings()->setApplyDeviceScaleFactorInCompositor(false);
- webView->settings()->setApplyPageScaleFactorInCompositor(false);
- webView->enableFixedLayoutMode(true);
- webView->resize(WebSize(viewportWidth, viewportHeight));
- webView->setPageScaleFactorLimits(1, 4);
- webView->layout();
-
- WebViewImpl* webViewImpl = static_cast<WebViewImpl*>(webView);
- webViewImpl->shouldUseAnimateDoubleTapTimeZeroForTesting(true);
- webViewImpl->page()->settings()->setTextAutosizingFontScaleFactor(textAutosizingFontScaleFactor);
- float doubleTapZoomAlreadyLegibleScale = webViewImpl->minimumPageScaleFactor() * doubleTapZoomAlreadyLegibleRatio;
-
- WebRect div(200, 100, 200, 150);
- WebPoint doubleTapPoint(div.x + 50, div.y + 50);
- float scale;
-
- // Test double tap scale bounds.
- // minimumPageScale < doubleTapZoomAlreadyLegibleScale < deviceDpiScale < deviceDpiScale * textAutosizingFontScaleFactor
- webViewImpl->setDeviceScaleFactor(1.5f);
- float legibleScale = webViewImpl->deviceScaleFactor() * textAutosizingFontScaleFactor;
- setScaleAndScrollAndLayout(webViewImpl, WebPoint(0, 0), (webViewImpl->minimumPageScaleFactor()) * (1 + doubleTapZoomAlreadyLegibleRatio) / 2);
- simulateDoubleTap(webViewImpl, doubleTapPoint, scale);
- EXPECT_FLOAT_EQ(legibleScale, scale);
- simulateDoubleTap(webViewImpl, doubleTapPoint, scale);
- EXPECT_FLOAT_EQ(webViewImpl->minimumPageScaleFactor(), scale);
- simulateDoubleTap(webViewImpl, doubleTapPoint, scale);
- EXPECT_FLOAT_EQ(legibleScale, scale);
-
- // Zoom in to reset double_tap_zoom_in_effect flag.
- webViewImpl->applyScrollAndScale(WebSize(), 1.1f);
- // deviceDpiScale < deviceDpiScale * textAutosizingFontScaleFactor < minimumPageScale < doubleTapZoomAlreadyLegibleScale
- webViewImpl->setDeviceScaleFactor(0.5f);
- legibleScale = webViewImpl->deviceScaleFactor() * textAutosizingFontScaleFactor;
- setScaleAndScrollAndLayout(webViewImpl, WebPoint(0, 0), (webViewImpl->minimumPageScaleFactor()) * (1 + doubleTapZoomAlreadyLegibleRatio) / 2);
- simulateDoubleTap(webViewImpl, doubleTapPoint, scale);
- EXPECT_FLOAT_EQ(webViewImpl->minimumPageScaleFactor(), scale);
- simulateDoubleTap(webViewImpl, doubleTapPoint, scale);
- EXPECT_FLOAT_EQ(doubleTapZoomAlreadyLegibleScale, scale);
- simulateDoubleTap(webViewImpl, doubleTapPoint, scale);
- EXPECT_FLOAT_EQ(webViewImpl->minimumPageScaleFactor(), scale);
-
- // Zoom in to reset double_tap_zoom_in_effect flag.
- webViewImpl->applyScrollAndScale(WebSize(), 1.1f);
- // minimumPageScale < deviceDpiScale < deviceDpiScale * textAutosizingFontScaleFactor < doubleTapZoomAlreadyLegibleScale
- webViewImpl->setDeviceScaleFactor(1.05f);
- legibleScale = webViewImpl->deviceScaleFactor() * textAutosizingFontScaleFactor;
- setScaleAndScrollAndLayout(webViewImpl, WebPoint(0, 0), (webViewImpl->minimumPageScaleFactor()) * (1 + doubleTapZoomAlreadyLegibleRatio) / 2);
- simulateDoubleTap(webViewImpl, doubleTapPoint, scale);
- EXPECT_FLOAT_EQ(webViewImpl->minimumPageScaleFactor(), scale);
- simulateDoubleTap(webViewImpl, doubleTapPoint, scale);
- EXPECT_FLOAT_EQ(doubleTapZoomAlreadyLegibleScale, scale);
- simulateDoubleTap(webViewImpl, doubleTapPoint, scale);
- EXPECT_FLOAT_EQ(webViewImpl->minimumPageScaleFactor(), scale);
-
- // Zoom in to reset double_tap_zoom_in_effect flag.
- webViewImpl->applyScrollAndScale(WebSize(), 1.1f);
- // minimumPageScale < deviceDpiScale < doubleTapZoomAlreadyLegibleScale < deviceDpiScale * textAutosizingFontScaleFactor
- webViewImpl->setDeviceScaleFactor(1.1f);
- legibleScale = webViewImpl->deviceScaleFactor() * textAutosizingFontScaleFactor;
- setScaleAndScrollAndLayout(webViewImpl, WebPoint(0, 0), (webViewImpl->minimumPageScaleFactor()) * (1 + doubleTapZoomAlreadyLegibleRatio) / 2);
- simulateDoubleTap(webViewImpl, doubleTapPoint, scale);
- EXPECT_FLOAT_EQ(legibleScale, scale);
- simulateDoubleTap(webViewImpl, doubleTapPoint, scale);
- EXPECT_FLOAT_EQ(webViewImpl->minimumPageScaleFactor(), scale);
- simulateDoubleTap(webViewImpl, doubleTapPoint, scale);
- EXPECT_FLOAT_EQ(legibleScale, scale);
-}
-
TEST_F(WebFrameTest, DivAutoZoomScaleFontScaleFactorTestCompositorScaling)
{
registerMockedHttpURLLoad("get_scale_bounds_check_for_auto_zoom_test.html");