Bug 578905 - Let nsRange methods from DOM interfaces use NS_IMETHODIMP on their implementations. r=bz
authorCraig Topper <craig.topper@gmail.com>
Sat, 17 Jul 2010 18:24:50 +0200
changeset 47862 95cae32d3eee5f9e6335ca855ecd6623c85960d9
parent 47861 d9504ca064765c49f5dd283a895e54905413ea1a
child 47863 a0a4df1ca019e868b75b9a9292c5cb0411887d7a
push id14453
push userdgottwald@mozilla.com
push dateSat, 17 Jul 2010 16:28:03 +0000
treeherderautoland@d2f2b0cd7cbd [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbz
bugs578905
milestone2.0b2pre
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 578905 - Let nsRange methods from DOM interfaces use NS_IMETHODIMP on their implementations. r=bz
content/base/src/nsRange.cpp
--- a/content/base/src/nsRange.cpp
+++ b/content/base/src/nsRange.cpp
@@ -491,83 +491,89 @@ IndexOf(nsIDOMNode* aChildNode)
   // finally we get the index
   return parent ? parent->IndexOf(child) : -1;
 }
 
 /******************************************************
  * nsIRange implementation
  ******************************************************/
 
-nsINode*
+/* virtual */ nsINode*
 nsRange::GetCommonAncestor() const
 {
   return mIsPositioned ?
     nsContentUtils::GetCommonAncestor(mStartParent, mEndParent) :
     nsnull;
 }
 
-void
+/* virtual */ void
 nsRange::Reset()
 {
   DoSetRange(nsnull, 0, nsnull, 0, nsnull);
 }
 
 /******************************************************
  * public functionality
  ******************************************************/
 
-nsresult nsRange::GetStartContainer(nsIDOMNode** aStartParent)
+NS_IMETHODIMP
+nsRange::GetStartContainer(nsIDOMNode** aStartParent)
 {
   if (!mIsPositioned)
     return NS_ERROR_NOT_INITIALIZED;
 
   return CallQueryInterface(mStartParent, aStartParent);
 }
 
-nsresult nsRange::GetStartOffset(PRInt32* aStartOffset)
+NS_IMETHODIMP
+nsRange::GetStartOffset(PRInt32* aStartOffset)
 {
   if (!mIsPositioned)
     return NS_ERROR_NOT_INITIALIZED;
 
   *aStartOffset = mStartOffset;
 
   return NS_OK;
 }
 
-nsresult nsRange::GetEndContainer(nsIDOMNode** aEndParent)
+NS_IMETHODIMP
+nsRange::GetEndContainer(nsIDOMNode** aEndParent)
 {
   if (!mIsPositioned)
     return NS_ERROR_NOT_INITIALIZED;
 
   return CallQueryInterface(mEndParent, aEndParent);
 }
 
-nsresult nsRange::GetEndOffset(PRInt32* aEndOffset)
+NS_IMETHODIMP
+nsRange::GetEndOffset(PRInt32* aEndOffset)
 {
   if (!mIsPositioned)
     return NS_ERROR_NOT_INITIALIZED;
 
   *aEndOffset = mEndOffset;
 
   return NS_OK;
 }
 
-nsresult nsRange::GetCollapsed(PRBool* aIsCollapsed)
+NS_IMETHODIMP
+nsRange::GetCollapsed(PRBool* aIsCollapsed)
 {
   if(mIsDetached)
     return NS_ERROR_DOM_INVALID_STATE_ERR;
   if (!mIsPositioned)
     return NS_ERROR_NOT_INITIALIZED;
 
   *aIsCollapsed = Collapsed();
 
   return NS_OK;
 }
 
-nsresult nsRange::GetCommonAncestorContainer(nsIDOMNode** aCommonParent)
+NS_IMETHODIMP
+nsRange::GetCommonAncestorContainer(nsIDOMNode** aCommonParent)
 {
   *aCommonParent = nsnull;
   if(mIsDetached)
     return NS_ERROR_DOM_INVALID_STATE_ERR;
   if (!mIsPositioned)
     return NS_ERROR_NOT_INITIALIZED;
 
   nsINode* container = nsContentUtils::GetCommonAncestor(mStartParent, mEndParent);
@@ -620,25 +626,27 @@ nsINode* nsRange::IsValidBoundary(nsINod
                    root->IsNodeOfType(nsINode::eATTRIBUTE),
                    "Creating a DOM Range using root which isn't in DOM!");
 #endif
 
   // We allow this because of backward compatibility.
   return root;
 }
 
