From 3b71ecc4584594f398e02839b8eb21a21140f6c9 Mon Sep 17 00:00:00 2001 From: Andrew McCreight Date: Tue, 8 Jul 2014 13:46:24 -0700 Subject: [PATCH] Bug 1034906 - Don't manually delete NodeIterator. r=ehsan --- content/base/src/NodeIterator.h | 9 ++------- editor/libeditor/text/nsTextEditRules.cpp | 6 +++--- 2 files changed, 5 insertions(+), 10 deletions(-) diff --git a/content/base/src/NodeIterator.h b/content/base/src/NodeIterator.h index 29edaf761644..705adffd4257 100644 --- a/content/base/src/NodeIterator.h +++ b/content/base/src/NodeIterator.h @@ -33,7 +33,6 @@ public: NodeIterator(nsINode *aRoot, uint32_t aWhatToShow, const NodeFilterHolder &aFilter); - virtual ~NodeIterator(); NS_DECL_NSIMUTATIONOBSERVER_CONTENTREMOVED @@ -73,6 +72,8 @@ public: JSObject* WrapObject(JSContext *cx); private: + virtual ~NodeIterator(); + struct NodePointer { NodePointer() : mNode(nullptr) {} NodePointer(nsINode *aNode, bool aBeforeNode); @@ -116,12 +117,6 @@ private: } // namespace dom -template<> -struct HasDangerousPublicDestructor -{ - static const bool value = true; -}; - } // namespace mozilla #endif // mozilla_dom_NodeIterator_h diff --git a/editor/libeditor/text/nsTextEditRules.cpp b/editor/libeditor/text/nsTextEditRules.cpp index 01d1d927d114..cc352f6dcbe9 100644 --- a/editor/libeditor/text/nsTextEditRules.cpp +++ b/editor/libeditor/text/nsTextEditRules.cpp @@ -481,10 +481,10 @@ GetTextNode(nsISelection *selection, nsEditor *editor) { // if node is null, return it to indicate there's no text NS_ENSURE_TRUE(node, nullptr); // This should be the root node, walk the tree looking for text nodes - mozilla::dom::NodeFilterHolder filter; - mozilla::dom::NodeIterator iter(node, nsIDOMNodeFilter::SHOW_TEXT, filter); + NodeFilterHolder filter; + nsRefPtr iter = new NodeIterator(node, nsIDOMNodeFilter::SHOW_TEXT, filter); while (!editor->IsTextNode(selNode)) { - if (NS_FAILED(res = iter.NextNode(getter_AddRefs(selNode))) || !selNode) { + if (NS_FAILED(res = iter->NextNode(getter_AddRefs(selNode))) || !selNode) { return nullptr; } }