Bug 337656. Navigation methods of nsAccessNode should not throw exception when no node reached. Patch by Alexander Surkov. r=aaronlev

This commit is contained in:
aaronleventhal%moonset.net 2007-02-16 05:04:50 +00:00
Родитель 70373c271f
Коммит 2854daec0f
1 изменённых файлов: 21 добавлений и 12 удалений

Просмотреть файл

@ -355,6 +355,8 @@ nsAccessNode::GetInnerHTML(nsAString& aInnerHTML)
nsresult nsresult
nsAccessNode::MakeAccessNode(nsIDOMNode *aNode, nsIAccessNode **aAccessNode) nsAccessNode::MakeAccessNode(nsIDOMNode *aNode, nsIAccessNode **aAccessNode)
{ {
*aAccessNode = nsnull;
nsIAccessibilityService *accService = GetAccService(); nsIAccessibilityService *accService = GetAccService();
NS_ENSURE_TRUE(accService, NS_ERROR_FAILURE); NS_ENSURE_TRUE(accService, NS_ERROR_FAILURE);
@ -388,74 +390,81 @@ nsAccessNode::MakeAccessNode(nsIDOMNode *aNode, nsIAccessNode **aAccessNode)
NS_IMETHODIMP NS_IMETHODIMP
nsAccessNode::GetFirstChildNode(nsIAccessNode **aAccessNode) nsAccessNode::GetFirstChildNode(nsIAccessNode **aAccessNode)
{ {
NS_ENSURE_ARG_POINTER(aAccessNode);
*aAccessNode = nsnull;
NS_ENSURE_TRUE(mDOMNode, NS_ERROR_NULL_POINTER); NS_ENSURE_TRUE(mDOMNode, NS_ERROR_NULL_POINTER);
nsCOMPtr<nsIDOMNode> domNode; nsCOMPtr<nsIDOMNode> domNode;
mDOMNode->GetFirstChild(getter_AddRefs(domNode)); mDOMNode->GetFirstChild(getter_AddRefs(domNode));
NS_ENSURE_TRUE(domNode, NS_ERROR_NULL_POINTER);
return MakeAccessNode(domNode, aAccessNode); return domNode ? MakeAccessNode(domNode, aAccessNode) : NS_OK;
} }
NS_IMETHODIMP NS_IMETHODIMP
nsAccessNode::GetLastChildNode(nsIAccessNode **aAccessNode) nsAccessNode::GetLastChildNode(nsIAccessNode **aAccessNode)
{ {
NS_ENSURE_ARG_POINTER(aAccessNode);
*aAccessNode = nsnull;
NS_ENSURE_TRUE(mDOMNode, NS_ERROR_NULL_POINTER); NS_ENSURE_TRUE(mDOMNode, NS_ERROR_NULL_POINTER);
nsCOMPtr<nsIDOMNode> domNode; nsCOMPtr<nsIDOMNode> domNode;
mDOMNode->GetLastChild(getter_AddRefs(domNode)); mDOMNode->GetLastChild(getter_AddRefs(domNode));
NS_ENSURE_TRUE(domNode, NS_ERROR_NULL_POINTER);
return MakeAccessNode(domNode, aAccessNode); return domNode ? MakeAccessNode(domNode, aAccessNode) : NS_OK;
} }
NS_IMETHODIMP NS_IMETHODIMP
nsAccessNode::GetParentNode(nsIAccessNode **aAccessNode) nsAccessNode::GetParentNode(nsIAccessNode **aAccessNode)
{ {
NS_ENSURE_ARG_POINTER(aAccessNode);
*aAccessNode = nsnull;
NS_ENSURE_TRUE(mDOMNode, NS_ERROR_NULL_POINTER); NS_ENSURE_TRUE(mDOMNode, NS_ERROR_NULL_POINTER);
nsCOMPtr<nsIDOMNode> domNode; nsCOMPtr<nsIDOMNode> domNode;
mDOMNode->GetParentNode(getter_AddRefs(domNode)); mDOMNode->GetParentNode(getter_AddRefs(domNode));
NS_ENSURE_TRUE(domNode, NS_ERROR_NULL_POINTER);
return MakeAccessNode(domNode, aAccessNode); return domNode ? MakeAccessNode(domNode, aAccessNode) : NS_OK;
} }
NS_IMETHODIMP NS_IMETHODIMP
nsAccessNode::GetPreviousSiblingNode(nsIAccessNode **aAccessNode) nsAccessNode::GetPreviousSiblingNode(nsIAccessNode **aAccessNode)
{ {
NS_ENSURE_ARG_POINTER(aAccessNode);
*aAccessNode = nsnull;
NS_ENSURE_TRUE(mDOMNode, NS_ERROR_NULL_POINTER); NS_ENSURE_TRUE(mDOMNode, NS_ERROR_NULL_POINTER);
nsCOMPtr<nsIDOMNode> domNode; nsCOMPtr<nsIDOMNode> domNode;
mDOMNode->GetPreviousSibling(getter_AddRefs(domNode)); mDOMNode->GetPreviousSibling(getter_AddRefs(domNode));
NS_ENSURE_TRUE(domNode, NS_ERROR_NULL_POINTER);
return MakeAccessNode(domNode, aAccessNode); return domNode ? MakeAccessNode(domNode, aAccessNode) : NS_OK;
} }
NS_IMETHODIMP NS_IMETHODIMP
nsAccessNode::GetNextSiblingNode(nsIAccessNode **aAccessNode) nsAccessNode::GetNextSiblingNode(nsIAccessNode **aAccessNode)
{ {
NS_ENSURE_ARG_POINTER(aAccessNode);
*aAccessNode = nsnull;
NS_ENSURE_TRUE(mDOMNode, NS_ERROR_NULL_POINTER); NS_ENSURE_TRUE(mDOMNode, NS_ERROR_NULL_POINTER);
nsCOMPtr<nsIDOMNode> domNode; nsCOMPtr<nsIDOMNode> domNode;
mDOMNode->GetNextSibling(getter_AddRefs(domNode)); mDOMNode->GetNextSibling(getter_AddRefs(domNode));
NS_ENSURE_TRUE(domNode, NS_ERROR_NULL_POINTER);
return MakeAccessNode(domNode, aAccessNode); return domNode ? MakeAccessNode(domNode, aAccessNode) : NS_OK;
} }
NS_IMETHODIMP NS_IMETHODIMP
nsAccessNode::GetChildNodeAt(PRInt32 aChildNum, nsIAccessNode **aAccessNode) nsAccessNode::GetChildNodeAt(PRInt32 aChildNum, nsIAccessNode **aAccessNode)
{ {
NS_ENSURE_ARG_POINTER(aAccessNode);
*aAccessNode = nsnull;
nsCOMPtr<nsIContent> content(do_QueryInterface(mDOMNode)); nsCOMPtr<nsIContent> content(do_QueryInterface(mDOMNode));
NS_ENSURE_TRUE(content, NS_ERROR_NULL_POINTER); NS_ENSURE_TRUE(content, NS_ERROR_NULL_POINTER);
nsCOMPtr<nsIDOMNode> domNode = nsCOMPtr<nsIDOMNode> domNode =
do_QueryInterface(content->GetChildAt(aChildNum)); do_QueryInterface(content->GetChildAt(aChildNum));
NS_ENSURE_TRUE(domNode, NS_ERROR_NULL_POINTER);
return MakeAccessNode(domNode, aAccessNode); return domNode ? MakeAccessNode(domNode, aAccessNode) : NS_OK;
} }
NS_IMETHODIMP NS_IMETHODIMP