From 8c50bda914b9f833ca0be9ff54dae967a243b5a9 Mon Sep 17 00:00:00 2001 From: "aaronleventhal%moonset.net" Date: Wed, 19 Jul 2006 17:50:44 +0000 Subject: [PATCH] Bug 345192. Some caret events not reported in midas text edit areas. r=evan.yan --- accessible/src/base/nsCaretAccessible.cpp | 25 +++++++++++------------ 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/accessible/src/base/nsCaretAccessible.cpp b/accessible/src/base/nsCaretAccessible.cpp index 56b55dfaa1c3..408d1461863a 100644 --- a/accessible/src/base/nsCaretAccessible.cpp +++ b/accessible/src/base/nsCaretAccessible.cpp @@ -183,24 +183,23 @@ NS_IMETHODIMP nsCaretAccessible::NotifySelectionChanged(nsIDOMDocument *aDoc, ns // Get accessible from selection's focus node or its parent nsCOMPtr focusNode; domSel->GetFocusNode(getter_AddRefs(focusNode)); - nsCOMPtr internalNode = do_QueryInterface(focusNode); - if (!internalNode) { + if (!focusNode) { return NS_OK; // No selection } nsCOMPtr textAcc; - while (internalNode) { - nsCOMPtr caretNode = do_QueryInterface(internalNode); - if (PR_FALSE == internalNode->IsNodeOfType(nsINode::eTEXT)) { - nsCOMPtr content = do_QueryInterface(internalNode); - if (PR_FALSE == content->IsNativeAnonymous()) { // Don't want anonymous nodes inside a form control - accService->GetAccessibleInShell(caretNode, presShell, getter_AddRefs(accessible)); - textAcc = do_QueryInterface(accessible); - if (textAcc) { - break; - } + while (focusNode) { + nsCOMPtr content = do_QueryInterface(focusNode); + if (!content || (PR_FALSE == content->IsNodeOfType(nsINode::eTEXT) && + PR_FALSE == content->IsNativeAnonymous())) { // Don't want anonymous nodes inside a form control + accService->GetAccessibleInShell(focusNode, presShell, getter_AddRefs(accessible)); + textAcc = do_QueryInterface(accessible); + if (textAcc) { + break; } } - internalNode = internalNode->GetParent(); + nsCOMPtr parentNode; + focusNode->GetParentNode(getter_AddRefs(parentNode)); + focusNode.swap(parentNode); } NS_ASSERTION(textAcc, "No nsIAccessibleText for caret move event!"); // No nsIAccessibleText for caret move event! NS_ENSURE_TRUE(textAcc, NS_ERROR_FAILURE);