Bug 798481 - Make IndexOf a little more const-correct; r=mounir
authorMs2ger <ms2ger@gmail.com>
Sat, 06 Oct 2012 09:19:46 +0200
changeset 115649 28dd4861bf8ac720f42d81d3f3672eb40800bb77
parent 115648 1c64ccca68601029c7ea0a8a22b7c9c75e55b412
child 115650 78978886622b63b476f628e3adddcb4021dd0da1
push id1708
push userakeybl@mozilla.com
push dateMon, 19 Nov 2012 21:10:21 +0000
treeherdermozilla-beta@27b14fe50103 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmounir
bugs798481
milestone18.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 798481 - Make IndexOf a little more const-correct; r=mounir
content/base/public/FragmentOrElement.h
content/base/public/nsINode.h
content/base/src/FragmentOrElement.cpp
content/base/src/nsAttrAndChildArray.cpp
content/base/src/nsAttrAndChildArray.h
content/base/src/nsDOMAttribute.cpp
content/base/src/nsDOMAttribute.h
content/base/src/nsDocument.cpp
content/base/src/nsDocument.h
content/base/src/nsGenericDOMDataNode.cpp
content/base/src/nsGenericDOMDataNode.h
--- a/content/base/public/FragmentOrElement.h
+++ b/content/base/public/FragmentOrElement.h
@@ -182,17 +182,17 @@ public:
    * get an interface for this element.
    */
   nsresult PostQueryInterface(REFNSIID aIID, void** aInstancePtr);
 
   // nsINode interface methods
   virtual uint32_t GetChildCount() const;
   virtual nsIContent *GetChildAt(uint32_t aIndex) const;
   virtual nsIContent * const * GetChildArray(uint32_t* aChildCount) const;
-  virtual int32_t IndexOf(nsINode* aPossibleChild) const;
+  virtual int32_t IndexOf(const nsINode* aPossibleChild) const MOZ_OVERRIDE;
   virtual nsresult InsertChildAt(nsIContent* aKid, uint32_t aIndex,
                                  bool aNotify);
   virtual void RemoveChildAt(uint32_t aIndex, bool aNotify);
   NS_IMETHOD GetTextContent(nsAString &aTextContent);
   NS_IMETHOD SetTextContent(const nsAString& aTextContent);
 
   // nsIContent interface methods
   virtual already_AddRefed<nsINodeList> GetChildren(uint32_t aFilter);
--- a/content/base/public/nsINode.h
+++ b/content/base/public/nsINode.h
@@ -411,17 +411,17 @@ public:
   /**
    * Get the index of a child within this content
    * @param aPossibleChild the child to get the index of.
    * @return the index of the child, or -1 if not a child
    *
    * If the return value is not -1, then calling GetChildAt() with that value
    * will return aPossibleChild.
    */
-  virtual int32_t IndexOf(nsINode* aPossibleChild) const = 0;
+  virtual int32_t IndexOf(const nsINode* aPossibleChild) const = 0;
 
   /**
    * Return the "owner document" of this node.  Note that this is not the same
    * as the DOM ownerDocument -- that's null for Document nodes, whereas for a
    * nsIDocument GetOwnerDocument returns the document itself.  For nsIContent
    * implementations the two are the same.
    */
   nsIDocument *OwnerDoc() const
