Content element should be able to be dynamically added/removed/replaced in a shadow...
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 1 Feb 2012 06:39:11 +0000 (06:39 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 1 Feb 2012 06:39:11 +0000 (06:39 +0000)
commit135e0b012c7fbb05945db97e589a1b7337160427
tree3987f38020fc243e747b0e3646df2344320bcf3a
parente19c72129e01e1c60da2de217ca63315b2610e18
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-01-31
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:
(WebCore::ShadowRoot::recalcShadowTreeStyle):
  Recalculates light children and shadow tree.
(WebCore::ShadowRoot::reattachHostChildrenAndShadow):
  Detaches shadow tree and host light children, and attaches them again.
* dom/ShadowRoot.h:
  Added a flag to recalculate shadow tree.
(WebCore::ShadowRoot::setNeedsShadowTreeStyleRecalc):
(WebCore::ShadowRoot::clearNeedsShadowTreeStyleRecalc):
(WebCore::ShadowRoot::needsShadowTreeStyleRecalc):
* 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@106432 268f45cc-cd09-0410-ab3c-d52691b4dbfc
LayoutTests/ChangeLog
LayoutTests/fast/dom/shadow/content-element-move-expected.txt [new file with mode: 0644]
LayoutTests/fast/dom/shadow/content-element-move.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/dom/Element.cpp
Source/WebCore/dom/ShadowRoot.cpp
Source/WebCore/dom/ShadowRoot.h
Source/WebCore/html/shadow/HTMLContentElement.cpp