Title: [109290] trunk
Revision
109290
Author
[email protected]
Date
2012-02-29 17:55:08 -0800 (Wed, 29 Feb 2012)

Log Message

Methods in ShadowTree and TreeScopeAdopter should be multiple shadow roots aware.
https://bugs.webkit.org/show_bug.cgi?id=79768

Reviewed by Hajime Morita.

Source/WebCore:

Some methods in ShadowTree and TreeScopeAdopter were not multiple shadow roots aware.
They should consider multiple shadow roots.

Test: fast/dom/shadow/multiple-shadowroot-adopt.html

* dom/ShadowTree.cpp:
(WebCore::ShadowTree::setParentTreeScope):
(WebCore):
(WebCore::ShadowTree::childNeedsStyleRecalc):
(WebCore::ShadowTree::needsStyleRecalc):
* dom/ShadowTree.h:
(WebCore):
(ShadowTree):
* dom/TreeScopeAdopter.cpp:
(WebCore::shadowTreeFor):
(WebCore::TreeScopeAdopter::moveTreeToNewScope):
(WebCore::TreeScopeAdopter::moveTreeToNewDocument):
(WebCore::TreeScopeAdopter::moveShadowTreeToNewDocument):
(WebCore):
* dom/TreeScopeAdopter.h:
(TreeScopeAdopter):

LayoutTests:

* fast/dom/shadow/multiple-shadowroot-adopt-expected.txt: Added.
* fast/dom/shadow/multiple-shadowroot-adopt.html: Added.
* platform/efl/Skipped:
* platform/mac/Skipped:
* platform/qt/Skipped:
* platform/win/Skipped:
* platform/wincairo/Skipped:
* platform/wk2/Skipped:

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (109289 => 109290)


--- trunk/LayoutTests/ChangeLog	2012-03-01 01:34:07 UTC (rev 109289)
+++ trunk/LayoutTests/ChangeLog	2012-03-01 01:55:08 UTC (rev 109290)
@@ -1,3 +1,19 @@
+2012-02-29  Shinya Kawanaka  <[email protected]>
+
+        Methods in ShadowTree and TreeScopeAdopter should be multiple shadow roots aware.
+        https://bugs.webkit.org/show_bug.cgi?id=79768
+
+        Reviewed by Hajime Morita.
+
+        * fast/dom/shadow/multiple-shadowroot-adopt-expected.txt: Added.
+        * fast/dom/shadow/multiple-shadowroot-adopt.html: Added.
+        * platform/efl/Skipped:
+        * platform/mac/Skipped:
+        * platform/qt/Skipped:
+        * platform/win/Skipped:
+        * platform/wincairo/Skipped:
+        * platform/wk2/Skipped:
+
 2012-02-29  David Levin  <[email protected]>
 
         [chromium] Add the ability to turn off autoresize.

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


--- trunk/LayoutTests/fast/dom/shadow/multiple-shadowroot-adopt-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/fast/dom/shadow/multiple-shadowroot-adopt-expected.txt	2012-03-01 01:55:08 UTC (rev 109290)
@@ -0,0 +1,10 @@
+This test checks multiple shadow trees can be moved into another document.
+
+PASS document is sr1.ownerDocument
+PASS sr1.ownerDocument is sr2.ownerDocument
+PASS sr1.ownerDocument is iframeDoc
+PASS sr2.ownerDocument is iframeDoc
+PASS successfullyParsed is true
+
+TEST COMPLETE
+

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


