| 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 1299 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1310 EXPECT_EQ(0.0, compositor->containerLayer()->size().height()); | 1310 EXPECT_EQ(0.0, compositor->containerLayer()->size().height()); |
| 1311 | 1311 |
| 1312 // Two flags PinchVirtualViewportEnabled and ForceZeroLayoutHeight will caus
e the following | 1312 // Two flags PinchVirtualViewportEnabled and ForceZeroLayoutHeight will caus
e the following |
| 1313 // resize of viewport height to be ignored by the outer viewport (the contai
ner layer of | 1313 // resize of viewport height to be ignored by the outer viewport (the contai
ner layer of |
| 1314 // LayerCompositor). The height of the pinchViewport, however, is not affect
ed. | 1314 // LayerCompositor). The height of the pinchViewport, however, is not affect
ed. |
| 1315 webViewHelper.webView()->resize(WebSize(viewportWidth, viewportHeight)); | 1315 webViewHelper.webView()->resize(WebSize(viewportWidth, viewportHeight)); |
| 1316 EXPECT_FALSE(webViewHelper.webViewImpl()->mainFrameImpl()->frameView()->need
sLayout()); | 1316 EXPECT_FALSE(webViewHelper.webViewImpl()->mainFrameImpl()->frameView()->need
sLayout()); |
| 1317 EXPECT_EQ(viewportWidth, webViewHelper.webViewImpl()->mainFrameImpl()->frame
View()->layoutSize().width()); | 1317 EXPECT_EQ(viewportWidth, webViewHelper.webViewImpl()->mainFrameImpl()->frame
View()->layoutSize().width()); |
| 1318 EXPECT_EQ(0, webViewHelper.webViewImpl()->mainFrameImpl()->frameView()->layo
utSize().height()); | 1318 EXPECT_EQ(0, webViewHelper.webViewImpl()->mainFrameImpl()->frameView()->layo
utSize().height()); |
| 1319 EXPECT_EQ(viewportWidth, compositor->containerLayer()->size().width()); | 1319 EXPECT_EQ(viewportWidth, compositor->containerLayer()->size().width()); |
| 1320 EXPECT_EQ(0.0, compositor->containerLayer()->size().height()); | 1320 EXPECT_EQ(viewportHeight, compositor->containerLayer()->size().height()); |
| 1321 | 1321 |
| 1322 LocalFrame* frame = webViewHelper.webViewImpl()->mainFrameImpl()->frame(); | 1322 LocalFrame* frame = webViewHelper.webViewImpl()->mainFrameImpl()->frame(); |
| 1323 PinchViewport& pinchViewport = frame->page()->frameHost().pinchViewport(); | 1323 PinchViewport& pinchViewport = frame->page()->frameHost().pinchViewport(); |
| 1324 EXPECT_EQ(viewportHeight, pinchViewport.containerLayer()->size().height()); | 1324 EXPECT_EQ(viewportHeight, pinchViewport.containerLayer()->size().height()); |
| 1325 EXPECT_TRUE(pinchViewport.containerLayer()->platformLayer()->masksToBounds()
); | 1325 EXPECT_TRUE(pinchViewport.containerLayer()->platformLayer()->masksToBounds()
); |
| 1326 EXPECT_FALSE(compositor->containerLayer()->platformLayer()->masksToBounds())
; | 1326 EXPECT_FALSE(compositor->containerLayer()->platformLayer()->masksToBounds())
; |
| 1327 } | 1327 } |
| 1328 | 1328 |
| 1329 TEST_F(WebFrameTest, SetForceZeroLayoutHeight) | 1329 TEST_F(WebFrameTest, SetForceZeroLayoutHeight) |
| 1330 { | 1330 { |
| (...skipping 22 matching lines...) Expand all Loading... |
| 1353 EXPECT_EQ(0, webViewHelper.webViewImpl()->mainFrameImpl()->frameView()->layo
utSize().height()); | 1353 EXPECT_EQ(0, webViewHelper.webViewImpl()->mainFrameImpl()->frameView()->layo
utSize().height()); |
| 1354 | 1354 |
| 1355 webViewHelper.webView()->resize(WebSize(viewportWidth * 2, viewportHeight)); | 1355 webViewHelper.webView()->resize(WebSize(viewportWidth * 2, viewportHeight)); |
| 1356 webViewHelper.webView()->layout(); | 1356 webViewHelper.webView()->layout(); |
| 1357 EXPECT_EQ(0, webViewHelper.webViewImpl()->mainFrameImpl()->frameView()->layo
utSize().height()); | 1357 EXPECT_EQ(0, webViewHelper.webViewImpl()->mainFrameImpl()->frameView()->layo
utSize().height()); |
| 1358 | 1358 |
| 1359 webViewHelper.webView()->settings()->setForceZeroLayoutHeight(false); | 1359 webViewHelper.webView()->settings()->setForceZeroLayoutHeight(false); |
| 1360 EXPECT_LE(viewportHeight, webViewHelper.webViewImpl()->mainFrameImpl()->fram
eView()->layoutSize().height()); | 1360 EXPECT_LE(viewportHeight, webViewHelper.webViewImpl()->mainFrameImpl()->fram
eView()->layoutSize().height()); |
| 1361 } | 1361 } |
| 1362 | 1362 |
| 1363 TEST_F(WebFrameTest, SetForceZeroLayoutHeightWorksWithRelayoutsWhenHeightChanged
) |
| 1364 { |
| 1365 // this unit test is an attempt to target a real world case where an app cou
ld |
| 1366 // 1. call resize(width, 0) and setForceZeroLayoutHeight(true) |
| 1367 // 2. load content (hoping that the viewport height would increase |
| 1368 // as more content is added) |
| 1369 // 3. fail to register touch events aimed at the loaded content |
| 1370 // because the layout is only updated if either width or height is changed |
| 1371 UseMockScrollbarSettings mockScrollbarSettings; |
| 1372 registerMockedHttpURLLoad("button.html"); |
| 1373 |
| 1374 FixedLayoutTestWebViewClient client; |
| 1375 client.m_screenInfo.deviceScaleFactor = 1; |
| 1376 int viewportWidth = 640; |
| 1377 int viewportHeight = 480; |
| 1378 |
| 1379 FrameTestHelpers::WebViewHelper webViewHelper; |
| 1380 |
| 1381 webViewHelper.initializeAndLoad(m_baseURL + "button.html", true, 0, &client,
configurePinchVirtualViewport); |
| 1382 // set view height to zero so that if the height of the view is not |
| 1383 // successfully updated during later resizes touch events will fail |
| 1384 // (as in not hit content included in the view) |
| 1385 webViewHelper.webView()->resize(WebSize(viewportWidth, 0)); |
| 1386 webViewHelper.webView()->layout(); |
| 1387 |
| 1388 webViewHelper.webView()->settings()->setForceZeroLayoutHeight(true); |
| 1389 webViewHelper.webView()->resize(WebSize(viewportWidth, viewportHeight)); |
| 1390 |
| 1391 IntPoint hitPoint = IntPoint(30, 30); // button size is 100x100 |
| 1392 |
| 1393 WebLocalFrameImpl* frame = toWebLocalFrameImpl(webViewHelper.webView()->main
Frame()); |
| 1394 Document* document = frame->frame()->document(); |
| 1395 Element* element = document->getElementById("tap_button"); |
| 1396 |
| 1397 ASSERT_NE(nullptr, element); |
| 1398 EXPECT_EQ(String("oldValue"), element->innerText()); |
| 1399 |
| 1400 PlatformGestureEvent gestureEvent(PlatformEvent::Type::GestureTap, hitPoint,
hitPoint, IntSize(0, 0), 0, false, false, false, false, 0.0, 0.0, 0.0, 0.0, fal
se); |
| 1401 webViewHelper.webViewImpl()->mainFrameImpl()->frame()->eventHandler().handle
GestureEvent(gestureEvent); |
| 1402 // when pressed, the button changes its own text to "updatedValue" |
| 1403 EXPECT_EQ(String("updatedValue"), element->innerText()); |
| 1404 } |
| 1405 |
| 1363 TEST_F(WebFrameTest, SetForceZeroLayoutHeightWorksAcrossNavigations) | 1406 TEST_F(WebFrameTest, SetForceZeroLayoutHeightWorksAcrossNavigations) |
| 1364 { | 1407 { |
| 1365 UseMockScrollbarSettings mockScrollbarSettings; | 1408 UseMockScrollbarSettings mockScrollbarSettings; |
| 1366 registerMockedHttpURLLoad("200-by-300.html"); | 1409 registerMockedHttpURLLoad("200-by-300.html"); |
| 1367 registerMockedHttpURLLoad("large-div.html"); | 1410 registerMockedHttpURLLoad("large-div.html"); |
| 1368 | 1411 |
| 1369 FixedLayoutTestWebViewClient client; | 1412 FixedLayoutTestWebViewClient client; |
| 1370 client.m_screenInfo.deviceScaleFactor = 1; | 1413 client.m_screenInfo.deviceScaleFactor = 1; |
| 1371 int viewportWidth = 640; | 1414 int viewportWidth = 640; |
| 1372 int viewportHeight = 480; | 1415 int viewportHeight = 480; |
| (...skipping 5813 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7186 EXPECT_EQ(1u, frameClient.navigationalDataReceivedCount()); | 7229 EXPECT_EQ(1u, frameClient.navigationalDataReceivedCount()); |
| 7187 | 7230 |
| 7188 // Neither should a page reload. | 7231 // Neither should a page reload. |
| 7189 localFrame->reload(); | 7232 localFrame->reload(); |
| 7190 EXPECT_EQ(4u, frameClient.provisionalLoadCount()); | 7233 EXPECT_EQ(4u, frameClient.provisionalLoadCount()); |
| 7191 EXPECT_FALSE(frameClient.wasLastProvisionalLoadATransition()); | 7234 EXPECT_FALSE(frameClient.wasLastProvisionalLoadATransition()); |
| 7192 EXPECT_EQ(1u, frameClient.navigationalDataReceivedCount()); | 7235 EXPECT_EQ(1u, frameClient.navigationalDataReceivedCount()); |
| 7193 } | 7236 } |
| 7194 | 7237 |
| 7195 } // namespace | 7238 } // namespace |
| OLD | NEW |