Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(89)

Side by Side Diff: Source/web/tests/WebFrameTest.cpp

Issue 453893002: Add a force-layout-height-to-zero layout mode to WebViewImpl (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « Source/web/WebViewImpl.cpp ('k') | public/web/WebSettings.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 1359 matching lines...) Expand 10 before | Expand all | Expand 10 after
1370 1370
1371 EXPECT_EQ(viewportWidth, webViewHelper.webViewImpl()->mainFrameImpl()->frame View()->layoutSize().width()); 1371 EXPECT_EQ(viewportWidth, webViewHelper.webViewImpl()->mainFrameImpl()->frame View()->layoutSize().width());
1372 EXPECT_EQ(1, webViewHelper.webView()->pageScaleFactor()); 1372 EXPECT_EQ(1, webViewHelper.webView()->pageScaleFactor());
1373 1373
1374 webViewHelper.webView()->setFixedLayoutSize(WebSize(2000, 1500)); 1374 webViewHelper.webView()->setFixedLayoutSize(WebSize(2000, 1500));
1375 webViewHelper.webView()->layout(); 1375 webViewHelper.webView()->layout();
1376 EXPECT_EQ(2000, webViewHelper.webViewImpl()->mainFrameImpl()->frameView()->l ayoutSize().width()); 1376 EXPECT_EQ(2000, webViewHelper.webViewImpl()->mainFrameImpl()->frameView()->l ayoutSize().width());
1377 EXPECT_EQ(0.5f, webViewHelper.webView()->pageScaleFactor()); 1377 EXPECT_EQ(0.5f, webViewHelper.webView()->pageScaleFactor());
1378 } 1378 }
1379 1379
1380 TEST_F(WebFrameTest, SetForceZeroLayoutHeight)
1381 {
1382 UseMockScrollbarSettings mockScrollbarSettings;
1383 registerMockedHttpURLLoad("200-by-300.html");
1384
1385 FixedLayoutTestWebViewClient client;
1386 client.m_screenInfo.deviceScaleFactor = 1;
1387 int viewportWidth = 640;
1388 int viewportHeight = 480;
1389
1390 FrameTestHelpers::WebViewHelper webViewHelper;
1391
1392 webViewHelper.initializeAndLoad(m_baseURL + "200-by-300.html", true, 0, &cli ent, enableViewportSettings);
1393 webViewHelper.webView()->resize(WebSize(viewportWidth, viewportHeight));
1394 webViewHelper.webView()->layout();
1395
1396 EXPECT_LE(viewportHeight, webViewHelper.webViewImpl()->mainFrameImpl()->fram eView()->layoutSize().height());
1397 webViewHelper.webView()->settings()->setForceZeroLayoutHeight(true);
1398 EXPECT_TRUE(webViewHelper.webViewImpl()->mainFrameImpl()->frameView()->needs Layout());
1399
1400 EXPECT_EQ(0, webViewHelper.webViewImpl()->mainFrameImpl()->frameView()->layo utSize().height());
1401
1402 webViewHelper.webView()->resize(WebSize(viewportWidth, viewportHeight * 2));
1403 EXPECT_FALSE(webViewHelper.webViewImpl()->mainFrameImpl()->frameView()->need sLayout());
1404 EXPECT_EQ(0, webViewHelper.webViewImpl()->mainFrameImpl()->frameView()->layo utSize().height());
1405
1406 webViewHelper.webView()->resize(WebSize(viewportWidth * 2, viewportHeight));
1407 webViewHelper.webView()->layout();
1408 EXPECT_EQ(0, webViewHelper.webViewImpl()->mainFrameImpl()->frameView()->layo utSize().height());
1409
1410 webViewHelper.webView()->settings()->setForceZeroLayoutHeight(false);
1411 EXPECT_LE(viewportHeight, webViewHelper.webViewImpl()->mainFrameImpl()->fram eView()->layoutSize().height());
1412 }
1413
1414 TEST_F(WebFrameTest, SetForceZeroLayoutHeightWorksAcrossNavigations)
1415 {
1416 UseMockScrollbarSettings mockScrollbarSettings;
1417 registerMockedHttpURLLoad("200-by-300.html");
1418 registerMockedHttpURLLoad("large-div.html");
1419
1420 FixedLayoutTestWebViewClient client;
1421 client.m_screenInfo.deviceScaleFactor = 1;
1422 int viewportWidth = 640;
1423 int viewportHeight = 480;
1424
1425 FrameTestHelpers::WebViewHelper webViewHelper;
1426
1427 webViewHelper.initializeAndLoad(m_baseURL + "200-by-300.html", true, 0, &cli ent, enableViewportSettings);
1428 webViewHelper.webView()->settings()->setForceZeroLayoutHeight(true);
1429 webViewHelper.webView()->resize(WebSize(viewportWidth, viewportHeight));
1430 webViewHelper.webView()->layout();
1431
1432 FrameTestHelpers::loadFrame(webViewHelper.webView()->mainFrame(), m_baseURL + "large-div.html");
1433 webViewHelper.webView()->layout();
1434
1435 EXPECT_EQ(0, webViewHelper.webViewImpl()->mainFrameImpl()->frameView()->layo utSize().height());
1436 }
1437
1438 TEST_F(WebFrameTest, SetForceZeroLayoutHeightWithWideViewportQuirk)
1439 {
1440 UseMockScrollbarSettings mockScrollbarSettings;
1441 registerMockedHttpURLLoad("200-by-300.html");
1442
1443 FixedLayoutTestWebViewClient client;
1444 client.m_screenInfo.deviceScaleFactor = 1;
1445 int viewportWidth = 640;
1446 int viewportHeight = 480;
1447
1448 FrameTestHelpers::WebViewHelper webViewHelper;
1449
1450 webViewHelper.initializeAndLoad(m_baseURL + "200-by-300.html", true, 0, &cli ent, enableViewportSettings);
1451 webViewHelper.webView()->settings()->setWideViewportQuirkEnabled(true);
1452 webViewHelper.webView()->settings()->setUseWideViewport(true);
1453 webViewHelper.webView()->settings()->setForceZeroLayoutHeight(true);
1454 webViewHelper.webView()->resize(WebSize(viewportWidth, viewportHeight));
1455 webViewHelper.webView()->layout();
1456
1457 EXPECT_EQ(0, webViewHelper.webViewImpl()->mainFrameImpl()->frameView()->layo utSize().height());
1458 }
1459
1380 TEST_F(WebFrameTest, WideViewportAndWideContentWithInitialScale) 1460 TEST_F(WebFrameTest, WideViewportAndWideContentWithInitialScale)
1381 { 1461 {
1382 UseMockScrollbarSettings mockScrollbarSettings; 1462 UseMockScrollbarSettings mockScrollbarSettings;
1383 registerMockedHttpURLLoad("wide_document_width_viewport.html"); 1463 registerMockedHttpURLLoad("wide_document_width_viewport.html");
1384 1464
1385 FixedLayoutTestWebViewClient client; 1465 FixedLayoutTestWebViewClient client;
1386 client.m_screenInfo.deviceScaleFactor = 1; 1466 client.m_screenInfo.deviceScaleFactor = 1;
1387 int viewportWidth = 600; 1467 int viewportWidth = 600;
1388 int viewportHeight = 800; 1468 int viewportHeight = 800;
1389 1469
(...skipping 4553 matching lines...) Expand 10 before | Expand all | Expand 10 after
5943 6023
5944 client.reset(); 6024 client.reset();
5945 // Try to load the request with cross origin access. Should succeed. 6025 // Try to load the request with cross origin access. Should succeed.
5946 options.crossOriginRequestPolicy = blink::AllowCrossOriginRequests; 6026 options.crossOriginRequestPolicy = blink::AllowCrossOriginRequests;
5947 blink::DocumentThreadableLoader::loadResourceSynchronously( 6027 blink::DocumentThreadableLoader::loadResourceSynchronously(
5948 *frame->document(), blink::ResourceRequest(resourceUrl), client, options , resourceLoaderOptions); 6028 *frame->document(), blink::ResourceRequest(resourceUrl), client, options , resourceLoaderOptions);
5949 EXPECT_FALSE(client.failed()); 6029 EXPECT_FALSE(client.failed());
5950 } 6030 }
5951 6031
5952 } // namespace 6032 } // namespace
OLDNEW
« no previous file with comments | « Source/web/WebViewImpl.cpp ('k') | public/web/WebSettings.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698