Bug 1299956 - Better use of kungFuDeathGrip in EventListenerManager, r=smaug
authorAndrea Marchesini <amarchesini@mozilla.com>
Fri, 02 Sep 2016 06:59:42 -0700
changeset 312438 2ec87b37b16d0c4f8a966b8fe69c5042488d17d8
parent 312437 8f63dddb267503a9b751f833ac37f5efc974949e
child 312439 bdf79acb0726bf6e46453d3c94ad1df63a53b3ee
push id20447
push userkwierso@gmail.com
push dateFri, 02 Sep 2016 20:36:44 +0000
treeherderfx-team@969397f22187 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssmaug
bugs1299956
milestone51.0a1
Bug 1299956 - Better use of kungFuDeathGrip in EventListenerManager, r=smaug
dom/events/EventListenerManager.cpp
--- a/dom/events/EventListenerManager.cpp
+++ b/dom/events/EventListenerManager.cpp
@@ -650,24 +650,25 @@ EventListenerManager::RemoveEventListene
   }
 
   Listener* listener;
 
   uint32_t count = mListeners.Length();
   uint32_t typeCount = 0;
   bool deviceType = IsDeviceType(aEventMessage);
 
+  RefPtr<EventListenerManager> kungFuDeathGrip(this);
+
   for (uint32_t i = 0; i < count; ++i) {
     listener = &mListeners.ElementAt(i);
     if (EVENT_TYPE_EQUALS(listener, aEventMessage, aUserType, aTypeString,
                           aAllEvents)) {
       ++typeCount;
       if (listener->mListener == aListenerHolder &&
           listener->mFlags.EqualsForRemoval(aFlags)) {
-        RefPtr<EventListenerManager> kungFuDeathGrip(this);
         mListeners.RemoveElementAt(i);
         --count;
         NotifyEventListenerRemoved(aUserType);
         if (!deviceType) {
           return;
         }
         --typeCount;
       }