Bug 776536 part 1. Rename nsNodeIterator to mozilla::dom::NodeIterator. r=peterv
authorBoris Zbarsky <bzbarsky@mit.edu>
Thu, 28 Feb 2013 12:56:41 -0500
changeset 134607 cbf95d0e69410fc17de71247e59e341b7a884fe1
parent 134606 38578014b8a8c20bf5a200b3040e5c7a7d02c74f
child 134608 5e0a9285a7aa898c3a16e2c8ce978c1591b5a342
push id336
push userakeybl@mozilla.com
push dateMon, 17 Jun 2013 22:53:19 +0000
treeherdermozilla-release@574a39cdf657 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerspeterv
bugs776536
milestone22.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 776536 part 1. Rename nsNodeIterator to mozilla::dom::NodeIterator. r=peterv
content/base/src/Makefile.in
content/base/src/NodeIterator.cpp
content/base/src/NodeIterator.h
content/base/src/nsDocument.cpp
content/base/src/nsNodeIterator.cpp
content/base/src/nsNodeIterator.h
editor/libeditor/text/nsTextEditRules.cpp
--- a/content/base/src/Makefile.in
+++ b/content/base/src/Makefile.in
@@ -46,16 +46,17 @@ EXPORTS_NAMESPACES = mozilla/dom
 
 EXPORTS_mozilla/dom = \
   Comment.h \
   DocumentFragment.h \
   DocumentType.h \
   DOMImplementation.h \
   EventSource.h \
   Link.h \
+  NodeIterator.h \
   Text.h \
   $(NULL)
 
 CPPSRCS		= \
 		Comment.cpp \
 		DirectionalityUtils.cpp \
 		DocumentType.cpp \
 		DOMImplementation.cpp \
@@ -102,17 +103,17 @@ CPPSRCS		= \
 		nsINode.cpp \
 		nsLineBreaker.cpp \
 		nsMappedAttributeElement.cpp \
 		nsMappedAttributes.cpp \
 		nsNameSpaceManager.cpp \
 		nsNoDataProtocolContentPolicy.cpp \
 		nsNodeInfo.cpp \
 		nsNodeInfoManager.cpp \
-		nsNodeIterator.cpp \
+		NodeIterator.cpp \
 		nsNodeUtils.cpp \
 		nsObjectLoadingContent.cpp \
 		nsPlainTextSerializer.cpp \
 		nsPropertyTable.cpp \
 		nsRange.cpp \
 		nsReferencedElement.cpp \
 		nsScriptElement.cpp \
 		nsScriptLoader.cpp \
rename from content/base/src/nsNodeIterator.cpp
rename to content/base/src/NodeIterator.cpp
--- a/content/base/src/nsNodeIterator.cpp
+++ b/content/base/src/NodeIterator.cpp
@@ -3,42 +3,44 @@
  * This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 /*
  * Implementation of DOM Traversal's nsIDOMNodeIterator
  */
 
-#include "nsNodeIterator.h"
+#include "mozilla/dom/NodeIterator.h"
 
 #include "nsIDOMNode.h"
 #include "nsIDOMNodeFilter.h"
 #include "nsError.h"
 
 #include "nsIContent.h"
 #include "nsIDocument.h"
 #include "nsDOMClassInfoID.h"
 #include "nsContentUtils.h"
 #include "nsCOMPtr.h"
 #include "mozilla/dom/NodeFilterBinding.h"
 
