Bug 743198 part 5 - Check legacy event listener only if listener is found in the current group. r=smaug

--HG--
extra : source : b141db892428ebcbc2dbf213aea759aa88f6e8bf
This commit is contained in:
Xidorn Quan 2016-02-17 08:47:11 +08:00
parent 52ccd4a553
commit 8bc3b5685b

View File

@ -1192,6 +1192,7 @@ EventListenerManager::HandleEventInternal(nsPresContext* aPresContext,
}
bool hasListener = false;
bool hasListenerForCurrentGroup = false;
bool usingLegacyMessage = false;
EventMessage eventMessage = aEvent->mMessage;
@ -1207,6 +1208,8 @@ EventListenerManager::HandleEventInternal(nsPresContext* aPresContext,
// Handle only trusted events, except when listener permits untrusted events.
if (ListenerCanHandle(listener, aEvent, eventMessage)) {
hasListener = true;
hasListenerForCurrentGroup = hasListenerForCurrentGroup ||
listener->mFlags.mInSystemGroup == aEvent->mFlags.mInSystemGroup;
if (listener->IsListening(aEvent) &&
(aEvent->mFlags.mIsTrusted ||
listener->mFlags.mAllowUntrustedEvents)) {
@ -1271,7 +1274,7 @@ EventListenerManager::HandleEventInternal(nsPresContext* aPresContext,
// If we didn't find any matching listeners, and our event has a legacy
// version, we'll now switch to looking for that legacy version and we'll
// recheck our listeners.
if (hasListener || usingLegacyMessage) {
if (hasListenerForCurrentGroup || usingLegacyMessage) {
// (No need to recheck listeners, because we already found a match, or we
// already rechecked them.)
break;