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

Unified Diff: Source/WebCore/dom/TreeScope.h

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/ShadowRoot.cpp ('k') | Source/WebCore/dom/TreeScope.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/WebCore/dom/TreeScope.h
===================================================================
--- Source/WebCore/dom/TreeScope.h (revision 145445)
+++ Source/WebCore/dom/TreeScope.h (working copy)
@@ -92,7 +92,7 @@
// Used by the basic DOM mutation methods (e.g., appendChild()).
void adoptIfNeeded(Node*);
- ContainerNode* rootNode() const { return m_rootNode; }
+ Node* rootNode() const { return m_rootNode; }
IdTargetObserverRegistry& idTargetObserverRegistry() const { return *m_idTargetObserverRegistry.get(); }
@@ -104,6 +104,29 @@
return &instance;
}
+ // Nodes belonging to this scope hold guard references -
+ // these are enough to keep the scope from being destroyed, but
+ // not enough to keep it from removing its children. This allows a
+ // node that outlives its scope to still have a valid document
+ // pointer without introducing reference cycles.
+ void guardRef()
+ {
+ ASSERT(!deletionHasBegun());
+ ++m_guardRefCount;
+ }
+
+ void guardDeref()
+ {
+ ASSERT(!deletionHasBegun());
+ --m_guardRefCount;
+ if (!m_guardRefCount && !refCount() && this != noDocumentInstance()) {
+ beginDeletion();
+ delete this;
+ }
+ }
+
+ void removedLastRefToScope();
+
protected:
TreeScope(ContainerNode*, Document*);
TreeScope(Document*);
@@ -118,12 +141,26 @@
m_documentScope = document;
}
+ bool hasGuardRefCount() const { return m_guardRefCount; }
+
private:
TreeScope();
- ContainerNode* m_rootNode;
+ virtual void dispose() { }
+
+ int refCount() const;
+#ifndef NDEBUG
+ bool deletionHasBegun();
+ void beginDeletion();
+#else
+ bool deletionHasBegun() { return false; }
+ void beginDeletion() { }
+#endif
+
+ Node* m_rootNode;
Document* m_documentScope;
TreeScope* m_parentTreeScope;
+ int m_guardRefCount;
OwnPtr<DocumentOrderedMap> m_elementsById;
OwnPtr<DocumentOrderedMap> m_imageMapsByName;
« no previous file with comments | « Source/WebCore/dom/ShadowRoot.cpp ('k') | Source/WebCore/dom/TreeScope.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698