Index: Source/WebCore/dom/TreeScopeAdopter.cpp |
=================================================================== |
--- Source/WebCore/dom/TreeScopeAdopter.cpp (revision 140739) |
+++ Source/WebCore/dom/TreeScopeAdopter.cpp (working copy) |
@@ -51,15 +51,14 @@ |
for (Node* node = root; node; node = NodeTraversal::next(node, root)) { |
node->setTreeScope(m_newScope); |
- if (node->hasRareData()) { |
+ if (willMoveToNewDocument) |
+ moveNodeToNewDocument(node, oldDocument, newDocument); |
+ else if (node->hasRareData()) { |
NodeRareData* rareData = node->rareData(); |
if (rareData->nodeLists()) |
- rareData->nodeLists()->adoptTreeScope(oldDocument, newDocument); |
+ rareData->nodeLists()->adoptTreeScope(); |
} |
- if (willMoveToNewDocument) |
- moveNodeToNewDocument(node, oldDocument, newDocument); |
- |
for (ShadowRoot* shadow = node->youngestShadowRoot(); shadow; shadow = shadow->olderShadowRoot()) { |
shadow->setParentTreeScope(m_newScope); |
if (willMoveToNewDocument) |
@@ -93,6 +92,12 @@ |
{ |
ASSERT(!node->inDocument() || oldDocument != newDocument); |
+ if (node->hasRareData()) { |
+ NodeRareData* rareData = node->rareData(); |
+ if (rareData->nodeLists()) |
+ rareData->nodeLists()->adoptDocument(oldDocument, newDocument); |
+ } |
+ |
newDocument->guardRef(); |
if (oldDocument) |
oldDocument->moveNodeIteratorsToNewDocument(node, newDocument); |