-nsresult nsRange::SetStart(nsIDOMNode* aParent, PRInt32 aOffset)
+NS_IMETHODIMP
+nsRange::SetStart(nsIDOMNode* aParent, PRInt32 aOffset)
 {
   VALIDATE_ACCESS(aParent);
 
   nsCOMPtr<nsINode> parent = do_QueryInterface(aParent);
   return SetStart(parent, aOffset);
 }
 
-nsresult nsRange::SetStart(nsINode* aParent, PRInt32 aOffset)
+/* virtual */ nsresult
+nsRange::SetStart(nsINode* aParent, PRInt32 aOffset)
 {
   nsINode* newRoot = IsValidBoundary(aParent);
   NS_ENSURE_TRUE(newRoot, NS_ERROR_DOM_RANGE_INVALID_NODE_TYPE_ERR);
 
   PRInt32 len = GetNodeLength(aParent);
   if (aOffset < 0 || aOffset > len)
     return NS_ERROR_DOM_INDEX_SIZE_ERR;
 
@@ -652,52 +660,56 @@ nsresult nsRange::SetStart(nsINode* aPar
     return NS_OK;
   }
 
   DoSetRange(aParent, aOffset, mEndParent, mEndOffset, mRoot);
   
   return NS_OK;
 }
 
-nsresult nsRange::SetStartBefore(nsIDOMNode* aSibling)
+NS_IMETHODIMP
+nsRange::SetStartBefore(nsIDOMNode* aSibling)
 {
   VALIDATE_ACCESS(aSibling);
   
   nsCOMPtr<nsIDOMNode> parent;
   nsresult rv = aSibling->GetParentNode(getter_AddRefs(parent));
   if (NS_FAILED(rv) || !parent) {
     return NS_ERROR_DOM_RANGE_INVALID_NODE_TYPE_ERR;
   }
 
   return SetStart(parent, IndexOf(aSibling));
 }
 
-nsresult nsRange::SetStartAfter(nsIDOMNode* aSibling)
+NS_IMETHODIMP
+nsRange::SetStartAfter(nsIDOMNode* aSibling)
 {
   VALIDATE_ACCESS(aSibling);
 
   nsCOMPtr<nsIDOMNode> nParent;
   nsresult res = aSibling->GetParentNode(getter_AddRefs(nParent));
   if (NS_FAILED(res) || !nParent) {
     return NS_ERROR_DOM_RANGE_INVALID_NODE_TYPE_ERR;
   }
 
   return SetStart(nParent, IndexOf(aSibling) + 1);
 }
 
-nsresult nsRange::SetEnd(nsIDOMNode* aParent, PRInt32 aOffset)
+NS_IMETHODIMP
+nsRange::SetEnd(nsIDOMNode* aParent, PRInt32 aOffset)
 {
   VALIDATE_ACCESS(aParent);
 
   nsCOMPtr<nsINode> parent = do_QueryInterface(aParent);
   return SetEnd(parent, aOffset);
 }
 
 
-nsresult nsRange::SetEnd(nsINode* aParent, PRInt32 aOffset)
+/* virtual */ nsresult
+nsRange::SetEnd(nsINode* aParent, PRInt32 aOffset)
 {
   nsINode* newRoot = IsValidBoundary(aParent);
   NS_ENSURE_TRUE(newRoot, NS_ERROR_DOM_RANGE_INVALID_NODE_TYPE_ERR);
 
   PRInt32 len = GetNodeLength(aParent);
   if (aOffset < 0 || aOffset > len) {
     return NS_ERROR_DOM_INDEX_SIZE_ERR;
   }
@@ -712,58 +724,62 @@ nsresult nsRange::SetEnd(nsINode* aParen
     return NS_OK;
   }
 
   DoSetRange(mStartParent, mStartOffset, aParent, aOffset, mRoot);
 
   return NS_OK;
 }
 
-nsresult nsRange::SetEndBefore(nsIDOMNode* aSibling)
+NS_IMETHODIMP
+nsRange::SetEndBefore(nsIDOMNode* aSibling)
 {
   VALIDATE_ACCESS(aSibling);
   
   nsCOMPtr<nsIDOMNode> nParent;
   nsresult rv = aSibling->GetParentNode(getter_AddRefs(nParent));
   if (NS_FAILED(rv) || !nParent) {
     return NS_ERROR_DOM_RANGE_INVALID_NODE_TYPE_ERR;
   }
 
   return SetEnd(nParent, IndexOf(aSibling));
 }
 
-nsresult nsRange::SetEndAfter(nsIDOMNode* aSibling)
+NS_IMETHODIMP
+nsRange::SetEndAfter(nsIDOMNode* aSibling)
 {
   VALIDATE_ACCESS(aSibling);
   
   nsCOMPtr<nsIDOMNode> nParent;
   nsresult res = aSibling->GetParentNode(getter_AddRefs(nParent));
   if (NS_FAILED(res) || !nParent) {
     return NS_ERROR_DOM_RANGE_INVALID_NODE_TYPE_ERR;
   }
 
   return SetEnd(nParent, IndexOf(aSibling) + 1);
 }
 
