Bug 981261 part.6 Sort out variable names of EventListenerManager::Listener, EventListenerHolder, nsIJSEventListener and nsIDOMEventListener in EventListenerManager.cpp r=smaug
authorMasayuki Nakano <masayuki@d-toybox.com>
Mon, 17 Mar 2014 15:56:53 +0900
changeset 192082 f3f677c84bf2b44c441fa9bfaf16dbcc6a0eec8c
parent 192081 84f11c295ae334c5b3c070abf6a568a7a3ba9c09
child 192083 db2c6e0b798efe86895743f5e476bea406e1036a
push id474
push userasasaki@mozilla.com
push dateMon, 02 Jun 2014 21:01:02 +0000
treeherdermozilla-release@967f4cf1b31c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssmaug
bugs981261
milestone30.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 981261 part.6 Sort out variable names of EventListenerManager::Listener, EventListenerHolder, nsIJSEventListener and nsIDOMEventListener in EventListenerManager.cpp r=smaug
dom/events/EventListenerManager.cpp
--- a/dom/events/EventListenerManager.cpp
+++ b/dom/events/EventListenerManager.cpp
@@ -201,73 +201,73 @@ EventListenerManager::GetTargetAsInnerWi
   }
 
   NS_ASSERTION(window->IsInnerWindow(), "Target should not be an outer window");
   return window.forget();
 }
 
 void
 EventListenerManager::AddEventListenerInternal(
-                        const EventListenerHolder& aListener,
+                        const EventListenerHolder& aListenerHolder,
                         uint32_t aType,
                         nsIAtom* aTypeAtom,
                         const nsAString& aTypeString,
                         const EventListenerFlags& aFlags,
                         bool aHandler,
                         bool aAllEvents)
 {
   MOZ_ASSERT((NS_IsMainThread() && aType && aTypeAtom) || // Main thread
              (!NS_IsMainThread() && aType && !aTypeString.IsEmpty()) || // non-main-thread
              aAllEvents, "Missing type"); // all-events listener
 
-  if (!aListener || mClearingListeners) {
+  if (!aListenerHolder || mClearingListeners) {
     return;
   }
 
   // Since there is no public API to call us with an EventListenerHolder, we
   // know that there's an EventListenerHolder on the stack holding a strong ref
   // to the listener.
 
   Listener* listener;
   uint32_t count = mListeners.Length();
   for (uint32_t i = 0; i < count; i++) {
     listener = &mListeners.ElementAt(i);
-    // mListener == aListener is the last one, since it can be a bit slow.
+    // mListener == aListenerHolder is the last one, since it can be a bit slow.
     if (listener->mListenerIsHandler == aHandler &&
         listener->mFlags == aFlags &&
         EVENT_TYPE_EQUALS(listener, aType, aTypeAtom, aTypeString,
                           aAllEvents) &&
-        listener->mListener == aListener) {
+        listener->mListener == aListenerHolder) {
       return;
     }
   }
 
   mNoListenerForEvent = NS_EVENT_NULL;
   mNoListenerForEventAtom = nullptr;
 
   listener = aAllEvents ? mListeners.InsertElementAt(0) :
                           mListeners.AppendElement();
-  listener->mListener = aListener;
+  listener->mListener = aListenerHolder;
   MOZ_ASSERT(aType < PR_UINT16_MAX);
   listener->mEventType = aType;
   listener->mTypeString = aTypeString;
   listener->mTypeAtom = aTypeAtom;
   listener->mFlags = aFlags;
   listener->mListenerIsHandler = aHandler;
   listener->mHandlerIsString = false;
   listener->mAllEvents = aAllEvents;
 
   // Detect the type of event listener.
   nsCOMPtr<nsIXPConnectWrappedJS> wjs;
   if (aFlags.mListenerIsJSListener) {
-    MOZ_ASSERT(!aListener.HasWebIDLCallback());
+    MOZ_ASSERT(!aListenerHolder.HasWebIDLCallback());
     listener->mListenerType = Listener::eJSEventListener;
-  } else if (aListener.HasWebIDLCallback()) {
+  } else if (aListenerHolder.HasWebIDLCallback()) {
     listener->mListenerType = Listener::eWebIDLListener;
-  } else if ((wjs = do_QueryInterface(aListener.GetXPCOMCallback()))) {
+  } else if ((wjs = do_QueryInterface(aListenerHolder.GetXPCOMCallback()))) {
     listener->mListenerType = Listener::eWrappedJSListener;
   } else {
     listener->mListenerType = Listener::eNativeListener;
   }
 
 
   if (aFlags.mInSystemGroup) {
     mMayHaveSystemGroupListeners = true;
@@ -458,24 +458,24 @@ EventListenerManager::DisableDevice(uint
     default:
       NS_WARNING("Disabling an unknown device sensor.");
       break;
   }
 }
 
 void
 EventListenerManager::RemoveEventListenerInternal(
-                        const EventListenerHolder& aListener,
+                        const EventListenerHolder& aListenerHolder,
                         uint32_t aType,
                         nsIAtom* aUserType,
                         const nsAString& aTypeString,
                         const EventListenerFlags& aFlags,
                         bool aAllEvents)
 {
-  if (!aListener || !aType || mClearingListeners) {
+  if (!aListenerHolder || !aType || mClearingListeners) {
     return;
   }
 
   Listener* listener;
 
   uint32_t count = mListeners.Length();
   uint32_t typeCount = 0;
   bool deviceType = IsDeviceType(aType);
@@ -485,17 +485,17 @@ EventListenerManager::RemoveEventListene
                        aType == NS_NETWORK_DOWNLOAD_EVENT);
 #endif // MOZ_B2G
 
   for (uint32_t i = 0; i < count; ++i) {
     listener = &mListeners.ElementAt(i);
     if (EVENT_TYPE_EQUALS(listener, aType, aUserType, aTypeString,
                           aAllEvents)) {
       ++typeCount;
-      if (listener->mListener == aListener &&
+      if (listener->mListener == aListenerHolder &&
           listener->mFlags.EqualsIgnoringTrustness(aFlags)) {
         nsRefPtr<EventListenerManager> kungFuDeathGrip(this);
         mListeners.RemoveElementAt(i);
         --count;
         mNoListenerForEvent = NS_EVENT_NULL;
         mNoListenerForEventAtom = nullptr;
         if (mTarget && aUserType) {
           mTarget->EventListenerRemoved(aUserType);
@@ -548,36 +548,36 @@ EventListenerManager::ListenerCanHandle(
     return aListener->mTypeString.Equals(aEvent->typeString);
   }
   MOZ_ASSERT(mIsMainThreadELM);
   return aListener->mEventType == aEvent->message;
 }
 
 void
 EventListenerManager::AddEventListenerByType(
-                        const EventListenerHolder& aListener,
+                        const EventListenerHolder& aListenerHolder,
                         const nsAString& aType,
                         const EventListenerFlags& aFlags)
 {
   nsCOMPtr<nsIAtom> atom =
     mIsMainThreadELM ? do_GetAtom(NS_LITERAL_STRING("on") + aType) : nullptr;
   uint32_t type = nsContentUtils::GetEventId(atom);
-  AddEventListenerInternal(aListener, type, atom, aType, aFlags);
+  AddEventListenerInternal(aListenerHolder, type, atom, aType, aFlags);
 }
 
 void
 EventListenerManager::RemoveEventListenerByType(
-                        const EventListenerHolder& aListener,
+                        const EventListenerHolder& aListenerHolder,
                         const nsAString& aType,
                         const EventListenerFlags& aFlags)
 {
   nsCOMPtr<nsIAtom> atom =
     mIsMainThreadELM ? do_GetAtom(NS_LITERAL_STRING("on") + aType) : nullptr;
   uint32_t type = nsContentUtils::GetEventId(atom);
-  RemoveEventListenerInternal(aListener, type, atom, aType, aFlags);
+  RemoveEventListenerInternal(aListenerHolder, type, atom, aType, aFlags);
 }
 
 EventListenerManager::Listener*
 EventListenerManager::FindEventHandler(uint32_t aEventType,
                                        nsIAtom* aTypeAtom,
                                        const nsAString& aTypeString)
 {
   // Run through the listeners for this type and see if a script
@@ -611,32 +611,32 @@ EventListenerManager::SetEventHandlerInt
   Listener* listener = FindEventHandler(eventType, aName, aTypeString);
 
   if (!listener) {
     // If we didn't find a script listener or no listeners existed
     // create and add a new one.
     EventListenerFlags flags;
     flags.mListenerIsJSListener = true;
 
-    nsCOMPtr<nsIJSEventListener> scriptListener;
+    nsCOMPtr<nsIJSEventListener> jsListener;
     NS_NewJSEventListener(aScopeObject, mTarget, aName,
-                          aHandler, getter_AddRefs(scriptListener));
-    EventListenerHolder holder(scriptListener);
-    AddEventListenerInternal(holder, eventType, aName, aTypeString, flags,
-                             true);
+                          aHandler, getter_AddRefs(jsListener));
+    EventListenerHolder listenerHolder(jsListener);
+    AddEventListenerInternal(listenerHolder, eventType, aName, aTypeString,
+                             flags, true);
 
     listener = FindEventHandler(eventType, aName, aTypeString);
   } else {
-    nsIJSEventListener* scriptListener = listener->GetJSListener();
-    MOZ_ASSERT(scriptListener,
+    nsIJSEventListener* jsListener = listener->GetJSListener();
+    MOZ_ASSERT(jsListener,
                "How can we have an event handler with no nsIJSEventListener?");
 
-    bool same = scriptListener->GetHandler() == aHandler;
+    bool same = jsListener->GetHandler() == aHandler;
     // Possibly the same listener, but update still the context and scope.
-    scriptListener->SetHandler(aHandler, aScopeObject);
+    jsListener->SetHandler(aHandler, aScopeObject);
     if (mTarget && !same && aName) {
       mTarget->EventListenerRemoved(aName);
       mTarget->EventListenerAdded(aName);
     }
   }
 
   // Set flag to indicate possible need for compilation later
   listener->mHandlerIsString = !aHandler.HasEventHandler();
@@ -1054,63 +1054,66 @@ EventListenerManager::HandleEventInterna
 void
 EventListenerManager::Disconnect()
 {
   mTarget = nullptr;
   RemoveAllListeners();
 }
 
 void
-EventListenerManager::AddEventListener(const nsAString& aType,
-                                       const EventListenerHolder& aListener,
-                                       bool aUseCapture,
-                                       bool aWantsUntrusted)
+EventListenerManager::AddEventListener(
+                        const nsAString& aType,
+                        const EventListenerHolder& aListenerHolder,
+                        bool aUseCapture,
+                        bool aWantsUntrusted)
 {
   EventListenerFlags flags;
   flags.mCapture = aUseCapture;
   flags.mAllowUntrustedEvents = aWantsUntrusted;
-  return AddEventListenerByType(aListener, aType, flags);
+  return AddEventListenerByType(aListenerHolder, aType, flags);
 }
 
 void
-EventListenerManager::RemoveEventListener(const nsAString& aType,
-                                          const EventListenerHolder& aListener,
-                                          bool aUseCapture)
+EventListenerManager::RemoveEventListener(
+                        const nsAString& aType,
+                        const EventListenerHolder& aListenerHolder,
+                        bool aUseCapture)
 {
   EventListenerFlags flags;
   flags.mCapture = aUseCapture;
-  RemoveEventListenerByType(aListener, aType, flags);
+  RemoveEventListenerByType(aListenerHolder, aType, flags);
 }
 
 void
-EventListenerManager::AddListenerForAllEvents(nsIDOMEventListener* aListener,
+EventListenerManager::AddListenerForAllEvents(nsIDOMEventListener* aDOMListener,
                                               bool aUseCapture,
                                               bool aWantsUntrusted,
                                               bool aSystemEventGroup)
 {
   EventListenerFlags flags;
   flags.mCapture = aUseCapture;
   flags.mAllowUntrustedEvents = aWantsUntrusted;
   flags.mInSystemGroup = aSystemEventGroup;
-  EventListenerHolder holder(aListener);
-  AddEventListenerInternal(holder, NS_EVENT_ALL, nullptr, EmptyString(),
+  EventListenerHolder listenerHolder(aDOMListener);
+  AddEventListenerInternal(listenerHolder, NS_EVENT_ALL, nullptr, EmptyString(),
                            flags, false, true);
 }
 
 void
-EventListenerManager::RemoveListenerForAllEvents(nsIDOMEventListener* aListener,
-                                                 bool aUseCapture,
-                                                 bool aSystemEventGroup)
+EventListenerManager::RemoveListenerForAllEvents(
+                        nsIDOMEventListener* aDOMListener,
+                        bool aUseCapture,
+                        bool aSystemEventGroup)
 {
   EventListenerFlags flags;
   flags.mCapture = aUseCapture;
   flags.mInSystemGroup = aSystemEventGroup;
-  EventListenerHolder holder(aListener);
-  RemoveEventListenerInternal(holder, NS_EVENT_ALL, nullptr, EmptyString(),
-                              flags, true);
+  EventListenerHolder listenerHolder(aDOMListener);
+  RemoveEventListenerInternal(listenerHolder, NS_EVENT_ALL, nullptr,
+                              EmptyString(), flags, true);
 }
 
 bool
 EventListenerManager::HasMutationListeners()
 {
   if (mMayHaveMutationListeners) {
     uint32_t count = mListeners.Length();
     for (uint32_t i = 0; i < count; ++i) {
@@ -1328,22 +1331,22 @@ EventListenerManager::SizeOfIncludingThi
 }
 
 void
 EventListenerManager::MarkForCC()
 {
   uint32_t count = mListeners.Length();
   for (uint32_t i = 0; i < count; ++i) {
     const Listener& listener = mListeners.ElementAt(i);
-    nsIJSEventListener* jsl = listener.GetJSListener();
-    if (jsl) {
-      if (jsl->GetHandler().HasEventHandler()) {
-        JS::ExposeObjectToActiveJS(jsl->GetHandler().Ptr()->Callable());
+    nsIJSEventListener* jsListener = listener.GetJSListener();
+    if (jsListener) {
+      if (jsListener->GetHandler().HasEventHandler()) {
+        JS::ExposeObjectToActiveJS(jsListener->GetHandler().Ptr()->Callable());
       }
-      if (JSObject* scope = jsl->GetEventScope()) {
+      if (JSObject* scope = jsListener->GetEventScope()) {
         JS::ExposeObjectToActiveJS(scope);
       }
     } else if (listener.mListenerType == Listener::eWrappedJSListener) {
       xpc_TryUnmarkWrappedGrayObject(listener.mListener.GetXPCOMCallback());
     } else if (listener.mListenerType == Listener::eWebIDLListener) {
       // Callback() unmarks gray
       listener.mListener.GetWebIDLCallback()->Callback();
     }