--- trunk/LayoutTests/fast/dom/shadow/multiple-shadowroot-adopt.html	                        (rev 0)
+++ trunk/LayoutTests/fast/dom/shadow/multiple-shadowroot-adopt.html	2012-03-01 01:55:08 UTC (rev 109290)
@@ -0,0 +1,44 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script src=""
+</head>
+<body>
+<p>This test checks multiple shadow trees can be moved into another document.</p>
+<pre id="console"></pre>
+
+<iframe id="iframe"></iframe>
+
+<script>
+function setUpOnce() {
+    internals.setMultipleShadowSubtreesEnabled(true);
+}
+
+function tearDownOnce() {
+    internals.setMultipleShadowSubtreesEnabled(false);
+}
+
+function doTest() {
+    var target = document.createElement('div');
+    sr1 = new WebKitShadowRoot(target);
+    sr2 = new WebKitShadowRoot(target);
+
+    shouldBe('document', 'sr1.ownerDocument');
+    shouldBe('sr1.ownerDocument', 'sr2.ownerDocument');
+
+    var iframe = document.getElementById('iframe');
+    iframeDoc = iframe.contentDocument;
+    iframeDoc.body.appendChild(target);
+
+    shouldBe('sr1.ownerDocument', 'iframeDoc');
+    shouldBe('sr2.ownerDocument', 'iframeDoc');
+}
+
+setUpOnce();
+doTest();
+tearDownOnce();
+var successfullyParsed = true;
+</script>
+<script src=""
+</body>
+</html>

Modified: trunk/LayoutTests/platform/efl/Skipped (109289 => 109290)


--- trunk/LayoutTests/platform/efl/Skipped	2012-03-01 01:34:07 UTC (rev 109289)
+++ trunk/LayoutTests/platform/efl/Skipped	2012-03-01 01:55:08 UTC (rev 109290)
@@ -2094,6 +2094,7 @@
 fast/dom/shadow/shadow-root-new.html
 fast/dom/shadow/multiple-shadowroot.html
 fast/dom/shadow/multiple-shadowroot-rendering.html
+fast/dom/shadow/multiple-shadowroot-adopt.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 (109289 => 109290)


--- trunk/LayoutTests/platform/mac/Skipped	2012-03-01 01:34:07 UTC (rev 109289)
+++ trunk/LayoutTests/platform/mac/Skipped	2012-03-01 01:55:08 UTC (rev 109290)
@@ -437,6 +437,7 @@
 fast/dom/shadow/shadow-ul-li.html
 fast/dom/shadow/multiple-shadowroot.html
 fast/dom/shadow/multiple-shadowroot-rendering.html
+fast/dom/shadow/multiple-shadowroot-adopt.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 (109289 => 109290)


--- trunk/LayoutTests/platform/qt/Skipped	2012-03-01 01:34:07 UTC (rev 109289)
+++ trunk/LayoutTests/platform/qt/Skipped	2012-03-01 01:55:08 UTC (rev 109290)
@@ -175,6 +175,7 @@
 fast/dom/shadow/shadow-ul-li.html
 fast/dom/shadow/multiple-shadowroot.html
 fast/dom/shadow/multiple-shadowroot-rendering.html
+fast/dom/shadow/multiple-shadowroot-adopt.html
 
 # CSS Regions support not yet enabled. http://webkit.org/b/57312
 fast/regions

Modified: trunk/LayoutTests/platform/win/Skipped (109289 => 109290)


--- trunk/LayoutTests/platform/win/Skipped	2012-03-01 01:34:07 UTC (rev 109289)
+++ trunk/LayoutTests/platform/win/Skipped	2012-03-01 01:55:08 UTC (rev 109290)
@@ -1463,6 +1463,7 @@
 fast/dom/shadow/shadow-ul-li.html
 fast/dom/shadow/multiple-shadowroot.html
 fast/dom/shadow/multiple-shadowroot-rendering.html
+fast/dom/shadow/multiple-shadowroot-adopt.html
 
 # CSS Regions support not yet enabled. http://webkit.org/b/57312
 fast/regions

Modified: trunk/LayoutTests/platform/wincairo/Skipped (109289 => 109290)


--- trunk/LayoutTests/platform/wincairo/Skipped	2012-03-01 01:34:07 UTC (rev 109289)
+++ trunk/LayoutTests/platform/wincairo/Skipped	2012-03-01 01:55:08 UTC (rev 109290)
@@ -1976,6 +1976,7 @@
 fast/dom/shadow/shadow-root-new.html
 fast/dom/shadow/multiple-shadowroot.html
 fast/dom/shadow/multiple-shadowroot-rendering.html
+fast/dom/shadow/multiple-shadowroot-adopt.html
 
 # CSS Regions support not yet enabled. http://webkit.org/b/57312
 fast/regions

Modified: trunk/LayoutTests/platform/wk2/Skipped (109289 => 109290)