-nsresult nsRange::Collapse(PRBool aToStart)
+NS_IMETHODIMP
+nsRange::Collapse(PRBool aToStart)
 {
   if(mIsDetached)
     return NS_ERROR_DOM_INVALID_STATE_ERR;
   if (!mIsPositioned)
     return NS_ERROR_NOT_INITIALIZED;
 
   if (aToStart)
     DoSetRange(mStartParent, mStartOffset, mStartParent, mStartOffset, mRoot);
   else
     DoSetRange(mEndParent, mEndOffset, mEndParent, mEndOffset, mRoot);
 
   return NS_OK;
 }
 
-nsresult nsRange::SelectNode(nsIDOMNode* aN)
+NS_IMETHODIMP
+nsRange::SelectNode(nsIDOMNode* aN)
 {
   VALIDATE_ACCESS(aN);
   
   nsCOMPtr<nsINode> node = do_QueryInterface(aN);
   NS_ENSURE_TRUE(node, NS_ERROR_DOM_RANGE_INVALID_NODE_TYPE_ERR);
 
   nsINode* parent = node->GetNodeParent();
   nsINode* newRoot = IsValidBoundary(parent);
@@ -774,17 +790,18 @@ nsresult nsRange::SelectNode(nsIDOMNode*
     return NS_ERROR_DOM_RANGE_INVALID_NODE_TYPE_ERR;
   }
 
   DoSetRange(parent, index, parent, index + 1, newRoot);
   
   return NS_OK;
 }
 
