OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2011, 2012 Google Inc. All rights reserved. | 2 * Copyright (C) 2011, 2012 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 1192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1203 webViewImpl->resize(WebSize(800, 600)); | 1203 webViewImpl->resize(WebSize(800, 600)); |
1204 webViewImpl->updateAllLifecyclePhases(); | 1204 webViewImpl->updateAllLifecyclePhases(); |
1205 | 1205 |
1206 // Scroll the page down. | 1206 // Scroll the page down. |
1207 webViewImpl->mainFrame()->setScrollOffset(WebSize(0, 2000)); | 1207 webViewImpl->mainFrame()->setScrollOffset(WebSize(0, 2000)); |
1208 ASSERT_EQ(2000, webViewImpl->mainFrame()->scrollOffset().height); | 1208 ASSERT_EQ(2000, webViewImpl->mainFrame()->scrollOffset().height); |
1209 | 1209 |
1210 // Enter fullscreen. | 1210 // Enter fullscreen. |
1211 Element* element = static_cast<Element*>( | 1211 Element* element = static_cast<Element*>( |
1212 webViewImpl->mainFrame()->document().getElementById("fullscreenElement")
); | 1212 webViewImpl->mainFrame()->document().getElementById("fullscreenElement")
); |
1213 webViewImpl->enterFullScreenForElement(element); | 1213 webViewImpl->enterFullscreenForElement(element); |
1214 webViewImpl->didEnterFullscreen(); | 1214 webViewImpl->didEnterFullscreen(); |
1215 webViewImpl->updateAllLifecyclePhases(); | 1215 webViewImpl->updateAllLifecyclePhases(); |
1216 | 1216 |
1217 // Sanity-check. There should be no scrolling possible. | 1217 // Sanity-check. There should be no scrolling possible. |
1218 ASSERT_EQ(0, webViewImpl->mainFrame()->scrollOffset().height); | 1218 ASSERT_EQ(0, webViewImpl->mainFrame()->scrollOffset().height); |
1219 ASSERT_EQ(0, webViewImpl->mainFrameImpl()->frameView()->maximumScrollPositio
n().y()); | 1219 ASSERT_EQ(0, webViewImpl->mainFrameImpl()->frameView()->maximumScrollPositio
n().y()); |
1220 | 1220 |
1221 // Confirm that after exiting and doing a layout, the scroll and scale | 1221 // Confirm that after exiting and doing a layout, the scroll and scale |
1222 // parameters are reset. The page sets display: none on overflowing elements | 1222 // parameters are reset. The page sets display: none on overflowing elements |
1223 // while in fullscreen so if we try to restore before the style and layout | 1223 // while in fullscreen so if we try to restore before the style and layout |
(...skipping 16 matching lines...) Expand all Loading... |
1240 webViewImpl->resize(WebSize(800, 600)); | 1240 webViewImpl->resize(WebSize(800, 600)); |
1241 webViewImpl->updateAllLifecyclePhases(); | 1241 webViewImpl->updateAllLifecyclePhases(); |
1242 | 1242 |
1243 // Scroll the page down. | 1243 // Scroll the page down. |
1244 webViewImpl->mainFrame()->setScrollOffset(WebSize(0, 2000)); | 1244 webViewImpl->mainFrame()->setScrollOffset(WebSize(0, 2000)); |
1245 ASSERT_EQ(2000, webViewImpl->mainFrame()->scrollOffset().height); | 1245 ASSERT_EQ(2000, webViewImpl->mainFrame()->scrollOffset().height); |
1246 | 1246 |
1247 // Enter fullscreen. | 1247 // Enter fullscreen. |
1248 Element* element = static_cast<Element*>( | 1248 Element* element = static_cast<Element*>( |
1249 webViewImpl->mainFrame()->document().getElementById("fullscreenElement")
); | 1249 webViewImpl->mainFrame()->document().getElementById("fullscreenElement")
); |
1250 webViewImpl->enterFullScreenForElement(element); | 1250 webViewImpl->enterFullscreenForElement(element); |
1251 webViewImpl->didEnterFullscreen(); | 1251 webViewImpl->didEnterFullscreen(); |
1252 webViewImpl->updateAllLifecyclePhases(); | 1252 webViewImpl->updateAllLifecyclePhases(); |
1253 | 1253 |
1254 // Sanity-check. There should be no scrolling possible. | 1254 // Sanity-check. There should be no scrolling possible. |
1255 ASSERT_EQ(0, webViewImpl->mainFrame()->scrollOffset().height); | 1255 ASSERT_EQ(0, webViewImpl->mainFrame()->scrollOffset().height); |
1256 ASSERT_EQ(0, webViewImpl->mainFrameImpl()->frameView()->maximumScrollPositio
n().y()); | 1256 ASSERT_EQ(0, webViewImpl->mainFrameImpl()->frameView()->maximumScrollPositio
n().y()); |
1257 | 1257 |
1258 // Exit and, without performing a layout, reenter fullscreen again. We | 1258 // Exit and, without performing a layout, reenter fullscreen again. We |
1259 // shouldn't try to restore the scroll and scale values when we layout to | 1259 // shouldn't try to restore the scroll and scale values when we layout to |
1260 // enter fullscreen. | 1260 // enter fullscreen. |
1261 webViewImpl->exitFullScreenForElement(element); | 1261 webViewImpl->exitFullscreenForElement(element); |
1262 webViewImpl->didExitFullscreen(); | 1262 webViewImpl->didExitFullscreen(); |
1263 webViewImpl->enterFullScreenForElement(element); | 1263 webViewImpl->enterFullscreenForElement(element); |
1264 webViewImpl->didEnterFullscreen(); | 1264 webViewImpl->didEnterFullscreen(); |
1265 webViewImpl->updateAllLifecyclePhases(); | 1265 webViewImpl->updateAllLifecyclePhases(); |
1266 | 1266 |
1267 // Sanity-check. There should be no scrolling possible. | 1267 // Sanity-check. There should be no scrolling possible. |
1268 ASSERT_EQ(0, webViewImpl->mainFrame()->scrollOffset().height); | 1268 ASSERT_EQ(0, webViewImpl->mainFrame()->scrollOffset().height); |
1269 ASSERT_EQ(0, webViewImpl->mainFrameImpl()->frameView()->maximumScrollPositio
n().y()); | 1269 ASSERT_EQ(0, webViewImpl->mainFrameImpl()->frameView()->maximumScrollPositio
n().y()); |
1270 | 1270 |
1271 // When we exit now, we should restore the original scroll value. | 1271 // When we exit now, we should restore the original scroll value. |
1272 webViewImpl->exitFullScreenForElement(element); | 1272 webViewImpl->exitFullscreenForElement(element); |
1273 webViewImpl->didExitFullscreen(); | 1273 webViewImpl->didExitFullscreen(); |
1274 webViewImpl->updateAllLifecyclePhases(); | 1274 webViewImpl->updateAllLifecyclePhases(); |
1275 | 1275 |
1276 EXPECT_EQ(2000, webViewImpl->mainFrame()->scrollOffset().height); | 1276 EXPECT_EQ(2000, webViewImpl->mainFrame()->scrollOffset().height); |
1277 } | 1277 } |
1278 | 1278 |
1279 TEST_F(WebViewTest, EnterFullscreenResetScrollAndScaleState) | 1279 TEST_F(WebViewTest, EnterFullscreenResetScrollAndScaleState) |
1280 { | 1280 { |
1281 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c
_str()), WebString::fromUTF8("200-by-300.html")); | 1281 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c
_str()), WebString::fromUTF8("200-by-300.html")); |
1282 WebViewImpl* webViewImpl = m_webViewHelper.initializeAndLoad(m_baseURL + "20
0-by-300.html"); | 1282 WebViewImpl* webViewImpl = m_webViewHelper.initializeAndLoad(m_baseURL + "20
0-by-300.html"); |
1283 webViewImpl->resize(WebSize(100, 150)); | 1283 webViewImpl->resize(WebSize(100, 150)); |
1284 webViewImpl->updateAllLifecyclePhases(); | 1284 webViewImpl->updateAllLifecyclePhases(); |
1285 EXPECT_EQ(0, webViewImpl->mainFrame()->scrollOffset().width); | 1285 EXPECT_EQ(0, webViewImpl->mainFrame()->scrollOffset().width); |
1286 EXPECT_EQ(0, webViewImpl->mainFrame()->scrollOffset().height); | 1286 EXPECT_EQ(0, webViewImpl->mainFrame()->scrollOffset().height); |
1287 | 1287 |
1288 // Make the page scale and scroll with the given paremeters. | 1288 // Make the page scale and scroll with the given paremeters. |
1289 webViewImpl->setPageScaleFactor(2.0f); | 1289 webViewImpl->setPageScaleFactor(2.0f); |
1290 webViewImpl->mainFrame()->setScrollOffset(WebSize(94, 111)); | 1290 webViewImpl->mainFrame()->setScrollOffset(WebSize(94, 111)); |
1291 webViewImpl->setVisualViewportOffset(WebFloatPoint(12, 20)); | 1291 webViewImpl->setVisualViewportOffset(WebFloatPoint(12, 20)); |
1292 EXPECT_EQ(2.0f, webViewImpl->pageScaleFactor()); | 1292 EXPECT_EQ(2.0f, webViewImpl->pageScaleFactor()); |
1293 EXPECT_EQ(94, webViewImpl->mainFrame()->scrollOffset().width); | 1293 EXPECT_EQ(94, webViewImpl->mainFrame()->scrollOffset().width); |
1294 EXPECT_EQ(111, webViewImpl->mainFrame()->scrollOffset().height); | 1294 EXPECT_EQ(111, webViewImpl->mainFrame()->scrollOffset().height); |
1295 EXPECT_EQ(12, webViewImpl->visualViewportOffset().x); | 1295 EXPECT_EQ(12, webViewImpl->visualViewportOffset().x); |
1296 EXPECT_EQ(20, webViewImpl->visualViewportOffset().y); | 1296 EXPECT_EQ(20, webViewImpl->visualViewportOffset().y); |
1297 | 1297 |
1298 Element* element = static_cast<Element*>(webViewImpl->mainFrame()->document(
).body()); | 1298 Element* element = static_cast<Element*>(webViewImpl->mainFrame()->document(
).body()); |
1299 webViewImpl->enterFullScreenForElement(element); | 1299 webViewImpl->enterFullscreenForElement(element); |
1300 webViewImpl->didEnterFullscreen(); | 1300 webViewImpl->didEnterFullscreen(); |
1301 | 1301 |
1302 // Page scale factor must be 1.0 during fullscreen for elements to be sized | 1302 // Page scale factor must be 1.0 during fullscreen for elements to be sized |
1303 // properly. | 1303 // properly. |
1304 EXPECT_EQ(1.0f, webViewImpl->pageScaleFactor()); | 1304 EXPECT_EQ(1.0f, webViewImpl->pageScaleFactor()); |
1305 | 1305 |
1306 // Make sure fullscreen nesting doesn't disrupt scroll/scale saving. | 1306 // Make sure fullscreen nesting doesn't disrupt scroll/scale saving. |
1307 Element* otherElement = static_cast<Element*>(webViewImpl->mainFrame()->docu
ment().head()); | 1307 Element* otherElement = static_cast<Element*>(webViewImpl->mainFrame()->docu
ment().head()); |
1308 webViewImpl->enterFullScreenForElement(otherElement); | 1308 webViewImpl->enterFullscreenForElement(otherElement); |
1309 | 1309 |
1310 // Confirm that exiting fullscreen restores the parameters. | 1310 // Confirm that exiting fullscreen restores the parameters. |
1311 webViewImpl->exitFullScreenForElement(element); | 1311 webViewImpl->exitFullscreenForElement(element); |
1312 webViewImpl->didExitFullscreen(); | 1312 webViewImpl->didExitFullscreen(); |
1313 webViewImpl->updateAllLifecyclePhases(); | 1313 webViewImpl->updateAllLifecyclePhases(); |
1314 | 1314 |
1315 EXPECT_EQ(2.0f, webViewImpl->pageScaleFactor()); | 1315 EXPECT_EQ(2.0f, webViewImpl->pageScaleFactor()); |
1316 EXPECT_EQ(94, webViewImpl->mainFrame()->scrollOffset().width); | 1316 EXPECT_EQ(94, webViewImpl->mainFrame()->scrollOffset().width); |
1317 EXPECT_EQ(111, webViewImpl->mainFrame()->scrollOffset().height); | 1317 EXPECT_EQ(111, webViewImpl->mainFrame()->scrollOffset().height); |
1318 EXPECT_EQ(12, webViewImpl->visualViewportOffset().x); | 1318 EXPECT_EQ(12, webViewImpl->visualViewportOffset().x); |
1319 EXPECT_EQ(20, webViewImpl->visualViewportOffset().y); | 1319 EXPECT_EQ(20, webViewImpl->visualViewportOffset().y); |
1320 } | 1320 } |
1321 | 1321 |
(...skipping 2043 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3365 EXPECT_TRUE(webView->page()->defersLoading()); | 3365 EXPECT_TRUE(webView->page()->defersLoading()); |
3366 } | 3366 } |
3367 | 3367 |
3368 EXPECT_TRUE(webView->page()->defersLoading()); | 3368 EXPECT_TRUE(webView->page()->defersLoading()); |
3369 } | 3369 } |
3370 | 3370 |
3371 EXPECT_FALSE(webView->page()->defersLoading()); | 3371 EXPECT_FALSE(webView->page()->defersLoading()); |
3372 } | 3372 } |
3373 | 3373 |
3374 } // namespace blink | 3374 } // namespace blink |
OLD | NEW |