Bug 370651. Fire correct caret moved event for jumps to empty anchors. r=ginn.chen

git-svn-id: svn://10.0.0.236/trunk@224739 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
aaronleventhal%moonset.net
2007-04-19 13:56:09 +00:00
parent ab3e0c5246
commit 3957d92e36

View File

@@ -495,8 +495,16 @@ nsresult nsHyperTextAccessible::DOMPointToOffset(nsIDOMNode* aNode, PRInt32 aNod
nsCOMPtr<nsIContent> parentContent(do_QueryInterface(aNode));
// Should not happen, but better to protect against crash if doc node is somehow passed in
NS_ENSURE_TRUE(parentContent, NS_ERROR_FAILURE);
// findNode could be null if aNodeOffset == # of child nodes, which means we're at the end of the children
// findNode could be null if aNodeOffset == # of child nodes, which means one of two things:
// 1) we're at the end of the children, keep findNode = null, so that we get the last possible offset
// 2) there are no children, use parentContent for the node to find. In this case parentContent can't be
// the nsIAccessibleText, because an accesible text must have children
findNode = do_QueryInterface(parentContent->GetChildAt(aNodeOffset));
if (!findNode && !aNodeOffset) {
NS_ASSERTION(!SameCOMIdentity(parentContent, mDOMNode), "Cannot find child for DOMPointToOffset search");
findNode = do_QueryInterface(parentContent); // Case #2: there are no children
}
}
// Get accessible for this findNode, or if that node isn't accessible, use the