| 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
|
|
|