Commit 0884f324 authored by falken@chromium.org's avatar falken@chromium.org

Top layer fails for inline elements

https://bugs.webkit.org/show_bug.cgi?id=106538

Reviewed by Hajime Morita.

Source/WebCore:

This patch makes position 'static' and 'relative' compute to
'absolute' for elements in the top layer, as mandated by the
Fullscreen spec.[1] By doing so, we also fix a crash that occurred in
RenderLayer::rebuildZOrderLists when an inline element wrapped in an
anonymous block was added to the top layer.

[1]: http://fullscreen.spec.whatwg.org/#new-stacking-layer

Tests: fast/dom/HTMLDialogElement/element-removed-from-top-layer-has-original-position.html
       fast/dom/HTMLDialogElement/top-layer-position-relative.html
       fast/dom/HTMLDialogElement/top-layer-position-static.html

* css/StyleResolver.cpp:
(WebCore::StyleResolver::adjustRenderStyle): Set position 'absolute'
for an element in the top layer. Typically, absolutely positioned
elements also automatically get display 'block', but it seems we must do
that manually here. We require display 'block' to ensure the renderer is not
considered inline and consequently wrapped in an anonymous block.
* rendering/RenderLayer.cpp:
(WebCore::RenderLayer::rebuildZOrderLists): Check node() so we don't
crash on, e.g., an anonymous block. We don't expect top layer
renderers to have anonymous blocks anymore, but we nevertheless
shouldn't crash if some other renderer is parented by RenderView.

LayoutTests:

