| 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 6365 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6444 webViewHelper.webView()->settings()->setWideViewportQuirkEnabled(true); | 6442 webViewHelper.webView()->settings()->setWideViewportQuirkEnabled(true); |
| 6445 webViewHelper.webView()->settings()->setLoadWithOverviewMode(true); | 6443 webViewHelper.webView()->settings()->setLoadWithOverviewMode(true); |
| 6446 webViewHelper.webView()->settings()->setUseWideViewport(true); | 6444 webViewHelper.webView()->settings()->setUseWideViewport(true); |
| 6447 webViewHelper.resize(WebSize(viewportWidth, viewportHeight)); | 6445 webViewHelper.resize(WebSize(viewportWidth, viewportHeight)); |
| 6448 webViewHelper.webView()->updateAllLifecyclePhases(); | 6446 webViewHelper.webView()->updateAllLifecyclePhases(); |
| 6449 | 6447 |
| 6450 FrameView* frameView = webViewHelper.webViewImpl()->mainFrameImpl()->frameVi
ew(); | 6448 FrameView* frameView = webViewHelper.webViewImpl()->mainFrameImpl()->frameVi
ew(); |
| 6451 EXPECT_LT(frameView->maximumScrollPosition().x(), 0); | 6449 EXPECT_LT(frameView->maximumScrollPosition().x(), 0); |
| 6452 } | 6450 } |
| 6453 | 6451 |
| 6452 TEST_F(WebFrameTest, FullscreenCleanTopLayerAndFullscreenStack) |
| 6453 { |
| 6454 FakeCompositingWebViewClient client; |
| 6455 registerMockedHttpURLLoad("fullscreen_div.html"); |
| 6456 FrameTestHelpers::WebViewHelper webViewHelper; |
| 6457 int viewportWidth = 640; |
| 6458 int viewportHeight = 480; |
| 6459 client.m_screenInfo.rect.width = viewportWidth; |
| 6460 client.m_screenInfo.rect.height = viewportHeight; |
| 6461 WebViewImpl* webViewImpl = webViewHelper.initializeAndLoad( |
| 6462 m_baseURL + "fullscreen_div.html", true, 0, &client, nullptr, configureA
ndroid); |
| 6463 webViewImpl->resize(WebSize(viewportWidth, viewportHeight)); |
| 6464 webViewImpl->updateAllLifecyclePhases(); |
| 6465 |
| 6466 UserGestureIndicator gesture(DefinitelyProcessingUserGesture); |
| 6467 Document* document = toWebLocalFrameImpl(webViewImpl->mainFrame())->frame()-
>document(); |
| 6468 Fullscreen& fullscreen = Fullscreen::from(*document); |
| 6469 |
| 6470 Element* divFullscreen = document->getElementById("div1"); |
| 6471 fullscreen.requestFullscreen(*divFullscreen, Fullscreen::PrefixedRequest); |
| 6472 webViewImpl->didEnterFullscreen(); |
| 6473 ASSERT_TRUE(Fullscreen::isFullScreen(*document)); |
| 6474 |
| 6475 // Sanity check. We should have both in our stack. |
| 6476 ASSERT_EQ(fullscreen.fullScreenElementStack().size(), 1UL); |
| 6477 ASSERT_EQ(document->topLayerElements().size(), 2UL); |
| 6478 |
| 6479 fullscreen.exitFullscreen(); |
| 6480 webViewImpl->didExitFullscreen(); |
| 6481 |
| 6482 ASSERT_EQ(fullscreen.fullScreenElementStack().size(), 0UL); |
| 6483 ASSERT_EQ(document->topLayerElements().size(), 0UL); |
| 6484 } |
| 6485 |
| 6454 TEST_P(ParameterizedWebFrameTest, FullscreenLayerSize) | 6486 TEST_P(ParameterizedWebFrameTest, FullscreenLayerSize) |
| 6455 { | 6487 { |
| 6456 FakeCompositingWebViewClient client; | 6488 FakeCompositingWebViewClient client; |
| 6457 registerMockedHttpURLLoad("fullscreen_div.html"); | 6489 registerMockedHttpURLLoad("fullscreen_div.html"); |
| 6458 FrameTestHelpers::WebViewHelper webViewHelper(this); | 6490 FrameTestHelpers::WebViewHelper webViewHelper(this); |
| 6459 int viewportWidth = 640; | 6491 int viewportWidth = 640; |
| 6460 int viewportHeight = 480; | 6492 int viewportHeight = 480; |
| 6461 client.m_screenInfo.rect.width = viewportWidth; | 6493 client.m_screenInfo.rect.width = viewportWidth; |
| 6462 client.m_screenInfo.rect.height = viewportHeight; | 6494 client.m_screenInfo.rect.height = viewportHeight; |
| 6463 WebViewImpl* webViewImpl = webViewHelper.initializeAndLoad(m_baseURL + "full
screen_div.html", true, nullptr, &client, nullptr, configureAndroid); | 6495 WebViewImpl* webViewImpl = webViewHelper.initializeAndLoad(m_baseURL + "full
screen_div.html", true, nullptr, &client, nullptr, configureAndroid); |
| 6464 webViewHelper.resize(WebSize(viewportWidth, viewportHeight)); | 6496 webViewHelper.resize(WebSize(viewportWidth, viewportHeight)); |
| 6465 webViewImpl->updateAllLifecyclePhases(); | 6497 webViewImpl->updateAllLifecyclePhases(); |
| 6466 | 6498 |
| 6467 Document* document = toWebLocalFrameImpl(webViewImpl->mainFrame())->frame()-
>document(); | 6499 Document* document = toWebLocalFrameImpl(webViewImpl->mainFrame())->frame()-
>document(); |
| 6468 UserGestureIndicator gesture(DefinitelyProcessingUserGesture); | 6500 UserGestureIndicator gesture(DefinitelyProcessingUserGesture); |
| 6469 Element* divFullscreen = document->getElementById("div1"); | 6501 Element* divFullscreen = document->getElementById("div1"); |
| 6470 Fullscreen::from(*document).requestFullscreen(*divFullscreen, Fullscreen::Pr
efixedRequest); | 6502 Fullscreen::from(*document).requestFullscreen(*divFullscreen, Fullscreen::Pr
efixedRequest); |
| 6471 webViewImpl->didEnterFullscreen(); | 6503 webViewImpl->didEnterFullscreen(); |
| 6472 webViewImpl->updateAllLifecyclePhases(); | 6504 webViewImpl->updateAllLifecyclePhases(); |
| 6473 ASSERT_TRUE(Fullscreen::isFullScreen(*document)); | 6505 ASSERT_TRUE(Fullscreen::isFullScreen(*document)); |
| 6474 | 6506 |
| 6475 // Verify that the element is sized to the viewport. | 6507 // Verify that the element is sized to the viewport. |
| 6476 LayoutFullScreen* fullscreenLayoutObject = Fullscreen::from(*document).fullS
creenLayoutObject(); | 6508 Element* fullscreenElement = Fullscreen::currentFullScreenElementFrom(*docum
ent); |
| 6509 LayoutBox* fullscreenLayoutObject = toLayoutBox(fullscreenElement->layoutObj
ect()); |
| 6477 EXPECT_EQ(viewportWidth, fullscreenLayoutObject->logicalWidth().toInt()); | 6510 EXPECT_EQ(viewportWidth, fullscreenLayoutObject->logicalWidth().toInt()); |
| 6478 EXPECT_EQ(viewportHeight, fullscreenLayoutObject->logicalHeight().toInt()); | 6511 EXPECT_EQ(viewportHeight, fullscreenLayoutObject->logicalHeight().toInt()); |
| 6479 | 6512 |
| 6480 // Verify it's updated after a device rotation. | 6513 // Verify it's updated after a device rotation. |
| 6481 client.m_screenInfo.rect.width = viewportHeight; | 6514 client.m_screenInfo.rect.width = viewportHeight; |
| 6482 client.m_screenInfo.rect.height = viewportWidth; | 6515 client.m_screenInfo.rect.height = viewportWidth; |
| 6483 webViewHelper.resize(WebSize(viewportHeight, viewportWidth)); | 6516 webViewHelper.resize(WebSize(viewportHeight, viewportWidth)); |
| 6484 webViewImpl->updateAllLifecyclePhases(); | 6517 webViewImpl->updateAllLifecyclePhases(); |
| 6485 EXPECT_EQ(viewportHeight, fullscreenLayoutObject->logicalWidth().toInt()); | 6518 EXPECT_EQ(viewportHeight, fullscreenLayoutObject->logicalWidth().toInt()); |
| 6486 EXPECT_EQ(viewportWidth, fullscreenLayoutObject->logicalHeight().toInt()); | 6519 EXPECT_EQ(viewportWidth, fullscreenLayoutObject->logicalHeight().toInt()); |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6570 webViewImpl->updateAllLifecyclePhases(); | 6603 webViewImpl->updateAllLifecyclePhases(); |
| 6571 | 6604 |
| 6572 Document* document = toWebLocalFrameImpl(webViewHelper.webView()->mainFrame(
)->firstChild())->frame()->document(); | 6605 Document* document = toWebLocalFrameImpl(webViewHelper.webView()->mainFrame(
)->firstChild())->frame()->document(); |
| 6573 UserGestureIndicator gesture(DefinitelyProcessingUserGesture); | 6606 UserGestureIndicator gesture(DefinitelyProcessingUserGesture); |
| 6574 Element* divFullscreen = document->getElementById("div1"); | 6607 Element* divFullscreen = document->getElementById("div1"); |
| 6575 Fullscreen::from(*document).requestFullscreen(*divFullscreen, Fullscreen::Pr
efixedRequest); | 6608 Fullscreen::from(*document).requestFullscreen(*divFullscreen, Fullscreen::Pr
efixedRequest); |
| 6576 webViewImpl->didEnterFullscreen(); | 6609 webViewImpl->didEnterFullscreen(); |
| 6577 webViewImpl->updateAllLifecyclePhases(); | 6610 webViewImpl->updateAllLifecyclePhases(); |
| 6578 | 6611 |
| 6579 // Verify that the element is sized to the viewport. | 6612 // Verify that the element is sized to the viewport. |
| 6580 LayoutFullScreen* fullscreenLayoutObject = Fullscreen::from(*document).fullS
creenLayoutObject(); | 6613 Element* fullscreenElement = Fullscreen::currentFullScreenElementFrom(*docum
ent); |
| 6614 LayoutBox* fullscreenLayoutObject = toLayoutBox(fullscreenElement->layoutObj
ect()); |
| 6581 EXPECT_EQ(viewportWidth, fullscreenLayoutObject->logicalWidth().toInt()); | 6615 EXPECT_EQ(viewportWidth, fullscreenLayoutObject->logicalWidth().toInt()); |
| 6582 EXPECT_EQ(viewportHeight, fullscreenLayoutObject->logicalHeight().toInt()); | 6616 EXPECT_EQ(viewportHeight, fullscreenLayoutObject->logicalHeight().toInt()); |
| 6583 | 6617 |
| 6584 // Verify it's updated after a device rotation. | 6618 // Verify it's updated after a device rotation. |
| 6585 client.m_screenInfo.rect.width = viewportHeight; | 6619 client.m_screenInfo.rect.width = viewportHeight; |
| 6586 client.m_screenInfo.rect.height = viewportWidth; | 6620 client.m_screenInfo.rect.height = viewportWidth; |
| 6587 webViewHelper.resize(WebSize(viewportHeight, viewportWidth)); | 6621 webViewHelper.resize(WebSize(viewportHeight, viewportWidth)); |
| 6588 webViewImpl->updateAllLifecyclePhases(); | 6622 webViewImpl->updateAllLifecyclePhases(); |
| 6589 EXPECT_EQ(viewportHeight, fullscreenLayoutObject->logicalWidth().toInt()); | 6623 EXPECT_EQ(viewportHeight, fullscreenLayoutObject->logicalWidth().toInt()); |
| 6590 EXPECT_EQ(viewportWidth, fullscreenLayoutObject->logicalHeight().toInt()); | 6624 EXPECT_EQ(viewportWidth, fullscreenLayoutObject->logicalHeight().toInt()); |
| (...skipping 2219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8810 request.setRequestorOrigin(WebSecurityOrigin::createUnique()); | 8844 request.setRequestorOrigin(WebSecurityOrigin::createUnique()); |
| 8811 helper.webViewImpl()->mainFrame()->toWebLocalFrame()->loadRequest(request); | 8845 helper.webViewImpl()->mainFrame()->toWebLocalFrame()->loadRequest(request); |
| 8812 | 8846 |
| 8813 // Normally, the result of the JS url replaces the existing contents on the | 8847 // Normally, the result of the JS url replaces the existing contents on the |
| 8814 // Document. However, if the JS triggers a navigation, the contents should | 8848 // Document. However, if the JS triggers a navigation, the contents should |
| 8815 // not be replaced. | 8849 // not be replaced. |
| 8816 EXPECT_EQ("", toLocalFrame(helper.webViewImpl()->page()->mainFrame())->docum
ent()->documentElement()->innerText()); | 8850 EXPECT_EQ("", toLocalFrame(helper.webViewImpl()->page()->mainFrame())->docum
ent()->documentElement()->innerText()); |
| 8817 } | 8851 } |
| 8818 | 8852 |
| 8819 } // namespace blink | 8853 } // namespace blink |
| OLD | NEW |