--- a/content/base/src/FragmentOrElement.cpp
+++ b/content/base/src/FragmentOrElement.cpp
@@ -1927,17 +1927,17 @@ FragmentOrElement::GetChildAt(uint32_t a
 
 nsIContent * const *
 FragmentOrElement::GetChildArray(uint32_t* aChildCount) const
 {
   return mAttrsAndChildren.GetChildArray(aChildCount);
 }
 
 int32_t
-FragmentOrElement::IndexOf(nsINode* aPossibleChild) const
+FragmentOrElement::IndexOf(const nsINode* aPossibleChild) const
 {
   return mAttrsAndChildren.IndexOfChild(aPossibleChild);
 }
 
 nsINode::nsSlots*
 FragmentOrElement::CreateSlots()
 {
   return new nsDOMSlots();
--- a/content/base/src/nsAttrAndChildArray.cpp
+++ b/content/base/src/nsAttrAndChildArray.cpp
@@ -209,17 +209,17 @@ nsAttrAndChildArray::TakeChildAt(uint32_
 
   memmove(pos, pos + 1, (childCount - aPos - 1) * sizeof(nsIContent*));
   SetChildCount(childCount - 1);
 
   return child;
 }
 
 int32_t
-nsAttrAndChildArray::IndexOfChild(nsINode* aPossibleChild) const
+nsAttrAndChildArray::IndexOfChild(const nsINode* aPossibleChild) const
 {
   if (!mImpl) {
     return -1;
   }
   void** children = mImpl->mBuffer + AttrSlotsSize();
   // Use signed here since we compare count to cursor which has to be signed
   int32_t i, count = ChildCount();
 
--- a/content/base/src/nsAttrAndChildArray.h
+++ b/content/base/src/nsAttrAndChildArray.h
@@ -63,17 +63,17 @@ public:
   {
     return InsertChildAt(aChild, ChildCount());
   }
   nsresult InsertChildAt(nsIContent* aChild, uint32_t aPos);
   void RemoveChildAt(uint32_t aPos);
   // Like RemoveChildAt but hands the reference to the child being
   // removed back to the caller instead of just releasing it.
   already_AddRefed<nsIContent> TakeChildAt(uint32_t aPos);
-  int32_t IndexOfChild(nsINode* aPossibleChild) const;
+  int32_t IndexOfChild(const nsINode* aPossibleChild) const;
 
   uint32_t AttrCount() const;
   const nsAttrValue* GetAttr(nsIAtom* aLocalName, int32_t aNamespaceID = kNameSpaceID_None) const;
   // Get an nsAttrValue by qualified name.  Can optionally do
   // ASCII-case-insensitive name matching.
   const nsAttrValue* GetAttr(const nsAString& aName,
                              nsCaseTreatment aCaseSensitive) const;
   const nsAttrValue* AttrAt(uint32_t aPos) const;
--- a/content/base/src/nsDOMAttribute.cpp
+++ b/content/base/src/nsDOMAttribute.cpp
@@ -581,17 +581,17 @@ nsDOMAttribute::GetChildAt(uint32_t aInd
 nsIContent * const *
 nsDOMAttribute::GetChildArray(uint32_t* aChildCount) const
 {
   *aChildCount = 0;
   return NULL;
 }
 
 int32_t
-nsDOMAttribute::IndexOf(nsINode* aPossibleChild) const
+nsDOMAttribute::IndexOf(const nsINode* aPossibleChild) const
 {
   return -1;
 }
 
 nsresult
 nsDOMAttribute::InsertChildAt(nsIContent* aKid, uint32_t aIndex,
                               bool aNotify)
 {
--- a/content/base/src/nsDOMAttribute.h
+++ b/content/base/src/nsDOMAttribute.h
@@ -48,17 +48,17 @@ public:
   nsIContent *GetContent() const;
   nsresult SetOwnerDocument(nsIDocument* aDocument);
 
   // nsINode interface
   virtual bool IsNodeOfType(uint32_t aFlags) const;
   virtual uint32_t GetChildCount() const;
   virtual nsIContent *GetChildAt(uint32_t aIndex) const;
   virtual nsIContent * const * GetChildArray(uint32_t* aChildCount) const;
-  virtual int32_t IndexOf(nsINode* aPossibleChild) const;
+  virtual int32_t IndexOf(const nsINode* aPossibleChild) const MOZ_OVERRIDE;
   virtual nsresult InsertChildAt(nsIContent* aKid, uint32_t aIndex,
                                  bool aNotify);
   virtual nsresult AppendChildTo(nsIContent* aKid, bool aNotify);
   virtual void RemoveChildAt(uint32_t aIndex, bool aNotify);
   virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const;
   virtual already_AddRefed<nsIURI> GetBaseURI() const;
 
   static void Initialize();
--- a/content/base/src/nsDocument.cpp
+++ b/content/base/src/nsDocument.cpp
@@ -3495,17 +3495,17 @@ nsDocument::GetRootElementInternal() con
 
 nsIContent *
 nsDocument::GetChildAt(uint32_t aIndex) const
 {
   return mChildren.GetSafeChildAt(aIndex);
 }
 
 int32_t
-nsDocument::IndexOf(nsINode* aPossibleChild) const
+nsDocument::IndexOf(const nsINode* aPossibleChild) const
 {
   return mChildren.IndexOfChild(aPossibleChild);
 }
 
 uint32_t
 nsDocument::GetChildCount() const
 {
   return mChildren.ChildCount();
--- a/content/base/src/nsDocument.h
+++ b/content/base/src/nsDocument.h
@@ -689,17 +689,17 @@ public:
   
   virtual void WillDispatchMutationEvent(nsINode* aTarget);
   virtual void MutationEventDispatched(nsINode* aTarget);
 
   // nsINode
   virtual bool IsNodeOfType(uint32_t aFlags) const;
   virtual nsIContent *GetChildAt(uint32_t aIndex) const;
   virtual nsIContent * const * GetChildArray(uint32_t* aChildCount) const;
-  virtual int32_t IndexOf(nsINode* aPossibleChild) const;
+  virtual int32_t IndexOf(const nsINode* aPossibleChild) const MOZ_OVERRIDE;
   virtual uint32_t GetChildCount() const;
   virtual nsresult InsertChildAt(nsIContent* aKid, uint32_t aIndex,
                                  bool aNotify);
   virtual nsresult AppendChildTo(nsIContent* aKid, bool aNotify);
   virtual void RemoveChildAt(uint32_t aIndex, bool aNotify);
   virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const
   {
     return NS_ERROR_NOT_IMPLEMENTED;
--- a/content/base/src/nsGenericDOMDataNode.cpp
+++ b/content/base/src/nsGenericDOMDataNode.cpp
@@ -624,17 +624,17 @@ nsGenericDOMDataNode::GetChildAt(uint32_
 nsIContent * const *
 nsGenericDOMDataNode::GetChildArray(uint32_t* aChildCount) const
 {
   *aChildCount = 0;
   return nullptr;
 }
 
 int32_t
-nsGenericDOMDataNode::IndexOf(nsINode* aPossibleChild) const
+nsGenericDOMDataNode::IndexOf(const nsINode* aPossibleChild) const
 {
   return -1;
 }
 
 nsresult
 nsGenericDOMDataNode::InsertChildAt(nsIContent* aKid, uint32_t aIndex,
                                     bool aNotify)
 {
--- a/content/base/src/nsGenericDOMDataNode.h
+++ b/content/base/src/nsGenericDOMDataNode.h
@@ -137,17 +137,17 @@ public:
   nsresult DeleteData(uint32_t aOffset, uint32_t aCount);
   nsresult ReplaceData(uint32_t aOffset, uint32_t aCount,
                        const nsAString& aArg);
 
   // nsINode methods
   virtual uint32_t GetChildCount() const;
   virtual nsIContent *GetChildAt(uint32_t aIndex) const;
   virtual nsIContent * const * GetChildArray(uint32_t* aChildCount) const;
-  virtual int32_t IndexOf(nsINode* aPossibleChild) const;
+  virtual int32_t IndexOf(const nsINode* aPossibleChild) const MOZ_OVERRIDE;
   virtual nsresult InsertChildAt(nsIContent* aKid, uint32_t aIndex,
                                  bool aNotify);
   virtual void RemoveChildAt(uint32_t aIndex, bool aNotify);
   NS_IMETHOD GetTextContent(nsAString &aTextContent)
   {
     nsresult rv = GetNodeValue(aTextContent);
     NS_ASSERTION(NS_SUCCEEDED(rv), "GetNodeValue() failed?");
     return rv;