--- trunk/LayoutTests/platform/wk2/Skipped	2012-03-01 01:34:07 UTC (rev 109289)
+++ trunk/LayoutTests/platform/wk2/Skipped	2012-03-01 01:55:08 UTC (rev 109290)
@@ -1074,6 +1074,7 @@
 fast/dom/shadow/shadow-ul-li.html
 fast/dom/shadow/multiple-shadowroot.html
 fast/dom/shadow/multiple-shadowroot-rendering.html
+fast/dom/shadow/multiple-shadowroot-adopt.html
 
 # WTR needs an implementation for eventSender.continuousMouseScrollBy
 # https://bugs.webkit.org/show_bug.cgi?id=69417

Modified: trunk/Source/WebCore/ChangeLog (109289 => 109290)


--- trunk/Source/WebCore/ChangeLog	2012-03-01 01:34:07 UTC (rev 109289)
+++ trunk/Source/WebCore/ChangeLog	2012-03-01 01:55:08 UTC (rev 109290)
@@ -1,3 +1,32 @@
+2012-02-29  Shinya Kawanaka  <[email protected]>
+
+        Methods in ShadowTree and TreeScopeAdopter should be multiple shadow roots aware.
+        https://bugs.webkit.org/show_bug.cgi?id=79768
+
+        Reviewed by Hajime Morita.
+
+        Some methods in ShadowTree and TreeScopeAdopter were not multiple shadow roots aware.
+        They should consider multiple shadow roots.
+
+        Test: fast/dom/shadow/multiple-shadowroot-adopt.html
+
+        * dom/ShadowTree.cpp:
+        (WebCore::ShadowTree::setParentTreeScope):
+        (WebCore):
+        (WebCore::ShadowTree::childNeedsStyleRecalc):
+        (WebCore::ShadowTree::needsStyleRecalc):
+        * dom/ShadowTree.h:
+        (WebCore):
+        (ShadowTree):
+        * dom/TreeScopeAdopter.cpp:
+        (WebCore::shadowTreeFor):
+        (WebCore::TreeScopeAdopter::moveTreeToNewScope):
+        (WebCore::TreeScopeAdopter::moveTreeToNewDocument):
+        (WebCore::TreeScopeAdopter::moveShadowTreeToNewDocument):
+        (WebCore):
+        * dom/TreeScopeAdopter.h:
+        (TreeScopeAdopter):
+
 2012-02-29  David Levin  <[email protected]>
 
         [chromium] Add the ability to turn off autoresize.

Modified: trunk/Source/WebCore/dom/ShadowTree.cpp (109289 => 109290)


--- trunk/Source/WebCore/dom/ShadowTree.cpp	2012-03-01 01:34:07 UTC (rev 109289)
+++ trunk/Source/WebCore/dom/ShadowTree.cpp	2012-03-01 01:55:08 UTC (rev 109290)
@@ -151,6 +151,12 @@
         root->willRemove();
 }
 
