Title: [109096] trunk
Revision
109096
Author
[email protected]
Date
2012-02-28 03:36:37 -0800 (Tue, 28 Feb 2012)

Log Message

Element should be able to have multiple shadow roots.
https://bugs.webkit.org/show_bug.cgi?id=77931

Reviewed by Hajime Morita.

.:

* Source/autotools/symbols.filter:

Source/WebCore:

This patch enables us to add multiple shadow subtrees into elements.
Note that multiple shadow subtrees are enabled
only if RuntimeEnabledFeatures::multipleShadowSubtrees is enabled.

Since we don't have <shadow> element yet, only the youngest shadow tree
will be rendered. This patch includes tests to confirm adding a new shadow
tree dynamically to confirm only the youngest shadow tree is renderered.

Tests: fast/dom/shadow/multiple-shadowroot-rendering.html
       fast/dom/shadow/multiple-shadowroot.html

* WebCore.exp.in:
* dom/Element.cpp:
  Uses ShadowRootList interfaces directly instead of ShadowRootList emulation methods.
(WebCore::Element::~Element):
(WebCore::Element::attach):
(WebCore::Element::addShadowRoot):
(WebCore::Element::removeShadowRootList):
* dom/Element.h:
(Element):
* dom/NodeRenderingContext.cpp:
  Makes non-youngest shadow subtrees hidden.
(WebCore::NodeRenderingContext::NodeRenderingContext):
(WebCore::NodeRenderingContext::hostChildrenChanged):
  Since non-youngest children may be changed, make sure host children are changed.
* dom/ShadowRoot.cpp:
(WebCore::ShadowRoot::create):
* dom/ShadowRoot.h:
  Utility methods to make code intention clear are added.
(WebCore::ShadowRoot::youngerShadowRoot):
(WebCore::ShadowRoot::olderShadowRoot):
(ShadowRoot):
(WebCore::ShadowRoot::isYoungest):
(WebCore::ShadowRoot::isOldest):
* dom/ShadowRootList.cpp:
(WebCore::ShadowRootList::popShadowRoot):
(WebCore::ShadowRootList::attach):
(WebCore::ShadowRootList::detach):
  Detaches shadow subtrees.
* testing/Internals.cpp:
(WebCore::Internals::address):
(WebCore):
(WebCore::Internals::youngerShadowRoot):
(WebCore::Internals::olderShadowRoot):
(WebCore::Internals::removeShadowRoot):
* testing/Internals.h:
(Internals):
* testing/Internals.idl:

Source/WebKit2:

* win/WebKit2.def:
* win/WebKit2CFLite.def:

LayoutTests:

* fast/dom/resources/shadow-test-driver.js:
(createSpanWithText):
(doneTest):
(doTest):
* fast/dom/shadow/multiple-shadowroot-expected.txt: Added.
* fast/dom/shadow/multiple-shadowroot-rendering-expected.txt: Added.
* fast/dom/shadow/multiple-shadowroot-rendering.html: Added.
* fast/dom/shadow/multiple-shadowroot.html: Added.
* platform/efl/Skipped:
* platform/gtk/Skipped:
* platform/mac/Skipped:
* platform/qt/Skipped:
* platform/win/Skipped:
* platform/wincairo/Skipped:
* platform/wk2/Skipped:

Modified Paths

Added Paths

Diff

Modified: trunk/ChangeLog (109095 => 109096)


--- trunk/ChangeLog	2012-02-28 10:55:28 UTC (rev 109095)
+++ trunk/ChangeLog	2012-02-28 11:36:37 UTC (rev 109096)
@@ -1,3 +1,12 @@
+2012-02-28  Shinya Kawanaka  <[email protected]>
+
+        Element should be able to have multiple shadow roots.
+        https://bugs.webkit.org/show_bug.cgi?id=77931
+
+        Reviewed by Hajime Morita.
+
+        * Source/autotools/symbols.filter:
+
 2012-02-27  Shinya Kawanaka  <[email protected]>
 
         Element::removeShadowRoot() and setShadowRoot() should be moved into ShadowTree.

Modified: trunk/LayoutTests/ChangeLog (109095 => 109096)


--- trunk/LayoutTests/ChangeLog	2012-02-28 10:55:28 UTC (rev 109095)
+++ trunk/LayoutTests/ChangeLog	2012-02-28 11:36:37 UTC (rev 109096)
@@ -1,3 +1,26 @@
+2012-02-28  Shinya Kawanaka  <[email protected]>
+
+        Element should be able to have multiple shadow roots.
+        https://bugs.webkit.org/show_bug.cgi?id=77931
+
+        Reviewed by Hajime Morita.
+
+        * fast/dom/resources/shadow-test-driver.js:
+        (createSpanWithText):
+        (doneTest):
+        (doTest):
+        * fast/dom/shadow/multiple-shadowroot-expected.txt: Added.
+        * fast/dom/shadow/multiple-shadowroot-rendering-expected.txt: Added.
+        * fast/dom/shadow/multiple-shadowroot-rendering.html: Added.
+        * fast/dom/shadow/multiple-shadowroot.html: Added.
+        * platform/efl/Skipped:
+        * platform/gtk/Skipped:
+        * platform/mac/Skipped:
+        * platform/qt/Skipped:
+        * platform/win/Skipped:
+        * platform/wincairo/Skipped:
+        * platform/wk2/Skipped:
+
 2012-02-28  Yoshifumi Inoue  <[email protected]>
 
         [Chromium] We should reset mouse position before calling eventSender.mouseMove in LayoutTest