* fast/dom/HTMLDialogElement/element-removed-from-top-layer-has-original-position-expected.html: Added.
* fast/dom/HTMLDialogElement/element-removed-from-top-layer-has-original-position.html: Added.
* fast/dom/HTMLDialogElement/top-layer-position-relative-expected.html: Added.
* fast/dom/HTMLDialogElement/top-layer-position-relative.html: Added.
* fast/dom/HTMLDialogElement/top-layer-position-static-expected.html: Added.
* fast/dom/HTMLDialogElement/top-layer-position-static.html: Added.


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@140075 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent f3e7e0ca
2013-01-17 Matt Falkenhagen <falken@chromium.org>
Top layer fails for inline elements
https://bugs.webkit.org/show_bug.cgi?id=106538
Reviewed by Hajime Morita.
* fast/dom/HTMLDialogElement/element-removed-from-top-layer-has-original-position-expected.html: Added.
* fast/dom/HTMLDialogElement/element-removed-from-top-layer-has-original-position.html: Added.
* fast/dom/HTMLDialogElement/top-layer-position-relative-expected.html: Added.
* fast/dom/HTMLDialogElement/top-layer-position-relative.html: Added.
* fast/dom/HTMLDialogElement/top-layer-position-static-expected.html: Added.
* fast/dom/HTMLDialogElement/top-layer-position-static.html: Added.
2013-01-17 Alpha Lam <hclam@chromium.org>
[chromium] Test expectations update
<!DOCTYPE html>
<html>
<head>
<script>
if (window.internals)
internals.settings.setDialogElementEnabled(true);
</script>
<style>
.green {
color: green;
}
</style>
</head>
<body>
<p>Bug <a href="http://webkit.org/b/106538">106538</a>: Top layer fails for inline elements</p>
<p>This tests that position 'static' no longer computes to 'absolute' for an
element that has been removed from the top layer. The test passes if you see
a single line of text.</p>
<span class="green">This is the span.</span>
<span class="green">This is the dialog following it.</span>
</body>
</html>
<!DOCTYPE html>
<html>
<head>
<script>
if (window.internals)
internals.settings.setDialogElementEnabled(true);
</script>
<style>
.green {
color: green;
}
#right-dialog {
position: static;
border: none;
padding: 0;
margin: 0;
}
</style>
</head>
<body>
<p>Bug <a href="http://webkit.org/b/106538">106538</a>: Top layer fails for inline elements</p>
<p>This tests that position 'static' no longer computes to 'absolute' for an
element that has been removed from the top layer. The test passes if you see
a single line of text.</p>
<span class="green">This is the span.</span>
<dialog class="green" id="right-dialog">This is the dialog following it.</dialog>
<script>
var dialog = document.getElementById('right-dialog');
dialog.showModal();
dialog.close();
dialog.show();
</script>
</body>
</html>
<!DOCTYPE html>
<html>
<head>
<style>
div {
background-color: green;
position: absolute;
top: 100px;
left: 100px;
height: 50px;
width: 150px;
}
</style>
</head>
<body>
<p>Bug <a href="http://webkit.org/b/106538">106538</a>: Top layer fails for inline elements
<p>This tests that position 'relative' computes to 'absolute' in the top layer. The test passes if you see a single green box.</p>
<div></div>
</body>
</html>
<!DOCTYPE html>
<html>
<head>
<script>
if (window.internals)
internals.settings.setDialogElementEnabled(true);
</script>
<style>
.green-box {
background-color: green;
height: 50px;
width: 50px;
border: none;
padding: 0;
margin: 0;
}
#left-div {
position: absolute;
top: 100px;
left: 100px;
}
#middle-dialog {
position: relative;
top: 100px;
left: 150px;
}
#right-dialog {
position: relative;
top: 100px;
left: 200px;
}
</style>
</head>
<body>
<p>Bug <a href="http://webkit.org/b/106538">106538</a>: Top layer fails for inline elements
<p>This tests that position 'relative' computes to 'absolute' in the top layer. The test passes if you see a single green box.</p>
<div id="left-div" class="green-box"></div>
<dialog id="middle-dialog" class="green-box"></dialog>
<dialog id="right-dialog" class="green-box"></dialog>
<script>
document.getElementById('middle-dialog').showModal();
var rightDialog = document.getElementById('right-dialog');
rightDialog.showModal();
rightDialog.style.position = 'absolute';
</script>
</body>
</html>
<!DOCTYPE html>
<html>
<head>
<style>
div {
background-color: green;
position: absolute;
top: 100px;
left: 100px;
height: 50px;
width: 150px;
}
</style>
</head>
<body>
<p>Bug <a href="http://webkit.org/b/106538">106538</a>: Top layer fails for inline elements
<p>This tests that position 'static' computes to 'absolute' in the top layer. The test passes if you see a single green box.</p>
<div></div>
</body>
</html>
<!DOCTYPE html>
<html>
<head>
<script>
if (window.internals)
internals.settings.setDialogElementEnabled(true);
</script>
<style>
.green-box {
background-color: green;
height: 50px;
width: 50px;
border: none;
padding: 0;
margin: 0;
}
#left-div {
position: absolute;
top: 100px;
left: 100px;
}
#middle-dialog {
position: static;
top: 100px;
left: 150px;
}
#right-dialog {
position: static;
top: 100px;
left: 200px;
}
</style>
</head>
<body>
<p>Bug <a href="http://webkit.org/b/106538">106538</a>: Top layer fails for inline elements
<p>This tests that position 'static' computes to 'absolute' in the top layer. The test passes if you see a single green box.</p>
<div id="left-div" class="green-box"></div>
<dialog id="middle-dialog" class="green-box"></dialog>
<dialog id="right-dialog" class="green-box"></dialog>
<script>
document.getElementById('middle-dialog').showModal();
var rightDialog = document.getElementById('right-dialog');
rightDialog.showModal();
rightDialog.style.position = 'absolute';
</script>
</body>
</html>
2013-01-17 Matt Falkenhagen <falken@chromium.org>
Top layer fails for inline elements
https://bugs.webkit.org/show_bug.cgi?id=106538
Reviewed by Hajime Morita.
This patch makes position 'static' and 'relative' compute to
'absolute' for elements in the top layer, as mandated by the
Fullscreen spec.[1] By doing so, we also fix a crash that occurred in
RenderLayer::rebuildZOrderLists when an inline element wrapped in an
anonymous block was added to the top layer.
[1]: http://fullscreen.spec.whatwg.org/#new-stacking-layer
Tests: fast/dom/HTMLDialogElement/element-removed-from-top-layer-has-original-position.html
fast/dom/HTMLDialogElement/top-layer-position-relative.html
fast/dom/HTMLDialogElement/top-layer-position-static.html
* css/StyleResolver.cpp:
(WebCore::StyleResolver::adjustRenderStyle): Set position 'absolute'
for an element in the top layer. Typically, absolutely positioned
elements also automatically get display 'block', but it seems we must do
that manually here. We require display 'block' to ensure the renderer is not
considered inline and consequently wrapped in an anonymous block.
* rendering/RenderLayer.cpp:
(WebCore::RenderLayer::rebuildZOrderLists): Check node() so we don't
crash on, e.g., an anonymous block. We don't expect top layer
renderers to have anonymous blocks anymore, but we nevertheless
shouldn't crash if some other renderer is parented by RenderView.
2013-01-17 Simon Fraser <simon.fraser@apple.com>
Fix crash accessing RenderView's layer's backing when not composited
......@@ -2003,6 +2003,14 @@ void StyleResolver::adjustRenderStyle(RenderStyle* style, RenderStyle* parentSty
style->setFloating(NoFloat);
style->setDisplay(equivalentBlockDisplay(style->display(), style->isFloating(), m_selectorChecker.strictParsing()));
}
#if ENABLE(DIALOG_ELEMENT)
// Per the spec, position 'static' and 'relative' in the top layer compute to 'absolute'.
if (e && e->isInTopLayer() && (style->position() == StaticPosition || style->position() == RelativePosition)) {
style->setPosition(AbsolutePosition);
style->setDisplay(BLOCK);
}
#endif
}
// Make sure our z-index value is only applied if the object is positioned.
......
......@@ -5153,7 +5153,7 @@ void RenderLayer::rebuildZOrderLists()
if (isRootLayer()) {
RenderObject* view = renderer()->view();
for (RenderObject* child = view->firstChild(); child; child = child->nextSibling()) {
Element* childElement = child->node()->isElementNode() ? toElement(child->node()) : 0;
Element* childElement = (child->node() && child->node()->isElementNode()) ? toElement(child->node()) : 0;
if (childElement && childElement->isInTopLayer()) {
RenderLayer* layer = toRenderLayerModelObject(child)->layer();
m_posZOrderList->append(layer);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment