Bug 564979. Get rid of nsINode::GetSibling and just use GetNext/PreviousSibling instead. r=peterv, sr=sicking

This commit is contained in:
Boris Zbarsky 2010-05-17 14:18:25 -04:00
parent 270ae8d585
commit 6644f13f29
4 changed files with 9 additions and 16 deletions

View File

@ -922,15 +922,6 @@ public:
nsIContent* GetSelectionRootContent(nsIPresShell* aPresShell);
virtual nsINodeList* GetChildNodesList();
nsIContent* GetSibling(PRInt32 aOffset)
{
nsINode *parent = GetNodeParent();
if (!parent) {
return nsnull;
}
return parent->GetChildAt(parent->IndexOf(this) + aOffset);
}
nsIContent* GetFirstChild() const { return mFirstChild; }
nsIContent* GetLastChild() const
{

View File

@ -514,7 +514,7 @@ nsINode::GetPreviousSibling(nsIDOMNode** aPrevSibling)
{
*aPrevSibling = nsnull;
nsIContent *sibling = GetSibling(-1);
nsIContent *sibling = GetPreviousSibling();
return sibling ? CallQueryInterface(sibling, aPrevSibling) : NS_OK;
}
@ -524,7 +524,7 @@ nsINode::GetNextSibling(nsIDOMNode** aNextSibling)
{
*aNextSibling = nsnull;
nsIContent *sibling = GetSibling(1);
nsIContent *sibling = GetNextSibling();
return sibling ? CallQueryInterface(sibling, aNextSibling) : NS_OK;
}

View File

@ -134,6 +134,7 @@ typedef void (* OnLeaveNodeFunPtr)(nsIDOMNode* aNode, void* aClosure);
// Find the next node in the DOM tree in preorder. This isn't fast because
// one call to GetNextSibling can be O(N) in the number of siblings...
// Calls OnLeaveNodeFunPtr when the traversal leaves a node
// XXXbz if this used nsINode, this would be trivial
static nsIDOMNode*
FindNextNode(nsIDOMNode* aNode, nsIDOMNode* aRoot,
OnLeaveNodeFunPtr aOnLeaveNode = nsnull, void* aClosure = nsnull)
@ -188,7 +189,8 @@ FindNextTextNode(nsIDOMNode* aNode, PRInt32 aOffset, nsIDOMNode* aRoot)
} else {
// aOffset was beyond the end of the child list.
// goto next node in a preorder DOM traversal.
nsINode* next = node->GetSibling(1);
// XXXbz this is generally reimplementing GetNextNode.
nsINode* next = node->GetNextSibling();
if (!next) {
nsCOMPtr<nsINode> root = do_QueryInterface(aRoot);
while (!next) {
@ -198,7 +200,7 @@ FindNextTextNode(nsIDOMNode* aNode, PRInt32 aOffset, nsIDOMNode* aRoot)
return nsnull;
}
node = next;
next = node->GetSibling(1);
next = node->GetNextSibling();
}
}
checkNode = do_QueryInterface(next);

View File

@ -565,12 +565,12 @@ CUSTOM_QS_TN = {
customMethodCalls = {
'nsIDOMNode_GetNextSibling': {
'thisType': 'nsINode',
'code': ' nsINode *result = self->GetSibling(1);',
'code': ' nsINode *result = self->GetNextSibling();',
'canFail': False
},
'nsIDOMNode_GetFirstChild': {
'thisType': 'nsINode',
'code': ' nsINode *result = self->GetChildAt(0);',
'code': ' nsINode *result = self->GetFirstChild();',
'canFail': False
},
'nsIDOMNode_GetChildNodes': {
@ -579,7 +579,7 @@ customMethodCalls = {
},
'nsIDOMNode_GetPreviousSibling': {
'thisType': 'nsINode',
'code': ' nsINode *result = self->GetSibling(-1);',
'code': ' nsINode *result = self->GetPreviousSibling();',
'canFail': False
},
'nsIDOMNode_GetLastChild': {