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 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
57 #include "core/frame/RemoteFrame.h" | 57 #include "core/frame/RemoteFrame.h" |
58 #include "core/frame/Settings.h" | 58 #include "core/frame/Settings.h" |
59 #include "core/frame/VisualViewport.h" | 59 #include "core/frame/VisualViewport.h" |
60 #include "core/html/HTMLBodyElement.h" | 60 #include "core/html/HTMLBodyElement.h" |
61 #include "core/html/HTMLDocument.h" | 61 #include "core/html/HTMLDocument.h" |
62 #include "core/html/HTMLFormElement.h" | 62 #include "core/html/HTMLFormElement.h" |
63 #include "core/html/HTMLMediaElement.h" | 63 #include "core/html/HTMLMediaElement.h" |
64 #include "core/html/ImageDocument.h" | 64 #include "core/html/ImageDocument.h" |
65 #include "core/input/EventHandler.h" | 65 #include "core/input/EventHandler.h" |
66 #include "core/layout/HitTestResult.h" | 66 #include "core/layout/HitTestResult.h" |
67 #include "core/layout/LayoutFullScreen.h" | |
68 #include "core/layout/api/LayoutViewItem.h" | |
69 #include "core/layout/compositing/PaintLayerCompositor.h" | 67 #include "core/layout/compositing/PaintLayerCompositor.h" |
70 #include "core/loader/DocumentLoader.h" | 68 #include "core/loader/DocumentLoader.h" |
71 #include "core/loader/DocumentThreadableLoader.h" | 69 #include "core/loader/DocumentThreadableLoader.h" |
72 #include "core/loader/DocumentThreadableLoaderClient.h" | 70 #include "core/loader/DocumentThreadableLoaderClient.h" |
73 #include "core/loader/FrameLoadRequest.h" | 71 #include "core/loader/FrameLoadRequest.h" |
74 #include "core/loader/ThreadableLoader.h" | 72 #include "core/loader/ThreadableLoader.h" |
75 #include "core/page/Page.h" | 73 #include "core/page/Page.h" |
76 #include "core/paint/PaintLayer.h" | 74 #include "core/paint/PaintLayer.h" |
77 #include "core/testing/NullExecutionContext.h" | 75 #include "core/testing/NullExecutionContext.h" |
78 #include "modules/mediastream/MediaStream.h" | 76 #include "modules/mediastream/MediaStream.h" |
(...skipping 6369 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6448 webViewHelper.webView()->settings()->setWideViewportQuirkEnabled(true); | 6446 webViewHelper.webView()->settings()->setWideViewportQuirkEnabled(true); |
6449 webViewHelper.webView()->settings()->setLoadWithOverviewMode(true); | 6447 webViewHelper.webView()->settings()->setLoadWithOverviewMode(true); |
6450 webViewHelper.webView()->settings()->setUseWideViewport(true); | 6448 webViewHelper.webView()->settings()->setUseWideViewport(true); |
6451 webViewHelper.resize(WebSize(viewportWidth, viewportHeight)); | 6449 webViewHelper.resize(WebSize(viewportWidth, viewportHeight)); |
6452 webViewHelper.webView()->updateAllLifecyclePhases(); | 6450 webViewHelper.webView()->updateAllLifecyclePhases(); |
6453 | 6451 |
6454 FrameView* frameView = webViewHelper.webViewImpl()->mainFrameImpl()->frameVi
ew(); | 6452 FrameView* frameView = webViewHelper.webViewImpl()->mainFrameImpl()->frameVi
ew(); |
6455 EXPECT_LT(frameView->maximumScrollPosition().x(), 0); | 6453 EXPECT_LT(frameView->maximumScrollPosition().x(), 0); |
6456 } | 6454 } |
6457 | 6455 |
| 6456 TEST_F(WebFrameTest, FullscreenCleanTopLayerAndFullscreenStack) |
| 6457 { |
| 6458 FakeCompositingWebViewClient client; |
| 6459 registerMockedHttpURLLoad("fullscreen_div.html"); |
| 6460 FrameTestHelpers::WebViewHelper webViewHelper; |
| 6461 int viewportWidth = 640; |
| 6462 int viewportHeight = 480; |
| 6463 client.m_screenInfo.rect.width = viewportWidth; |
| 6464 client.m_screenInfo.rect.height = viewportHeight; |
| 6465 WebViewImpl* webViewImpl = webViewHelper.initializeAndLoad( |
| 6466 m_baseURL + "fullscreen_div.html", true, 0, &client, nullptr, configureA
ndroid); |
| 6467 webViewImpl->resize(WebSize(viewportWidth, viewportHeight)); |
| 6468 webViewImpl->updateAllLifecyclePhases(); |
| 6469 |
| 6470 UserGestureIndicator gesture(DefinitelyProcessingUserGesture); |
| 6471 Document* document = toWebLocalFrameImpl(webViewImpl->mainFrame())->frame()-
>document(); |
| 6472 Fullscreen& fullscreen = Fullscreen::from(*document); |
| 6473 |
| 6474 Element* divFullscreen = document->getElementById("div1"); |
| 6475 fullscreen.requestFullscreen(*divFullscreen, Fullscreen::PrefixedRequest); |
| 6476 webViewImpl->didEnterFullScreen(); |
| 6477 ASSERT_TRUE(Fullscreen::isFullScreen(*document)); |
| 6478 |
| 6479 // Sanity check. We should have both in our stack. |
| 6480 ASSERT_EQ(fullscreen.fullScreenElementStack().size(), 1UL); |
| 6481 ASSERT_EQ(document->topLayerElements().size(), 2UL); |
| 6482 |
| 6483 fullscreen.exitFullscreen(); |
| 6484 webViewImpl->didExitFullScreen(); |
| 6485 |
| 6486 ASSERT_EQ(fullscreen.fullScreenElementStack().size(), 0UL); |
| 6487 ASSERT_EQ(document->topLayerElements().size(), 0UL); |
| 6488 } |
| 6489 |
6458 TEST_P(ParameterizedWebFrameTest, FullscreenLayerSize) | 6490 TEST_P(ParameterizedWebFrameTest, FullscreenLayerSize) |
6459 { | 6491 { |
6460 FakeCompositingWebViewClient client; | 6492 FakeCompositingWebViewClient client; |
6461 registerMockedHttpURLLoad("fullscreen_div.html"); | 6493 registerMockedHttpURLLoad("fullscreen_div.html"); |
6462 FrameTestHelpers::WebViewHelper webViewHelper(this); | 6494 FrameTestHelpers::WebViewHelper webViewHelper(this); |
6463 int viewportWidth = 640; | 6495 int viewportWidth = 640; |
6464 int viewportHeight = 480; | 6496 int viewportHeight = 480; |
6465 client.m_screenInfo.rect.width = viewportWidth; | 6497 client.m_screenInfo.rect.width = viewportWidth; |
6466 client.m_screenInfo.rect.height = viewportHeight; | 6498 client.m_screenInfo.rect.height = viewportHeight; |
6467 WebViewImpl* webViewImpl = webViewHelper.initializeAndLoad(m_baseURL + "full
screen_div.html", true, nullptr, &client, nullptr, configureAndroid); | 6499 WebViewImpl* webViewImpl = webViewHelper.initializeAndLoad(m_baseURL + "full
screen_div.html", true, nullptr, &client, nullptr, configureAndroid); |
6468 webViewHelper.resize(WebSize(viewportWidth, viewportHeight)); | 6500 webViewHelper.resize(WebSize(viewportWidth, viewportHeight)); |
6469 webViewImpl->updateAllLifecyclePhases(); | 6501 webViewImpl->updateAllLifecyclePhases(); |
6470 | 6502 |
6471 Document* document = toWebLocalFrameImpl(webViewImpl->mainFrame())->frame()-
>document(); | 6503 Document* document = toWebLocalFrameImpl(webViewImpl->mainFrame())->frame()-
>document(); |
6472 UserGestureIndicator gesture(DefinitelyProcessingUserGesture); | 6504 UserGestureIndicator gesture(DefinitelyProcessingUserGesture); |
6473 Element* divFullscreen = document->getElementById("div1"); | 6505 Element* divFullscreen = document->getElementById("div1"); |
6474 Fullscreen::from(*document).requestFullscreen(*divFullscreen, Fullscreen::Pr
efixedRequest); | 6506 Fullscreen::from(*document).requestFullscreen(*divFullscreen, Fullscreen::Pr
efixedRequest); |
6475 webViewImpl->didEnterFullScreen(); | 6507 webViewImpl->didEnterFullScreen(); |
6476 webViewImpl->updateAllLifecyclePhases(); | 6508 webViewImpl->updateAllLifecyclePhases(); |
6477 ASSERT_TRUE(Fullscreen::isFullScreen(*document)); | 6509 ASSERT_TRUE(Fullscreen::isFullScreen(*document)); |
6478 | 6510 |
6479 // Verify that the element is sized to the viewport. | 6511 // Verify that the element is sized to the viewport. |
6480 LayoutFullScreen* fullscreenLayoutObject = Fullscreen::from(*document).fullS
creenLayoutObject(); | 6512 Element* fullscreenElement = Fullscreen::currentFullScreenElementFrom(*docum
ent); |
| 6513 LayoutBox* fullscreenLayoutObject = toLayoutBox(fullscreenElement->layoutObj
ect()); |
6481 EXPECT_EQ(viewportWidth, fullscreenLayoutObject->logicalWidth().toInt()); | 6514 EXPECT_EQ(viewportWidth, fullscreenLayoutObject->logicalWidth().toInt()); |
6482 EXPECT_EQ(viewportHeight, fullscreenLayoutObject->logicalHeight().toInt()); | 6515 EXPECT_EQ(viewportHeight, fullscreenLayoutObject->logicalHeight().toInt()); |
6483 | 6516 |
6484 // Verify it's updated after a device rotation. | 6517 // Verify it's updated after a device rotation. |
6485 client.m_screenInfo.rect.width = viewportHeight; | 6518 client.m_screenInfo.rect.width = viewportHeight; |
6486 client.m_screenInfo.rect.height = viewportWidth; | 6519 client.m_screenInfo.rect.height = viewportWidth; |
6487 webViewHelper.resize(WebSize(viewportHeight, viewportWidth)); | 6520 webViewHelper.resize(WebSize(viewportHeight, viewportWidth)); |
6488 webViewImpl->updateAllLifecyclePhases(); | 6521 webViewImpl->updateAllLifecyclePhases(); |
6489 EXPECT_EQ(viewportHeight, fullscreenLayoutObject->logicalWidth().toInt()); | 6522 EXPECT_EQ(viewportHeight, fullscreenLayoutObject->logicalWidth().toInt()); |
6490 EXPECT_EQ(viewportWidth, fullscreenLayoutObject->logicalHeight().toInt()); | 6523 EXPECT_EQ(viewportWidth, fullscreenLayoutObject->logicalHeight().toInt()); |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6574 webViewImpl->updateAllLifecyclePhases(); | 6607 webViewImpl->updateAllLifecyclePhases(); |
6575 | 6608 |
6576 Document* document = toWebLocalFrameImpl(webViewHelper.webView()->mainFrame(
)->firstChild())->frame()->document(); | 6609 Document* document = toWebLocalFrameImpl(webViewHelper.webView()->mainFrame(
)->firstChild())->frame()->document(); |
6577 UserGestureIndicator gesture(DefinitelyProcessingUserGesture); | 6610 UserGestureIndicator gesture(DefinitelyProcessingUserGesture); |
6578 Element* divFullscreen = document->getElementById("div1"); | 6611 Element* divFullscreen = document->getElementById("div1"); |
6579 Fullscreen::from(*document).requestFullscreen(*divFullscreen, Fullscreen::Pr
efixedRequest); | 6612 Fullscreen::from(*document).requestFullscreen(*divFullscreen, Fullscreen::Pr
efixedRequest); |
6580 webViewImpl->didEnterFullScreen(); | 6613 webViewImpl->didEnterFullScreen(); |
6581 webViewImpl->updateAllLifecyclePhases(); | 6614 webViewImpl->updateAllLifecyclePhases(); |
6582 | 6615 |
6583 // Verify that the element is sized to the viewport. | 6616 // Verify that the element is sized to the viewport. |
6584 LayoutFullScreen* fullscreenLayoutObject = Fullscreen::from(*document).fullS
creenLayoutObject(); | 6617 Element* fullscreenElement = Fullscreen::currentFullScreenElementFrom(*docum
ent); |
| 6618 LayoutBox* fullscreenLayoutObject = toLayoutBox(fullscreenElement->layoutObj
ect()); |
6585 EXPECT_EQ(viewportWidth, fullscreenLayoutObject->logicalWidth().toInt()); | 6619 EXPECT_EQ(viewportWidth, fullscreenLayoutObject->logicalWidth().toInt()); |
6586 EXPECT_EQ(viewportHeight, fullscreenLayoutObject->logicalHeight().toInt()); | 6620 EXPECT_EQ(viewportHeight, fullscreenLayoutObject->logicalHeight().toInt()); |
6587 | 6621 |
6588 // Verify it's updated after a device rotation. | 6622 // Verify it's updated after a device rotation. |
6589 client.m_screenInfo.rect.width = viewportHeight; | 6623 client.m_screenInfo.rect.width = viewportHeight; |
6590 client.m_screenInfo.rect.height = viewportWidth; | 6624 client.m_screenInfo.rect.height = viewportWidth; |
6591 webViewHelper.resize(WebSize(viewportHeight, viewportWidth)); | 6625 webViewHelper.resize(WebSize(viewportHeight, viewportWidth)); |
6592 webViewImpl->updateAllLifecyclePhases(); | 6626 webViewImpl->updateAllLifecyclePhases(); |
6593 EXPECT_EQ(viewportHeight, fullscreenLayoutObject->logicalWidth().toInt()); | 6627 EXPECT_EQ(viewportHeight, fullscreenLayoutObject->logicalWidth().toInt()); |
6594 EXPECT_EQ(viewportWidth, fullscreenLayoutObject->logicalHeight().toInt()); | 6628 EXPECT_EQ(viewportWidth, fullscreenLayoutObject->logicalHeight().toInt()); |
(...skipping 2217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8812 request.setURL(toKURL("javascript:location='" + redirectURL + "'")); | 8846 request.setURL(toKURL("javascript:location='" + redirectURL + "'")); |
8813 helper.webViewImpl()->mainFrame()->toWebLocalFrame()->loadRequest(request); | 8847 helper.webViewImpl()->mainFrame()->toWebLocalFrame()->loadRequest(request); |
8814 | 8848 |
8815 // Normally, the result of the JS url replaces the existing contents on the | 8849 // Normally, the result of the JS url replaces the existing contents on the |
8816 // Document. However, if the JS triggers a navigation, the contents should | 8850 // Document. However, if the JS triggers a navigation, the contents should |
8817 // not be replaced. | 8851 // not be replaced. |
8818 EXPECT_EQ("", toLocalFrame(helper.webViewImpl()->page()->mainFrame())->docum
ent()->documentElement()->innerText()); | 8852 EXPECT_EQ("", toLocalFrame(helper.webViewImpl()->page()->mainFrame())->docum
ent()->documentElement()->innerText()); |
8819 } | 8853 } |
8820 | 8854 |
8821 } // namespace blink | 8855 } // namespace blink |
OLD | NEW |