From 3957d92e368fbfb946dbff4d004cebfc08820891 Mon Sep 17 00:00:00 2001 From: "aaronleventhal%moonset.net" Date: Thu, 19 Apr 2007 13:56:09 +0000 Subject: [PATCH] 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 --- mozilla/accessible/src/html/nsHyperTextAccessible.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/mozilla/accessible/src/html/nsHyperTextAccessible.cpp b/mozilla/accessible/src/html/nsHyperTextAccessible.cpp index 23bb8cd8a2c..f9921a82f7d 100644 --- a/mozilla/accessible/src/html/nsHyperTextAccessible.cpp +++ b/mozilla/accessible/src/html/nsHyperTextAccessible.cpp @@ -495,8 +495,16 @@ nsresult nsHyperTextAccessible::DOMPointToOffset(nsIDOMNode* aNode, PRInt32 aNod nsCOMPtr 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