-using namespace mozilla::dom;
+DOMCI_DATA(NodeIterator, mozilla::dom::NodeIterator)
+
+namespace mozilla {
+namespace dom {
 
 /*
  * NodePointer implementation
  */
-nsNodeIterator::NodePointer::NodePointer(nsINode *aNode,
-                                         bool aBeforeNode) :
+NodeIterator::NodePointer::NodePointer(nsINode *aNode, bool aBeforeNode) :
     mNode(aNode),
     mBeforeNode(aBeforeNode)
 {
 }
 
-bool nsNodeIterator::NodePointer::MoveToNext(nsINode *aRoot)
+bool NodeIterator::NodePointer::MoveToNext(nsINode *aRoot)
 {
     if (!mNode)
       return false;
 
     if (mBeforeNode) {
         mBeforeNode = false;
         return true;
     }
@@ -47,17 +49,17 @@ bool nsNodeIterator::NodePointer::MoveTo
     if (child) {
         mNode = child;
         return true;
     }
 
     return MoveForward(aRoot, mNode);
 }
 
-bool nsNodeIterator::NodePointer::MoveToPrevious(nsINode *aRoot)
+bool NodeIterator::NodePointer::MoveToPrevious(nsINode *aRoot)
 {
     if (!mNode)
       return false;
 
     if (!mBeforeNode) {
         mBeforeNode = true;
         return true;
     }
@@ -65,20 +67,20 @@ bool nsNodeIterator::NodePointer::MoveTo
     if (mNode == aRoot)
         return false;
 
     MoveBackward(mNode->GetParentNode(), mNode->GetPreviousSibling());
 
     return true;
 }
 
-void nsNodeIterator::NodePointer::AdjustAfterRemoval(nsINode *aRoot,
-                                                     nsINode *aContainer,
-                                                     nsIContent *aChild,
-                                                     nsIContent *aPreviousSibling)
+void NodeIterator::NodePointer::AdjustAfterRemoval(nsINode *aRoot,
+                                                   nsINode *aContainer,
+                                                   nsIContent *aChild,
+                                                   nsIContent *aPreviousSibling)
 {
     // If mNode is null or the root there is nothing to do.
     if (!mNode || mNode == aRoot)
         return;
 
     // check if ancestor was removed
     if (!nsContentUtils::ContentIsDescendantOf(mNode, aChild))
         return;
@@ -100,137 +102,135 @@ void nsNodeIterator::NodePointer::Adjust
 
         // No suitable node was found so try going backwards
         mBeforeNode = false;
     }
 
     MoveBackward(aContainer, aPreviousSibling);
 }
 
-bool nsNodeIterator::NodePointer::MoveForward(nsINode *aRoot, nsINode *aNode)
+bool NodeIterator::NodePointer::MoveForward(nsINode *aRoot, nsINode *aNode)
 {
     while (1) {
         if (aNode == aRoot)
             break;
 
         nsINode *sibling = aNode->GetNextSibling();
         if (sibling) {
             mNode = sibling;
             return true;
         }
         aNode = aNode->GetParentNode();
     }
 
     return false;
 }
 
-void nsNodeIterator::NodePointer::MoveBackward(nsINode *aParent, nsINode *aNode)
+void NodeIterator::NodePointer::MoveBackward(nsINode *aParent, nsINode *aNode)
 {
     if (aNode) {
         do {
             mNode = aNode;
             aNode = aNode->GetLastChild();
         } while (aNode);
     } else {
         mNode = aParent;
     }
 }
 
 /*
  * Factories, constructors and destructors
  */
 
-nsNodeIterator::nsNodeIterator(nsINode *aRoot,
-                               uint32_t aWhatToShow,
-                               const NodeFilterHolder &aFilter) :
+NodeIterator::NodeIterator(nsINode *aRoot,
+                           uint32_t aWhatToShow,
+                           const NodeFilterHolder &aFilter) :
     nsTraversal(aRoot, aWhatToShow, aFilter),
     mDetached(false),
     mPointer(mRoot, true)
 {
     aRoot->AddMutationObserver(this);
 }
 
-nsNodeIterator::~nsNodeIterator()
+NodeIterator::~NodeIterator()
 {
     /* destructor code */
     if (!mDetached && mRoot)
         mRoot->RemoveMutationObserver(this);
 }
 
 /*
  * nsISupports and cycle collection stuff
  */
 
-NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(nsNodeIterator)
+NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(NodeIterator)
     if (!tmp->mDetached && tmp->mRoot)
         tmp->mRoot->RemoveMutationObserver(tmp);
   NS_IMPL_CYCLE_COLLECTION_UNLINK(mRoot)
   NS_IMPL_CYCLE_COLLECTION_UNLINK(mFilter)
 NS_IMPL_CYCLE_COLLECTION_UNLINK_END
-NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(nsNodeIterator)
+NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(NodeIterator)
   NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mRoot)
   NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mFilter)
 NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
 
