Bug 1034906 - Don't manually delete NodeIterator. r=ehsan
authorAndrew McCreight <continuation@gmail.com>
Tue, 08 Jul 2014 13:46:24 -0700
changeset 192870 7f6cbfe1a68b95787ceedf1e98b951f8f9a157de
parent 192869 2e1c25d3cd2ab7580a1c8345abe1cc35215ca3a3
child 192871 c45fdb6a9e358f7192659edc02bb95a179824ae4
push id45963
push useramccreight@mozilla.com
push dateTue, 08 Jul 2014 20:46:42 +0000
treeherdermozilla-inbound@7f6cbfe1a68b [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersehsan
bugs1034906
milestone33.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1034906 - Don't manually delete NodeIterator. r=ehsan
content/base/src/NodeIterator.h
editor/libeditor/text/nsTextEditRules.cpp
--- a/content/base/src/NodeIterator.h
+++ b/content/base/src/NodeIterator.h
@@ -28,17 +28,16 @@ class NodeIterator MOZ_FINAL : public ns
 {
 public:
     NS_DECL_CYCLE_COLLECTING_ISUPPORTS
     NS_DECL_NSIDOMNODEITERATOR
 
     NodeIterator(nsINode *aRoot,
                  uint32_t aWhatToShow,
                  const NodeFilterHolder &aFilter);
-    virtual ~NodeIterator();
 
     NS_DECL_NSIMUTATIONOBSERVER_CONTENTREMOVED
 
     NS_DECL_CYCLE_COLLECTION_CLASS_AMBIGUOUS(NodeIterator, nsIDOMNodeIterator)
 
     // WebIDL API
     nsINode* Root() const
     {
@@ -68,16 +67,18 @@ public:
     {
         return NextOrPrevNode(&NodePointer::MoveToPrevious, aResult);
     }
     // The XPCOM Detach() is fine for our purposes
 
     JSObject* WrapObject(JSContext *cx);
 
 private:
+    virtual ~NodeIterator();
+
     struct NodePointer {
         NodePointer() : mNode(nullptr) {}
         NodePointer(nsINode *aNode, bool aBeforeNode);
 
         typedef bool (NodePointer::*MoveToMethodType)(nsINode*);
         bool MoveToNext(nsINode *aRoot);
         bool MoveToPrevious(nsINode *aRoot);
 
@@ -111,17 +112,11 @@ private:
     NextOrPrevNode(NodePointer::MoveToMethodType aMove, ErrorResult& aResult);
 
     NodePointer mPointer;
     NodePointer mWorkingPointer;
 };
 
 } // namespace dom
 
-template<>
-struct HasDangerousPublicDestructor<dom::NodeIterator>
-{
-  static const bool value = true;
-};
-
 } // namespace mozilla
 
 #endif // mozilla_dom_NodeIterator_h
--- a/editor/libeditor/text/nsTextEditRules.cpp
+++ b/editor/libeditor/text/nsTextEditRules.cpp
@@ -476,20 +476,20 @@ GetTextNode(nsISelection *selection, nsE
   nsresult res = editor->GetStartNodeAndOffset(selection, getter_AddRefs(selNode), &selOffset);
   NS_ENSURE_SUCCESS(res, nullptr);
   if (!editor->IsTextNode(selNode)) {
     // Get an nsINode from the nsIDOMNode
     nsCOMPtr<nsINode> node = do_QueryInterface(selNode);
     // 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<NodeIterator> 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;
       }
     }
   }
   return selNode.forget();
 }
 #ifdef DEBUG
 #define ASSERT_PASSWORD_LENGTHS_EQUAL()                                \