Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright (C) 2010 Google Inc. All rights reserved. | 2 * Copyright (C) 2010 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 85 using namespace WebKit; | 85 using namespace WebKit; |
| 86 using WebCore::Document; | 86 using WebCore::Document; |
| 87 using WebCore::DocumentMarker; | 87 using WebCore::DocumentMarker; |
| 88 using WebCore::Element; | 88 using WebCore::Element; |
| 89 using WebCore::FloatRect; | 89 using WebCore::FloatRect; |
| 90 using WebCore::HitTestRequest; | 90 using WebCore::HitTestRequest; |
| 91 using WebCore::Range; | 91 using WebCore::Range; |
| 92 using WebKit::URLTestHelpers::toKURL; | 92 using WebKit::URLTestHelpers::toKURL; |
| 93 using WebKit::FrameTestHelpers::runPendingTasks; | 93 using WebKit::FrameTestHelpers::runPendingTasks; |
| 94 | 94 |
| 95 static const int touchPointPadding = 32; | |
|
jochen (gone - plz use gerrit)
2013/07/30 06:41:11
nit you can just move this into the anonymous name
| |
| 96 | |
| 95 namespace { | 97 namespace { |
| 96 | 98 |
| 97 #define EXPECT_EQ_RECT(a, b) \ | 99 #define EXPECT_EQ_RECT(a, b) \ |
| 98 EXPECT_EQ(a.x(), b.x()); \ | 100 EXPECT_EQ(a.x(), b.x()); \ |
| 99 EXPECT_EQ(a.y(), b.y()); \ | 101 EXPECT_EQ(a.y(), b.y()); \ |
| 100 EXPECT_EQ(a.width(), b.width()); \ | 102 EXPECT_EQ(a.width(), b.width()); \ |
| 101 EXPECT_EQ(a.height(), b.height()); | 103 EXPECT_EQ(a.height(), b.height()); |
| 102 | 104 |
| 103 class FakeWebFrameClient : public WebFrameClient { | 105 class FakeWebFrameClient : public WebFrameClient { |
| 104 // To make the destructor public. | 106 // To make the destructor public. |
| (...skipping 1056 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1161 m_webView = FrameTestHelpers::createWebViewAndLoad(m_baseURL + "get_scale_fo r_auto_zoom_into_div_test.html"); // | 1163 m_webView = FrameTestHelpers::createWebViewAndLoad(m_baseURL + "get_scale_fo r_auto_zoom_into_div_test.html"); // |
| 1162 m_webView->setDeviceScaleFactor(deviceScaleFactor); | 1164 m_webView->setDeviceScaleFactor(deviceScaleFactor); |
| 1163 m_webView->setPageScaleFactorLimits(0.01f, 4); | 1165 m_webView->setPageScaleFactorLimits(0.01f, 4); |
| 1164 m_webView->setPageScaleFactor(0.5f, WebPoint(0, 0)); | 1166 m_webView->setPageScaleFactor(0.5f, WebPoint(0, 0)); |
| 1165 m_webView->resize(WebSize(viewportWidth, viewportHeight)); | 1167 m_webView->resize(WebSize(viewportWidth, viewportHeight)); |
| 1166 m_webView->enableFixedLayoutMode(true); | 1168 m_webView->enableFixedLayoutMode(true); |
| 1167 m_webView->layout(); | 1169 m_webView->layout(); |
| 1168 | 1170 |
| 1169 WebRect wideDiv(200, 100, 400, 150); | 1171 WebRect wideDiv(200, 100, 400, 150); |
| 1170 WebRect tallDiv(200, 300, 400, 800); | 1172 WebRect tallDiv(200, 300, 400, 800); |
| 1171 WebRect doubleTapPointWide(wideDiv.x + 50, wideDiv.y + 50, 0, 0); | 1173 WebRect doubleTapPointWide( |
| 1172 WebRect doubleTapPointTall(tallDiv.x + 50, tallDiv.y + 50, 0, 0); | 1174 wideDiv.x + 50, wideDiv.y + 50, touchPointPadding, touchPointPadding); |
| 1175 WebRect doubleTapPointTall( | |
| 1176 tallDiv.x + 50, tallDiv.y + 50, touchPointPadding, touchPointPadding); | |
| 1177 WebRect wideBlockBounds; | |
| 1178 WebRect tallBlockBounds; | |
| 1173 float scale; | 1179 float scale; |
| 1174 WebPoint scroll; | 1180 WebPoint scroll; |
| 1175 bool isAnchor; | 1181 bool doubleTapShouldZoomOut; |
| 1176 | 1182 |
| 1177 WebViewImpl* webViewImpl = static_cast<WebViewImpl*>(m_webView); | 1183 WebViewImpl* webViewImpl = static_cast<WebViewImpl*>(m_webView); |
| 1178 // Test double-tap zooming into wide div. | 1184 // Test double-tap zooming into wide div. |
| 1179 webViewImpl->computeScaleAndScrollForHitRect(doubleTapPointWide, WebViewImpl ::DoubleTap, scale, scroll, isAnchor); | 1185 wideBlockBounds = |
| 1186 webViewImpl->computeBlockBounds(doubleTapPointWide, false); | |
| 1187 webViewImpl->computeScaleAndScrollForBlockRect( | |
| 1188 wideBlockBounds, touchPointPadding, scale, scroll, | |
| 1189 doubleTapShouldZoomOut); | |
| 1180 // The div should horizontally fill the screen (modulo margins), and | 1190 // The div should horizontally fill the screen (modulo margins), and |
| 1181 // vertically centered (modulo integer rounding). | 1191 // vertically centered (modulo integer rounding). |
| 1182 EXPECT_NEAR(viewportWidth / (float) wideDiv.width, scale, 0.1); | 1192 EXPECT_NEAR(viewportWidth / (float) wideDiv.width, scale, 0.1); |
| 1183 EXPECT_NEAR(wideDiv.x, scroll.x, 20); | 1193 EXPECT_NEAR(wideDiv.x, scroll.x, 20); |
| 1184 EXPECT_EQ(0, scroll.y); | 1194 EXPECT_EQ(0, scroll.y); |
| 1185 EXPECT_FALSE(isAnchor); | 1195 EXPECT_FALSE(doubleTapShouldZoomOut); |
| 1186 | 1196 |
| 1187 setScaleAndScrollAndLayout(webViewImpl, scroll, scale); | 1197 setScaleAndScrollAndLayout(webViewImpl, scroll, scale); |
| 1188 | 1198 |
| 1189 // Test zoom out back to minimum scale. | 1199 // Test zoom out back to minimum scale. |
| 1190 webViewImpl->computeScaleAndScrollForHitRect(doubleTapPointWide, WebViewImpl ::DoubleTap, scale, scroll, isAnchor); | 1200 wideBlockBounds = |
| 1191 EXPECT_FLOAT_EQ(webViewImpl->minimumPageScaleFactor(), scale); | 1201 webViewImpl->computeBlockBounds(doubleTapPointWide, false); |
| 1192 EXPECT_TRUE(isAnchor); | 1202 webViewImpl->computeScaleAndScrollForBlockRect( |
| 1203 wideBlockBounds, touchPointPadding, scale, scroll, | |
| 1204 doubleTapShouldZoomOut); | |
| 1205 EXPECT_TRUE(doubleTapShouldZoomOut); | |
| 1193 | 1206 |
| 1207 scale = webViewImpl->minimumPageScaleFactor(); | |
| 1194 setScaleAndScrollAndLayout(webViewImpl, WebPoint(0, 0), scale); | 1208 setScaleAndScrollAndLayout(webViewImpl, WebPoint(0, 0), scale); |
| 1195 | 1209 |
| 1196 // Test double-tap zooming into tall div. | 1210 // Test double-tap zooming into tall div. |
| 1197 webViewImpl->computeScaleAndScrollForHitRect(doubleTapPointTall, WebViewImpl ::DoubleTap, scale, scroll, isAnchor); | 1211 tallBlockBounds = |
| 1212 webViewImpl->computeBlockBounds(doubleTapPointTall, false); | |
| 1213 webViewImpl->computeScaleAndScrollForBlockRect( | |
| 1214 tallBlockBounds, touchPointPadding, scale, scroll, | |
| 1215 doubleTapShouldZoomOut); | |
| 1198 // The div should start at the top left of the viewport. | 1216 // The div should start at the top left of the viewport. |
| 1199 EXPECT_NEAR(viewportWidth / (float) tallDiv.width, scale, 0.1); | 1217 EXPECT_NEAR(viewportWidth / (float) tallDiv.width, scale, 0.1); |
| 1200 EXPECT_NEAR(tallDiv.x, scroll.x, 20); | 1218 EXPECT_NEAR(tallDiv.x, scroll.x, 20); |
| 1201 EXPECT_NEAR(tallDiv.y, scroll.y, 20); | 1219 EXPECT_NEAR(tallDiv.y, scroll.y, 20); |
| 1202 EXPECT_FALSE(isAnchor); | 1220 EXPECT_FALSE(doubleTapShouldZoomOut); |
| 1203 | 1221 |
| 1204 // Test for Non-doubletap scaling | 1222 // Test for Non-doubletap scaling |
| 1205 // Test zooming into div. | 1223 // Test zooming into div. |
| 1206 webViewImpl->computeScaleAndScrollForHitRect(WebRect(250, 250, 10, 10), WebV iewImpl::FindInPage, scale, scroll, isAnchor); | 1224 webViewImpl->computeScaleAndScrollForBlockRect( |
| 1225 webViewImpl->computeBlockBounds(WebRect(250, 250, 10, 10), true), | |
| 1226 0, scale, scroll, doubleTapShouldZoomOut); | |
| 1207 EXPECT_NEAR(viewportWidth / (float) wideDiv.width, scale, 0.1); | 1227 EXPECT_NEAR(viewportWidth / (float) wideDiv.width, scale, 0.1); |
| 1208 } | 1228 } |
| 1209 | 1229 |
| 1230 void simulatePageScale(WebViewImpl* webViewImpl, float& scale) | |
| 1231 { | |
| 1232 WebCore::IntSize scrollDelta = | |
| 1233 webViewImpl->fakePageScaleAnimationTargetPositionForTesting() | |
| 1234 - webViewImpl->mainFrameImpl()->frameView()->scrollPosition(); | |
| 1235 float scaleDelta = | |
| 1236 webViewImpl->fakePageScaleAnimationPageScaleForTesting() | |
| 1237 / webViewImpl->pageScaleFactor(); | |
| 1238 webViewImpl->applyScrollAndScale(scrollDelta, scaleDelta); | |
| 1239 scale = webViewImpl->pageScaleFactor(); | |
| 1240 } | |
| 1241 | |
| 1242 void simulateMultiTargetZoom( | |
| 1243 WebViewImpl* webViewImpl, | |
|
jochen (gone - plz use gerrit)
2013/07/30 06:41:11
put all parameters in one line (no character limit
| |
| 1244 const WebRect& rect, | |
| 1245 float& scale) | |
| 1246 { | |
| 1247 if (webViewImpl->zoomToMultipleTargetsRect(rect)) | |
| 1248 simulatePageScale(webViewImpl, scale); | |
| 1249 } | |
| 1250 | |
| 1210 void simulateDoubleTap(WebViewImpl* webViewImpl, WebPoint& point, float& scale) | 1251 void simulateDoubleTap(WebViewImpl* webViewImpl, WebPoint& point, float& scale) |
| 1211 { | 1252 { |
| 1212 webViewImpl->animateZoomAroundPoint(point, WebViewImpl::DoubleTap); | 1253 webViewImpl->animateDoubleTapZoom(point); |
| 1213 EXPECT_TRUE(webViewImpl->fakeDoubleTapAnimationPendingForTesting()); | 1254 EXPECT_TRUE(webViewImpl->fakeDoubleTapAnimationPendingForTesting()); |
| 1214 WebCore::IntSize scrollDelta = webViewImpl->fakeDoubleTapTargetPositionForTe sting() - webViewImpl->mainFrameImpl()->frameView()->scrollPosition(); | 1255 simulatePageScale(webViewImpl, scale); |
| 1215 float scaleDelta = webViewImpl->fakeDoubleTapPageScaleFactorForTesting() / w ebViewImpl->pageScaleFactor(); | |
| 1216 webViewImpl->applyScrollAndScale(scrollDelta, scaleDelta); | |
| 1217 scale = webViewImpl->pageScaleFactor(); | |
| 1218 } | 1256 } |
| 1219 | 1257 |
| 1220 TEST_F(WebFrameTest, DivAutoZoomMultipleDivsTest) | 1258 TEST_F(WebFrameTest, DivAutoZoomMultipleDivsTest) |
| 1221 { | 1259 { |
| 1222 registerMockedHttpURLLoad("get_multiple_divs_for_auto_zoom_test.html"); | 1260 registerMockedHttpURLLoad("get_multiple_divs_for_auto_zoom_test.html"); |
| 1223 | 1261 |
| 1224 const float deviceScaleFactor = 2.0f; | 1262 const float deviceScaleFactor = 2.0f; |
| 1225 int viewportWidth = 640 / deviceScaleFactor; | 1263 int viewportWidth = 640 / deviceScaleFactor; |
| 1226 int viewportHeight = 1280 / deviceScaleFactor; | 1264 int viewportHeight = 1280 / deviceScaleFactor; |
| 1227 float doubleTapZoomAlreadyLegibleRatio = 1.2f; | 1265 float doubleTapZoomAlreadyLegibleRatio = 1.2f; |
| 1228 m_webView = FrameTestHelpers::createWebViewAndLoad(m_baseURL + "get_multiple _divs_for_auto_zoom_test.html"); | 1266 m_webView = FrameTestHelpers::createWebViewAndLoad(m_baseURL + "get_multiple _divs_for_auto_zoom_test.html"); |
| 1229 m_webView->enableFixedLayoutMode(true); | 1267 m_webView->enableFixedLayoutMode(true); |
| 1230 m_webView->resize(WebSize(viewportWidth, viewportHeight)); | 1268 m_webView->resize(WebSize(viewportWidth, viewportHeight)); |
| 1231 m_webView->setPageScaleFactorLimits(0.5f, 4); | 1269 m_webView->setPageScaleFactorLimits(0.5f, 4); |
| 1232 m_webView->setDeviceScaleFactor(deviceScaleFactor); | 1270 m_webView->setDeviceScaleFactor(deviceScaleFactor); |
| 1233 m_webView->setPageScaleFactor(0.5f, WebPoint(0, 0)); | 1271 m_webView->setPageScaleFactor(0.5f, WebPoint(0, 0)); |
| 1234 m_webView->layout(); | 1272 m_webView->layout(); |
| 1235 | 1273 |
| 1236 WebViewImpl* webViewImpl = static_cast<WebViewImpl*>(m_webView); | 1274 WebViewImpl* webViewImpl = static_cast<WebViewImpl*>(m_webView); |
| 1237 webViewImpl->enableFakeDoubleTapAnimationForTesting(true); | 1275 webViewImpl->enableFakePageScaleAnimationForTesting(true); |
| 1238 | 1276 |
| 1239 WebRect topDiv(200, 100, 200, 150); | 1277 WebRect topDiv(200, 100, 200, 150); |
| 1240 WebRect bottomDiv(200, 300, 200, 150); | 1278 WebRect bottomDiv(200, 300, 200, 150); |
| 1241 WebPoint topPoint(topDiv.x + 50, topDiv.y + 50); | 1279 WebPoint topPoint(topDiv.x + 50, topDiv.y + 50); |
| 1242 WebPoint bottomPoint(bottomDiv.x + 50, bottomDiv.y + 50); | 1280 WebPoint bottomPoint(bottomDiv.x + 50, bottomDiv.y + 50); |
| 1243 float scale; | 1281 float scale; |
| 1244 setScaleAndScrollAndLayout(webViewImpl, WebPoint(0, 0), (webViewImpl->minimu mPageScaleFactor()) * (1 + doubleTapZoomAlreadyLegibleRatio) / 2); | 1282 setScaleAndScrollAndLayout(webViewImpl, WebPoint(0, 0), (webViewImpl->minimu mPageScaleFactor()) * (1 + doubleTapZoomAlreadyLegibleRatio) / 2); |
| 1245 | 1283 |
| 1246 // Test double tap on two different divs | 1284 // Test double tap on two different divs |
| 1247 // After first zoom, we should go back to minimum page scale with a second d ouble tap. | 1285 // After first zoom, we should go back to minimum page scale with a second d ouble tap. |
| 1248 simulateDoubleTap(webViewImpl, topPoint, scale); | 1286 simulateDoubleTap(webViewImpl, topPoint, scale); |
| 1249 EXPECT_FLOAT_EQ(1, scale); | 1287 EXPECT_FLOAT_EQ(1, scale); |
| 1250 simulateDoubleTap(webViewImpl, bottomPoint, scale); | 1288 simulateDoubleTap(webViewImpl, bottomPoint, scale); |
| 1251 EXPECT_FLOAT_EQ(webViewImpl->minimumPageScaleFactor(), scale); | 1289 EXPECT_FLOAT_EQ(webViewImpl->minimumPageScaleFactor(), scale); |
| 1252 | 1290 |
| 1253 // If the user pinch zooms after double tap, a second double tap should zoom back to the div. | 1291 // If the user pinch zooms after double tap, a second double tap should zoom back to the div. |
| 1254 simulateDoubleTap(webViewImpl, topPoint, scale); | 1292 simulateDoubleTap(webViewImpl, topPoint, scale); |
| 1255 EXPECT_FLOAT_EQ(1, scale); | 1293 EXPECT_FLOAT_EQ(1, scale); |
| 1256 webViewImpl->applyScrollAndScale(WebSize(), 0.6f); | 1294 webViewImpl->applyScrollAndScale(WebSize(), 0.6f); |
| 1257 simulateDoubleTap(webViewImpl, bottomPoint, scale); | 1295 simulateDoubleTap(webViewImpl, bottomPoint, scale); |
| 1258 EXPECT_FLOAT_EQ(1, scale); | 1296 EXPECT_FLOAT_EQ(1, scale); |
| 1259 simulateDoubleTap(webViewImpl, bottomPoint, scale); | 1297 simulateDoubleTap(webViewImpl, bottomPoint, scale); |
| 1260 EXPECT_FLOAT_EQ(webViewImpl->minimumPageScaleFactor(), scale); | 1298 EXPECT_FLOAT_EQ(webViewImpl->minimumPageScaleFactor(), scale); |
| 1261 | 1299 |
| 1262 // If we didn't yet get an auto-zoom update and a second double-tap arrives, should go back to minimum scale. | 1300 // If we didn't yet get an auto-zoom update and a second double-tap arrives, should go back to minimum scale. |
| 1263 webViewImpl->applyScrollAndScale(WebSize(), 1.1f); | 1301 webViewImpl->applyScrollAndScale(WebSize(), 1.1f); |
| 1264 webViewImpl->animateZoomAroundPoint(topPoint, WebViewImpl::DoubleTap); | 1302 webViewImpl->animateDoubleTapZoom(topPoint); |
| 1265 EXPECT_TRUE(webViewImpl->fakeDoubleTapAnimationPendingForTesting()); | 1303 EXPECT_TRUE(webViewImpl->fakeDoubleTapAnimationPendingForTesting()); |
| 1266 simulateDoubleTap(webViewImpl, bottomPoint, scale); | 1304 simulateDoubleTap(webViewImpl, bottomPoint, scale); |
| 1267 EXPECT_FLOAT_EQ(webViewImpl->minimumPageScaleFactor(), scale); | 1305 EXPECT_FLOAT_EQ(webViewImpl->minimumPageScaleFactor(), scale); |
| 1268 } | 1306 } |
| 1269 | 1307 |
| 1270 TEST_F(WebFrameTest, DivAutoZoomScaleBoundsTest) | 1308 TEST_F(WebFrameTest, DivAutoZoomScaleBoundsTest) |
| 1271 { | 1309 { |
| 1272 registerMockedHttpURLLoad("get_scale_bounds_check_for_auto_zoom_test.html"); | 1310 registerMockedHttpURLLoad("get_scale_bounds_check_for_auto_zoom_test.html"); |
| 1273 | 1311 |
| 1274 int viewportWidth = 320; | 1312 int viewportWidth = 320; |
| 1275 int viewportHeight = 480; | 1313 int viewportHeight = 480; |
| 1276 float doubleTapZoomAlreadyLegibleRatio = 1.2f; | 1314 float doubleTapZoomAlreadyLegibleRatio = 1.2f; |
| 1277 m_webView = FrameTestHelpers::createWebViewAndLoad(m_baseURL + "get_scale_bo unds_check_for_auto_zoom_test.html"); | 1315 m_webView = FrameTestHelpers::createWebViewAndLoad(m_baseURL + "get_scale_bo unds_check_for_auto_zoom_test.html"); |
| 1278 m_webView->enableFixedLayoutMode(true); | 1316 m_webView->enableFixedLayoutMode(true); |
| 1279 m_webView->resize(WebSize(viewportWidth, viewportHeight)); | 1317 m_webView->resize(WebSize(viewportWidth, viewportHeight)); |
| 1280 m_webView->setDeviceScaleFactor(1.5f); | 1318 m_webView->setDeviceScaleFactor(1.5f); |
| 1281 m_webView->layout(); | 1319 m_webView->layout(); |
| 1282 | 1320 |
| 1283 WebViewImpl* webViewImpl = static_cast<WebViewImpl*>(m_webView); | 1321 WebViewImpl* webViewImpl = static_cast<WebViewImpl*>(m_webView); |
| 1284 webViewImpl->enableFakeDoubleTapAnimationForTesting(true); | 1322 webViewImpl->enableFakePageScaleAnimationForTesting(true); |
| 1285 | 1323 |
| 1286 WebRect div(200, 100, 200, 150); | 1324 WebRect div(200, 100, 200, 150); |
| 1287 WebPoint doubleTapPoint(div.x + 50, div.y + 50); | 1325 WebPoint doubleTapPoint(div.x + 50, div.y + 50); |
| 1288 float scale; | 1326 float scale; |
| 1289 | 1327 |
| 1290 // Test double tap scale bounds. | 1328 // Test double tap scale bounds. |
| 1291 // minimumPageScale < doubleTapZoomAlreadyLegibleScale < 1 | 1329 // minimumPageScale < doubleTapZoomAlreadyLegibleScale < 1 |
| 1292 m_webView->setPageScaleFactorLimits(0.5f, 4); | 1330 m_webView->setPageScaleFactorLimits(0.5f, 4); |
| 1293 m_webView->layout(); | 1331 m_webView->layout(); |
| 1294 float doubleTapZoomAlreadyLegibleScale = webViewImpl->minimumPageScaleFactor () * doubleTapZoomAlreadyLegibleRatio; | 1332 float doubleTapZoomAlreadyLegibleScale = webViewImpl->minimumPageScaleFactor () * doubleTapZoomAlreadyLegibleRatio; |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1336 int viewportWidth = 320; | 1374 int viewportWidth = 320; |
| 1337 int viewportHeight = 480; | 1375 int viewportHeight = 480; |
| 1338 float doubleTapZoomAlreadyLegibleRatio = 1.2f; | 1376 float doubleTapZoomAlreadyLegibleRatio = 1.2f; |
| 1339 float textAutosizingFontScaleFactor = 1.13f; | 1377 float textAutosizingFontScaleFactor = 1.13f; |
| 1340 m_webView = FrameTestHelpers::createWebViewAndLoad(m_baseURL + "get_scale_bo unds_check_for_auto_zoom_test.html"); | 1378 m_webView = FrameTestHelpers::createWebViewAndLoad(m_baseURL + "get_scale_bo unds_check_for_auto_zoom_test.html"); |
| 1341 m_webView->enableFixedLayoutMode(true); | 1379 m_webView->enableFixedLayoutMode(true); |
| 1342 m_webView->resize(WebSize(viewportWidth, viewportHeight)); | 1380 m_webView->resize(WebSize(viewportWidth, viewportHeight)); |
| 1343 m_webView->layout(); | 1381 m_webView->layout(); |
| 1344 | 1382 |
| 1345 WebViewImpl* webViewImpl = static_cast<WebViewImpl*>(m_webView); | 1383 WebViewImpl* webViewImpl = static_cast<WebViewImpl*>(m_webView); |
| 1346 webViewImpl->enableFakeDoubleTapAnimationForTesting(true); | 1384 webViewImpl->enableFakePageScaleAnimationForTesting(true); |
| 1347 webViewImpl->page()->settings()->setTextAutosizingFontScaleFactor(textAutosi zingFontScaleFactor); | 1385 webViewImpl->page()->settings()->setTextAutosizingFontScaleFactor(textAutosi zingFontScaleFactor); |
| 1348 | 1386 |
| 1349 WebRect div(200, 100, 200, 150); | 1387 WebRect div(200, 100, 200, 150); |
| 1350 WebPoint doubleTapPoint(div.x + 50, div.y + 50); | 1388 WebPoint doubleTapPoint(div.x + 50, div.y + 50); |
| 1351 float scale; | 1389 float scale; |
| 1352 | 1390 |
| 1353 // Test double tap scale bounds. | 1391 // Test double tap scale bounds. |
| 1354 // minimumPageScale < doubleTapZoomAlreadyLegibleScale < 1 < textAutosizingF ontScaleFactor | 1392 // minimumPageScale < doubleTapZoomAlreadyLegibleScale < 1 < textAutosizingF ontScaleFactor |
| 1355 float legibleScale = textAutosizingFontScaleFactor; | 1393 float legibleScale = textAutosizingFontScaleFactor; |
| 1356 setScaleAndScrollAndLayout(webViewImpl, WebPoint(0, 0), (webViewImpl->minimu mPageScaleFactor()) * (1 + doubleTapZoomAlreadyLegibleRatio) / 2); | 1394 setScaleAndScrollAndLayout(webViewImpl, WebPoint(0, 0), (webViewImpl->minimu mPageScaleFactor()) * (1 + doubleTapZoomAlreadyLegibleRatio) / 2); |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1400 doubleTapZoomAlreadyLegibleScale = webViewImpl->minimumPageScaleFactor() * d oubleTapZoomAlreadyLegibleRatio; | 1438 doubleTapZoomAlreadyLegibleScale = webViewImpl->minimumPageScaleFactor() * d oubleTapZoomAlreadyLegibleRatio; |
| 1401 setScaleAndScrollAndLayout(webViewImpl, WebPoint(0, 0), (webViewImpl->minimu mPageScaleFactor()) * (1 + doubleTapZoomAlreadyLegibleRatio) / 2); | 1439 setScaleAndScrollAndLayout(webViewImpl, WebPoint(0, 0), (webViewImpl->minimu mPageScaleFactor()) * (1 + doubleTapZoomAlreadyLegibleRatio) / 2); |
| 1402 simulateDoubleTap(webViewImpl, doubleTapPoint, scale); | 1440 simulateDoubleTap(webViewImpl, doubleTapPoint, scale); |
| 1403 EXPECT_FLOAT_EQ(legibleScale, scale); | 1441 EXPECT_FLOAT_EQ(legibleScale, scale); |
| 1404 simulateDoubleTap(webViewImpl, doubleTapPoint, scale); | 1442 simulateDoubleTap(webViewImpl, doubleTapPoint, scale); |
| 1405 EXPECT_FLOAT_EQ(webViewImpl->minimumPageScaleFactor(), scale); | 1443 EXPECT_FLOAT_EQ(webViewImpl->minimumPageScaleFactor(), scale); |
| 1406 simulateDoubleTap(webViewImpl, doubleTapPoint, scale); | 1444 simulateDoubleTap(webViewImpl, doubleTapPoint, scale); |
| 1407 EXPECT_FLOAT_EQ(legibleScale, scale); | 1445 EXPECT_FLOAT_EQ(legibleScale, scale); |
| 1408 } | 1446 } |
| 1409 | 1447 |
| 1448 TEST_F(WebFrameTest, DivMultipleTargetZoomMultipleDivsTest) | |
| 1449 { | |
| 1450 registerMockedHttpURLLoad("get_multiple_divs_for_auto_zoom_test.html"); | |
| 1451 | |
| 1452 const float deviceScaleFactor = 2.0f; | |
| 1453 int viewportWidth = 640 / deviceScaleFactor; | |
| 1454 int viewportHeight = 1280 / deviceScaleFactor; | |
| 1455 float doubleTapZoomAlreadyLegibleRatio = 1.2f; | |
| 1456 m_webView = FrameTestHelpers::createWebViewAndLoad( | |
| 1457 m_baseURL + "get_multiple_divs_for_auto_zoom_test.html"); | |
| 1458 m_webView->enableFixedLayoutMode(true); | |
| 1459 m_webView->resize(WebSize(viewportWidth, viewportHeight)); | |
| 1460 m_webView->setPageScaleFactorLimits(0.5f, 4); | |
| 1461 m_webView->setDeviceScaleFactor(deviceScaleFactor); | |
| 1462 m_webView->setPageScaleFactor(0.5f, WebPoint(0, 0)); | |
| 1463 m_webView->layout(); | |
| 1464 | |
| 1465 WebViewImpl* webViewImpl = static_cast<WebViewImpl*>(m_webView); | |
| 1466 webViewImpl->enableFakePageScaleAnimationForTesting(true); | |
| 1467 | |
| 1468 WebRect viewportRect(0, 0, viewportWidth, viewportHeight); | |
| 1469 WebRect topDiv(200, 100, 200, 150); | |
| 1470 WebRect bottomDiv(200, 300, 200, 150); | |
| 1471 float scale; | |
| 1472 setScaleAndScrollAndLayout(webViewImpl, WebPoint(0, 0), | |
| 1473 (webViewImpl->minimumPageScaleFactor()) | |
| 1474 * (1 + doubleTapZoomAlreadyLegibleRatio) / 2); | |
| 1475 | |
| 1476 simulateMultiTargetZoom(webViewImpl, topDiv, scale); | |
| 1477 EXPECT_FLOAT_EQ(1, scale); | |
| 1478 simulateMultiTargetZoom(webViewImpl, bottomDiv, scale); | |
| 1479 EXPECT_FLOAT_EQ(1, scale); | |
| 1480 simulateMultiTargetZoom(webViewImpl, viewportRect, scale); | |
| 1481 EXPECT_FLOAT_EQ(1, scale); | |
| 1482 webViewImpl->setPageScaleFactor( | |
| 1483 webViewImpl->minimumPageScaleFactor(), WebPoint(0, 0)); | |
| 1484 simulateMultiTargetZoom(webViewImpl, topDiv, scale); | |
| 1485 EXPECT_FLOAT_EQ(1, scale); | |
| 1486 } | |
| 1487 | |
| 1410 TEST_F(WebFrameTest, DivScrollIntoEditableTest) | 1488 TEST_F(WebFrameTest, DivScrollIntoEditableTest) |
| 1411 { | 1489 { |
| 1412 registerMockedHttpURLLoad("get_scale_for_zoom_into_editable_test.html"); | 1490 registerMockedHttpURLLoad("get_scale_for_zoom_into_editable_test.html"); |
| 1413 | 1491 |
| 1414 int viewportWidth = 450; | 1492 int viewportWidth = 450; |
| 1415 int viewportHeight = 300; | 1493 int viewportHeight = 300; |
| 1416 float leftBoxRatio = 0.3f; | 1494 float leftBoxRatio = 0.3f; |
| 1417 int caretPadding = 10; | 1495 int caretPadding = 10; |
| 1418 float minReadableCaretHeight = 18.0f; | 1496 float minReadableCaretHeight = 18.0f; |
| 1419 m_webView = FrameTestHelpers::createWebViewAndLoad(m_baseURL + "get_scale_fo r_zoom_into_editable_test.html"); | 1497 m_webView = FrameTestHelpers::createWebViewAndLoad(m_baseURL + "get_scale_fo r_zoom_into_editable_test.html"); |
| 1420 m_webView->enableFixedLayoutMode(true); | 1498 m_webView->enableFixedLayoutMode(true); |
| 1421 m_webView->resize(WebSize(viewportWidth, viewportHeight)); | 1499 m_webView->resize(WebSize(viewportWidth, viewportHeight)); |
| 1422 m_webView->setPageScaleFactorLimits(1, 4); | 1500 m_webView->setPageScaleFactorLimits(1, 4); |
| 1423 m_webView->layout(); | 1501 m_webView->layout(); |
| 1424 m_webView->setDeviceScaleFactor(1.5f); | 1502 m_webView->setDeviceScaleFactor(1.5f); |
| 1425 m_webView->settings()->setAutoZoomFocusedNodeToLegibleScale(true); | 1503 m_webView->settings()->setAutoZoomFocusedNodeToLegibleScale(true); |
| 1426 | 1504 |
| 1427 WebViewImpl* webViewImpl = static_cast<WebViewImpl*>(m_webView); | 1505 WebViewImpl* webViewImpl = static_cast<WebViewImpl*>(m_webView); |
| 1428 webViewImpl->enableFakeDoubleTapAnimationForTesting(true); | 1506 webViewImpl->enableFakePageScaleAnimationForTesting(true); |
| 1429 | 1507 |
| 1430 WebRect editBoxWithText(200, 200, 250, 20); | 1508 WebRect editBoxWithText(200, 200, 250, 20); |
| 1431 WebRect editBoxWithNoText(200, 250, 250, 20); | 1509 WebRect editBoxWithNoText(200, 250, 250, 20); |
| 1432 | 1510 |
| 1433 // Test scrolling the focused node | 1511 // Test scrolling the focused node |
| 1434 // The edit box is shorter and narrower than the viewport when legible. | 1512 // The edit box is shorter and narrower than the viewport when legible. |
| 1435 m_webView->advanceFocus(false); | 1513 m_webView->advanceFocus(false); |
| 1436 // Set the caret to the end of the input box. | 1514 // Set the caret to the end of the input box. |
| 1437 m_webView->mainFrame()->document().getElementById("EditBoxWithText").to<WebI nputElement>().setSelectionRange(1000, 1000); | 1515 m_webView->mainFrame()->document().getElementById("EditBoxWithText").to<WebI nputElement>().setSelectionRange(1000, 1000); |
| 1438 setScaleAndScrollAndLayout(m_webView, WebPoint(0, 0), 1); | 1516 setScaleAndScrollAndLayout(m_webView, WebPoint(0, 0), 1); |
| (...skipping 1969 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3408 frame->reload(); | 3486 frame->reload(); |
| 3409 Platform::current()->unitTestSupport()->serveAsynchronousMockedRequests(); | 3487 Platform::current()->unitTestSupport()->serveAsynchronousMockedRequests(); |
| 3410 EXPECT_EQ(WebURLRequest::ReloadIgnoringCacheData, frame->dataSource()->reque st().cachePolicy()); | 3488 EXPECT_EQ(WebURLRequest::ReloadIgnoringCacheData, frame->dataSource()->reque st().cachePolicy()); |
| 3411 | 3489 |
| 3412 m_webView->close(); | 3490 m_webView->close(); |
| 3413 m_webView = 0; | 3491 m_webView = 0; |
| 3414 } | 3492 } |
| 3415 | 3493 |
| 3416 | 3494 |
| 3417 } // namespace | 3495 } // namespace |
| OLD | NEW |