Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(114)

Unified Diff: Source/WebCore/dom/TreeScopeAdopter.cpp

Issue 12518022: Merge 143840 (Closed) Base URL: http://svn.webkit.org/repository/webkit/branches/chromium/1410/
Patch Set: Created 7 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/WebCore/dom/TreeScopeAdopter.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/WebCore/dom/TreeScopeAdopter.cpp
===================================================================
--- Source/WebCore/dom/TreeScopeAdopter.cpp (revision 145445)
+++ Source/WebCore/dom/TreeScopeAdopter.cpp (working copy)
@@ -40,6 +40,8 @@
{
ASSERT(needsScopeChange());
+ m_oldScope->guardRef();
+
// If an element is moved from a document and then eventually back again the collection cache for
// that element may contain stale data as changes made to it will have updated the DOMTreeVersion
// of the document it was moved to. By increasing the DOMTreeVersion of the donating document here
@@ -51,7 +53,7 @@
oldDocument->incDOMTreeVersion();
for (Node* node = root; node; node = NodeTraversal::next(node, root)) {
- node->setTreeScope(m_newScope);
+ updateTreeScope(node);
if (willMoveToNewDocument)
moveNodeToNewDocument(node, oldDocument, newDocument);
@@ -76,6 +78,8 @@
moveTreeToNewDocument(shadow, oldDocument, newDocument);
}
}
+
+ m_oldScope->guardDeref();
}
void TreeScopeAdopter::moveTreeToNewDocument(Node* root, Document* oldDocument, Document* newDocument) const
@@ -99,6 +103,15 @@
}
#endif
+inline void TreeScopeAdopter::updateTreeScope(Node* node) const
+{
+ ASSERT(!node->isTreeScope());
+ ASSERT(node->treeScope() == m_oldScope);
+ m_newScope->guardRef();
+ m_oldScope->guardDeref();
+ node->setTreeScope(m_newScope);
+}
+
inline void TreeScopeAdopter::moveNodeToNewDocument(Node* node, Document* oldDocument, Document* newDocument) const
{
ASSERT(!node->inDocument() || oldDocument != newDocument);
@@ -109,7 +122,6 @@
rareData->nodeLists()->adoptDocument(oldDocument, newDocument);
}
- newDocument->guardRef();
if (oldDocument)
oldDocument->moveNodeIteratorsToNewDocument(node, newDocument);
@@ -123,9 +135,6 @@
node->didMoveToNewDocument(oldDocument);
ASSERT(didMoveToNewDocumentWasCalled);
-
- if (oldDocument)
- oldDocument->guardDeref();
}
}
« no previous file with comments | « Source/WebCore/dom/TreeScopeAdopter.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698