Elements must be reattached when inserted/removed from top layer
authorfalken@chromium.org <falken@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 11 Jan 2013 04:46:21 +0000 (04:46 +0000)
committerfalken@chromium.org <falken@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 11 Jan 2013 04:46:21 +0000 (04:46 +0000)
commite1193601fb8c7e5032bf9f816ad85aeb1b387726
tree6e67f235f045a5a7d4cb42b97dac855051f5e688
parent93b126a3329a3a5169a052452d29baaa4f60f4bb
Elements must be reattached when inserted/removed from top layer
https://bugs.webkit.org/show_bug.cgi?id=105489

Reviewed by Julien Chaffraix.

Source/WebCore:

Ensure a reattach occurs when an element is inserted/removed from top layer, so its renderer can be inserted correctly:
as a child of RenderView in top layer sibling order if it's in the top layer, and in the usual place otherwise.

We previously relied on style recalc to catch when an element is inserted/removed from the top layer, because it
only happens on dialog.show/close which toggle display: none. But that is incorrect because, for example, close()
followed immediately by show() results in no style change.

Tests: fast/dom/HTMLDialogElement/removed-element-is-removed-from-top-layer.html
       fast/dom/HTMLDialogElement/top-layer-stacking-correct-order-remove-readd.html

* dom/Element.cpp:
(WebCore::Element::removedFrom): Call Document::removeFromTopLayer to let the element be removed from the top layer vector.
removeFromTopLayer calls Element::setIsInTopLayer(false) itself if needed.
(WebCore::Element::setIsInTopLayer): Ensure a reattach occurs if the element is already attached.

LayoutTests:

* fast/dom/HTMLDialogElement/removed-element-is-removed-from-top-layer-expected.html: Added.
* fast/dom/HTMLDialogElement/removed-element-is-removed-from-top-layer.html: Added.
This tests that a top layer element removed from the document does not reappear in the top layer if readded.
This test actually would pass before this patch, but just by good fortune (see bug).
* fast/dom/HTMLDialogElement/top-layer-stacking-correct-order-remove-readd-expected.html: Added.
* fast/dom/HTMLDialogElement/top-layer-stacking-correct-order-remove-readd.html: Added.
This tests that top layer ordering is correct after removing and readding an element to the top layer.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@139402 268f45cc-cd09-0410-ab3c-d52691b4dbfc
LayoutTests/ChangeLog
LayoutTests/fast/dom/HTMLDialogElement/removed-element-is-removed-from-top-layer-expected.html [new file with mode: 0644]
LayoutTests/fast/dom/HTMLDialogElement/removed-element-is-removed-from-top-layer.html [new file with mode: 0644]
LayoutTests/fast/dom/HTMLDialogElement/top-layer-stacking-correct-order-remove-readd-expected.html [new file with mode: 0644]
LayoutTests/fast/dom/HTMLDialogElement/top-layer-stacking-correct-order-remove-readd.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/dom/Element.cpp