Modified: trunk/LayoutTests/fast/dom/resources/shadow-test-driver.js (109095 => 109096)


--- trunk/LayoutTests/fast/dom/resources/shadow-test-driver.js	2012-02-28 10:55:28 UTC (rev 109095)
+++ trunk/LayoutTests/fast/dom/resources/shadow-test-driver.js	2012-02-28 11:36:37 UTC (rev 109096)
@@ -53,9 +53,11 @@
     }
 }
 
-function createSpanWithText(text) {
+function createSpanWithText(text, className) {
     var span = document.createElement('span');
     span.appendChild(document.createTextNode(text));
+    if (className)
+        span.className = className;
     return span;
 }
 
@@ -118,11 +120,16 @@
 
 function doneTest() {
     log("TEST COMPLETED");
+    if (window.tearDownOnce)
+        window.tearDownOnce();
     layoutTestController.notifyDone();
 }
 
 // A test driver. Call this body.onload.
 function doTest(tests) {
+    if (window.setUpOnce)
+        window.setUpOnce();
+
     if (window.layoutTestController) {
         layoutTestController.waitUntilDone();
         layoutTestController.dumpAsText();

Added: trunk/LayoutTests/fast/dom/shadow/multiple-shadowroot-expected.txt (0 => 109096)


--- trunk/LayoutTests/fast/dom/shadow/multiple-shadowroot-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/fast/dom/shadow/multiple-shadowroot-expected.txt	2012-02-28 11:36:37 UTC (rev 109096)
@@ -0,0 +1,17 @@
+This test ensure that the multiple shadow root is available.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS internals.shadowRoot(div) is null
+PASS internals.shadowRoot(div) is shadowRoot1
+PASS internals.olderShadowRoot(shadowRoot1) is null
+PASS internals.shadowRoot(div) is shadowRoot2
+PASS internals.olderShadowRoot(shadowRoot2) is shadowRoot1
+PASS internals.shadowRoot(div) is shadowRoot3
+PASS internals.olderShadowRoot(shadowRoot3) is shadowRoot2
+PASS internals.shadowRoot(div) is null
+PASS successfullyParsed is true
+
+TEST COMPLETE
+

Added: trunk/LayoutTests/fast/dom/shadow/multiple-shadowroot-rendering-expected.txt (0 => 109096)


--- trunk/LayoutTests/fast/dom/shadow/multiple-shadowroot-rendering-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/fast/dom/shadow/multiple-shadowroot-rendering-expected.txt	2012-02-28 11:36:37 UTC (rev 109096)
@@ -0,0 +1,14 @@
+testDoubleShadowSubtrees
+PASS
+testTripleShadowSubtrees
+PASS
+testShadowSubtreesWithContent
+PASS
+testShadowSubtreesWithContentInOlderSubtree
+PASS
+testShadowSubtreesWithDynamicCreation
+PASS
+testShadowSubtreesWithDynamicCreationOutOfTree
+PASS
+TEST COMPLETED
+

Added: trunk/LayoutTests/fast/dom/shadow/multiple-shadowroot-rendering.html (0 => 109096)


--- trunk/LayoutTests/fast/dom/shadow/multiple-shadowroot-rendering.html	                        (rev 0)
+++ trunk/LayoutTests/fast/dom/shadow/multiple-shadowroot-rendering.html	2012-02-28 11:36:37 UTC (rev 109096)
@@ -0,0 +1,174 @@
+<!DOCTYPE html>
+<html>
+<head>
+<style>
+/* relative positioning ensures underlying RenderLayer */
+.container {
+    position: relative;
+}
+
+.span {
+    display: boxed-inline;
+    margin: 2px;
+    border: solid;
+}
+</style>
+<script src=""
+<script>
+function setUpOnce() {
+    internals.setMultipleShadowSubtreesEnabled(true);
+}
+
+function teatDownOnce() {
+    internals.setMultipleShadowSubtreesEnabled(false);
+}
+
+var testFuncs = [];
+
+testFuncs.push(function testDoubleShadowSubtrees(callIfDone) {
+    document.getElementById('expect-container').innerHTML = "<div><span>BEFORE</span><span>MID</span><span>AFTER</span></div>";
+
+    var root = document.createElement('div');
+    root.appendChild(createSpanWithText('LIGHT'));
+
+    var sr1 = new WebKitShadowRoot(root);
+    sr1.appendChild(createSpanWithText('BEFORE: SHOULD NOT BE RENDERED'));
+    sr1.appendChild(createSpanWithText('MID: SHOULD NOT BE RENDERED'));
+    sr1.appendChild(createSpanWithText('AFTER: SHOULD NOT BE RENDERED'));
+
+    var sr2 = new WebKitShadowRoot(root);
+    sr2.appendChild(createSpanWithText('BEFORE'));
+    sr2.appendChild(createSpanWithText('MID'));
+    sr2.appendChild(createSpanWithText('AFTER'));
+
+    document.getElementById('actual-container').appendChild(root);
+
+    callIfDone();
+});
+
+testFuncs.push(function testTripleShadowSubtrees(callIfDone) {
+    document.getElementById('expect-container').innerHTML = "<div><span>BEFORE</span><span>MID</span><span>AFTER</span></div>";
+
+    var root = document.createElement('div');
+    root.appendChild(createSpanWithText('LIGHT'));
+
+    var sr1 = new WebKitShadowRoot(root);
+    sr1.appendChild(createSpanWithText('BEFORE: SHOULD NOT BE RENDERED'));
+    sr1.appendChild(createSpanWithText('MID: SHOULD NOT BE RENDERED'));
+    sr1.appendChild(createSpanWithText('AFTER: SHOULD NOT BE RENDERED'));
+
+    var sr2 = new WebKitShadowRoot(root);
+    sr2.appendChild(createSpanWithText('BEFORE: SHOULD NOT BE RENDERED'));
+    sr2.appendChild(createSpanWithText('MID: SHOULD NOT BE RENDERED'));
+    sr2.appendChild(createSpanWithText('AFTER: SHOULD NOT BE RENDERED'));
+
+    var sr3 = new WebKitShadowRoot(root);
+    sr3.appendChild(createSpanWithText('BEFORE'));
+    sr3.appendChild(createSpanWithText('MID'));
+    sr3.appendChild(createSpanWithText('AFTER'));
+
+    document.getElementById('actual-container').appendChild(root);
+
+    callIfDone();
+});
+
+testFuncs.push(function testShadowSubtreesWithContent(callIfDone) {
+    document.getElementById('expect-container').innerHTML = "<div><span>BEFORE</span><span>LIGHT</span><span>AFTER</span></div>";
+
+    var root = document.createElement('div');
+    root.appendChild(createSpanWithText('LIGHT'));
+
+    var sr1 = new WebKitShadowRoot(root);
+    sr1.appendChild(createSpanWithText('BEFORE: SHOULD NOT BE RENDERED'));
+    sr1.appendChild(createSpanWithText('MID: SHOULD NOT BE RENDERED'));
+    sr1.appendChild(createSpanWithText('AFTER: SHOULD NOT BE RENDERED'));
+
+    var sr2 = new WebKitShadowRoot(root);
+    sr2.appendChild(createSpanWithText('BEFORE'));
+    sr2.appendChild(createContentWithSelect('span', 'FALLBACK'));
+    sr2.appendChild(createSpanWithText('AFTER'));
+
+    document.getElementById('actual-container').appendChild(root);
+
+    callIfDone();
+});
+
+testFuncs.push(function testShadowSubtreesWithContentInOlderSubtree(callIfDone) {
+    document.getElementById('expect-container').innerHTML = "<div><span>BEFORE</span><span>LIGHT 1</span><span>AFTER</span></div>";
+
+    var root = document.createElement('div');
+    root.appendChild(createSpanWithText('LIGHT 1', 'c1'));
+    root.appendChild(createSpanWithText('LIGHT 2', 'c2'));
+
+    var sr1 = new WebKitShadowRoot(root);
+    sr1.appendChild(createSpanWithText('BEFORE: SHOULD NOT BE RENDERED'));
+    sr1.appendChild(createContentWithSelect('.c2', 'FALLBACK'));
+    sr1.appendChild(createSpanWithText('AFTER: SHOULD NOT BE RENDERED'));
+
+    var sr2 = new WebKitShadowRoot(root);
+    sr2.appendChild(createSpanWithText('BEFORE'));
+    sr2.appendChild(createContentWithSelect('.c1', 'FALLBACK'));
+    sr2.appendChild(createSpanWithText('AFTER'));
+
+    document.getElementById('actual-container').appendChild(root);
+
+    callIfDone();
+});
+
+testFuncs.push(function testShadowSubtreesWithDynamicCreation(callIfDone) {
+    document.getElementById('expect-container').innerHTML = "<div><span>BEFORE</span><span>LIGHT 1</span><span>LIGHT 2</span><span>AFTER</span></div>";
+
+    var root = document.createElement('div');
+    root.appendChild(createSpanWithText('LIGHT 1', 'c1'));
+    root.appendChild(createSpanWithText('LIGHT 2', 'c2'));
+
+    var sr1 = new WebKitShadowRoot(root);
+    sr1.appendChild(createSpanWithText('BEFORE: SHOULD NOT BE RENDERED'));
+    sr1.appendChild(createContentWithSelect('span', 'FALLBACK'));
+    sr1.appendChild(createSpanWithText('AFTER: SHOULD NOT BE RENDERED'));
+
+    document.getElementById('actual-container').appendChild(root);
+
+    setTimeout((function(callIfDone, root) { return function() {
+        var sr2 = new WebKitShadowRoot(root);
+        sr2.appendChild(createSpanWithText('BEFORE'));
+        sr2.appendChild(createContentWithSelect('span', 'FALLBACK'));
+        sr2.appendChild(createSpanWithText('AFTER'));
+
+        callIfDone();
+    };})(callIfDone, root), 0);
+});
+
+testFuncs.push(function testShadowSubtreesWithDynamicCreationOutOfTree(callIfDone) {
+    document.getElementById('expect-container').innerHTML = "<div><span>BEFORE</span><span>LIGHT 1</span><span>LIGHT 2</span><span>AFTER</span></div>";
+
+    var root = document.createElement('div');
+    root.appendChild(createSpanWithText('LIGHT 1', 'c1'));
+    root.appendChild(createSpanWithText('LIGHT 2', 'c2'));
+
+    var sr1 = new WebKitShadowRoot(root);
+    sr1.appendChild(createSpanWithText('BEFORE: SHOULD NOT BE RENDERED'));
+    sr1.appendChild(createContentWithSelect('span', 'FALLBACK'));
+    sr1.appendChild(createSpanWithText('AFTER: SHOULD NOT BE RENDERED'));
+
+    setTimeout((function(callIfDone, root) { return function() {
+        var sr2 = new WebKitShadowRoot(root);
+        sr2.appendChild(createSpanWithText('BEFORE'));
+        sr2.appendChild(createContentWithSelect('span', 'FALLBACK'));
+        sr2.appendChild(createSpanWithText('AFTER'));
+
+        document.getElementById('actual-container').appendChild(root);
+
+        callIfDone();
+    };})(callIfDone, root), 0);
+});
+</script>
+</head>
+<body _onload_="doTest(testFuncs)">
+
+<div id="actual-container" class="container"></div>
+<div id="expect-container" class="container"></div>
+<pre id="console"></pre>
+
+</body>
+</html>

Added: trunk/LayoutTests/fast/dom/shadow/multiple-shadowroot.html (0 => 109096)


--- trunk/LayoutTests/fast/dom/shadow/multiple-shadowroot.html	                        (rev 0)
+++ trunk/LayoutTests/fast/dom/shadow/multiple-shadowroot.html	2012-02-28 11:36:37 UTC (rev 109096)
@@ -0,0 +1,35 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script src=""
+</head>
+<body>
+<script>
+description("This test ensure that the multiple shadow root is available.");
+
+internals.setMultipleShadowSubtreesEnabled(true);
+
+var div = document.createElement('div');
+shouldBe("internals.shadowRoot(div)", "null");
+var shadowRoot1 = new WebKitShadowRoot(div);
+shouldBe("internals.shadowRoot(div)", "shadowRoot1");
+shouldBe("internals.olderShadowRoot(shadowRoot1)", "null");
+
+var shadowRoot2 = new WebKitShadowRoot(div)
+shouldBe("internals.shadowRoot(div)", "shadowRoot2");
+shouldBe("internals.olderShadowRoot(shadowRoot2)", "shadowRoot1");
+
+var shadowRoot3 = new WebKitShadowRoot(div);
+shouldBe("internals.shadowRoot(div)", "shadowRoot3");
+shouldBe("internals.olderShadowRoot(shadowRoot3)", "shadowRoot2");
+
+internals.removeShadowRoot(div);
+shouldBe("internals.shadowRoot(div)", "null");
+
+internals.setMultipleShadowSubtreesEnabled(false);
+
+var successfullyParsed = true;
+</script>
+<script src=""
+</body>
+</html>

Modified: trunk/LayoutTests/platform/efl/Skipped (109095 => 109096)


--- trunk/LayoutTests/platform/efl/Skipped	2012-02-28 10:55:28 UTC (rev 109095)
+++ trunk/LayoutTests/platform/efl/Skipped	2012-02-28 11:36:37 UTC (rev 109096)
@@ -2091,6 +2091,8 @@
 fast/dom/shadow/shadow-disable.html
 fast/dom/shadow/shadow-root-attached.html
 fast/dom/shadow/shadow-root-new.html
+fast/dom/shadow/multiple-shadowroot.html
+fast/dom/shadow/multiple-shadowroot-rendering.html
 
 # CSS Filters support not yet enabled (needs ENABLE_CSS_FILTERS).
 # https://bugs.webkit.org/show_bug.cgi?id=68469

Modified: trunk/LayoutTests/platform/mac/Skipped (109095 => 109096)


--- trunk/LayoutTests/platform/mac/Skipped	2012-02-28 10:55:28 UTC (rev 109095)
+++ trunk/LayoutTests/platform/mac/Skipped	2012-02-28 11:36:37 UTC (rev 109096)
@@ -430,6 +430,8 @@
 fast/dom/shadow/shadow-root-attached.html
 fast/dom/shadow/shadow-root-new.html
 fast/dom/shadow/shadow-ul-li.html
+fast/dom/shadow/multiple-shadowroot.html
+fast/dom/shadow/multiple-shadowroot-rendering.html
 
 # JSC does not support setIsolatedWorldSecurityOrigin (http://webkit.org/b/61540)
 http/tests/security/isolatedWorld/cross-origin-xhr.html

Modified: trunk/LayoutTests/platform/qt/Skipped (109095 => 109096)


--- trunk/LayoutTests/platform/qt/Skipped	2012-02-28 10:55:28 UTC (rev 109095)
+++ trunk/LayoutTests/platform/qt/Skipped	2012-02-28 11:36:37 UTC (rev 109096)
@@ -168,6 +168,8 @@
 fast/dom/shadow/shadow-root-attached.html
 fast/dom/shadow/shadow-root-new.html
 fast/dom/shadow/shadow-ul-li.html
+fast/dom/shadow/multiple-shadowroot.html
+fast/dom/shadow/multiple-shadowroot-rendering.html
 
 # CSS Regions support not yet enabled. http://webkit.org/b/57312
 fast/regions

Modified: trunk/LayoutTests/platform/win/Skipped (109095 => 109096)


--- trunk/LayoutTests/platform/win/Skipped	2012-02-28 10:55:28 UTC (rev 109095)
+++ trunk/LayoutTests/platform/win/Skipped	2012-02-28 11:36:37 UTC (rev 109096)
@@ -1459,6 +1459,8 @@
 fast/dom/shadow/shadow-root-attached.html
 fast/dom/shadow/shadow-root-new.html
 fast/dom/shadow/shadow-ul-li.html
+fast/dom/shadow/multiple-shadowroot.html
+fast/dom/shadow/multiple-shadowroot-rendering.html
 
 # CSS Regions support not yet enabled. http://webkit.org/b/57312
 fast/regions

Modified: trunk/LayoutTests/platform/wincairo/Skipped (109095 => 109096)


--- trunk/LayoutTests/platform/wincairo/Skipped	2012-02-28 10:55:28 UTC (rev 109095)
+++ trunk/LayoutTests/platform/wincairo/Skipped	2012-02-28 11:36:37 UTC (rev 109096)
@@ -1969,6 +1969,8 @@
 fast/dom/shadow/shadow-disable.html
 fast/dom/shadow/shadow-root-attached.html
 fast/dom/shadow/shadow-root-new.html
+fast/dom/shadow/multiple-shadowroot.html
+fast/dom/shadow/multiple-shadowroot-rendering.html
 
 # CSS Regions support not yet enabled. http://webkit.org/b/57312
 fast/regions

Modified: trunk/LayoutTests/platform/wk2/Skipped (109095 => 109096)


--- trunk/LayoutTests/platform/wk2/Skipped	2012-02-28 10:55:28 UTC (rev 109095)
+++ trunk/LayoutTests/platform/wk2/Skipped	2012-02-28 11:36:37 UTC (rev 109096)
@@ -1070,6 +1070,8 @@
 fast/dom/shadow/shadow-root-attached.html
 fast/dom/shadow/shadow-root-new.html
 fast/dom/shadow/shadow-ul-li.html
+fast/dom/shadow/multiple-shadowroot.html
+fast/dom/shadow/multiple-shadowroot-rendering.html
 
 # WTR needs an implementation for eventSender.continuousMouseScrollBy
 # https://bugs.webkit.org/show_bug.cgi?id=69417

Modified: trunk/Source/WebCore/ChangeLog (109095 => 109096)


--- trunk/Source/WebCore/ChangeLog	2012-02-28 10:55:28 UTC (rev 109095)
+++ trunk/Source/WebCore/ChangeLog	2012-02-28 11:36:37 UTC (rev 109096)
@@ -1,3 +1,59 @@
+2012-02-28  Shinya Kawanaka  <[email protected]>
+
+        Element should be able to have multiple shadow roots.
+        https://bugs.webkit.org/show_bug.cgi?id=77931
+
+        Reviewed by Hajime Morita.
+
+        This patch enables us to add multiple shadow subtrees into elements.
+        Note that multiple shadow subtrees are enabled
+        only if RuntimeEnabledFeatures::multipleShadowSubtrees is enabled.
+
+        Since we don't have <shadow> element yet, only the youngest shadow tree
+        will be rendered. This patch includes tests to confirm adding a new shadow
+        tree dynamically to confirm only the youngest shadow tree is renderered.
+
+        Tests: fast/dom/shadow/multiple-shadowroot-rendering.html
+               fast/dom/shadow/multiple-shadowroot.html
+
+        * WebCore.exp.in:
+        * dom/Element.cpp:
+          Uses ShadowRootList interfaces directly instead of ShadowRootList emulation methods.
+        (WebCore::Element::~Element):
+        (WebCore::Element::attach):
+        (WebCore::Element::addShadowRoot):
+        (WebCore::Element::removeShadowRootList):
+        * dom/Element.h:
+        (Element):
+        * dom/NodeRenderingContext.cpp:
+          Makes non-youngest shadow subtrees hidden.
+        (WebCore::NodeRenderingContext::NodeRenderingContext):
+        (WebCore::NodeRenderingContext::hostChildrenChanged):
+          Since non-youngest children may be changed, make sure host children are changed.
+        * dom/ShadowRoot.cpp:
+        (WebCore::ShadowRoot::create):
+        * dom/ShadowRoot.h:
+          Utility methods to make code intention clear are added.
+        (WebCore::ShadowRoot::youngerShadowRoot):
+        (WebCore::ShadowRoot::olderShadowRoot):
+        (ShadowRoot):
+        (WebCore::ShadowRoot::isYoungest):
+        (WebCore::ShadowRoot::isOldest):
+        * dom/ShadowRootList.cpp:
+        (WebCore::ShadowRootList::popShadowRoot):
+        (WebCore::ShadowRootList::attach):
+        (WebCore::ShadowRootList::detach):
+          Detaches shadow subtrees.
+        * testing/Internals.cpp:
+        (WebCore::Internals::address):
+        (WebCore):
+        (WebCore::Internals::youngerShadowRoot):
+        (WebCore::Internals::olderShadowRoot):
+        (WebCore::Internals::removeShadowRoot):
+        * testing/Internals.h:
+        (Internals):
+        * testing/Internals.idl:
+
 2012-02-28  Antti Koivisto  <[email protected]>
 
         Split CSSStyleRule into internal and CSSOM type

Modified: trunk/Source/WebCore/dom/Element.cpp (109095 => 109096)


--- trunk/Source/WebCore/dom/Element.cpp	2012-02-28 10:55:28 UTC (rev 109095)
+++ trunk/Source/WebCore/dom/Element.cpp	2012-02-28 11:36:37 UTC (rev 109096)
@@ -60,6 +60,7 @@
 #include "RenderRegion.h"
 #include "RenderView.h"
 #include "RenderWidget.h"
+#include "RuntimeEnabledFeatures.h"
 #include "Settings.h"
 #include "ShadowRoot.h"
 #include "Text.h"
@@ -931,7 +932,7 @@
         parentPusher.push();
         shadowTree()->attach();
 
-        // In a shadow tree, some of light children may be attached by 'content' element.
+        // In a shadow tree, some of light children may be attached by <content> or <shadow>.
         // However, when there is no content element or content element does not select
         // all light children, we have to attach the rest of light children here.
         for (Node* child = firstChild(); child; child = child->nextSibling()) {

Modified: trunk/Source/WebCore/dom/NodeRenderingContext.cpp (109095 => 109096)


--- trunk/Source/WebCore/dom/NodeRenderingContext.cpp	2012-02-28 10:55:28 UTC (rev 109095)
+++ trunk/Source/WebCore/dom/NodeRenderingContext.cpp	2012-02-28 11:36:37 UTC (rev 109096)
@@ -57,7 +57,12 @@
         return;
 
     if (parent->isShadowRoot()) {
-        m_phase = AttachingShadowChild;
+        // FIXME: We don't support <shadow> yet, so the non-youngest shadow won't be rendered.
+        // https://bugs.webkit.org/shod_bugs.cgi?id=78596
+        if (toShadowRoot(parent)->isYoungest())
+            m_phase = AttachingShadowChild;
+        else
+            m_phase = AttachingNotDistributed;
         m_parentNodeForRenderingAndStyle = parent->shadowHost();
         return;
     }
@@ -67,9 +72,14 @@
             m_visualParentShadowTree = toElement(parent)->shadowTree();
             if ((m_insertionPoint = m_visualParentShadowTree->insertionPointFor(m_node))
                 && m_visualParentShadowTree->isSelectorActive()) {
-                m_phase = AttachingDistributed;
-                m_parentNodeForRenderingAndStyle = NodeRenderingContext(m_insertionPoint).parentNodeForRenderingAndStyle();
-                return;
+
+                // FIXME: We don't support <shadow> yet, so the non-youngest shadow won't be rendered.
+                // https://bugs.webkit.org/show_bugs.cgi?id=78596
+                if (toShadowRoot(m_insertionPoint->shadowTreeRootNode())->isYoungest()) {
+                    m_phase = AttachingDistributed;
+                    m_parentNodeForRenderingAndStyle = NodeRenderingContext(m_insertionPoint).parentNodeForRenderingAndStyle();
+                    return;
+                }
             }
 
             m_phase = AttachingNotDistributed;
@@ -260,7 +270,7 @@
 
 void NodeRenderingContext::hostChildrenChanged()
 {
-    if (m_phase == AttachingNotDistributed)
+    if (m_phase == AttachingNotDistributed && m_visualParentShadowTree)
         m_visualParentShadowTree->hostChildrenChanged();
 }
 

Modified: trunk/Source/WebCore/dom/ShadowRoot.cpp (109095 => 109096)


--- trunk/Source/WebCore/dom/ShadowRoot.cpp	2012-02-28 10:55:28 UTC (rev 109095)
+++ trunk/Source/WebCore/dom/ShadowRoot.cpp	2012-02-28 11:36:37 UTC (rev 109096)
@@ -184,17 +184,4 @@
     m_applyAuthorSheets = value;
 }
 
-void ShadowRoot::attach()
-{
-    // Children of m_selector is populated lazily in
-    // ensureSelector(), and here we just ensure that
-    // it is in clean state.
-    // FIXME: This assertion breaks if multiple shadow roots are being attached.
-    // ShadowTree should have responsibility of side effect of selector in attaching/detaching.
-    ASSERT(!tree()->selector() || !tree()->selector()->hasCandidates());
-    DocumentFragment::attach();
-    if (HTMLContentSelector* selector = tree()->selector())
-        selector->didSelect();
 }
-
-}

Modified: trunk/Source/WebCore/dom/ShadowRoot.h (109095 => 109096)


--- trunk/Source/WebCore/dom/ShadowRoot.h	2012-02-28 10:55:28 UTC (rev 109095)
+++ trunk/Source/WebCore/dom/ShadowRoot.h	2012-02-28 11:36:37 UTC (rev 109096)
@@ -64,8 +64,6 @@
     InsertionPoint* insertionPointFor(Node*) const;
     void hostChildrenChanged();
 
-    virtual void attach();
-
     virtual bool applyAuthorSheets() const;
     void setApplyAuthorSheets(bool);
 
@@ -75,6 +73,9 @@
     ShadowRoot* youngerShadowRoot() const { return prev(); }
     ShadowRoot* olderShadowRoot() const { return next(); }
 
+    bool isYoungest() const { return !youngerShadowRoot(); }
+    bool isOldest() const { return !olderShadowRoot(); }
+
     bool hasContentElement() const;
 
 private:

Modified: trunk/Source/WebCore/dom/ShadowTree.cpp (109095 => 109096)


--- trunk/Source/WebCore/dom/ShadowTree.cpp	2012-02-28 10:55:28 UTC (rev 109095)
+++ trunk/Source/WebCore/dom/ShadowTree.cpp	2012-02-28 11:36:37 UTC (rev 109096)
@@ -109,6 +109,8 @@
             oldRoot->detach();
 
         oldRoot->setShadowHost(0);
+        oldRoot->setPrev(0);
+        oldRoot->setNext(0);
         shadowHost->document()->adoptIfNeeded(oldRoot.get());
         if (oldRoot->inDocument())
             oldRoot->removedFromDocument();
@@ -156,22 +158,21 @@
 
 void ShadowTree::attach()
 {
-    // FIXME: Currently we only support the case that the shadow root list has at most one shadow root.
-    // See also https://bugs.webkit.org/show_bug.cgi?id=77503 and its dependent bugs.
-    ASSERT(m_shadowRoots.size() <= 1);
+    // Children of m_selector is populated lazily in
+    // ensureSelector(), and here we just ensure that it is in clean state.
+    ASSERT(!selector() || !selector()->hasCandidates());
 
     for (ShadowRoot* root = youngestShadowRoot(); root; root = root->olderShadowRoot()) {
         if (!root->attached())
             root->attach();
     }
+
+    if (HTMLContentSelector* contentSelector = selector())
+        contentSelector->didSelect();
 }
 
 void ShadowTree::detach()
 {
-    // FIXME: Currently we only support the case that the shadow root list has at most one shadow root.
-    // See also https://bugs.webkit.org/show_bug.cgi?id=77503 and its dependent bugs.
-    ASSERT(m_shadowRoots.size() <= 1);
-
     for (ShadowRoot* root = youngestShadowRoot(); root; root = root->olderShadowRoot()) {
         if (root->attached())
             root->detach();

Modified: trunk/Source/WebCore/testing/Internals.cpp (109095 => 109096)


--- trunk/Source/WebCore/testing/Internals.cpp	2012-02-28 10:55:28 UTC (rev 109095)
+++ trunk/Source/WebCore/testing/Internals.cpp	2012-02-28 11:36:37 UTC (rev 109096)
@@ -119,6 +119,14 @@
     reset(document);
 }
 
+String Internals::address(Node* node)
+{
+    char buf[32];
+    sprintf(buf, "%p", node);
+
+    return String(buf);
+}
+
 bool Internals::isPreloaded(Document* document, const String& url)
 {
     if (!document)
@@ -241,6 +249,26 @@
     return host->shadowTree()->oldestShadowRoot();
 }
 
+Internals::ShadowRootIfShadowDOMEnabledOrNode* Internals::youngerShadowRoot(Node* shadow, ExceptionCode& ec)
+{
+    if (!shadow || !shadow->isShadowRoot()) {
+        ec = INVALID_ACCESS_ERR;
+        return 0;
+    }
+
+    return toShadowRoot(shadow)->youngerShadowRoot();
+}
+
+Internals::ShadowRootIfShadowDOMEnabledOrNode* Internals::olderShadowRoot(Node* shadow, ExceptionCode& ec)
+{
+    if (!shadow || !shadow->isShadowRoot()) {
+        ec = INVALID_ACCESS_ERR;
+        return 0;
+    }
+
+    return toShadowRoot(shadow)->olderShadowRoot();
+}
+
 void Internals::removeShadowRoot(Element* host, ExceptionCode& ec)
 {
     if (!host) {

Modified: trunk/Source/WebCore/testing/Internals.h (109095 => 109096)


--- trunk/Source/WebCore/testing/Internals.h	2012-02-28 10:55:28 UTC (rev 109095)
+++ trunk/Source/WebCore/testing/Internals.h	2012-02-28 11:36:37 UTC (rev 109096)
@@ -55,6 +55,8 @@
 
     String elementRenderTreeAsText(Element*, ExceptionCode&);
 
+    String address(Node*);
+
     bool isPreloaded(Document*, const String& url);
 
     size_t numberOfScopedHTMLStyleChildren(const Node*, ExceptionCode&) const;
@@ -68,6 +70,8 @@
     ShadowRootIfShadowDOMEnabledOrNode* shadowRoot(Element* host, ExceptionCode&);
     ShadowRootIfShadowDOMEnabledOrNode* youngestShadowRoot(Element* host, ExceptionCode&);
     ShadowRootIfShadowDOMEnabledOrNode* oldestShadowRoot(Element* host, ExceptionCode&);
+    ShadowRootIfShadowDOMEnabledOrNode* youngerShadowRoot(Node* shadow, ExceptionCode&);
+    ShadowRootIfShadowDOMEnabledOrNode* olderShadowRoot(Node* shadow, ExceptionCode&);
     void removeShadowRoot(Element* host, ExceptionCode&);
     void setMultipleShadowSubtreesEnabled(bool);
     Element* includerFor(Node*, ExceptionCode&);

Modified: trunk/Source/WebCore/testing/Internals.idl (109095 => 109096)


--- trunk/Source/WebCore/testing/Internals.idl	2012-02-28 10:55:28 UTC (rev 109095)
+++ trunk/Source/WebCore/testing/Internals.idl	2012-02-28 11:36:37 UTC (rev 109096)
@@ -27,6 +27,8 @@
     interface [
         OmitConstructor
     ] Internals {
+        DOMString address(in Node node);
+
         DOMString elementRenderTreeAsText(in Element element) raises(DOMException);
         boolean isPreloaded(in Document document, in DOMString url);
 
@@ -37,11 +39,15 @@
         ShadowRoot shadowRoot(in Element host) raises (DOMException);
         ShadowRoot youngestShadowRoot(in Element host) raises (DOMException);
         ShadowRoot oldestShadowRoot(in Element host) raises (DOMException);
+        ShadowRoot youngerShadowRoot(in Node root) raises (DOMException);
+        ShadowRoot olderShadowRoot(in Node root) raises (DOMException);
 #else
         Node ensureShadowRoot(in Element host) raises (DOMException);
         Node shadowRoot(in Element host) raises (DOMException);
         Node youngestShadowRoot(in Element host) raises (DOMException);
         Node oldestShadowRoot(in Element host) raises (DOMException);
+        Node youngerShadowRoot(in Node root) raises (DOMException);
+        Node youngerShadowRoot(in Node root) raises (DOMException);
 #endif
         void setMultipleShadowSubtreesEnabled(in boolean enabled);
         Element includerFor(in Node node) raises (DOMException);

Modified: trunk/Source/WebKit2/ChangeLog (109095 => 109096)


--- trunk/Source/WebKit2/ChangeLog	2012-02-28 10:55:28 UTC (rev 109095)
+++ trunk/Source/WebKit2/ChangeLog	2012-02-28 11:36:37 UTC (rev 109096)
@@ -1,3 +1,13 @@
+2012-02-28  Shinya Kawanaka  <[email protected]>
+
+        Element should be able to have multiple shadow roots.
+        https://bugs.webkit.org/show_bug.cgi?id=77931
+
+        Reviewed by Hajime Morita.
+
+        * win/WebKit2.def:
+        * win/WebKit2CFLite.def:
+
 2012-02-28  Hugo Parente Lima  <[email protected]>
 
         [Qt][WK2] Use movementStarted/Ended signals instead of movingChanged on QtViewportInterationEngine

Modified: trunk/Source/WebKit2/win/WebKit2.def (109095 => 109096)


--- trunk/Source/WebKit2/win/WebKit2.def	2012-02-28 10:55:28 UTC (rev 109095)
+++ trunk/Source/WebKit2/win/WebKit2.def	2012-02-28 11:36:37 UTC (rev 109096)
@@ -177,6 +177,7 @@
         ?paintControlTints@FrameView@WebCore@@AAEXXZ
         ?rangeFromLocationAndLength@TextIterator@WebCore@@SA?AV?$PassRefPtr@VRange@WebCore@@@WTF@@PAVElement@2@HH_N@Z
         ?removeAllShadowRoots@ShadowTree@WebCore@@QAEXXZ
+        ?s_info@JSNode@WebCore@@2UClassInfo@JSC@@B
         ?scriptExecutionContext@JSDOMGlobalObject@WebCore@@QBEPAVScriptExecutionContext@2@XZ
         ?scrollElementToRect@FrameView@WebCore@@QAEXPAVElement@2@ABVIntRect@2@@Z
         ?setDOMException@WebCore@@YAXPAVExecState@JSC@@H@Z

Modified: trunk/Source/WebKit2/win/WebKit2CFLite.def (109095 => 109096)


--- trunk/Source/WebKit2/win/WebKit2CFLite.def	2012-02-28 10:55:28 UTC (rev 109095)
+++ trunk/Source/WebKit2/win/WebKit2CFLite.def	2012-02-28 11:36:37 UTC (rev 109096)
@@ -169,7 +169,8 @@
         ?page@Document@WebCore@@QBEPAVPage@2@XZ
         ?paintControlTints@FrameView@WebCore@@AAEXXZ
         ?rangeFromLocationAndLength@TextIterator@WebCore@@SA?AV?$PassRefPtr@VRange@WebCore@@@WTF@@PAVElement@2@HH_N@Z
-        ?removeAllShadowRoots@ShadowTree@WebCore@@QAEXXZ
+        ?removeShadowRootList@Element@WebCore@@QAEXXZ
+        ?s_info@JSNode@WebCore@@2UClassInfo@JSC@@B
         ?scriptExecutionContext@JSDOMGlobalObject@WebCore@@QBEPAVScriptExecutionContext@2@XZ
         ?scrollElementToRect@FrameView@WebCore@@QAEXPAVElement@2@ABVIntRect@2@@Z
         ?setDOMException@WebCore@@YAXPAVExecState@JSC@@H@Z

Modified: trunk/Source/autotools/symbols.filter (109095 => 109096)


--- trunk/Source/autotools/symbols.filter	2012-02-28 10:55:28 UTC (rev 109095)
+++ trunk/Source/autotools/symbols.filter	2012-02-28 11:36:37 UTC (rev 109096)
@@ -67,6 +67,7 @@
 _ZN7WebCore6JSNode20visitChildrenVirtualERN3JSC11SlotVisitorE;
 _ZN7WebCore6JSNode6s_infoE;
 _ZN7WebCore6toNodeEN3JSC7JSValueE;
+_ZN7WebCore7Element20removeShadowRootListEv;
 _ZN7WebCore7toRangeEN3JSC7JSValueE;
 _ZN7WebCore9JSElement10putVirtualEPN3JSC9ExecStateERKNS1_10IdentifierENS1_7JSValueERNS1_15PutPropertySlotE;
 _ZN7WebCore9JSElement6s_infoE;
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to