Bug 1961832: When queuing an event, don't append it to the array at all if it is a duplicate and duplicates aren't allowed. r=eeejay
Differential Revision: https://phabricator.services.mozilla.com/D246400
This commit is contained in:
@@ -38,6 +38,26 @@ bool EventQueue::PushEvent(AccEvent* aEvent) {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (aEvent->mEventRule == AccEvent::eRemoveDupes && !mEvents.IsEmpty()) {
|
||||||
|
// Check for duplicate events. If aEvent is identical to an older event, do
|
||||||
|
// not append aEvent. We do this here rather than in CoalesceEvents because
|
||||||
|
// CoalesceEvents never *removes* events; it only sets them to eDoNotEmit.
|
||||||
|
// If there are many duplicate events and we appended them, this would
|
||||||
|
// result in a massive event queue and coalescing would become increasingly
|
||||||
|
// slow with each event queued. Doing it here, we avoid appending a
|
||||||
|
// duplicate event in the first place.
|
||||||
|
uint32_t last = mEvents.Length() - 1;
|
||||||
|
for (uint32_t index = last; index <= last; --index) {
|
||||||
|
AccEvent* checkEvent = mEvents[index];
|
||||||
|
if (checkEvent->mEventType == aEvent->mEventType &&
|
||||||
|
checkEvent->mEventRule == aEvent->mEventRule &&
|
||||||
|
checkEvent->mAccessible == aEvent->mAccessible) {
|
||||||
|
aEvent->mEventRule = AccEvent::eDoNotEmit;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// XXX(Bug 1631371) Check if this should use a fallible operation as it
|
// XXX(Bug 1631371) Check if this should use a fallible operation as it
|
||||||
// pretended earlier, or change the return type to void.
|
// pretended earlier, or change the return type to void.
|
||||||
mEvents.AppendElement(aEvent);
|
mEvents.AppendElement(aEvent);
|
||||||
@@ -45,10 +65,10 @@ bool EventQueue::PushEvent(AccEvent* aEvent) {
|
|||||||
// Filter events.
|
// Filter events.
|
||||||
CoalesceEvents();
|
CoalesceEvents();
|
||||||
|
|
||||||
if (aEvent->mEventRule != AccEvent::eDoNotEmit &&
|
if (aEvent->mEventType == nsIAccessibleEvent::EVENT_NAME_CHANGE ||
|
||||||
(aEvent->mEventType == nsIAccessibleEvent::EVENT_NAME_CHANGE ||
|
aEvent->mEventType == nsIAccessibleEvent::EVENT_TEXT_REMOVED ||
|
||||||
aEvent->mEventType == nsIAccessibleEvent::EVENT_TEXT_REMOVED ||
|
aEvent->mEventType == nsIAccessibleEvent::EVENT_TEXT_INSERTED) {
|
||||||
aEvent->mEventType == nsIAccessibleEvent::EVENT_TEXT_INSERTED)) {
|
MOZ_ASSERT(aEvent->mEventRule != AccEvent::eDoNotEmit);
|
||||||
PushNameOrDescriptionChange(aEvent);
|
PushNameOrDescriptionChange(aEvent);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
@@ -258,23 +278,9 @@ void EventQueue::CoalesceEvents() {
|
|||||||
break; // eCoalesceTextSelChange
|
break; // eCoalesceTextSelChange
|
||||||
}
|
}
|
||||||
|
|
||||||
case AccEvent::eRemoveDupes: {
|
|
||||||
// Check for repeat events, coalesce newly appended event by more older
|
|
||||||
// event.
|
|
||||||
for (uint32_t index = tail - 1; index < tail; index--) {
|
|
||||||
AccEvent* accEvent = mEvents[index];
|
|
||||||
if (accEvent->mEventType == tailEvent->mEventType &&
|
|
||||||
accEvent->mEventRule == tailEvent->mEventRule &&
|
|
||||||
accEvent->mAccessible == tailEvent->mAccessible) {
|
|
||||||
tailEvent->mEventRule = AccEvent::eDoNotEmit;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break; // case eRemoveDupes
|
|
||||||
}
|
|
||||||
|
|
||||||
default:
|
default:
|
||||||
break; // case eAllowDupes, eDoNotEmit
|
// eRemoveDupes is handled in PushEvent.
|
||||||
|
break; // case eRemoveDupes, eAllowDupes, eDoNotEmit
|
||||||
} // switch
|
} // switch
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user