Bug 1293443: Coalesce show/hide pairs for the same child node
MozReview-Commit-ID: Frqtx5tHPfo
--- 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.