mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-29 15:52:07 +00:00
bug fixes + changing broken "dont_QueryInterface" additions to "do_QueryInterface"
This commit is contained in:
parent
73a6b0852b
commit
17efdd55c0
@ -173,7 +173,7 @@ nsresult nsContentIterator::Init(nsIContent* aRoot)
|
||||
if (!aRoot)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
nsCOMPtr<nsIContent> root( dont_QueryInterface(aRoot) );
|
||||
nsCOMPtr<nsIContent> root( do_QueryInterface(aRoot) );
|
||||
mFirst = GetDeepFirstChild(root);
|
||||
mLast = root;
|
||||
mCommonParent = root;
|
||||
@ -349,6 +349,7 @@ nsresult nsContentIterator::GetNextSibling(nsCOMPtr<nsIContent> aNode, nsCOMPtr<
|
||||
|
||||
if (!NS_SUCCEEDED(aNode->GetParent(*getter_AddRefs(parent))))
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
if (!NS_SUCCEEDED(parent->IndexOf(aNode, indx)))
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
@ -358,7 +359,7 @@ nsresult nsContentIterator::GetNextSibling(nsCOMPtr<nsIContent> aNode, nsCOMPtr<
|
||||
}
|
||||
else if (parent != mCommonParent)
|
||||
{
|
||||
GetNextSibling(parent, aSibling);
|
||||
return GetNextSibling(parent, aSibling);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -382,6 +383,7 @@ nsresult nsContentIterator::GetPrevSibling(nsCOMPtr<nsIContent> aNode, nsCOMPtr<
|
||||
|
||||
if (!NS_SUCCEEDED(aNode->GetParent(*getter_AddRefs(parent))))
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
if (!NS_SUCCEEDED(parent->IndexOf(aNode, indx)))
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
@ -391,7 +393,7 @@ nsresult nsContentIterator::GetPrevSibling(nsCOMPtr<nsIContent> aNode, nsCOMPtr<
|
||||
}
|
||||
else if (parent != mCommonParent)
|
||||
{
|
||||
GetPrevSibling(parent, aSibling);
|
||||
return GetPrevSibling(parent, aSibling);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -612,7 +614,7 @@ nsresult nsContentSubtreeIterator::Init(nsIDOMRange* aRange)
|
||||
if (!aRange)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
mRange = dont_QueryInterface(aRange);
|
||||
mRange = do_QueryInterface(aRange);
|
||||
|
||||
// get the start node and offset, convert to nsIContent
|
||||
nsCOMPtr<nsIDOMNode> commonParent;
|
||||
@ -621,7 +623,8 @@ nsresult nsContentSubtreeIterator::Init(nsIDOMRange* aRange)
|
||||
nsCOMPtr<nsIContent> cStartP;
|
||||
nsCOMPtr<nsIContent> cEndP;
|
||||
nsCOMPtr<nsIContent> cN;
|
||||
nsCOMPtr<nsIContent> candidate;
|
||||
nsCOMPtr<nsIContent> firstCandidate;
|
||||
nsCOMPtr<nsIContent> lastCandidate;
|
||||
|
||||
// get common content parent
|
||||
if (!NS_SUCCEEDED(aRange->GetCommonParent(getter_AddRefs(commonParent))) || !commonParent)
|
||||
@ -646,7 +649,7 @@ nsresult nsContentSubtreeIterator::Init(nsIDOMRange* aRange)
|
||||
PRInt32 numChildren;
|
||||
cStartP->ChildCount(numChildren);
|
||||
|
||||
if (numChildren) // no children, must be a text node
|
||||
if (!numChildren) // no children, must be a text node
|
||||
{
|
||||
cN = cStartP;
|
||||
}
|
||||
@ -659,28 +662,28 @@ nsresult nsContentSubtreeIterator::Init(nsIDOMRange* aRange)
|
||||
}
|
||||
else
|
||||
{
|
||||
candidate = cChild;
|
||||
firstCandidate = cChild;
|
||||
}
|
||||
}
|
||||
|
||||
if (!candidate)
|
||||
if (!firstCandidate)
|
||||
{
|
||||
// then candidate is next node after cN
|
||||
if (!NS_SUCCEEDED(GetNextSibling(cN, &candidate)))
|
||||
// then firstCandidate is next node after cN
|
||||
if (!NS_SUCCEEDED(GetNextSibling(cN, &firstCandidate)))
|
||||
{
|
||||
MakeEmpty();
|
||||
return NS_OK;
|
||||
}
|
||||
}
|
||||
|
||||
candidate = GetDeepFirstChild(candidate);
|
||||
firstCandidate = GetDeepFirstChild(firstCandidate);
|
||||
|
||||
// confirm that this first possible contained node
|
||||
// is indeed contained. Else we have a range that
|
||||
// does not fully contain any node.
|
||||
|
||||
PRBool nodeBefore, nodeAfter;
|
||||
if (!NS_SUCCEEDED(CompareNodeToRange(candidate, aRange, &nodeBefore, &nodeAfter)))
|
||||
if (!NS_SUCCEEDED(CompareNodeToRange(firstCandidate, aRange, &nodeBefore, &nodeAfter)))
|
||||
return NS_ERROR_FAILURE;
|
||||
if (nodeBefore || nodeAfter)
|
||||
{
|
||||
@ -691,7 +694,7 @@ nsresult nsContentSubtreeIterator::Init(nsIDOMRange* aRange)
|
||||
// cool, we have the first node in the range. Now we walk
|
||||
// up it's ancestors to find the most senior that is still
|
||||
// in the range. That's the real first node.
|
||||
if (!NS_SUCCEEDED(GetTopAncestorInRange(candidate, &mFirst)))
|
||||
if (!NS_SUCCEEDED(GetTopAncestorInRange(firstCandidate, &mFirst)))
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
|
||||
@ -706,7 +709,7 @@ nsresult nsContentSubtreeIterator::Init(nsIDOMRange* aRange)
|
||||
{
|
||||
cEndP->ChildCount(numChildren);
|
||||
|
||||
if (numChildren) // no children, must be a text node
|
||||
if (!numChildren) // no children, must be a text node
|
||||
{
|
||||
cN = cEndP;
|
||||
}
|
||||
@ -720,28 +723,28 @@ nsresult nsContentSubtreeIterator::Init(nsIDOMRange* aRange)
|
||||
}
|
||||
else
|
||||
{
|
||||
candidate = cChild;
|
||||
lastCandidate = cChild;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!candidate)
|
||||
if (!lastCandidate)
|
||||
{
|
||||
// then candidate is prev node before cN
|
||||
if (!NS_SUCCEEDED(GetPrevSibling(cN, &candidate)))
|
||||
// then lastCandidate is prev node before cN
|
||||
if (!NS_SUCCEEDED(GetPrevSibling(cN, &lastCandidate)))
|
||||
{
|
||||
MakeEmpty();
|
||||
return NS_OK;
|
||||
}
|
||||
}
|
||||
|
||||
candidate = GetDeepLastChild(candidate);
|
||||
lastCandidate = GetDeepLastChild(lastCandidate);
|
||||
|
||||
// confirm that this first possible contained node
|
||||
// is indeed contained. Else we have a range that
|
||||
// does not fully contain any node.
|
||||
|
||||
if (!NS_SUCCEEDED(CompareNodeToRange(candidate, aRange, &nodeBefore, &nodeAfter)))
|
||||
if (!NS_SUCCEEDED(CompareNodeToRange(lastCandidate, aRange, &nodeBefore, &nodeAfter)))
|
||||
return NS_ERROR_FAILURE;
|
||||
if (nodeBefore || nodeAfter)
|
||||
{
|
||||
@ -752,7 +755,7 @@ nsresult nsContentSubtreeIterator::Init(nsIDOMRange* aRange)
|
||||
// cool, we have the last node in the range. Now we walk
|
||||
// up it's ancestors to find the most senior that is still
|
||||
// in the range. That's the real first node.
|
||||
if (!NS_SUCCEEDED(GetTopAncestorInRange(candidate, &mLast)))
|
||||
if (!NS_SUCCEEDED(GetTopAncestorInRange(lastCandidate, &mLast)))
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
mCurNode = mFirst;
|
||||
|
@ -648,17 +648,12 @@ nsCOMPtr<nsIDOMNode> nsRange::CommonParent(nsCOMPtr<nsIDOMNode> aNode1, nsCOMPtr
|
||||
|
||||
// no null nodes please
|
||||
if (!aNode1 || !aNode2)
|
||||
return nsCOMPtr<nsIDOMNode>(); // moral equiv or nsnull
|
||||
return nsCOMPtr<nsIDOMNode>(); // moral equiv of nsnull
|
||||
|
||||
// shortcut for common case - both nodes are the same
|
||||
if (aNode1 == aNode2)
|
||||
{
|
||||
// should be able to remove this error check later
|
||||
nsresult res = aNode1->GetParentNode(getter_AddRefs(theParent));
|
||||
if (!NS_SUCCEEDED(res))
|
||||
return nsCOMPtr<nsIDOMNode>(); // moral equiv or nsnull
|
||||
|
||||
return theParent;
|
||||
return aNode1;
|
||||
}
|
||||
|
||||
// otherwise traverse the tree for the common ancestor
|
||||
@ -673,7 +668,7 @@ nsCOMPtr<nsIDOMNode> nsRange::CommonParent(nsCOMPtr<nsIDOMNode> aNode1, nsCOMPtr
|
||||
NS_NOTREACHED("nsRange::CommonParent");
|
||||
delete array1;
|
||||
delete array2;
|
||||
return nsCOMPtr<nsIDOMNode>();
|
||||
return nsCOMPtr<nsIDOMNode>(); // moral equiv of nsnull
|
||||
}
|
||||
|
||||
// get ancestors of each node
|
||||
@ -686,7 +681,7 @@ nsCOMPtr<nsIDOMNode> nsRange::CommonParent(nsCOMPtr<nsIDOMNode> aNode1, nsCOMPtr
|
||||
NS_NOTREACHED("nsRange::CommonParent");
|
||||
delete array1;
|
||||
delete array2;
|
||||
return nsCOMPtr<nsIDOMNode>();
|
||||
return nsCOMPtr<nsIDOMNode>(); // moral equiv of nsnull
|
||||
}
|
||||
|
||||
// sanity test (for now) - the end of each array
|
||||
@ -696,7 +691,7 @@ nsCOMPtr<nsIDOMNode> nsRange::CommonParent(nsCOMPtr<nsIDOMNode> aNode1, nsCOMPtr
|
||||
NS_NOTREACHED("nsRange::CommonParent");
|
||||
delete array1;
|
||||
delete array2;
|
||||
return nsCOMPtr<nsIDOMNode>();
|
||||
return nsCOMPtr<nsIDOMNode>(); // moral equiv of nsnull
|
||||
}
|
||||
|
||||
// back through the ancestors, starting from the root, until
|
||||
@ -881,7 +876,7 @@ nsresult nsRange::SetStart(nsIDOMNode* aParent, PRInt32 aOffset)
|
||||
|
||||
if (!aParent) return NS_ERROR_NULL_POINTER;
|
||||
|
||||
nsCOMPtr<nsIDOMNode>theParent( dont_QueryInterface(aParent) );
|
||||
nsCOMPtr<nsIDOMNode>theParent( do_QueryInterface(aParent) );
|
||||
|
||||
// must be in same document as endpoint, else
|
||||
// endpoint is collapsed to new start.
|
||||
@ -902,7 +897,7 @@ nsresult nsRange::SetStart(nsIDOMNode* aParent, PRInt32 aOffset)
|
||||
|
||||
nsresult nsRange::SetStartBefore(nsIDOMNode* aSibling)
|
||||
{
|
||||
nsCOMPtr<nsIDOMNode>theSibling( dont_QueryInterface(aSibling) );
|
||||
nsCOMPtr<nsIDOMNode>theSibling( do_QueryInterface(aSibling) );
|
||||
PRInt32 indx = IndexOf(theSibling);
|
||||
nsIDOMNode *nParent;
|
||||
theSibling->GetParentNode(&nParent);
|
||||
@ -911,7 +906,7 @@ nsresult nsRange::SetStartBefore(nsIDOMNode* aSibling)
|
||||
|
||||
nsresult nsRange::SetStartAfter(nsIDOMNode* aSibling)
|
||||
{
|
||||
nsCOMPtr<nsIDOMNode>theSibling( dont_QueryInterface(aSibling) );
|
||||
nsCOMPtr<nsIDOMNode>theSibling( do_QueryInterface(aSibling) );
|
||||
PRInt32 indx = IndexOf(theSibling) + 1;
|
||||
nsIDOMNode *nParent;
|
||||
theSibling->GetParentNode(&nParent);
|
||||
@ -924,7 +919,7 @@ nsresult nsRange::SetEnd(nsIDOMNode* aParent, PRInt32 aOffset)
|
||||
|
||||
if (!aParent) return NS_ERROR_NULL_POINTER;
|
||||
|
||||
nsCOMPtr<nsIDOMNode>theParent( dont_QueryInterface(aParent) );
|
||||
nsCOMPtr<nsIDOMNode>theParent( do_QueryInterface(aParent) );
|
||||
|
||||
// must be in same document as startpoint, else
|
||||
// endpoint is collapsed to new end.
|
||||
@ -945,7 +940,7 @@ nsresult nsRange::SetEnd(nsIDOMNode* aParent, PRInt32 aOffset)
|
||||
|
||||
nsresult nsRange::SetEndBefore(nsIDOMNode* aSibling)
|
||||
{
|
||||
nsCOMPtr<nsIDOMNode>theSibling( dont_QueryInterface(aSibling) );
|
||||
nsCOMPtr<nsIDOMNode>theSibling( do_QueryInterface(aSibling) );
|
||||
PRInt32 indx = IndexOf(theSibling);
|
||||
nsIDOMNode *nParent;
|
||||
theSibling->GetParentNode(&nParent);
|
||||
@ -954,7 +949,7 @@ nsresult nsRange::SetEndBefore(nsIDOMNode* aSibling)
|
||||
|
||||
nsresult nsRange::SetEndAfter(nsIDOMNode* aSibling)
|
||||
{
|
||||
nsCOMPtr<nsIDOMNode>theSibling( dont_QueryInterface(aSibling) );
|
||||
nsCOMPtr<nsIDOMNode>theSibling( do_QueryInterface(aSibling) );
|
||||
PRInt32 indx = IndexOf(theSibling) + 1;
|
||||
nsIDOMNode *nParent;
|
||||
theSibling->GetParentNode(&nParent);
|
||||
@ -985,7 +980,7 @@ nsresult nsRange::Unposition()
|
||||
nsresult nsRange::SelectNode(nsIDOMNode* aN)
|
||||
{
|
||||
nsCOMPtr<nsIDOMNode> parent;
|
||||
nsCOMPtr<nsIDOMNode> theNode( dont_QueryInterface(aN) );
|
||||
nsCOMPtr<nsIDOMNode> theNode( do_QueryInterface(aN) );
|
||||
|
||||
nsresult res = aN->GetParentNode(getter_AddRefs(parent));
|
||||
if (!NS_SUCCEEDED(res))
|
||||
@ -997,7 +992,7 @@ nsresult nsRange::SelectNode(nsIDOMNode* aN)
|
||||
|
||||
nsresult nsRange::SelectNodeContents(nsIDOMNode* aN)
|
||||
{
|
||||
nsCOMPtr<nsIDOMNode> theNode( dont_QueryInterface(aN) );
|
||||
nsCOMPtr<nsIDOMNode> theNode( do_QueryInterface(aN) );
|
||||
nsCOMPtr<nsIDOMNodeList> aChildNodes;
|
||||
|
||||
nsresult res = aN->GetChildNodes(getter_AddRefs(aChildNodes));
|
||||
@ -1503,7 +1498,7 @@ nsresult nsRange::OwnerChildInserted(nsIContent* aParentNode, PRInt32 aOffset)
|
||||
// sanity check - null nodes shouldn't have enclosed ranges
|
||||
if (!aParentNode) return NS_ERROR_UNEXPECTED;
|
||||
|
||||
nsCOMPtr<nsIContent> parent( dont_QueryInterface(aParentNode) );
|
||||
nsCOMPtr<nsIContent> parent( do_QueryInterface(aParentNode) );
|
||||
// quick return if no range list
|
||||
nsVoidArray *theRangeList;
|
||||
parent->GetRangeList(theRangeList);
|
||||
@ -1548,8 +1543,8 @@ nsresult nsRange::OwnerChildRemoved(nsIContent* aParentNode, PRInt32 aOffset, ns
|
||||
// sanity check - null nodes shouldn't have enclosed ranges
|
||||
if (!aParentNode) return NS_ERROR_UNEXPECTED;
|
||||
|
||||
nsCOMPtr<nsIContent> parent( dont_QueryInterface(aParentNode) );
|
||||
nsCOMPtr<nsIContent> removed( dont_QueryInterface(aRemovedNode) );
|
||||
nsCOMPtr<nsIContent> parent( do_QueryInterface(aParentNode) );
|
||||
nsCOMPtr<nsIContent> removed( do_QueryInterface(aRemovedNode) );
|
||||
// quick return if no range list
|
||||
nsVoidArray *theRangeList;
|
||||
parent->GetRangeList(theRangeList);
|
||||
@ -1606,8 +1601,8 @@ nsresult nsRange::OwnerChildReplaced(nsIContent* aParentNode, PRInt32 aOffset, n
|
||||
// but we do need to pop out any range endpoints inside the subtree
|
||||
// rooted by aReplacedNode.
|
||||
|
||||
nsCOMPtr<nsIContent> parent( dont_QueryInterface(aParentNode) );
|
||||
nsCOMPtr<nsIContent> replaced( dont_QueryInterface(aReplacedNode) );
|
||||
nsCOMPtr<nsIContent> parent( do_QueryInterface(aParentNode) );
|
||||
nsCOMPtr<nsIContent> replaced( do_QueryInterface(aReplacedNode) );
|
||||
nsCOMPtr<nsIDOMNode> parentDomNode;
|
||||
nsresult res;
|
||||
|
||||
@ -1626,7 +1621,7 @@ nsresult nsRange::TextOwnerChanged(nsIContent* aTextNode, PRInt32 aStartChanged,
|
||||
// sanity check - null nodes shouldn't have enclosed ranges
|
||||
if (!aTextNode) return NS_ERROR_UNEXPECTED;
|
||||
|
||||
nsCOMPtr<nsIContent> textNode( dont_QueryInterface(aTextNode) );
|
||||
nsCOMPtr<nsIContent> textNode( do_QueryInterface(aTextNode) );
|
||||
nsVoidArray *theRangeList;
|
||||
aTextNode->GetRangeList(theRangeList);
|
||||
// the caller already checked to see if there was a range list
|
||||
|
@ -173,7 +173,7 @@ nsresult nsContentIterator::Init(nsIContent* aRoot)
|
||||
if (!aRoot)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
nsCOMPtr<nsIContent> root( dont_QueryInterface(aRoot) );
|
||||
nsCOMPtr<nsIContent> root( do_QueryInterface(aRoot) );
|
||||
mFirst = GetDeepFirstChild(root);
|
||||
mLast = root;
|
||||
mCommonParent = root;
|
||||
@ -349,6 +349,7 @@ nsresult nsContentIterator::GetNextSibling(nsCOMPtr<nsIContent> aNode, nsCOMPtr<
|
||||
|
||||
if (!NS_SUCCEEDED(aNode->GetParent(*getter_AddRefs(parent))))
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
if (!NS_SUCCEEDED(parent->IndexOf(aNode, indx)))
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
@ -358,7 +359,7 @@ nsresult nsContentIterator::GetNextSibling(nsCOMPtr<nsIContent> aNode, nsCOMPtr<
|
||||
}
|
||||
else if (parent != mCommonParent)
|
||||
{
|
||||
GetNextSibling(parent, aSibling);
|
||||
return GetNextSibling(parent, aSibling);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -382,6 +383,7 @@ nsresult nsContentIterator::GetPrevSibling(nsCOMPtr<nsIContent> aNode, nsCOMPtr<
|
||||
|
||||
if (!NS_SUCCEEDED(aNode->GetParent(*getter_AddRefs(parent))))
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
if (!NS_SUCCEEDED(parent->IndexOf(aNode, indx)))
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
@ -391,7 +393,7 @@ nsresult nsContentIterator::GetPrevSibling(nsCOMPtr<nsIContent> aNode, nsCOMPtr<
|
||||
}
|
||||
else if (parent != mCommonParent)
|
||||
{
|
||||
GetPrevSibling(parent, aSibling);
|
||||
return GetPrevSibling(parent, aSibling);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -612,7 +614,7 @@ nsresult nsContentSubtreeIterator::Init(nsIDOMRange* aRange)
|
||||
if (!aRange)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
mRange = dont_QueryInterface(aRange);
|
||||
mRange = do_QueryInterface(aRange);
|
||||
|
||||
// get the start node and offset, convert to nsIContent
|
||||
nsCOMPtr<nsIDOMNode> commonParent;
|
||||
@ -621,7 +623,8 @@ nsresult nsContentSubtreeIterator::Init(nsIDOMRange* aRange)
|
||||
nsCOMPtr<nsIContent> cStartP;
|
||||
nsCOMPtr<nsIContent> cEndP;
|
||||
nsCOMPtr<nsIContent> cN;
|
||||
nsCOMPtr<nsIContent> candidate;
|
||||
nsCOMPtr<nsIContent> firstCandidate;
|
||||
nsCOMPtr<nsIContent> lastCandidate;
|
||||
|
||||
// get common content parent
|
||||
if (!NS_SUCCEEDED(aRange->GetCommonParent(getter_AddRefs(commonParent))) || !commonParent)
|
||||
@ -646,7 +649,7 @@ nsresult nsContentSubtreeIterator::Init(nsIDOMRange* aRange)
|
||||
PRInt32 numChildren;
|
||||
cStartP->ChildCount(numChildren);
|
||||
|
||||
if (numChildren) // no children, must be a text node
|
||||
if (!numChildren) // no children, must be a text node
|
||||
{
|
||||
cN = cStartP;
|
||||
}
|
||||
@ -659,28 +662,28 @@ nsresult nsContentSubtreeIterator::Init(nsIDOMRange* aRange)
|
||||
}
|
||||
else
|
||||
{
|
||||
candidate = cChild;
|
||||
firstCandidate = cChild;
|
||||
}
|
||||
}
|
||||
|
||||
if (!candidate)
|
||||
if (!firstCandidate)
|
||||
{
|
||||
// then candidate is next node after cN
|
||||
if (!NS_SUCCEEDED(GetNextSibling(cN, &candidate)))
|
||||
// then firstCandidate is next node after cN
|
||||
if (!NS_SUCCEEDED(GetNextSibling(cN, &firstCandidate)))
|
||||
{
|
||||
MakeEmpty();
|
||||
return NS_OK;
|
||||
}
|
||||
}
|
||||
|
||||
candidate = GetDeepFirstChild(candidate);
|
||||
firstCandidate = GetDeepFirstChild(firstCandidate);
|
||||
|
||||
// confirm that this first possible contained node
|
||||
// is indeed contained. Else we have a range that
|
||||
// does not fully contain any node.
|
||||
|
||||
PRBool nodeBefore, nodeAfter;
|
||||
if (!NS_SUCCEEDED(CompareNodeToRange(candidate, aRange, &nodeBefore, &nodeAfter)))
|
||||
if (!NS_SUCCEEDED(CompareNodeToRange(firstCandidate, aRange, &nodeBefore, &nodeAfter)))
|
||||
return NS_ERROR_FAILURE;
|
||||
if (nodeBefore || nodeAfter)
|
||||
{
|
||||
@ -691,7 +694,7 @@ nsresult nsContentSubtreeIterator::Init(nsIDOMRange* aRange)
|
||||
// cool, we have the first node in the range. Now we walk
|
||||
// up it's ancestors to find the most senior that is still
|
||||
// in the range. That's the real first node.
|
||||
if (!NS_SUCCEEDED(GetTopAncestorInRange(candidate, &mFirst)))
|
||||
if (!NS_SUCCEEDED(GetTopAncestorInRange(firstCandidate, &mFirst)))
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
|
||||
@ -706,7 +709,7 @@ nsresult nsContentSubtreeIterator::Init(nsIDOMRange* aRange)
|
||||
{
|
||||
cEndP->ChildCount(numChildren);
|
||||
|
||||
if (numChildren) // no children, must be a text node
|
||||
if (!numChildren) // no children, must be a text node
|
||||
{
|
||||
cN = cEndP;
|
||||
}
|
||||
@ -720,28 +723,28 @@ nsresult nsContentSubtreeIterator::Init(nsIDOMRange* aRange)
|
||||
}
|
||||
else
|
||||
{
|
||||
candidate = cChild;
|
||||
lastCandidate = cChild;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!candidate)
|
||||
if (!lastCandidate)
|
||||
{
|
||||
// then candidate is prev node before cN
|
||||
if (!NS_SUCCEEDED(GetPrevSibling(cN, &candidate)))
|
||||
// then lastCandidate is prev node before cN
|
||||
if (!NS_SUCCEEDED(GetPrevSibling(cN, &lastCandidate)))
|
||||
{
|
||||
MakeEmpty();
|
||||
return NS_OK;
|
||||
}
|
||||
}
|
||||
|
||||
candidate = GetDeepLastChild(candidate);
|
||||
lastCandidate = GetDeepLastChild(lastCandidate);
|
||||
|
||||
// confirm that this first possible contained node
|
||||
// is indeed contained. Else we have a range that
|
||||
// does not fully contain any node.
|
||||
|
||||
if (!NS_SUCCEEDED(CompareNodeToRange(candidate, aRange, &nodeBefore, &nodeAfter)))
|
||||
if (!NS_SUCCEEDED(CompareNodeToRange(lastCandidate, aRange, &nodeBefore, &nodeAfter)))
|
||||
return NS_ERROR_FAILURE;
|
||||
if (nodeBefore || nodeAfter)
|
||||
{
|
||||
@ -752,7 +755,7 @@ nsresult nsContentSubtreeIterator::Init(nsIDOMRange* aRange)
|
||||
// cool, we have the last node in the range. Now we walk
|
||||
// up it's ancestors to find the most senior that is still
|
||||
// in the range. That's the real first node.
|
||||
if (!NS_SUCCEEDED(GetTopAncestorInRange(candidate, &mLast)))
|
||||
if (!NS_SUCCEEDED(GetTopAncestorInRange(lastCandidate, &mLast)))
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
mCurNode = mFirst;
|
||||
|
@ -648,17 +648,12 @@ nsCOMPtr<nsIDOMNode> nsRange::CommonParent(nsCOMPtr<nsIDOMNode> aNode1, nsCOMPtr
|
||||
|
||||
// no null nodes please
|
||||
if (!aNode1 || !aNode2)
|
||||
return nsCOMPtr<nsIDOMNode>(); // moral equiv or nsnull
|
||||
return nsCOMPtr<nsIDOMNode>(); // moral equiv of nsnull
|
||||
|
||||
// shortcut for common case - both nodes are the same
|
||||
if (aNode1 == aNode2)
|
||||
{
|
||||
// should be able to remove this error check later
|
||||
nsresult res = aNode1->GetParentNode(getter_AddRefs(theParent));
|
||||
if (!NS_SUCCEEDED(res))
|
||||
return nsCOMPtr<nsIDOMNode>(); // moral equiv or nsnull
|
||||
|
||||
return theParent;
|
||||
return aNode1;
|
||||
}
|
||||
|
||||
// otherwise traverse the tree for the common ancestor
|
||||
@ -673,7 +668,7 @@ nsCOMPtr<nsIDOMNode> nsRange::CommonParent(nsCOMPtr<nsIDOMNode> aNode1, nsCOMPtr
|
||||
NS_NOTREACHED("nsRange::CommonParent");
|
||||
delete array1;
|
||||
delete array2;
|
||||
return nsCOMPtr<nsIDOMNode>();
|
||||
return nsCOMPtr<nsIDOMNode>(); // moral equiv of nsnull
|
||||
}
|
||||
|
||||
// get ancestors of each node
|
||||
@ -686,7 +681,7 @@ nsCOMPtr<nsIDOMNode> nsRange::CommonParent(nsCOMPtr<nsIDOMNode> aNode1, nsCOMPtr
|
||||
NS_NOTREACHED("nsRange::CommonParent");
|
||||
delete array1;
|
||||
delete array2;
|
||||
return nsCOMPtr<nsIDOMNode>();
|
||||
return nsCOMPtr<nsIDOMNode>(); // moral equiv of nsnull
|
||||
}
|
||||
|
||||
// sanity test (for now) - the end of each array
|
||||
@ -696,7 +691,7 @@ nsCOMPtr<nsIDOMNode> nsRange::CommonParent(nsCOMPtr<nsIDOMNode> aNode1, nsCOMPtr
|
||||
NS_NOTREACHED("nsRange::CommonParent");
|
||||
delete array1;
|
||||
delete array2;
|
||||
return nsCOMPtr<nsIDOMNode>();
|
||||
return nsCOMPtr<nsIDOMNode>(); // moral equiv of nsnull
|
||||
}
|
||||
|
||||
// back through the ancestors, starting from the root, until
|
||||
@ -881,7 +876,7 @@ nsresult nsRange::SetStart(nsIDOMNode* aParent, PRInt32 aOffset)
|
||||
|
||||
if (!aParent) return NS_ERROR_NULL_POINTER;
|
||||
|
||||
nsCOMPtr<nsIDOMNode>theParent( dont_QueryInterface(aParent) );
|
||||
nsCOMPtr<nsIDOMNode>theParent( do_QueryInterface(aParent) );
|
||||
|
||||
// must be in same document as endpoint, else
|
||||
// endpoint is collapsed to new start.
|
||||
@ -902,7 +897,7 @@ nsresult nsRange::SetStart(nsIDOMNode* aParent, PRInt32 aOffset)
|
||||
|
||||
nsresult nsRange::SetStartBefore(nsIDOMNode* aSibling)
|
||||
{
|
||||
nsCOMPtr<nsIDOMNode>theSibling( dont_QueryInterface(aSibling) );
|
||||
nsCOMPtr<nsIDOMNode>theSibling( do_QueryInterface(aSibling) );
|
||||
PRInt32 indx = IndexOf(theSibling);
|
||||
nsIDOMNode *nParent;
|
||||
theSibling->GetParentNode(&nParent);
|
||||
@ -911,7 +906,7 @@ nsresult nsRange::SetStartBefore(nsIDOMNode* aSibling)
|
||||
|
||||
nsresult nsRange::SetStartAfter(nsIDOMNode* aSibling)
|
||||
{
|
||||
nsCOMPtr<nsIDOMNode>theSibling( dont_QueryInterface(aSibling) );
|
||||
nsCOMPtr<nsIDOMNode>theSibling( do_QueryInterface(aSibling) );
|
||||
PRInt32 indx = IndexOf(theSibling) + 1;
|
||||
nsIDOMNode *nParent;
|
||||
theSibling->GetParentNode(&nParent);
|
||||
@ -924,7 +919,7 @@ nsresult nsRange::SetEnd(nsIDOMNode* aParent, PRInt32 aOffset)
|
||||
|
||||
if (!aParent) return NS_ERROR_NULL_POINTER;
|
||||
|
||||
nsCOMPtr<nsIDOMNode>theParent( dont_QueryInterface(aParent) );
|
||||
nsCOMPtr<nsIDOMNode>theParent( do_QueryInterface(aParent) );
|
||||
|
||||
// must be in same document as startpoint, else
|
||||
// endpoint is collapsed to new end.
|
||||
@ -945,7 +940,7 @@ nsresult nsRange::SetEnd(nsIDOMNode* aParent, PRInt32 aOffset)
|
||||
|
||||
nsresult nsRange::SetEndBefore(nsIDOMNode* aSibling)
|
||||
{
|
||||
nsCOMPtr<nsIDOMNode>theSibling( dont_QueryInterface(aSibling) );
|
||||
nsCOMPtr<nsIDOMNode>theSibling( do_QueryInterface(aSibling) );
|
||||
PRInt32 indx = IndexOf(theSibling);
|
||||
nsIDOMNode *nParent;
|
||||
theSibling->GetParentNode(&nParent);
|
||||
@ -954,7 +949,7 @@ nsresult nsRange::SetEndBefore(nsIDOMNode* aSibling)
|
||||
|
||||
nsresult nsRange::SetEndAfter(nsIDOMNode* aSibling)
|
||||
{
|
||||
nsCOMPtr<nsIDOMNode>theSibling( dont_QueryInterface(aSibling) );
|
||||
nsCOMPtr<nsIDOMNode>theSibling( do_QueryInterface(aSibling) );
|
||||
PRInt32 indx = IndexOf(theSibling) + 1;
|
||||
nsIDOMNode *nParent;
|
||||
theSibling->GetParentNode(&nParent);
|
||||
@ -985,7 +980,7 @@ nsresult nsRange::Unposition()
|
||||
nsresult nsRange::SelectNode(nsIDOMNode* aN)
|
||||
{
|
||||
nsCOMPtr<nsIDOMNode> parent;
|
||||
nsCOMPtr<nsIDOMNode> theNode( dont_QueryInterface(aN) );
|
||||
nsCOMPtr<nsIDOMNode> theNode( do_QueryInterface(aN) );
|
||||
|
||||
nsresult res = aN->GetParentNode(getter_AddRefs(parent));
|
||||
if (!NS_SUCCEEDED(res))
|
||||
@ -997,7 +992,7 @@ nsresult nsRange::SelectNode(nsIDOMNode* aN)
|
||||
|
||||
nsresult nsRange::SelectNodeContents(nsIDOMNode* aN)
|
||||
{
|
||||
nsCOMPtr<nsIDOMNode> theNode( dont_QueryInterface(aN) );
|
||||
nsCOMPtr<nsIDOMNode> theNode( do_QueryInterface(aN) );
|
||||
nsCOMPtr<nsIDOMNodeList> aChildNodes;
|
||||
|
||||
nsresult res = aN->GetChildNodes(getter_AddRefs(aChildNodes));
|
||||
@ -1503,7 +1498,7 @@ nsresult nsRange::OwnerChildInserted(nsIContent* aParentNode, PRInt32 aOffset)
|
||||
// sanity check - null nodes shouldn't have enclosed ranges
|
||||
if (!aParentNode) return NS_ERROR_UNEXPECTED;
|
||||
|
||||
nsCOMPtr<nsIContent> parent( dont_QueryInterface(aParentNode) );
|
||||
nsCOMPtr<nsIContent> parent( do_QueryInterface(aParentNode) );
|
||||
// quick return if no range list
|
||||
nsVoidArray *theRangeList;
|
||||
parent->GetRangeList(theRangeList);
|
||||
@ -1548,8 +1543,8 @@ nsresult nsRange::OwnerChildRemoved(nsIContent* aParentNode, PRInt32 aOffset, ns
|
||||
// sanity check - null nodes shouldn't have enclosed ranges
|
||||
if (!aParentNode) return NS_ERROR_UNEXPECTED;
|
||||
|
||||
nsCOMPtr<nsIContent> parent( dont_QueryInterface(aParentNode) );
|
||||
nsCOMPtr<nsIContent> removed( dont_QueryInterface(aRemovedNode) );
|
||||
nsCOMPtr<nsIContent> parent( do_QueryInterface(aParentNode) );
|
||||
nsCOMPtr<nsIContent> removed( do_QueryInterface(aRemovedNode) );
|
||||
// quick return if no range list
|
||||
nsVoidArray *theRangeList;
|
||||
parent->GetRangeList(theRangeList);
|
||||
@ -1606,8 +1601,8 @@ nsresult nsRange::OwnerChildReplaced(nsIContent* aParentNode, PRInt32 aOffset, n
|
||||
// but we do need to pop out any range endpoints inside the subtree
|
||||
// rooted by aReplacedNode.
|
||||
|
||||
nsCOMPtr<nsIContent> parent( dont_QueryInterface(aParentNode) );
|
||||
nsCOMPtr<nsIContent> replaced( dont_QueryInterface(aReplacedNode) );
|
||||
nsCOMPtr<nsIContent> parent( do_QueryInterface(aParentNode) );
|
||||
nsCOMPtr<nsIContent> replaced( do_QueryInterface(aReplacedNode) );
|
||||
nsCOMPtr<nsIDOMNode> parentDomNode;
|
||||
nsresult res;
|
||||
|
||||
@ -1626,7 +1621,7 @@ nsresult nsRange::TextOwnerChanged(nsIContent* aTextNode, PRInt32 aStartChanged,
|
||||
// sanity check - null nodes shouldn't have enclosed ranges
|
||||
if (!aTextNode) return NS_ERROR_UNEXPECTED;
|
||||
|
||||
nsCOMPtr<nsIContent> textNode( dont_QueryInterface(aTextNode) );
|
||||
nsCOMPtr<nsIContent> textNode( do_QueryInterface(aTextNode) );
|
||||
nsVoidArray *theRangeList;
|
||||
aTextNode->GetRangeList(theRangeList);
|
||||
// the caller already checked to see if there was a range list
|
||||
|
Loading…
Reference in New Issue
Block a user