Content element should be able to be dynamically added/removed/replaced in a shadow tree.
https://bugs.webkit.org/show_bug.cgi?id=76611
Patch by Shinya Kawanaka <shinyak@google.com> on 2012-02-01
Reviewed by Hajime Morita
Source/WebCore:
When a content element is added/removed/replaced in a shadow tree, we have to recreate
the shadow tree to recalculate inclusions of content elements. Currently we didn't recalculate it
when content element is removed. (When added, it is recalculated.)
This patch enables us to recalcurate the shadow tree when content element is removed.
Test: fast/dom/shadow/content-element-move.html
* dom/Element.cpp:
(WebCore::Element::attach):
If a shadow root exists, attaches shadow tree before attaching child elements.
* dom/ShadowRoot.cpp:
Added a flag to recalculate shadow tree.
(WebCore::ShadowRoot::ShadowRoot):
(WebCore::ShadowRoot::recalcShadowTreeStyle):
Recalculates light children and shadow tree.
(WebCore::ShadowRoot::setNeedsReattachHostChildrenAndShadow):
(WebCore::ShadowRoot::reattachHostChildrenAndShadow):
Detaches shadow tree and host light children, and attaches them again.
* dom/ShadowRoot.h:
(WebCore::ShadowRoot::clearNeedsReattachHostChildrenAndShadow):
(WebCore::ShadowRoot::needsReattachHostChildrenAndShadow):
* html/shadow/HTMLContentElement.cpp:
(WebCore::HTMLContentElement::attach):
Does not need to detach included elements, because they are not attached in ContainerNode anymore.
(WebCore::HTMLContentElement::detach):
When a content element detached, reattaches a shadow tree.
LayoutTests:
Test cases for appending/removing/replacing content element in a shadow tree.
* fast/dom/shadow/content-element-move-expected.txt: Added.
* fast/dom/shadow/content-element-move.html: Added.
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@106465
268f45cc-cd09-0410-ab3c-
d52691b4dbfc