-DOMCI_DATA(NodeIterator, nsNodeIterator)
-
-// QueryInterface implementation for nsNodeIterator
-NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(nsNodeIterator)
+// QueryInterface implementation for NodeIterator
+NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(NodeIterator)
     NS_INTERFACE_MAP_ENTRY(nsIDOMNodeIterator)
     NS_INTERFACE_MAP_ENTRY(nsIMutationObserver)
     NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIDOMNodeIterator)
     NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(NodeIterator)
 NS_INTERFACE_MAP_END
 
-NS_IMPL_CYCLE_COLLECTING_ADDREF(nsNodeIterator)
-NS_IMPL_CYCLE_COLLECTING_RELEASE(nsNodeIterator)
+NS_IMPL_CYCLE_COLLECTING_ADDREF(NodeIterator)
+NS_IMPL_CYCLE_COLLECTING_RELEASE(NodeIterator)
 
 /* readonly attribute nsIDOMNode root; */
-NS_IMETHODIMP nsNodeIterator::GetRoot(nsIDOMNode * *aRoot)
+NS_IMETHODIMP NodeIterator::GetRoot(nsIDOMNode * *aRoot)
 {
     if (mRoot)
         return CallQueryInterface(mRoot, aRoot);
 
     *aRoot = nullptr;
 
     return NS_OK;
 }
 
 /* readonly attribute unsigned long whatToShow; */
-NS_IMETHODIMP nsNodeIterator::GetWhatToShow(uint32_t *aWhatToShow)
+NS_IMETHODIMP NodeIterator::GetWhatToShow(uint32_t *aWhatToShow)
 {
     *aWhatToShow = mWhatToShow;
     return NS_OK;
 }
 
 /* readonly attribute nsIDOMNodeFilter filter; */
-NS_IMETHODIMP nsNodeIterator::GetFilter(nsIDOMNodeFilter **aFilter)
+NS_IMETHODIMP NodeIterator::GetFilter(nsIDOMNodeFilter **aFilter)
 {
     NS_ENSURE_ARG_POINTER(aFilter);
 
     *aFilter = mFilter.ToXPCOMCallback().get();
 
     return NS_OK;
 }
 
 /* nsIDOMNode nextNode ()  raises (DOMException); */
-NS_IMETHODIMP nsNodeIterator::NextNode(nsIDOMNode **_retval)
+NS_IMETHODIMP NodeIterator::NextNode(nsIDOMNode **_retval)
 {
     return NextOrPrevNode(&NodePointer::MoveToNext, _retval);
 }
 
 /* nsIDOMNode previousNode ()  raises (DOMException); */
-NS_IMETHODIMP nsNodeIterator::PreviousNode(nsIDOMNode **_retval)
+NS_IMETHODIMP NodeIterator::PreviousNode(nsIDOMNode **_retval)
 {
     return NextOrPrevNode(&NodePointer::MoveToPrevious, _retval);
 }
 
 nsresult
-nsNodeIterator::NextOrPrevNode(NodePointer::MoveToMethodType aMove,
-                               nsIDOMNode **_retval)
+NodeIterator::NextOrPrevNode(NodePointer::MoveToMethodType aMove,
+                             nsIDOMNode **_retval)
 {
     nsresult rv;
     int16_t filtered;
 
     *_retval = nullptr;
 
     if (mDetached || mInAcceptNode)
         return NS_ERROR_DOM_INVALID_STATE_ERR;
@@ -256,53 +256,56 @@ nsNodeIterator::NextOrPrevNode(NodePoint
             return CallQueryInterface(testNode, _retval);
         }
     }
 
     return NS_OK;
 }
 
 /* void detach (); */
