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

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

Issue 2202493002: NOT FOR REVIEW: Fullscreen WIP (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 4 years, 1 month 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 | « third_party/WebKit/Source/web/WebRemoteFrameImpl.cpp ('k') | no next file » | 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 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
58 #include "core/frame/LocalFrame.h" 58 #include "core/frame/LocalFrame.h"
59 #include "core/frame/RemoteFrame.h" 59 #include "core/frame/RemoteFrame.h"
60 #include "core/frame/Settings.h" 60 #include "core/frame/Settings.h"
61 #include "core/frame/VisualViewport.h" 61 #include "core/frame/VisualViewport.h"
62 #include "core/html/HTMLBodyElement.h" 62 #include "core/html/HTMLBodyElement.h"
63 #include "core/html/HTMLFormElement.h" 63 #include "core/html/HTMLFormElement.h"
64 #include "core/html/HTMLMediaElement.h" 64 #include "core/html/HTMLMediaElement.h"
65 #include "core/html/ImageDocument.h" 65 #include "core/html/ImageDocument.h"
66 #include "core/input/EventHandler.h" 66 #include "core/input/EventHandler.h"
67 #include "core/layout/HitTestResult.h" 67 #include "core/layout/HitTestResult.h"
68 #include "core/layout/LayoutFullScreen.h"
69 #include "core/layout/api/LayoutViewItem.h" 68 #include "core/layout/api/LayoutViewItem.h"
70 #include "core/layout/compositing/PaintLayerCompositor.h" 69 #include "core/layout/compositing/PaintLayerCompositor.h"
71 #include "core/loader/DocumentLoader.h" 70 #include "core/loader/DocumentLoader.h"
72 #include "core/loader/DocumentThreadableLoader.h" 71 #include "core/loader/DocumentThreadableLoader.h"
73 #include "core/loader/DocumentThreadableLoaderClient.h" 72 #include "core/loader/DocumentThreadableLoaderClient.h"
74 #include "core/loader/FrameLoadRequest.h" 73 #include "core/loader/FrameLoadRequest.h"
75 #include "core/loader/ThreadableLoader.h" 74 #include "core/loader/ThreadableLoader.h"
76 #include "core/page/Page.h" 75 #include "core/page/Page.h"
77 #include "core/page/ScopedPageLoadDeferrer.h" 76 #include "core/page/ScopedPageLoadDeferrer.h"
78 #include "core/paint/PaintLayer.h" 77 #include "core/paint/PaintLayer.h"
(...skipping 7387 matching lines...) Expand 10 before | Expand all | Expand 10 after
7466 webViewHelper.webView()->settings()->setWideViewportQuirkEnabled(true); 7465 webViewHelper.webView()->settings()->setWideViewportQuirkEnabled(true);
7467 webViewHelper.webView()->settings()->setLoadWithOverviewMode(true); 7466 webViewHelper.webView()->settings()->setLoadWithOverviewMode(true);
7468 webViewHelper.webView()->settings()->setUseWideViewport(true); 7467 webViewHelper.webView()->settings()->setUseWideViewport(true);
7469 webViewHelper.resize(WebSize(viewportWidth, viewportHeight)); 7468 webViewHelper.resize(WebSize(viewportWidth, viewportHeight));
7470 webViewHelper.webView()->updateAllLifecyclePhases(); 7469 webViewHelper.webView()->updateAllLifecyclePhases();
7471 7470
7472 FrameView* frameView = webViewHelper.webView()->mainFrameImpl()->frameView(); 7471 FrameView* frameView = webViewHelper.webView()->mainFrameImpl()->frameView();
7473 EXPECT_LT(frameView->maximumScrollOffset().width(), 0); 7472 EXPECT_LT(frameView->maximumScrollOffset().width(), 0);
7474 } 7473 }
7475 7474
7475 TEST_F(WebFrameTest, FullscreenCleanTopLayerAndFullscreenStack) {
7476 FakeCompositingWebViewClient client;
7477 registerMockedHttpURLLoad("fullscreen_div.html");
7478 FrameTestHelpers::WebViewHelper webViewHelper;
7479 int viewportWidth = 640;
7480 int viewportHeight = 480;
7481 client.m_screenInfo.rect.width = viewportWidth;
7482 client.m_screenInfo.rect.height = viewportHeight;
7483 WebViewImpl* webViewImpl =
7484 webViewHelper.initializeAndLoad(m_baseURL + "fullscreen_div.html", true,
7485 0, &client, nullptr, configureAndroid);
7486 webViewImpl->resize(WebSize(viewportWidth, viewportHeight));
7487 webViewImpl->updateAllLifecyclePhases();
7488
7489 Document* document = webViewImpl->mainFrameImpl()->frame()->document();
7490 UserGestureIndicator gesture(DocumentUserGestureToken::create(document));
7491 Element* divFullscreen = document->getElementById("div1");
7492 Fullscreen::requestFullscreen(*divFullscreen, Fullscreen::PrefixedRequest);
7493 webViewImpl->didEnterFullscreen();
7494 ASSERT_EQ(Fullscreen::fullscreenElement(*document), divFullscreen);
7495
7496 // Sanity check. We should have both in our stack.
7497 ASSERT_EQ(document->topLayerElements().size(), 2UL);
7498
7499 Fullscreen::exitFullscreen(*document);
7500 webViewImpl->didExitFullscreen();
7501
7502 ASSERT_EQ(document->topLayerElements().size(), 0UL);
7503 }
7504
7476 TEST_P(ParameterizedWebFrameTest, FullscreenLayerSize) { 7505 TEST_P(ParameterizedWebFrameTest, FullscreenLayerSize) {
7477 FakeCompositingWebViewClient client; 7506 FakeCompositingWebViewClient client;
7478 registerMockedHttpURLLoad("fullscreen_div.html"); 7507 registerMockedHttpURLLoad("fullscreen_div.html");
7479 FrameTestHelpers::WebViewHelper webViewHelper; 7508 FrameTestHelpers::WebViewHelper webViewHelper;
7480 int viewportWidth = 640; 7509 int viewportWidth = 640;
7481 int viewportHeight = 480; 7510 int viewportHeight = 480;
7482 client.m_screenInfo.rect.width = viewportWidth; 7511 client.m_screenInfo.rect.width = viewportWidth;
7483 client.m_screenInfo.rect.height = viewportHeight; 7512 client.m_screenInfo.rect.height = viewportHeight;
7484 WebViewImpl* webViewImpl = webViewHelper.initializeAndLoad( 7513 WebViewImpl* webViewImpl = webViewHelper.initializeAndLoad(
7485 m_baseURL + "fullscreen_div.html", true, nullptr, &client, nullptr, 7514 m_baseURL + "fullscreen_div.html", true, nullptr, &client, nullptr,
7486 configureAndroid); 7515 configureAndroid);
7487 webViewHelper.resize(WebSize(viewportWidth, viewportHeight)); 7516 webViewHelper.resize(WebSize(viewportWidth, viewportHeight));
7488 webViewImpl->updateAllLifecyclePhases(); 7517 webViewImpl->updateAllLifecyclePhases();
7489 7518
7490 Document* document = webViewImpl->mainFrameImpl()->frame()->document(); 7519 Document* document = webViewImpl->mainFrameImpl()->frame()->document();
7491 UserGestureIndicator gesture(DocumentUserGestureToken::create(document)); 7520 UserGestureIndicator gesture(DocumentUserGestureToken::create(document));
7492 Element* divFullscreen = document->getElementById("div1"); 7521 Element* divFullscreen = document->getElementById("div1");
7493 Fullscreen::requestFullscreen(*divFullscreen, Fullscreen::PrefixedRequest); 7522 Fullscreen::requestFullscreen(*divFullscreen, Fullscreen::PrefixedRequest);
7494 webViewImpl->didEnterFullscreen(); 7523 webViewImpl->didEnterFullscreen();
7495 webViewImpl->updateAllLifecyclePhases(); 7524 webViewImpl->updateAllLifecyclePhases();
7496 EXPECT_EQ(Fullscreen::currentFullScreenElementFrom(*document), divFullscreen); 7525 EXPECT_EQ(Fullscreen::fullscreenElement(*document), divFullscreen);
7497 7526
7498 // Verify that the element is sized to the viewport. 7527 // Verify that the element is sized to the viewport.
7499 LayoutFullScreen* fullscreenLayoutObject = 7528 Element* fullscreenElement = Fullscreen::fullscreenElement(*document);
7500 Fullscreen::from(*document).fullScreenLayoutObject(); 7529 LayoutBox* fullscreenLayoutObject =
7530 toLayoutBox(fullscreenElement->layoutObject());
7501 EXPECT_EQ(viewportWidth, fullscreenLayoutObject->logicalWidth().toInt()); 7531 EXPECT_EQ(viewportWidth, fullscreenLayoutObject->logicalWidth().toInt());
7502 EXPECT_EQ(viewportHeight, fullscreenLayoutObject->logicalHeight().toInt()); 7532 EXPECT_EQ(viewportHeight, fullscreenLayoutObject->logicalHeight().toInt());
7503 7533
7504 // Verify it's updated after a device rotation. 7534 // Verify it's updated after a device rotation.
7505 client.m_screenInfo.rect.width = viewportHeight; 7535 client.m_screenInfo.rect.width = viewportHeight;
7506 client.m_screenInfo.rect.height = viewportWidth; 7536 client.m_screenInfo.rect.height = viewportWidth;
7507 webViewHelper.resize(WebSize(viewportHeight, viewportWidth)); 7537 webViewHelper.resize(WebSize(viewportHeight, viewportWidth));
7508 webViewImpl->updateAllLifecyclePhases(); 7538 webViewImpl->updateAllLifecyclePhases();
7509 EXPECT_EQ(viewportHeight, fullscreenLayoutObject->logicalWidth().toInt()); 7539 EXPECT_EQ(viewportHeight, fullscreenLayoutObject->logicalWidth().toInt());
7510 EXPECT_EQ(viewportWidth, fullscreenLayoutObject->logicalHeight().toInt()); 7540 EXPECT_EQ(viewportWidth, fullscreenLayoutObject->logicalHeight().toInt());
(...skipping 12 matching lines...) Expand all
7523 webViewImpl->updateAllLifecyclePhases(); 7553 webViewImpl->updateAllLifecyclePhases();
7524 7554
7525 Document* document = webViewImpl->mainFrameImpl()->frame()->document(); 7555 Document* document = webViewImpl->mainFrameImpl()->frame()->document();
7526 UserGestureIndicator gesture(DocumentUserGestureToken::create(document)); 7556 UserGestureIndicator gesture(DocumentUserGestureToken::create(document));
7527 Element* divFullscreen = document->getElementById("div1"); 7557 Element* divFullscreen = document->getElementById("div1");
7528 Fullscreen::requestFullscreen(*divFullscreen, Fullscreen::PrefixedRequest); 7558 Fullscreen::requestFullscreen(*divFullscreen, Fullscreen::PrefixedRequest);
7529 webViewImpl->didEnterFullscreen(); 7559 webViewImpl->didEnterFullscreen();
7530 webViewImpl->updateAllLifecyclePhases(); 7560 webViewImpl->updateAllLifecyclePhases();
7531 7561
7532 // Verify that the viewports are nonscrollable. 7562 // Verify that the viewports are nonscrollable.
7533 EXPECT_EQ(Fullscreen::currentFullScreenElementFrom(*document), divFullscreen); 7563 EXPECT_EQ(Fullscreen::fullscreenElement(*document), divFullscreen);
7534 FrameView* frameView = webViewHelper.webView()->mainFrameImpl()->frameView(); 7564 FrameView* frameView = webViewHelper.webView()->mainFrameImpl()->frameView();
7535 WebLayer* layoutViewportScrollLayer = 7565 WebLayer* layoutViewportScrollLayer =
7536 webViewImpl->compositor()->scrollLayer()->platformLayer(); 7566 webViewImpl->compositor()->scrollLayer()->platformLayer();
7537 WebLayer* visualViewportScrollLayer = frameView->page() 7567 WebLayer* visualViewportScrollLayer = frameView->page()
7538 ->frameHost() 7568 ->frameHost()
7539 .visualViewport() 7569 .visualViewport()
7540 .scrollLayer() 7570 .scrollLayer()
7541 ->platformLayer(); 7571 ->platformLayer();
7542 ASSERT_FALSE(layoutViewportScrollLayer->userScrollableHorizontal()); 7572 ASSERT_FALSE(layoutViewportScrollLayer->userScrollableHorizontal());
7543 ASSERT_FALSE(layoutViewportScrollLayer->userScrollableVertical()); 7573 ASSERT_FALSE(layoutViewportScrollLayer->userScrollableVertical());
7544 ASSERT_FALSE(visualViewportScrollLayer->userScrollableHorizontal()); 7574 ASSERT_FALSE(visualViewportScrollLayer->userScrollableHorizontal());
7545 ASSERT_FALSE(visualViewportScrollLayer->userScrollableVertical()); 7575 ASSERT_FALSE(visualViewportScrollLayer->userScrollableVertical());
7546 7576
7547 // Verify that the viewports are scrollable upon exiting fullscreen. 7577 // Verify that the viewports are scrollable upon exiting fullscreen.
7548 webViewImpl->didExitFullscreen(); 7578 webViewImpl->didExitFullscreen();
7549 webViewImpl->updateAllLifecyclePhases(); 7579 webViewImpl->updateAllLifecyclePhases();
7550 EXPECT_EQ(Fullscreen::currentFullScreenElementFrom(*document), nullptr); 7580 EXPECT_EQ(Fullscreen::fullscreenElement(*document), nullptr);
7551 ASSERT_TRUE(layoutViewportScrollLayer->userScrollableHorizontal()); 7581 ASSERT_TRUE(layoutViewportScrollLayer->userScrollableHorizontal());
7552 ASSERT_TRUE(layoutViewportScrollLayer->userScrollableVertical()); 7582 ASSERT_TRUE(layoutViewportScrollLayer->userScrollableVertical());
7553 ASSERT_TRUE(visualViewportScrollLayer->userScrollableHorizontal()); 7583 ASSERT_TRUE(visualViewportScrollLayer->userScrollableHorizontal());
7554 ASSERT_TRUE(visualViewportScrollLayer->userScrollableVertical()); 7584 ASSERT_TRUE(visualViewportScrollLayer->userScrollableVertical());
7555 } 7585 }
7556 7586
7557 TEST_P(ParameterizedWebFrameTest, FullscreenMainFrame) { 7587 TEST_P(ParameterizedWebFrameTest, FullscreenMainFrame) {
7558 FakeCompositingWebViewClient client; 7588 FakeCompositingWebViewClient client;
7559 registerMockedHttpURLLoad("fullscreen_div.html"); 7589 registerMockedHttpURLLoad("fullscreen_div.html");
7560 FrameTestHelpers::WebViewHelper webViewHelper; 7590 FrameTestHelpers::WebViewHelper webViewHelper;
7561 int viewportWidth = 640; 7591 int viewportWidth = 640;
7562 int viewportHeight = 480; 7592 int viewportHeight = 480;
7563 WebViewImpl* webViewImpl = webViewHelper.initializeAndLoad( 7593 WebViewImpl* webViewImpl = webViewHelper.initializeAndLoad(
7564 m_baseURL + "fullscreen_div.html", true, nullptr, &client, nullptr, 7594 m_baseURL + "fullscreen_div.html", true, nullptr, &client, nullptr,
7565 configureAndroid); 7595 configureAndroid);
7566 webViewHelper.resize(WebSize(viewportWidth, viewportHeight)); 7596 webViewHelper.resize(WebSize(viewportWidth, viewportHeight));
7567 webViewImpl->updateAllLifecyclePhases(); 7597 webViewImpl->updateAllLifecyclePhases();
7568 7598
7569 Document* document = webViewImpl->mainFrameImpl()->frame()->document(); 7599 Document* document = webViewImpl->mainFrameImpl()->frame()->document();
7570 UserGestureIndicator gesture(DocumentUserGestureToken::create(document)); 7600 UserGestureIndicator gesture(DocumentUserGestureToken::create(document));
7571 Fullscreen::requestFullscreen(*document->documentElement(), 7601 Fullscreen::requestFullscreen(*document->documentElement(),
7572 Fullscreen::PrefixedRequest); 7602 Fullscreen::PrefixedRequest);
7573 webViewImpl->didEnterFullscreen(); 7603 webViewImpl->didEnterFullscreen();
7574 webViewImpl->updateAllLifecyclePhases(); 7604 webViewImpl->updateAllLifecyclePhases();
7575 7605
7576 // Verify that the main frame is still scrollable. 7606 // Verify that the main frame is still scrollable.
7577 EXPECT_EQ(Fullscreen::currentFullScreenElementFrom(*document), 7607 EXPECT_EQ(Fullscreen::fullscreenElement(*document),
7578 document->documentElement()); 7608 document->documentElement());
7579 WebLayer* webScrollLayer = 7609 WebLayer* webScrollLayer =
7580 webViewImpl->compositor()->scrollLayer()->platformLayer(); 7610 webViewImpl->compositor()->scrollLayer()->platformLayer();
7581 ASSERT_TRUE(webScrollLayer->scrollable()); 7611 ASSERT_TRUE(webScrollLayer->scrollable());
7582 ASSERT_TRUE(webScrollLayer->userScrollableHorizontal()); 7612 ASSERT_TRUE(webScrollLayer->userScrollableHorizontal());
7583 ASSERT_TRUE(webScrollLayer->userScrollableVertical()); 7613 ASSERT_TRUE(webScrollLayer->userScrollableVertical());
7584 7614
7585 // Verify the main frame still behaves correctly after a resize. 7615 // Verify the main frame still behaves correctly after a resize.
7586 webViewHelper.resize(WebSize(viewportHeight, viewportWidth)); 7616 webViewHelper.resize(WebSize(viewportHeight, viewportWidth));
7587 ASSERT_TRUE(webScrollLayer->scrollable()); 7617 ASSERT_TRUE(webScrollLayer->scrollable());
(...skipping 20 matching lines...) Expand all
7608 toWebLocalFrameImpl(webViewHelper.webView()->mainFrame()->firstChild()) 7638 toWebLocalFrameImpl(webViewHelper.webView()->mainFrame()->firstChild())
7609 ->frame() 7639 ->frame()
7610 ->document(); 7640 ->document();
7611 UserGestureIndicator gesture(DocumentUserGestureToken::create(document)); 7641 UserGestureIndicator gesture(DocumentUserGestureToken::create(document));
7612 Element* divFullscreen = document->getElementById("div1"); 7642 Element* divFullscreen = document->getElementById("div1");
7613 Fullscreen::requestFullscreen(*divFullscreen, Fullscreen::PrefixedRequest); 7643 Fullscreen::requestFullscreen(*divFullscreen, Fullscreen::PrefixedRequest);
7614 webViewImpl->didEnterFullscreen(); 7644 webViewImpl->didEnterFullscreen();
7615 webViewImpl->updateAllLifecyclePhases(); 7645 webViewImpl->updateAllLifecyclePhases();
7616 7646
7617 // Verify that the element is sized to the viewport. 7647 // Verify that the element is sized to the viewport.
7618 LayoutFullScreen* fullscreenLayoutObject = 7648 Element* fullscreenElement = Fullscreen::fullscreenElement(*document);
7619 Fullscreen::from(*document).fullScreenLayoutObject(); 7649 LayoutBox* fullscreenLayoutObject =
7650 toLayoutBox(fullscreenElement->layoutObject());
7620 EXPECT_EQ(viewportWidth, fullscreenLayoutObject->logicalWidth().toInt()); 7651 EXPECT_EQ(viewportWidth, fullscreenLayoutObject->logicalWidth().toInt());
7621 EXPECT_EQ(viewportHeight, fullscreenLayoutObject->logicalHeight().toInt()); 7652 EXPECT_EQ(viewportHeight, fullscreenLayoutObject->logicalHeight().toInt());
7622 7653
7623 // Verify it's updated after a device rotation. 7654 // Verify it's updated after a device rotation.
7624 client.m_screenInfo.rect.width = viewportHeight; 7655 client.m_screenInfo.rect.width = viewportHeight;
7625 client.m_screenInfo.rect.height = viewportWidth; 7656 client.m_screenInfo.rect.height = viewportWidth;
7626 webViewHelper.resize(WebSize(viewportHeight, viewportWidth)); 7657 webViewHelper.resize(WebSize(viewportHeight, viewportWidth));
7627 webViewImpl->updateAllLifecyclePhases(); 7658 webViewImpl->updateAllLifecyclePhases();
7628 EXPECT_EQ(viewportHeight, fullscreenLayoutObject->logicalWidth().toInt()); 7659 EXPECT_EQ(viewportHeight, fullscreenLayoutObject->logicalWidth().toInt());
7629 EXPECT_EQ(viewportWidth, fullscreenLayoutObject->logicalHeight().toInt()); 7660 EXPECT_EQ(viewportWidth, fullscreenLayoutObject->logicalHeight().toInt());
(...skipping 2723 matching lines...) Expand 10 before | Expand all | Expand 10 after
10353 Frame* mainFrame = webViewHelper.webView()->mainFrameImpl()->frame(); 10384 Frame* mainFrame = webViewHelper.webView()->mainFrameImpl()->frame();
10354 HashSet<AtomicString> names; 10385 HashSet<AtomicString> names;
10355 for (Frame* frame = mainFrame->tree().firstChild(); frame; 10386 for (Frame* frame = mainFrame->tree().firstChild(); frame;
10356 frame = frame->tree().traverseNext()) { 10387 frame = frame->tree().traverseNext()) {
10357 EXPECT_TRUE(names.add(frame->tree().uniqueName()).isNewEntry); 10388 EXPECT_TRUE(names.add(frame->tree().uniqueName()).isNewEntry);
10358 } 10389 }
10359 EXPECT_EQ(10u, names.size()); 10390 EXPECT_EQ(10u, names.size());
10360 } 10391 }
10361 10392
10362 } // namespace blink 10393 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/web/WebRemoteFrameImpl.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698