diff --git a/accessible/src/base/nsDocAccessible.cpp b/accessible/src/base/nsDocAccessible.cpp index 433b5c2b1d0..5fb4e1b8e3d 100644 --- a/accessible/src/base/nsDocAccessible.cpp +++ b/accessible/src/base/nsDocAccessible.cpp @@ -1515,7 +1515,7 @@ nsDocAccessible::CreateTextChangeEventForNode(nsIAccessible *aContainerAccessibl PRInt32 offset; PRInt32 length = 0; - nsCOMPtr changeAccessible = + nsAccessible *changeAcc = textAccessible->DOMPointToHypertextOffset(aChangeNode, -1, &offset); if (!aAccessibleForChangeNode) { @@ -1524,33 +1524,29 @@ nsDocAccessible::CreateTextChangeEventForNode(nsIAccessible *aContainerAccessibl // into the parent hypertext. // In this case, accessibleToBeRemoved may just be the first // accessible that is removed, which affects the text in the hypertext container - if (!changeAccessible) { + if (!changeAcc) return nsnull; // No descendant content that represents any text in the hypertext parent - } nsCOMPtr changeNode(do_QueryInterface(aChangeNode)); - nsCOMPtr child = changeAccessible; - while (PR_TRUE) { - nsCOMPtr childAccessNode = - do_QueryInterface(changeAccessible); - nsCOMPtr childDOMNode; - childAccessNode->GetDOMNode(getter_AddRefs(childDOMNode)); + nsAccessible *parent = changeAcc->GetParent(); + PRInt32 childCount = parent->GetChildCount(); + PRInt32 changeAccIdx = parent->GetIndexOf(changeAcc); + + for (PRInt32 idx = changeAccIdx; idx < childCount; idx++) { + nsAccessible *child = parent->GetChildAt(idx); + nsCOMPtr childNode(do_QueryInterface(child->GetDOMNode())); - nsCOMPtr childNode(do_QueryInterface(childDOMNode)); if (!nsCoreUtils::IsAncestorOf(changeNode, childNode)) { - break; // We only want accessibles with DOM nodes as children of this node - } - length += nsAccUtils::TextLength(child); - child->GetNextSibling(getter_AddRefs(changeAccessible)); - if (!changeAccessible) { + // We only want accessibles with DOM nodes as children of this node break; } - child.swap(changeAccessible); + + length += nsAccUtils::TextLength(child); } } else { - NS_ASSERTION(!changeAccessible || changeAccessible == aAccessibleForChangeNode, + NS_ASSERTION(!changeAcc || changeAcc == aAccessibleForChangeNode, "Hypertext is reporting a different accessible for this node"); length = nsAccUtils::TextLength(aAccessibleForChangeNode); diff --git a/accessible/tests/mochitest/common.js b/accessible/tests/mochitest/common.js index b6cba65a26a..9abe50e3a21 100644 --- a/accessible/tests/mochitest/common.js +++ b/accessible/tests/mochitest/common.js @@ -8,6 +8,8 @@ const nsIAccessibleStateChangeEvent = Components.interfaces.nsIAccessibleStateChangeEvent; const nsIAccessibleCaretMoveEvent = Components.interfaces.nsIAccessibleCaretMoveEvent; +const nsIAccessibleTextChangeEvent = + Components.interfaces.nsIAccessibleTextChangeEvent; const nsIAccessibleStates = Components.interfaces.nsIAccessibleStates; const nsIAccessibleRole = Components.interfaces.nsIAccessibleRole; diff --git a/accessible/tests/mochitest/events.js b/accessible/tests/mochitest/events.js index 6b8a6037634..9c81e0d27ea 100644 --- a/accessible/tests/mochitest/events.js +++ b/accessible/tests/mochitest/events.js @@ -10,6 +10,7 @@ const EVENT_SCROLLING_START = nsIAccessibleEvent.EVENT_SCROLLING_START; const EVENT_SHOW = nsIAccessibleEvent.EVENT_SHOW; const EVENT_STATE_CHANGE = nsIAccessibleEvent.EVENT_STATE_CHANGE; const EVENT_TEXT_CARET_MOVED = nsIAccessibleEvent.EVENT_TEXT_CARET_MOVED; +const EVENT_TEXT_REMOVED = nsIAccessibleEvent.EVENT_TEXT_REMOVED; //////////////////////////////////////////////////////////////////////////////// // General diff --git a/accessible/tests/mochitest/events/Makefile.in b/accessible/tests/mochitest/events/Makefile.in index 4cccd0b5bbb..87109cb1711 100644 --- a/accessible/tests/mochitest/events/Makefile.in +++ b/accessible/tests/mochitest/events/Makefile.in @@ -61,6 +61,7 @@ _TEST_FILES =\ test_focusdoc.html \ test_mutation.html \ test_scroll.xul \ + test_text.html \ test_tree.xul \ test_valuechange.html \ $(NULL) diff --git a/accessible/tests/mochitest/events/test_text.html b/accessible/tests/mochitest/events/test_text.html new file mode 100644 index 00000000000..479c075373e --- /dev/null +++ b/accessible/tests/mochitest/events/test_text.html @@ -0,0 +1,89 @@ + + + + Accessible mutation events testing + + + + + + + + + + + + + + + + + Mozilla Bug 566293 + + +

+ +
+  
+
+ +

333221111

+ +