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 13:50:25 +0000 (13:50 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 1 Feb 2012 13:50:25 +0000 (13:50 +0000)
commitbcd7e04d7eb65c44cbc72e28e02f80fd2d6ad50f
tree4d0117dd46911950a94c2c0b09d13054b8560bd1
parenta37205fe54ee92e69e951e6c8d7b0baeb0009bf5
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
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