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

Unified Diff: Source/WebCore/dom/TreeScope.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/TreeScope.h ('k') | Source/WebCore/dom/TreeScopeAdopter.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/WebCore/dom/TreeScope.cpp
===================================================================
--- Source/WebCore/dom/TreeScope.cpp (revision 145445)
+++ Source/WebCore/dom/TreeScope.cpp (working copy)
@@ -59,6 +59,7 @@
struct SameSizeAsTreeScope {
virtual ~SameSizeAsTreeScope();
void* pointers[8];
+ int ints[1];
};
COMPILE_ASSERT(sizeof(TreeScope) == sizeof(SameSizeAsTreeScope), treescope_should_stay_small);
@@ -69,35 +70,47 @@
: m_rootNode(rootNode)
, m_documentScope(document)
, m_parentTreeScope(document)
+ , m_guardRefCount(0)
, m_idTargetObserverRegistry(IdTargetObserverRegistry::create())
{
ASSERT(rootNode);
ASSERT(document);
ASSERT(rootNode != document);
+ m_parentTreeScope->guardRef();
+ m_rootNode->setTreeScope(this);
}
TreeScope::TreeScope(Document* document)
: m_rootNode(document)
, m_documentScope(document)
, m_parentTreeScope(0)
+ , m_guardRefCount(0)
, m_idTargetObserverRegistry(IdTargetObserverRegistry::create())
{
ASSERT(document);
+ m_rootNode->setTreeScope(this);
}
TreeScope::TreeScope()
: m_rootNode(0)
, m_documentScope(0)
, m_parentTreeScope(0)
+ , m_guardRefCount(0)
{
}
TreeScope::~TreeScope()
{
+ ASSERT(!m_guardRefCount);
+ m_rootNode->setTreeScope(noDocumentInstance());
+
if (m_selection) {
m_selection->clearTreeScope();
m_selection = 0;
}
+
+ if (m_parentTreeScope)
+ m_parentTreeScope->guardDeref();
}
void TreeScope::destroyTreeScopeData()
@@ -120,6 +133,9 @@
// Every scope other than document needs a parent scope.
ASSERT(newParentScope);
+ newParentScope->guardRef();
+ if (m_parentTreeScope)
+ m_parentTreeScope->guardDeref();
m_parentTreeScope = newParentScope;
setDocumentScope(newParentScope->documentScope());
}
@@ -415,4 +431,24 @@
return treeScopesA[indexA] == treeScopesB[indexB] ? treeScopesA[indexA] : 0;
}
+#ifndef NDEBUG
+bool TreeScope::deletionHasBegun()
+{
+ return rootNode() && rootNode()->m_deletionHasBegun;
+}
+
+void TreeScope::beginDeletion()
+{
+ ASSERT(this != noDocumentInstance());
+ rootNode()->m_deletionHasBegun = true;
+}
+#endif
+
+int TreeScope::refCount() const
+{
+ if (Node* root = rootNode())
+ return root->refCount();
+ return 0;
+}
+
} // namespace WebCore
« no previous file with comments | « Source/WebCore/dom/TreeScope.h ('k') | Source/WebCore/dom/TreeScopeAdopter.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698