From cd55795e9ff3182477d993bf7376d7cbc3812569 Mon Sep 17 00:00:00 2001 From: Andrea Marchesini Date: Fri, 2 Sep 2016 06:59:42 -0700 Subject: [PATCH] Bug 1299956 - Better use of kungFuDeathGrip in EventListenerManager, r=smaug --- dom/events/EventListenerManager.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/dom/events/EventListenerManager.cpp b/dom/events/EventListenerManager.cpp index a7af43a59e45..11380ef879ee 100644 --- a/dom/events/EventListenerManager.cpp +++ b/dom/events/EventListenerManager.cpp @@ -655,6 +655,8 @@ EventListenerManager::RemoveEventListenerInternal( uint32_t typeCount = 0; bool deviceType = IsDeviceType(aEventMessage); + RefPtr kungFuDeathGrip(this); + for (uint32_t i = 0; i < count; ++i) { listener = &mListeners.ElementAt(i); if (EVENT_TYPE_EQUALS(listener, aEventMessage, aUserType, aTypeString, @@ -662,7 +664,6 @@ EventListenerManager::RemoveEventListenerInternal( ++typeCount; if (listener->mListener == aListenerHolder && listener->mFlags.EqualsForRemoval(aFlags)) { - RefPtr kungFuDeathGrip(this); mListeners.RemoveElementAt(i); --count; NotifyEventListenerRemoved(aUserType);