From 499efe0f100bda1cf3fb0cbd2100c4858efb288d Mon Sep 17 00:00:00 2001 From: Alexander Surkov Date: Wed, 20 Jul 2016 09:40:55 -0400 Subject: [PATCH] Bug 1286598 - make sure an accessible tree is updated on DOM tree removals, r=yzen --- accessible/generic/DocAccessible.cpp | 22 ++- .../tests/mochitest/treeupdate/a11y.ini | 1 + .../mochitest/treeupdate/test_bug1276857.html | 143 ++++++++++++++++++ 3 files changed, 163 insertions(+), 3 deletions(-) create mode 100644 accessible/tests/mochitest/treeupdate/test_bug1276857.html diff --git a/accessible/generic/DocAccessible.cpp b/accessible/generic/DocAccessible.cpp index d470972a1b15..f467482592d5 100644 --- a/accessible/generic/DocAccessible.cpp +++ b/accessible/generic/DocAccessible.cpp @@ -1130,10 +1130,26 @@ DocAccessible::ContentInserted(nsIDocument* aDocument, nsIContent* aContainer, } void -DocAccessible::ContentRemoved(nsIDocument* aDocument, nsIContent* aContainer, - nsIContent* aChild, int32_t /* unused */, - nsIContent* aPreviousSibling) +DocAccessible::ContentRemoved(nsIDocument* aDocument, + nsIContent* aContainerNode, + nsIContent* aChildNode, int32_t /* unused */, + nsIContent* aPreviousSiblingNode) { +#ifdef A11Y_LOG + if (logging::IsEnabled(logging::eTree)) { + logging::MsgBegin("TREE", "DOM content removed; doc: %p", this); + logging::Node("container node", aContainerNode); + logging::Node("content node", aChildNode); + logging::MsgEnd(); + } +#endif + // This one and content removal notification from layout may result in + // double processing of same subtrees. If it pops up in profiling, then + // consider reusing a document node cache to reject these notifications early. + Accessible* container = GetAccessibleOrContainer(aContainerNode); + if (container) { + UpdateTreeOnRemoval(container, aChildNode); + } } void diff --git a/accessible/tests/mochitest/treeupdate/a11y.ini b/accessible/tests/mochitest/treeupdate/a11y.ini index b3b6ccb86c83..d725ebff339a 100644 --- a/accessible/tests/mochitest/treeupdate/a11y.ini +++ b/accessible/tests/mochitest/treeupdate/a11y.ini @@ -14,6 +14,7 @@ support-files = [test_bug1100602.html] [test_bug1175913.html] [test_bug1189277.html] +[test_bug1276857.html] [test_canvas.html] [test_colorpicker.xul] [test_contextmenu.xul] diff --git a/accessible/tests/mochitest/treeupdate/test_bug1276857.html b/accessible/tests/mochitest/treeupdate/test_bug1276857.html new file mode 100644 index 000000000000..5eceae9eb5be --- /dev/null +++ b/accessible/tests/mochitest/treeupdate/test_bug1276857.html @@ -0,0 +1,143 @@ + + + + + DOM mutations test + + + + + + + + + + + + + +

+ +
+  
+ +
+ +
+ + + +
+ + + +