-NS_IMETHODIMP nsNodeIterator::Detach(void)
+NS_IMETHODIMP NodeIterator::Detach(void)
 {
     if (!mDetached) {
         mRoot->RemoveMutationObserver(this);
 
         mPointer.Clear();
 
         mDetached = true;
     }
 
     return NS_OK;
 }
 
 /* readonly attribute nsIDOMNode referenceNode; */
-NS_IMETHODIMP nsNodeIterator::GetReferenceNode(nsIDOMNode * *aRefNode)
+NS_IMETHODIMP NodeIterator::GetReferenceNode(nsIDOMNode * *aRefNode)
 {
     if (mPointer.mNode)
         return CallQueryInterface(mPointer.mNode, aRefNode);
 
     *aRefNode = nullptr;
     return NS_OK;
 }
 
 /* readonly attribute boolean pointerBeforeReferenceNode; */
-NS_IMETHODIMP nsNodeIterator::GetPointerBeforeReferenceNode(bool *aBeforeNode)
+NS_IMETHODIMP NodeIterator::GetPointerBeforeReferenceNode(bool *aBeforeNode)
 {
     *aBeforeNode = mPointer.mBeforeNode;
     return NS_OK;
 }
 
 /*
  * nsIMutationObserver interface
  */
 
-void nsNodeIterator::ContentRemoved(nsIDocument *aDocument,
-                                    nsIContent *aContainer,
-                                    nsIContent *aChild,
-                                    int32_t aIndexInContainer,
-                                    nsIContent *aPreviousSibling)
+void NodeIterator::ContentRemoved(nsIDocument *aDocument,
+                                  nsIContent *aContainer,
+                                  nsIContent *aChild,
+                                  int32_t aIndexInContainer,
+                                  nsIContent *aPreviousSibling)
 {
     nsINode *container = NODE_FROM(aContainer, aDocument);
 
     mPointer.AdjustAfterRemoval(mRoot, container, aChild, aPreviousSibling);
     mWorkingPointer.AdjustAfterRemoval(mRoot, container, aChild, aPreviousSibling);
 }
+
+} // namespace dom
+} // namespace mozilla
rename from content/base/src/nsNodeIterator.h
rename to content/base/src/NodeIterator.h
--- a/content/base/src/nsNodeIterator.h
+++ b/content/base/src/NodeIterator.h
@@ -3,44 +3,47 @@
  * This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
  
 /*
  * Implementation of DOM Traversal's nsIDOMNodeIterator
  */
 
-#ifndef nsNodeIterator_h___
-#define nsNodeIterator_h___
+#ifndef mozilla_dom_NodeIterator_h
+#define mozilla_dom_NodeIterator_h
 
 #include "nsIDOMNodeIterator.h"
 #include "nsTraversal.h"
 #include "nsCycleCollectionParticipant.h"
 #include "nsStubMutationObserver.h"
 
 class nsINode;
 class nsIDOMNode;
 class nsIDOMNodeFilter;
 
