From 5c16f8ec62aaee3d3c03c0bd3921d7409f4f1d81 Mon Sep 17 00:00:00 2001 From: Trevor Saunders Date: Mon, 25 Mar 2013 19:46:22 -0400 Subject: [PATCH] bug 852150 - handle removal of accessibles when reframe root doesn't have an accessible more correctly r=surkov --- accessible/src/generic/DocAccessible.cpp | 29 ++++++++- .../tests/mochitest/treeupdate/Makefile.in | 1 + .../mochitest/treeupdate/test_bug852150.xhtml | 59 +++++++++++++++++++ 3 files changed, 86 insertions(+), 3 deletions(-) create mode 100644 accessible/tests/mochitest/treeupdate/test_bug852150.xhtml diff --git a/accessible/src/generic/DocAccessible.cpp b/accessible/src/generic/DocAccessible.cpp index 33da0459cc5..4e653c4e791 100644 --- a/accessible/src/generic/DocAccessible.cpp +++ b/accessible/src/generic/DocAccessible.cpp @@ -1739,10 +1739,33 @@ DocAccessible::UpdateTree(Accessible* aContainer, nsIContent* aChildNode, if (child) { updateFlags |= UpdateTreeInternal(child, aIsInsert, reorderEvent); } else { - TreeWalker walker(aContainer, aChildNode, true); + if (aIsInsert) { + TreeWalker walker(aContainer, aChildNode, true); - while ((child = walker.NextChild())) - updateFlags |= UpdateTreeInternal(child, aIsInsert, reorderEvent); + while ((child = walker.NextChild())) + updateFlags |= UpdateTreeInternal(child, aIsInsert, reorderEvent); + } else { + // aChildNode may not coorespond to a particular accessible, to handle + // this we go through all the children of aContainer. Then if a child + // has aChildNode as an ancestor, or does not have the node for + // aContainer as an ancestor remove that child of aContainer. Note that + // when we are called aChildNode may already have been removed + // from the DOM so we can't expect it to have a parent or what was it's + // parent to have it as a child. + nsINode* containerNode = aContainer->GetNode(); + for (uint32_t idx = 0; idx < aContainer->ContentChildCount();) { + Accessible* child = aContainer->ContentChildAt(idx); + nsINode* childNode = child->GetContent(); + while (childNode != aChildNode && childNode != containerNode && + (childNode = childNode->GetParentNode())); + + if (childNode != containerNode) { + updateFlags |= UpdateTreeInternal(child, false, reorderEvent); + } else { + idx++; + } + } + } } // Content insertion/removal is not cause of accessible tree change. diff --git a/accessible/tests/mochitest/treeupdate/Makefile.in b/accessible/tests/mochitest/treeupdate/Makefile.in index 3ff227ad0a3..ca92d640d18 100644 --- a/accessible/tests/mochitest/treeupdate/Makefile.in +++ b/accessible/tests/mochitest/treeupdate/Makefile.in @@ -30,6 +30,7 @@ MOCHITEST_A11Y_FILES =\ test_optgroup.html \ test_recreation.html \ test_select.html \ + test_bug852150.xhtml \ test_textleaf.html \ test_visibility.html \ test_whitespace.html \ diff --git a/accessible/tests/mochitest/treeupdate/test_bug852150.xhtml b/accessible/tests/mochitest/treeupdate/test_bug852150.xhtml new file mode 100644 index 00000000000..094d148a002 --- /dev/null +++ b/accessible/tests/mochitest/treeupdate/test_bug852150.xhtml @@ -0,0 +1,59 @@ + + + Canvas subdom mutation + + + + + + + + + + + + + + Mozilla Bug 852150 + + +

+ +
+  
+ + +
+ + +