haikuwebkit/LayoutTests/fullscreen/full-screen-placeholder.html

74 lines
2.5 KiB
HTML
Raw Permalink Normal View History

2011-06-01 Jer Noble <jer.noble@apple.com> Reviewed by Simon Fraser. Flash of broken page when exiting full screen at jerryseinfeld.com https://bugs.webkit.org/show_bug.cgi?id=61897 <rdar://problem/9522985> * fullscreen/full-screen-placeholder-expected.txt: Added. * fullscreen/full-screen-placeholder.html: Added. 2011-06-01 Jer Noble <jer.noble@apple.com> Reviewed by Simon Fraser. Flash of broken page when exiting full screen at jerryseinfeld.com https://bugs.webkit.org/show_bug.cgi?id=61897 <rdar://problem/9522985> Test: fullscreen/full-screen-placeholder.html Entering full-screen mode is causing the page layout to change because the full-screen element is taken out of the normal flow. To counteract this effect, insert a placeholder block as a parent of the full-screen renderer with the same size and style as the full-screen element pre-full-screen. Only create a placeholder for block-level elements; the technique required for inline elements would be vastly more complicated. * dom/Document.cpp: (WebCore::Document::webkitWillEnterFullScreenForElement): Create a placeholder based on the size and style of the full-screen element. (WebCore::Document::setFullScreenRenderer): Persist the placeholder size and style across new renderers. * rendering/RenderFullScreen.cpp: (RenderFullScreen::RenderFullScreen): Added ivar. (RenderFullScreen::destroy): Make sure to safely destroy our placeholder. (RenderFullScreen::createPlaceholder): Added. * rendering/RenderFullScreen.h: (WebCore::RenderFullScreen::placeholder): Ivar accessor. Canonical link: https://commits.webkit.org/77499@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@88034 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2011-06-03 18:48:15 +00:00
<script src="full-screen-test.js"></script>
<style>
#float {
margin: 10px 0 0 10px;
height: 50px;
width: 50px;
float: left;
background-color: red;
}
#clear {
clear:left;
}
#one {
background-color: lightblue;
float: left;
}
#two {
background-color: lightgreen;
}
</style>
<body>
<div>This layout test checks that the offset positions of the blue and green divs does not change when the red div enters full-screen mode. Press <button onclick="document.getElementById('float').webkitRequestFullScreen()">go full-screen</a> to begin.</div>
<div id="float"></div>
<div id="one">One</div>
<div id="clear" />
<span id="two">Two</span>
<script>
var one = document.getElementById('one');
var two = document.getElementById('two');
// Bail out early if the full screen API is not enabled or is missing:
if (Element.prototype.webkitRequestFullScreen == undefined) {
logResult(false, "Element.prototype.webkitRequestFullScreen == undefined");
endTest();
} else {
var oneState = {'offsetLeft': one.offsetLeft, 'offsetTop': one.offsetTop };
var twoState = {'offsetLeft': two.offsetLeft, 'offsetTop': two.offsetTop };
var callback;
var fullscreenChanged = function(event)
{
if (callback)
callback(event)
};
waitForEvent(document, 'webkitfullscreenchange', fullscreenChanged);
var div = document.getElementById('float');
var divEnteredFullScreen = function() {
testExpected("document.webkitCurrentFullScreenElement", div);
testExpected("one.offsetLeft", oneState.offsetLeft);
testExpected("one.offsetTop", oneState.offsetTop);
testExpected("two.offsetLeft", twoState.offsetLeft);
testExpected("two.offsetTop", twoState.offsetTop);
callback = cancelledFullScreen;
runWithKeyDown(function(){document.webkitCancelFullScreen()});
};
var cancelledFullScreen = function() {
testExpected("document.webkitCurrentFullScreenElement", null);
testExpected("one.offsetLeft", oneState.offsetLeft);
testExpected("one.offsetTop", oneState.offsetTop);
testExpected("two.offsetLeft", twoState.offsetLeft);
testExpected("two.offsetTop", twoState.offsetTop);
callback = null;
endTest();
};
callback = divEnteredFullScreen;
runWithKeyDown(function(){div.webkitRequestFullScreen()});
}
</script>