-nsresult nsRange::SelectNodeContents(nsIDOMNode* aN)
+NS_IMETHODIMP
+nsRange::SelectNodeContents(nsIDOMNode* aN)
 {
   VALIDATE_ACCESS(aN);
 
   nsCOMPtr<nsINode> node = do_QueryInterface(aN);
   nsINode* newRoot = IsValidBoundary(node);
   NS_ENSURE_TRUE(newRoot, NS_ERROR_DOM_RANGE_INVALID_NODE_TYPE_ERR);
   
   DoSetRange(node, 0, node, GetNodeLength(node), newRoot);
@@ -1174,17 +1191,18 @@ static nsresult SplitDataNode(nsIDOMChar
 
   nsCOMPtr<nsIContent> newData;
   rv = dataNode->SplitData(aStartIndex, getter_AddRefs(newData),
                            aCloneAfterOriginal);
   NS_ENSURE_SUCCESS(rv, rv);
   return CallQueryInterface(newData, aEndNode);
 }
 
-nsresult PrependChild(nsIDOMNode* aParent, nsIDOMNode* aChild)
+NS_IMETHODIMP
+PrependChild(nsIDOMNode* aParent, nsIDOMNode* aChild)
 {
   nsCOMPtr<nsIDOMNode> first, tmpNode;
   aParent->GetFirstChild(getter_AddRefs(first));
   return aParent->InsertBefore(aChild, first, getter_AddRefs(tmpNode));
 }
 
 nsresult nsRange::CutContents(nsIDOMDocumentFragment** aFragment)
 { 
@@ -1441,22 +1459,24 @@ nsresult nsRange::CutContents(nsIDOMDocu
 
   rv = CollapseRangeAfterDelete(this);
   if (NS_SUCCEEDED(rv) && aFragment) {
     NS_ADDREF(*aFragment = retval);
   }
   return rv;
 }
 
-nsresult nsRange::DeleteContents()
+NS_IMETHODIMP
+nsRange::DeleteContents()
 {
   return CutContents(nsnull);
 }
 
-nsresult nsRange::ExtractContents(nsIDOMDocumentFragment** aReturn)
+NS_IMETHODIMP
+nsRange::ExtractContents(nsIDOMDocumentFragment** aReturn)
 {
   NS_ENSURE_ARG_POINTER(aReturn);
   return CutContents(aReturn);
 }
 
 NS_IMETHODIMP
 nsRange::CompareBoundaryPoints(PRUint16 aHow, nsIDOMRange* aOtherRange,
                                PRInt16* aCmpRet)
@@ -1506,17 +1526,17 @@ nsRange::CompareBoundaryPoints(PRUint16 
     return NS_ERROR_DOM_WRONG_DOCUMENT_ERR;
 
   *aCmpRet = nsContentUtils::ComparePoints(ourNode, ourOffset,
                                            otherNode, otherOffset);
 
   return NS_OK;
 }
 
-nsresult
+/* static */ nsresult
 nsRange::CloneParentsBetween(nsIDOMNode *aAncestor,
                              nsIDOMNode *aNode,
                              nsIDOMNode **aClosestAncestor,
                              nsIDOMNode **aFarthestAncestor)
 {
   NS_ENSURE_ARG_POINTER((aAncestor && aNode && aClosestAncestor && aFarthestAncestor));
 
   *aClosestAncestor  = nsnull;
@@ -1557,17 +1577,18 @@ nsRange::CloneParentsBetween(nsIDOMNode 
   NS_IF_ADDREF(*aClosestAncestor);
 
   *aFarthestAncestor = lastParent;
   NS_IF_ADDREF(*aFarthestAncestor);
 
   return NS_OK;
 }
 
-nsresult nsRange::CloneContents(nsIDOMDocumentFragment** aReturn)
+NS_IMETHODIMP
+nsRange::CloneContents(nsIDOMDocumentFragment** aReturn)
 {
   if (IsDetached())
     return NS_ERROR_DOM_INVALID_STATE_ERR;
 
   nsresult res;
   nsCOMPtr<nsIDOMNode> commonAncestor;
   res = GetCommonAncestorContainer(getter_AddRefs(commonAncestor));
   if (NS_FAILED(res)) return res;
@@ -1781,22 +1802,24 @@ NS_IMETHODIMP nsRange::CloneRange(nsIDOM
   nsIRange* clone;
   nsresult rv = DoCloneRange(&clone);
   if (NS_SUCCEEDED(rv)) {
     *aReturn = clone;
   }
   return rv;
 }
 
-nsresult nsRange::CloneRange(nsIRange** aReturn) const
+/* virtual */ nsresult
+nsRange::CloneRange(nsIRange** aReturn) const
 {
   return DoCloneRange(aReturn);
 }
 
-nsresult nsRange::InsertNode(nsIDOMNode* aN)
+NS_IMETHODIMP
+nsRange::InsertNode(nsIDOMNode* aN)
 {
   VALIDATE_ACCESS(aN);
   
   nsresult res;
   PRInt32 tStartOffset;
   this->GetStartOffset(&tStartOffset);
 
   nsCOMPtr<nsIDOMNode> tStartContainer;
@@ -1843,17 +1866,18 @@ nsresult nsRange::InsertNode(nsIDOMNode*
   nsCOMPtr<nsIDOMNode>tChildNode;
   res = tChildList->Item(tStartOffset, getter_AddRefs(tChildNode));
   if(NS_FAILED(res)) return res;
   
   nsCOMPtr<nsIDOMNode> tResultNode;
   return tStartContainer->InsertBefore(aN, tChildNode, getter_AddRefs(tResultNode));
 }
 
-nsresult nsRange::SurroundContents(nsIDOMNode* aNewParent)
+NS_IMETHODIMP
+nsRange::SurroundContents(nsIDOMNode* aNewParent)
 {
   VALIDATE_ACCESS(aNewParent);
 
   NS_ENSURE_TRUE(mRoot, NS_ERROR_DOM_INVALID_STATE_ERR);
   // BAD_BOUNDARYPOINTS_ERR: Raised if the Range partially selects a non-text
   // node.
   if (mStartParent != mEndParent) {
     PRBool startIsText = mStartParent->IsNodeOfType(nsINode::eTEXT);
@@ -1918,17 +1942,18 @@ nsresult nsRange::SurroundContents(nsIDO
   res = aNewParent->AppendChild(docFrag, getter_AddRefs(tmpNode));
   if (NS_FAILED(res)) return res;
 
   // Select aNewParent, and its contents.
 
   return SelectNode(aNewParent);
 }
 
-nsresult nsRange::ToString(nsAString& aReturn)
+NS_IMETHODIMP
+nsRange::ToString(nsAString& aReturn)
 { 
   if(mIsDetached)
     return NS_ERROR_DOM_INVALID_STATE_ERR;
 
   // clear the string
   aReturn.Truncate();
   
   // If we're unpositioned, return the empty string
@@ -2011,17 +2036,17 @@ nsresult nsRange::ToString(nsAString& aR
 #ifdef DEBUG_range
   printf("End Range dump: -----------------------\n");
 #endif /* DEBUG */
   return NS_OK;
 }
 
 
 
-nsresult
+NS_IMETHODIMP
 nsRange::Detach()
 {
   if(mIsDetached)
     return NS_ERROR_DOM_INVALID_STATE_ERR;
 
   mIsDetached = PR_TRUE;
 
   DoSetRange(nsnull, 0, nsnull, 0, nsnull);