Bug 1295603 - ignore mutation events if contained by shown or hidden container, r=surkov
authorMichael Li <michael.li11702@gmail.com>
Mon, 12 Sep 2016 10:43:40 -0400
changeset 354846 569def7d611ec9c0b8b9c538f6a48b7f87c02502
parent 354845 4b33830da34cb7b672c50007490bc1a8f441fec0
child 354847 b81f663f726fe9fd60fbb74166e82c75a32e907b
push id6570
push userraliiev@mozilla.com
push dateMon, 14 Nov 2016 12:26:13 +0000
treeherdermozilla-beta@f455459b2ae5 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssurkov
bugs1295603
milestone51.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1295603 - ignore mutation events if contained by shown or hidden container, r=surkov
accessible/base/EventTree.cpp
accessible/tests/mochitest/events/test_coalescence.html
--- a/accessible/base/EventTree.cpp
+++ b/accessible/base/EventTree.cpp
@@ -253,16 +253,34 @@ EventTree::FindOrInsert(Accessible* aCon
     while (parent) {
       // Reached a top, no match for a current event.
       if (parent == top) {
         break;
       }
 
       // We got a match.
       if (parent->Parent() == node->mContainer) {
+        // Reject the node if it's contained by a show/hide event target
+        uint32_t evCount = node->mDependentEvents.Length();
+        for (uint32_t idx = 0; idx < evCount; idx++) {
+          AccMutationEvent* ev = node->mDependentEvents[idx];
+          if (ev->GetAccessible() == parent) {
+#ifdef A11Y_LOG
+            if (logging::IsEnabledAll(logging::eEventTree |
+                                      logging::eVerbose)) {
+              logging::MsgBegin("EVENTS_TREE",
+                "Rejecting node since contained by show/hide target");
+              logging::AccessibleInfo("Container", aContainer);
+              logging::MsgEnd();
+            }
+#endif
+            return nullptr;
+          }
+        }
+
         return node->FindOrInsert(aContainer);
       }
 
       parent = parent->Parent();
       MOZ_ASSERT(parent, "Wrong tree");
     }
 
     // If the given container contains a current node
--- a/accessible/tests/mochitest/events/test_coalescence.html
+++ b/accessible/tests/mochitest/events/test_coalescence.html
@@ -441,16 +441,57 @@
         testIsDefunct(this.b);
       }
 
       this.getID = function test5_getID() {
         return "remove a child, remove a parent sibling, remove the parent";
       }
     }
 
+    /**
+     * Insert accessibles with a child node moved by aria-owns
+     * Markup:
+     * <div id="t6_fc">
+     *   <div id="t6_owns"></div>
+     * </div>
+     * <div id="t6_sc" aria-owns="t6_owns"></div>
+     */
+    function test6()
+    {
+      this.parent = getNode("t6");
+      this.fc = document.createElement("div");
+      this.fc.setAttribute("id", "t6_fc");
+      this.owns = document.createElement("div");
+      this.owns.setAttribute("id", "t6_owns");
+      this.sc = document.createElement("div");
+      this.sc.setAttribute("id", "t6_sc");
+
+      this.eventSeq = [
+        new invokerChecker(EVENT_SHOW, this.fc),
+        new invokerChecker(EVENT_SHOW, this.sc),
+        new invokerChecker(EVENT_REORDER, this.parent),
+        new unexpectedInvokerChecker(EVENT_REORDER, this.fc),
+        new unexpectedInvokerChecker(EVENT_REORDER, this.sc),
+        new unexpectedInvokerChecker(EVENT_HIDE, this.owns),
+        new unexpectedInvokerChecker(EVENT_SHOW, this.owns)
+      ];
+
+      this.invoke = function test6_invoke()
+      {
+        getNode("t6").appendChild(this.fc);
+        getNode("t6_fc").appendChild(this.owns);
+        getNode("t6").appendChild(this.sc);
+        getNode("t6_sc").setAttribute("aria-owns", "t6_owns");
+      };
+
+      this.getID = function test6_getID() {
+        return "Insert accessibles with a child node moved by aria-owns";
+      };
+    }
+
     ////////////////////////////////////////////////////////////////////////////
     // Do tests.
 
     //gA11yEventDumpToConsole = true; // debug stuff
     //enableLogging("tree,eventTree,verbose");
 
     var gQueue = null;
     function doTests()
@@ -472,16 +513,17 @@
       gQueue.push(new showParentNChild("select10", "option10", true));
       gQueue.push(new showParentNAddChild("select11", false));
       gQueue.push(new showParentNAddChild("select12", true));
 
       gQueue.push(new removeGrandChildrenNHideParent("t1_child1", "t1_child2", "t1_parent"));
       gQueue.push(new test3());
       gQueue.push(new test4());
       gQueue.push(new test5());
+      gQueue.push(new test6());
 
       gQueue.invoke(); // Will call SimpleTest.finish();
     }
 
     SimpleTest.waitForExplicitFinish();
     addA11yLoadEvent(doTests);
   </script>
 </head>
@@ -562,10 +604,13 @@
   </div>
 
   <div id="t5">
     <div role="button" id="t5_b">btn</div>
     <div role="listbox" id="t5_lb">
       <div role="option" id="t5_o">opt</div>
     </div>
   </div>
+
+  <div id="t6">
+  </div>
 </body>
 </html>