-class nsNodeIterator : public nsIDOMNodeIterator,
-                       public nsTraversal,
-                       public nsStubMutationObserver
+namespace mozilla {
+namespace dom {
+
+class NodeIterator : public nsIDOMNodeIterator,
+                     public nsTraversal,
+                     public nsStubMutationObserver
 {
 public:
     NS_DECL_CYCLE_COLLECTING_ISUPPORTS
     NS_DECL_NSIDOMNODEITERATOR
 
-    nsNodeIterator(nsINode *aRoot,
-                   uint32_t aWhatToShow,
-                   const mozilla::dom::NodeFilterHolder &aFilter);
-    virtual ~nsNodeIterator();
+    NodeIterator(nsINode *aRoot,
+                 uint32_t aWhatToShow,
+                 const NodeFilterHolder &aFilter);
+    virtual ~NodeIterator();
 
     NS_DECL_NSIMUTATIONOBSERVER_CONTENTREMOVED
 
-    NS_DECL_CYCLE_COLLECTION_CLASS_AMBIGUOUS(nsNodeIterator, nsIDOMNodeIterator)
+    NS_DECL_CYCLE_COLLECTION_CLASS_AMBIGUOUS(NodeIterator, nsIDOMNodeIterator)
 
 private:
     struct NodePointer {
         NodePointer() : mNode(nullptr) {}
         NodePointer(nsINode *aNode, bool aBeforeNode);
 
         typedef bool (NodePointer::*MoveToMethodType)(nsINode*);
         bool MoveToNext(nsINode *aRoot);
@@ -61,9 +64,12 @@ private:
     NextOrPrevNode(NodePointer::MoveToMethodType aMove,
                    nsIDOMNode **_retval);
 
     bool mDetached;
     NodePointer mPointer;
     NodePointer mWorkingPointer;
 };
 
-#endif
+} // namespace dom
+} // namespace mozilla
+
+#endif // mozilla_dom_NodeIterator_h
--- a/content/base/src/nsDocument.cpp
+++ b/content/base/src/nsDocument.cpp
@@ -52,17 +52,17 @@
 #include "nsLayoutUtils.h" // for GetFrameForPoint
 #include "nsIFrame.h"
 #include "nsITabChild.h"
 
 #include "nsRange.h"
 #include "nsIDOMText.h"
 #include "nsIDOMComment.h"
 #include "DocumentType.h"
-#include "nsNodeIterator.h"
+#include "mozilla/dom/NodeIterator.h"
 #include "nsTreeWalker.h"
 
 #include "nsIServiceManager.h"
 
 #include "nsContentCID.h"
 #include "nsError.h"
 #include "nsIPresShell.h"
 #include "nsPresContext.h"
@@ -5381,18 +5381,18 @@ nsIDocument::CreateNodeIterator(nsINode&
 {
   nsINode* root = &aRoot;
   nsresult res = nsContentUtils::CheckSameOrigin(this, root);
   if (NS_FAILED(res)) {
     rv.Throw(res);
     return nullptr;
   }
 
-  nsRefPtr<nsNodeIterator> iterator = new nsNodeIterator(root, aWhatToShow,
-                                                         aFilter);
+  nsRefPtr<NodeIterator> iterator = new NodeIterator(root, aWhatToShow,
+                                                     aFilter);
   return iterator.forget();
 }
 
 NS_IMETHODIMP
 nsDocument::CreateTreeWalker(nsIDOMNode *aRoot,
                              uint32_t aWhatToShow,
                              nsIDOMNodeFilter *aFilter,
                              uint8_t aOptionalArgc,
--- a/editor/libeditor/text/nsTextEditRules.cpp
+++ b/editor/libeditor/text/nsTextEditRules.cpp
@@ -31,17 +31,17 @@
 #include "nsIDOMText.h"
 #include "nsINameSpaceManager.h"
 #include "nsINode.h"
 #include "nsIPlaintextEditor.h"
 #include "nsISelection.h"
 #include "nsISelectionPrivate.h"
 #include "nsISupportsBase.h"
 #include "nsLiteralString.h"
-#include "nsNodeIterator.h"
+#include "mozilla/dom/NodeIterator.h"
 #include "nsTextEditRules.h"
 #include "nsTextEditUtils.h"
 #include "nsUnicharUtils.h"
 
 using namespace mozilla;
 
 #define CANCEL_OPERATION_IF_READONLY_OR_DISABLED \
   if (IsReadonly() || IsDisabled()) \
@@ -445,17 +445,17 @@ GetTextNode(nsISelection *selection, nsE
   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;
-    nsNodeIterator iter(node, nsIDOMNodeFilter::SHOW_TEXT, filter);
+    mozilla::dom::NodeIterator iter(node, nsIDOMNodeFilter::SHOW_TEXT, filter);
     while (!editor->IsTextNode(selNode)) {
       if (NS_FAILED(res = iter.NextNode(getter_AddRefs(selNode))) || !selNode) {
         return nullptr;
       }
     }
   }
   return selNode.forget();
 }