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

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

Issue 788073004: Replace RenderFullscreen with top layer - Take II (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Updated after review comments. Created 6 years 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 | Annotate | Revision Log
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 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
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/loader/DocumentThreadableLoader.h" 64 #include "core/loader/DocumentThreadableLoader.h"
65 #include "core/loader/DocumentThreadableLoaderClient.h" 65 #include "core/loader/DocumentThreadableLoaderClient.h"
66 #include "core/loader/FrameLoadRequest.h" 66 #include "core/loader/FrameLoadRequest.h"
67 #include "core/loader/ThreadableLoader.h" 67 #include "core/loader/ThreadableLoader.h"
68 #include "core/page/EventHandler.h" 68 #include "core/page/EventHandler.h"
69 #include "core/page/Page.h" 69 #include "core/page/Page.h"
70 #include "core/rendering/HitTestResult.h" 70 #include "core/rendering/HitTestResult.h"
71 #include "core/rendering/RenderFullScreen.h"
72 #include "core/rendering/RenderView.h" 71 #include "core/rendering/RenderView.h"
73 #include "core/rendering/compositing/RenderLayerCompositor.h" 72 #include "core/rendering/compositing/RenderLayerCompositor.h"
74 #include "core/testing/NullExecutionContext.h" 73 #include "core/testing/NullExecutionContext.h"
75 #include "core/testing/URLTestHelpers.h" 74 #include "core/testing/URLTestHelpers.h"
76 #include "modules/mediastream/MediaStream.h" 75 #include "modules/mediastream/MediaStream.h"
77 #include "modules/mediastream/MediaStreamRegistry.h" 76 #include "modules/mediastream/MediaStreamRegistry.h"
78 #include "platform/DragImage.h" 77 #include "platform/DragImage.h"
79 #include "platform/RuntimeEnabledFeatures.h" 78 #include "platform/RuntimeEnabledFeatures.h"
80 #include "platform/UserGestureIndicator.h" 79 #include "platform/UserGestureIndicator.h"
81 #include "platform/geometry/FloatRect.h" 80 #include "platform/geometry/FloatRect.h"
(...skipping 6083 matching lines...) Expand 10 before | Expand all | Expand 10 after
6165 // Show the top controls by just 1px, since we're zoomed in to 2X, that 6164 // Show the top controls by just 1px, since we're zoomed in to 2X, that
6166 // should allow an extra 0.5px of scrolling, but since we quantize to ints 6165 // should allow an extra 0.5px of scrolling, but since we quantize to ints
6167 // it should clamp such that we don't show anything outside bounds. 6166 // it should clamp such that we don't show anything outside bounds.
6168 webView->applyViewportDeltas(WebSize(0, 0), 1.0f, 1.0f); 6167 webView->applyViewportDeltas(WebSize(0, 0), 1.0f, 1.0f);
6169 EXPECT_POINT_EQ(IntPoint(50, 50), frameView->maximumScrollPosition()); 6168 EXPECT_POINT_EQ(IntPoint(50, 50), frameView->maximumScrollPosition());
6170 6169
6171 webView->applyViewportDeltas(WebSize(0, 0), 1.0f, 2.0f); 6170 webView->applyViewportDeltas(WebSize(0, 0), 1.0f, 2.0f);
6172 EXPECT_POINT_EQ(IntPoint(50, 51), frameView->maximumScrollPosition()); 6171 EXPECT_POINT_EQ(IntPoint(50, 51), frameView->maximumScrollPosition());
6173 } 6172 }
6174 6173
6174 TEST_F(WebFrameTest, FullscreenCleanTopLayerAndFullscreenStack)
6175 {
6176 FakeCompositingWebViewClient client;
6177 registerMockedHttpURLLoad("fullscreen_div.html");
6178 FrameTestHelpers::WebViewHelper webViewHelper;
6179 int viewportWidth = 640;
6180 int viewportHeight = 480;
6181 client.m_screenInfo.rect.width = viewportWidth;
6182 client.m_screenInfo.rect.height = viewportHeight;
6183 WebViewImpl* webViewImpl = webViewHelper.initializeAndLoad(m_baseURL + "full screen_div.html", true, 0, &client, configurePinchVirtualViewport);
6184 webViewImpl->resize(WebSize(viewportWidth, viewportHeight));
6185 webViewImpl->layout();
6186
6187 UserGestureIndicator gesture(DefinitelyProcessingUserGesture);
6188 Document* document = toWebLocalFrameImpl(webViewImpl->mainFrame())->frame()- >document();
6189 Fullscreen& fullscreen = Fullscreen::from(*document);
6190
6191 Element* divFullscreen = document->getElementById("div1");
6192 fullscreen.requestFullscreen(*divFullscreen, Fullscreen::PrefixedRequest);
6193 webViewImpl->didEnterFullScreen();
6194 ASSERT_TRUE(Fullscreen::isFullScreen(*document));
6195
6196 // Sanity check. We should have both in our stack.
6197 ASSERT_EQ(fullscreen.fullScreenElementStack().size(), 1UL);
6198 ASSERT_EQ(document->topLayerElements().size(), 2UL);
6199
6200 fullscreen.exitFullscreen();
6201 webViewImpl->didExitFullScreen();
6202
6203 ASSERT_EQ(fullscreen.fullScreenElementStack().size(), 0UL);
6204 ASSERT_EQ(document->topLayerElements().size(), 0UL);
6205 }
6206
6175 TEST_F(WebFrameTest, FullscreenLayerSize) 6207 TEST_F(WebFrameTest, FullscreenLayerSize)
6176 { 6208 {
6177 FakeCompositingWebViewClient client; 6209 FakeCompositingWebViewClient client;
6178 registerMockedHttpURLLoad("fullscreen_div.html"); 6210 registerMockedHttpURLLoad("fullscreen_div.html");
6179 FrameTestHelpers::WebViewHelper webViewHelper; 6211 FrameTestHelpers::WebViewHelper webViewHelper;
6180 int viewportWidth = 640; 6212 int viewportWidth = 640;
6181 int viewportHeight = 480; 6213 int viewportHeight = 480;
6182 client.m_screenInfo.rect.width = viewportWidth; 6214 client.m_screenInfo.rect.width = viewportWidth;
6183 client.m_screenInfo.rect.height = viewportHeight; 6215 client.m_screenInfo.rect.height = viewportHeight;
6184 WebViewImpl* webViewImpl = webViewHelper.initializeAndLoad(m_baseURL + "full screen_div.html", true, 0, &client, configurePinchVirtualViewport); 6216 WebViewImpl* webViewImpl = webViewHelper.initializeAndLoad(m_baseURL + "full screen_div.html", true, 0, &client, configurePinchVirtualViewport);
6185 webViewImpl->resize(WebSize(viewportWidth, viewportHeight)); 6217 webViewImpl->resize(WebSize(viewportWidth, viewportHeight));
6186 webViewImpl->layout(); 6218 webViewImpl->layout();
6187 6219
6188 Document* document = toWebLocalFrameImpl(webViewImpl->mainFrame())->frame()- >document(); 6220 Document* document = toWebLocalFrameImpl(webViewImpl->mainFrame())->frame()- >document();
6189 UserGestureIndicator gesture(DefinitelyProcessingUserGesture); 6221 UserGestureIndicator gesture(DefinitelyProcessingUserGesture);
6190 Element* divFullscreen = document->getElementById("div1"); 6222 Element* divFullscreen = document->getElementById("div1");
6191 Fullscreen::from(*document).requestFullscreen(*divFullscreen, Fullscreen::Pr efixedRequest); 6223 Fullscreen::from(*document).requestFullscreen(*divFullscreen, Fullscreen::Pr efixedRequest);
6192 webViewImpl->didEnterFullScreen(); 6224 webViewImpl->didEnterFullScreen();
6193 webViewImpl->layout(); 6225 webViewImpl->layout();
6194 ASSERT_TRUE(Fullscreen::isFullScreen(*document)); 6226 ASSERT_TRUE(Fullscreen::isFullScreen(*document));
6195 6227
6196 // Verify that the element is sized to the viewport. 6228 // Verify that the element is sized to the viewport.
6197 RenderFullScreen* fullscreenRenderer = Fullscreen::from(*document).fullScree nRenderer(); 6229 Element* fullscreenElement = Fullscreen::currentFullScreenElementFrom(*docum ent);
6230 RenderBox* fullscreenRenderer = toRenderBox(fullscreenElement->renderer());
6198 EXPECT_EQ(viewportWidth, fullscreenRenderer->logicalWidth().toInt()); 6231 EXPECT_EQ(viewportWidth, fullscreenRenderer->logicalWidth().toInt());
6199 EXPECT_EQ(viewportHeight, fullscreenRenderer->logicalHeight().toInt()); 6232 EXPECT_EQ(viewportHeight, fullscreenRenderer->logicalHeight().toInt());
6200 6233
6201 // Verify it's updated after a device rotation. 6234 // Verify it's updated after a device rotation.
6202 client.m_screenInfo.rect.width = viewportHeight; 6235 client.m_screenInfo.rect.width = viewportHeight;
6203 client.m_screenInfo.rect.height = viewportWidth; 6236 client.m_screenInfo.rect.height = viewportWidth;
6204 webViewImpl->resize(WebSize(viewportHeight, viewportWidth)); 6237 webViewImpl->resize(WebSize(viewportHeight, viewportWidth));
6205 webViewImpl->layout(); 6238 webViewImpl->layout();
6206 EXPECT_EQ(viewportHeight, fullscreenRenderer->logicalWidth().toInt()); 6239 EXPECT_EQ(viewportHeight, fullscreenRenderer->logicalWidth().toInt());
6207 EXPECT_EQ(viewportWidth, fullscreenRenderer->logicalHeight().toInt()); 6240 EXPECT_EQ(viewportWidth, fullscreenRenderer->logicalHeight().toInt());
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
6286 webViewImpl->layout(); 6319 webViewImpl->layout();
6287 6320
6288 Document* document = toWebLocalFrameImpl(webViewHelper.webView()->mainFrame( )->firstChild())->frame()->document(); 6321 Document* document = toWebLocalFrameImpl(webViewHelper.webView()->mainFrame( )->firstChild())->frame()->document();
6289 UserGestureIndicator gesture(DefinitelyProcessingUserGesture); 6322 UserGestureIndicator gesture(DefinitelyProcessingUserGesture);
6290 Element* divFullscreen = document->getElementById("div1"); 6323 Element* divFullscreen = document->getElementById("div1");
6291 Fullscreen::from(*document).requestFullscreen(*divFullscreen, Fullscreen::Pr efixedRequest); 6324 Fullscreen::from(*document).requestFullscreen(*divFullscreen, Fullscreen::Pr efixedRequest);
6292 webViewImpl->didEnterFullScreen(); 6325 webViewImpl->didEnterFullScreen();
6293 webViewImpl->layout(); 6326 webViewImpl->layout();
6294 6327
6295 // Verify that the element is sized to the viewport. 6328 // Verify that the element is sized to the viewport.
6296 RenderFullScreen* fullscreenRenderer = Fullscreen::from(*document).fullScree nRenderer(); 6329 Element* fullscreenElement = Fullscreen::currentFullScreenElementFrom(*docum ent);
6330 RenderBox* fullscreenRenderer = toRenderBox(fullscreenElement->renderer());
6297 EXPECT_EQ(viewportWidth, fullscreenRenderer->logicalWidth().toInt()); 6331 EXPECT_EQ(viewportWidth, fullscreenRenderer->logicalWidth().toInt());
6298 EXPECT_EQ(viewportHeight, fullscreenRenderer->logicalHeight().toInt()); 6332 EXPECT_EQ(viewportHeight, fullscreenRenderer->logicalHeight().toInt());
6299 6333
6300 // Verify it's updated after a device rotation. 6334 // Verify it's updated after a device rotation.
6301 client.m_screenInfo.rect.width = viewportHeight; 6335 client.m_screenInfo.rect.width = viewportHeight;
6302 client.m_screenInfo.rect.height = viewportWidth; 6336 client.m_screenInfo.rect.height = viewportWidth;
6303 webViewImpl->resize(WebSize(viewportHeight, viewportWidth)); 6337 webViewImpl->resize(WebSize(viewportHeight, viewportWidth));
6304 webViewImpl->layout(); 6338 webViewImpl->layout();
6305 EXPECT_EQ(viewportHeight, fullscreenRenderer->logicalWidth().toInt()); 6339 EXPECT_EQ(viewportHeight, fullscreenRenderer->logicalWidth().toInt());
6306 EXPECT_EQ(viewportWidth, fullscreenRenderer->logicalHeight().toInt()); 6340 EXPECT_EQ(viewportWidth, fullscreenRenderer->logicalHeight().toInt());
(...skipping 617 matching lines...) Expand 10 before | Expand all | Expand 10 after
6924 EXPECT_EQ(1u, frameClient.navigationalDataReceivedCount()); 6958 EXPECT_EQ(1u, frameClient.navigationalDataReceivedCount());
6925 6959
6926 // Neither should a page reload. 6960 // Neither should a page reload.
6927 localFrame->reload(); 6961 localFrame->reload();
6928 EXPECT_EQ(4u, frameClient.provisionalLoadCount()); 6962 EXPECT_EQ(4u, frameClient.provisionalLoadCount());
6929 EXPECT_FALSE(frameClient.wasLastProvisionalLoadATransition()); 6963 EXPECT_FALSE(frameClient.wasLastProvisionalLoadATransition());
6930 EXPECT_EQ(1u, frameClient.navigationalDataReceivedCount()); 6964 EXPECT_EQ(1u, frameClient.navigationalDataReceivedCount());
6931 } 6965 }
6932 6966
6933 } // namespace 6967 } // namespace
OLDNEW
« Source/web/FullscreenController.cpp ('K') | « Source/web/FullscreenController.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698