Bug 1293443: Coalesce show/hide pairs for the same child node draft
authorMichael Li <michael.li11702@gmail.com>
Mon, 08 Aug 2016 17:54:20 -0400
changeset 398206 76834ec5e28ce580966efca4fb42f8b31c54b51e
parent 398181 59ab92c9ef452811786eba024dc25cdba77eaab4
child 527619 e4adcb6f59304a258e6645c5deb93f3b153687da
push id25483
push userbmo:mili@mozilla.com
push dateMon, 08 Aug 2016 21:54:46 +0000
bugs1293443
milestone51.0a1
Bug 1293443: Coalesce show/hide pairs for the same child node MozReview-Commit-ID: Frqtx5tHPfo
accessible/base/EventTree.cpp
--- a/accessible/base/EventTree.cpp
+++ b/accessible/base/EventTree.cpp
@@ -432,16 +432,35 @@ EventTree::Mutated(AccMutationEvent* aEv
   while (*node) {
     if ((*node)->mContainer == aEv->mAccessible) {
       *node = Move((*node)->mNext);
       break;
     }
     node = &(*node)->mNext;
   }
 
+  // If we're adding a hide event, see if there's a corresponding show event for
+  // the same target, and if so, remove the show event and don't add a hide
+  // event.
+  if (aEv->IsHide()) {
+    uint32_t length = mDependentEvents.Length();
+    for (uint32_t idx = 0; idx < length; idx++) {
+      AccMutationEvent* ev = mDependentEvents[idx];
+      if (ev->GetAccessible() == aEv->GetAccessible() && ev->IsShow()) {
+#ifdef A11Y_LOG
+        logging::MsgBegin("EVENTS_TREE", "coalescing show/hide pair");
+        logging::AccessibleInfo("removing show/hide pair for", ev->GetAccessible());
+        logging::MsgEnd();
+#endif
+        mDependentEvents.RemoveElementAt(idx);
+        return;
+      }
+    }
+  }
+
   AccMutationEvent* prevEvent = mDependentEvents.SafeLastElement(nullptr);
   mDependentEvents.AppendElement(aEv);
 
   // Coalesce text change events from this hide/show event and the previous one.
   if (prevEvent && aEv->mEventType == prevEvent->mEventType) {
     if (aEv->IsHide()) {
       // XXX: we need a way to ignore SplitNode and JoinNode() when they do not
       // affect the text within the hypertext.