Title: [139958] trunk
Revision
139958
Author
morr...@google.com
Date
2013-01-16 20:22:41 -0800 (Wed, 16 Jan 2013)

Log Message

Attr.ownerDocument should change if its parent's owner did
https://bugs.webkit.org/show_bug.cgi?id=97644

Reviewed by Darin Adler.

Source/WebCore:

moveTreeToNewScope() didn't traverse its Attr instances. But it should.

Test: fast/dom/Attr/parent-adopt-node.html

* dom/ElementAttributeData.cpp:
(WebCore::ElementAttributeData::getExistingAttrs):
(WebCore):
* dom/ElementAttributeData.h:
(ElementAttributeData):
* dom/TreeScopeAdopter.cpp:
(WebCore::TreeScopeAdopter::moveTreeToNewScope):

LayoutTests:

* fast/dom/Attr/parent-adopt-node-expected.txt: Added.
* fast/dom/Attr/parent-adopt-node.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (139957 => 139958)


--- trunk/LayoutTests/ChangeLog	2013-01-17 04:00:01 UTC (rev 139957)
+++ trunk/LayoutTests/ChangeLog	2013-01-17 04:22:41 UTC (rev 139958)
@@ -1,3 +1,13 @@
+2013-01-16  MORITA Hajime  <morr...@google.com>
+
+        Attr.ownerDocument should change if its parent's owner did
+        https://bugs.webkit.org/show_bug.cgi?id=97644
+
+        Reviewed by Darin Adler.
+
+        * fast/dom/Attr/parent-adopt-node-expected.txt: Added.
+        * fast/dom/Attr/parent-adopt-node.html: Added.
+
 2013-01-16  Victor Carbune  <vcarb...@chromium.org>
 
         Cues not rendered when they should be

Added: trunk/LayoutTests/fast/dom/Attr/parent-adopt-node-expected.txt (0 => 139958)


--- trunk/LayoutTests/fast/dom/Attr/parent-adopt-node-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/fast/dom/Attr/parent-adopt-node-expected.txt	2013-01-17 04:22:41 UTC (rev 139958)
@@ -0,0 +1,5 @@
+PASS attr.ownerDocument.title is anotherDocument.title
+PASS successfullyParsed is true
+
+TEST COMPLETE
+

Added: trunk/LayoutTests/fast/dom/Attr/parent-adopt-node.html (0 => 139958)


--- trunk/LayoutTests/fast/dom/Attr/parent-adopt-node.html	                        (rev 0)
+++ trunk/LayoutTests/fast/dom/Attr/parent-adopt-node.html	2013-01-17 04:22:41 UTC (rev 139958)
@@ -0,0 +1,18 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script src=""
+</head>
+<body>
+<div id="target"></div>
+<script>
+var target = document.getElementById("target");
+var attr = target.attributes[0];
+var anotherDocument = document.implementation.createDocument("http://www.w3.org/1999/xhtml", "", null);
+anotherDocument.title = "Hello";
+anotherDocument.adoptNode(target);
+shouldBe("attr.ownerDocument.title", "anotherDocument.title");
+</script>
+<script src=""
+</body>
+</html>

Modified: trunk/Source/WebCore/ChangeLog (139957 => 139958)


--- trunk/Source/WebCore/ChangeLog	2013-01-17 04:00:01 UTC (rev 139957)
+++ trunk/Source/WebCore/ChangeLog	2013-01-17 04:22:41 UTC (rev 139958)
@@ -1,3 +1,22 @@
+2013-01-16  MORITA Hajime  <morr...@google.com>
+
+        Attr.ownerDocument should change if its parent's owner did
+        https://bugs.webkit.org/show_bug.cgi?id=97644
+
+        Reviewed by Darin Adler.
+
+        moveTreeToNewScope() didn't traverse its Attr instances. But it should.
+
+        Test: fast/dom/Attr/parent-adopt-node.html
+
+        * dom/ElementAttributeData.cpp:
+        (WebCore::ElementAttributeData::getExistingAttrs):
+        (WebCore):
+        * dom/ElementAttributeData.h:
+        (ElementAttributeData):
+        * dom/TreeScopeAdopter.cpp:
+        (WebCore::TreeScopeAdopter::moveTreeToNewScope):
+
 2013-01-16  Adam Barth  <aba...@webkit.org>
 
         Address tonyg's feedback on BackgroundHTMLParser

Modified: trunk/Source/WebCore/dom/Element.cpp (139957 => 139958)


--- trunk/Source/WebCore/dom/Element.cpp	2013-01-17 04:00:01 UTC (rev 139957)
+++ trunk/Source/WebCore/dom/Element.cpp	2013-01-17 04:22:41 UTC (rev 139958)
@@ -1642,6 +1642,12 @@
 }
 #endif
 
+const Vector<RefPtr<Attr> >& Element::attrNodeList()
+{
+    ASSERT(hasSyntheticAttrChildNodes());
+    return *attrNodeListForElement(this);
+}
+
 PassRefPtr<Attr> Element::setAttributeNode(Attr* attrNode, ExceptionCode& ec)
 {
     if (!attrNode) {

Modified: trunk/Source/WebCore/dom/Element.h (139957 => 139958)


--- trunk/Source/WebCore/dom/Element.h	2013-01-17 04:00:01 UTC (rev 139957)
+++ trunk/Source/WebCore/dom/Element.h	2013-01-17 04:22:41 UTC (rev 139958)
@@ -37,6 +37,7 @@
 
 namespace WebCore {
 
+class Attr;
 class Attribute;
 class ClientRect;
 class ClientRectList;
@@ -228,7 +229,9 @@
 
     PassRefPtr<Attr> attrIfExists(const QualifiedName&);
     PassRefPtr<Attr> ensureAttr(const QualifiedName&);
-    
+
+    const Vector<RefPtr<Attr> >& attrNodeList();
+
     virtual CSSStyleDeclaration* style();
 
     const QualifiedName& tagQName() const { return m_tagName; }

Modified: trunk/Source/WebCore/dom/TreeScopeAdopter.cpp (139957 => 139958)


--- trunk/Source/WebCore/dom/TreeScopeAdopter.cpp	2013-01-17 04:00:01 UTC (rev 139957)
+++ trunk/Source/WebCore/dom/TreeScopeAdopter.cpp	2013-01-17 04:22:41 UTC (rev 139958)
@@ -25,6 +25,7 @@
 #include "config.h"
 #include "TreeScopeAdopter.h"
 
+#include "Attr.h"
 #include "Document.h"
 #include "ElementRareData.h"
 #include "ElementShadow.h"
@@ -61,6 +62,15 @@
         if (willMoveToNewDocument)
             moveNodeToNewDocument(node, oldDocument, newDocument);
 
+        if (!node->isElementNode())
+            continue;
+
+        if (node->hasSyntheticAttrChildNodes()) {
+            const Vector<RefPtr<Attr> >& attrs = toElement(node)->attrNodeList();
+            for (unsigned i = 0; i < attrs.size(); ++i)
+                moveTreeToNewScope(attrs[i].get());
+        }
+
         for (ShadowRoot* shadow = node->youngestShadowRoot(); shadow; shadow = shadow->olderShadowRoot()) {
             shadow->setParentTreeScope(m_newScope);
             if (willMoveToNewDocument)
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to