+void ShadowTree::setParentTreeScope(TreeScope* scope)
+{
+    for (ShadowRoot* root = youngestShadowRoot(); root; root = root->olderShadowRoot())
+        root->setParentTreeScope(scope);
+}
+
 void ShadowTree::attach()
 {
     // Children of m_selector is populated lazily in
@@ -213,19 +219,21 @@
 bool ShadowTree::childNeedsStyleRecalc()
 {
     ASSERT(youngestShadowRoot());
-    if (!youngestShadowRoot())
-        return false;
+    for (ShadowRoot* root = youngestShadowRoot(); root; root = root->olderShadowRoot())
+        if (root->childNeedsStyleRecalc())
+            return true;
 
-    return youngestShadowRoot()->childNeedsStyleRecalc();
+    return false;
 }
 
 bool ShadowTree::needsStyleRecalc()
 {
     ASSERT(youngestShadowRoot());
-    if (!youngestShadowRoot())
-        return false;
+    for (ShadowRoot* root = youngestShadowRoot(); root; root = root->olderShadowRoot())
+        if (root->needsStyleRecalc())
+            return true;
 
-    return youngestShadowRoot()->needsStyleRecalc();
+    return false;
 }
 
 void ShadowTree::recalcShadowTreeStyle(Node::StyleChange change)

Modified: trunk/Source/WebCore/dom/ShadowTree.h (109289 => 109290)


--- trunk/Source/WebCore/dom/ShadowTree.h	2012-03-01 01:34:07 UTC (rev 109289)
+++ trunk/Source/WebCore/dom/ShadowTree.h	2012-03-01 01:55:08 UTC (rev 109290)
@@ -40,6 +40,7 @@
 class Element;
 class HTMLContentSelector;
 class InsertionPoint;
+class TreeScope;
 
 class ShadowTree {
 public:
@@ -59,6 +60,8 @@
     void removedFromTree(bool deep);
     void willRemove();
 
+    void setParentTreeScope(TreeScope*);
+
     void attach();
     void detach();
     void reattach();

Modified: trunk/Source/WebCore/dom/TreeScopeAdopter.cpp (109289 => 109290)


--- trunk/Source/WebCore/dom/TreeScopeAdopter.cpp	2012-03-01 01:34:07 UTC (rev 109289)
+++ trunk/Source/WebCore/dom/TreeScopeAdopter.cpp	2012-03-01 01:55:08 UTC (rev 109290)
@@ -32,9 +32,9 @@
 
 namespace WebCore {
 
-static inline ShadowRoot* shadowRootFor(Node* node)
+static inline ShadowTree* shadowTreeFor(Node* node)
 {
-    return node->isElementNode() && toElement(node)->hasShadowRoot() ? toElement(node)->shadowTree()->youngestShadowRoot() : 0;
+    return node->isElementNode() ? toElement(node)->shadowTree() : 0;
 }
 
 void TreeScopeAdopter::moveTreeToNewScope(Node* root) const
@@ -63,10 +63,10 @@
         if (willMoveToNewDocument)
             moveNodeToNewDocument(node, oldDocument, newDocument);
 
-        if (ShadowRoot* shadow = shadowRootFor(node)) {
-            shadow->setParentTreeScope(m_newScope);
+        if (ShadowTree* tree = shadowTreeFor(node)) {
+            tree->setParentTreeScope(m_newScope);
             if (willMoveToNewDocument)
-                moveTreeToNewDocument(shadow, oldDocument, newDocument);
+                moveShadowTreeToNewDocument(tree, oldDocument, newDocument);
         }
     }
 }
@@ -75,11 +75,17 @@
 {
     for (Node* node = root; node; node = node->traverseNextNode(root)) {
         moveNodeToNewDocument(node, oldDocument, newDocument);
-        if (ShadowRoot* shadow = shadowRootFor(node))
-            moveTreeToNewDocument(shadow, oldDocument, newDocument);
+        if (ShadowTree* tree = shadowTreeFor(node))
+            moveShadowTreeToNewDocument(tree, oldDocument, newDocument);
     }
 }
 
+inline void TreeScopeAdopter::moveShadowTreeToNewDocument(ShadowTree* tree, Document* oldDocument, Document* newDocument) const
+{
+    for (ShadowRoot* root = tree->youngestShadowRoot(); root; root = root->olderShadowRoot())
+        moveTreeToNewDocument(root, oldDocument, newDocument);
+}
+
 #ifndef NDEBUG
 static bool didMoveToNewDocumentWasCalled = false;
 static Document* oldDocumentDidMoveToNewDocumentWasCalledWith = 0;

Modified: trunk/Source/WebCore/dom/TreeScopeAdopter.h (109289 => 109290)


--- trunk/Source/WebCore/dom/TreeScopeAdopter.h	2012-03-01 01:34:07 UTC (rev 109289)
+++ trunk/Source/WebCore/dom/TreeScopeAdopter.h	2012-03-01 01:55:08 UTC (rev 109290)
@@ -46,6 +46,7 @@
     void moveTreeToNewScope(Node*) const;
     void moveTreeToNewDocument(Node*, Document* oldDocument, Document* newDocument) const;
     void moveNodeToNewDocument(Node*, Document* oldDocument, Document* newDocument) const;
+    void moveShadowTreeToNewDocument(ShadowTree*, Document* oldDocument, Document* newDocument) const;
 
     Node* m_toAdopt;
     TreeScope* m_newScope;
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to