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

Unified Diff: Source/WebCore/dom/Node.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/Node.h ('k') | Source/WebCore/dom/ShadowRoot.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/WebCore/dom/Node.cpp
===================================================================
--- Source/WebCore/dom/Node.cpp (revision 145445)
+++ Source/WebCore/dom/Node.cpp (working copy)
@@ -437,8 +437,7 @@
if (m_next)
m_next->setPreviousSibling(0);
- if (doc)
- doc->guardDeref();
+ m_treeScope->guardDeref();
InspectorCounters::decrementCounter(InspectorCounters::NodeCounter);
}
@@ -887,11 +886,6 @@
return true;
}
-bool Node::isTreeScope() const
-{
- return treeScope()->rootNode() == this;
-}
-
bool Node::isKeyboardFocusable(KeyboardEvent*) const
{
return isFocusable() && tabIndex() >= 0;
@@ -2561,6 +2555,31 @@
}
#endif
+// This is here for inlining
+inline void TreeScope::removedLastRefToScope()
+{
+ ASSERT(!deletionHasBegun());
+ if (m_guardRefCount) {
+ // If removing a child removes the last self-only ref, we don't
+ // want the scope to be destructed until after
+ // removeDetachedChildren returns, so we guard ourselves with an
+ // extra self-only ref.
+ guardRef();
+ dispose();
+#ifndef NDEBUG
+ // We need to do this right now since guardDeref() can delete this.
+ rootNode()->m_inRemovedLastRefFunction = false;
+#endif
+ guardDeref();
+ } else {
+#ifndef NDEBUG
+ rootNode()->m_inRemovedLastRefFunction = false;
+ beginDeletion();
+#endif
+ delete this;
+ }
+}
+
// It's important not to inline removedLastRef, because we don't want to inline the code to
// delete a Node at each deref call site.
void Node::removedLastRef()
@@ -2568,10 +2587,11 @@
// An explicit check for Document here is better than a virtual function since it is
// faster for non-Document nodes, and because the call to removedLastRef that is inlined
// at all deref call sites is smaller if it's a non-virtual function.
- if (isDocumentNode()) {
- static_cast<Document*>(this)->removedLastRef();
+ if (isTreeScope()) {
+ treeScope()->removedLastRefToScope();
return;
}
+
#ifndef NDEBUG
m_deletionHasBegun = true;
#endif
« no previous file with comments | « Source/WebCore/dom/Node.h ('k') | Source/WebCore/dom/ShadowRoot.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698