Bug 981261 part.1 Rename nsEventListener(Service|Info) to mozilla::EventListener(Service|Info) r=smaug
authorMasayuki Nakano <masayuki@d-toybox.com>
Mon, 17 Mar 2014 15:56:50 +0900
changeset 192077 b604111dc9d686f1bb2033a30523e9b8843dda28
parent 192076 0accce5c96a567094af21d8b3597e12af2e3ad06
child 192078 95a8536c310a983b1e35fb10660d5ec1b13a3975
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.1 Rename nsEventListener(Service|Info) to mozilla::EventListener(Service|Info) r=smaug
dom/events/EventListenerService.cpp
dom/events/EventListenerService.h
dom/events/moz.build
dom/events/nsEventListenerManager.cpp
dom/events/nsEventListenerService.cpp
dom/events/nsEventListenerService.h
rename from dom/events/nsEventListenerService.cpp
rename to dom/events/EventListenerService.cpp
--- a/dom/events/nsEventListenerService.cpp
+++ b/dom/events/EventListenerService.cpp
@@ -1,89 +1,98 @@
 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-#include "nsEventListenerService.h"
-#include "nsCOMArray.h"
-#include "nsEventListenerManager.h"
-#include "nsMemory.h"
-#include "nsCxPusher.h"
-#include "nsIXPConnect.h"
-#include "nsJSUtils.h"
-#include "nsEventDispatcher.h"
-#include "nsIJSEventListener.h"
+
+#include "EventListenerService.h"
 #ifdef MOZ_JSDEBUGGER
 #include "jsdIDebuggerService.h"
 #endif
-#include "nsDOMClassInfoID.h"
 #include "mozilla/BasicEvents.h"
 #include "mozilla/Maybe.h"
+#include "nsCOMArray.h"
+#include "nsCxPusher.h"
+#include "nsDOMClassInfoID.h"
+#include "nsEventDispatcher.h"
+#include "nsEventListenerManager.h"
+#include "nsIJSEventListener.h"
+#include "nsIXPConnect.h"
+#include "nsJSUtils.h"
+#include "nsMemory.h"
 #include "nsServiceManagerUtils.h"
 
-using namespace mozilla;
-using namespace mozilla::dom;
-using mozilla::AutoSafeJSContext;
+DOMCI_DATA(EventListenerInfo, mozilla::EventListenerInfo)
+
+namespace mozilla {
+
+using namespace dom;
 
-NS_IMPL_CYCLE_COLLECTION_1(nsEventListenerInfo, mListener)
+/******************************************************************************
+ * mozilla::EventListenerInfo
+ ******************************************************************************/
 
-DOMCI_DATA(EventListenerInfo, nsEventListenerInfo)
+NS_IMPL_CYCLE_COLLECTION_1(EventListenerInfo, mListener)
 
-NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(nsEventListenerInfo)
+NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(EventListenerInfo)
   NS_INTERFACE_MAP_ENTRY(nsIEventListenerInfo)
   NS_INTERFACE_MAP_ENTRY(nsISupports)
   NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(EventListenerInfo)
 NS_INTERFACE_MAP_END
 
-NS_IMPL_CYCLE_COLLECTING_ADDREF(nsEventListenerInfo)
-NS_IMPL_CYCLE_COLLECTING_RELEASE(nsEventListenerInfo)
+NS_IMPL_CYCLE_COLLECTING_ADDREF(EventListenerInfo)
+NS_IMPL_CYCLE_COLLECTING_RELEASE(EventListenerInfo)
 
 NS_IMETHODIMP
-nsEventListenerInfo::GetType(nsAString& aType)
+EventListenerInfo::GetType(nsAString& aType)
 {
   aType = mType;
   return NS_OK;
 }
 
 NS_IMETHODIMP
-nsEventListenerInfo::GetCapturing(bool* aCapturing)
+EventListenerInfo::GetCapturing(bool* aCapturing)
 {
   *aCapturing = mCapturing;
   return NS_OK;
 }
 
 NS_IMETHODIMP
-nsEventListenerInfo::GetAllowsUntrusted(bool* aAllowsUntrusted)
+EventListenerInfo::GetAllowsUntrusted(bool* aAllowsUntrusted)
 {
   *aAllowsUntrusted = mAllowsUntrusted;
   return NS_OK;
 }
 
 NS_IMETHODIMP
-nsEventListenerInfo::GetInSystemEventGroup(bool* aInSystemEventGroup)
+EventListenerInfo::GetInSystemEventGroup(bool* aInSystemEventGroup)
 {
   *aInSystemEventGroup = mInSystemEventGroup;
   return NS_OK;
 }
 
 NS_IMETHODIMP
-nsEventListenerInfo::GetListenerObject(JSContext* aCx,
-                                       JS::MutableHandle<JS::Value> aObject)
+EventListenerInfo::GetListenerObject(JSContext* aCx,
+                                     JS::MutableHandle<JS::Value> aObject)
 {
-  mozilla::Maybe<JSAutoCompartment> ac;
+  Maybe<JSAutoCompartment> ac;
   GetJSVal(aCx, ac, aObject);
   return NS_OK;
 }
 
-NS_IMPL_ISUPPORTS1(nsEventListenerService, nsIEventListenerService)
+/******************************************************************************
+ * mozilla::EventListenerService
+ ******************************************************************************/
+
+NS_IMPL_ISUPPORTS1(EventListenerService, nsIEventListenerService)
 
 bool
-nsEventListenerInfo::GetJSVal(JSContext* aCx,
-                              mozilla::Maybe<JSAutoCompartment>& aAc,
-                              JS::MutableHandle<JS::Value> aJSVal)
+EventListenerInfo::GetJSVal(JSContext* aCx,
+                            Maybe<JSAutoCompartment>& aAc,
+                            JS::MutableHandle<JS::Value> aJSVal)
 {
   aJSVal.setNull();
   nsCOMPtr<nsIXPConnectWrappedJS> wrappedJS = do_QueryInterface(mListener);
   if (wrappedJS) {
     JS::Rooted<JSObject*> object(aCx, wrappedJS->GetJSObject());
     if (!object) {
       return false;
     }
@@ -100,68 +109,68 @@ nsEventListenerInfo::GetJSVal(JSContext*
       aJSVal.setObject(*handler);
       return true;
     }
   }
   return false;
 }
 
 NS_IMETHODIMP
-nsEventListenerInfo::ToSource(nsAString& aResult)
+EventListenerInfo::ToSource(nsAString& aResult)
 {
   aResult.SetIsVoid(true);
 
   AutoSafeJSContext cx;
-  mozilla::Maybe<JSAutoCompartment> ac;
+  Maybe<JSAutoCompartment> ac;
   JS::Rooted<JS::Value> v(cx);
   if (GetJSVal(cx, ac, &v)) {
     JSString* str = JS_ValueToSource(cx, v);
     if (str) {
       nsDependentJSString depStr;
       if (depStr.init(cx, str)) {
         aResult.Assign(depStr);
       }
     }
   }
   return NS_OK;
 }
 
 NS_IMETHODIMP
-nsEventListenerInfo::GetDebugObject(nsISupports** aRetVal)
+EventListenerInfo::GetDebugObject(nsISupports** aRetVal)
 {
   *aRetVal = nullptr;
 
 #ifdef MOZ_JSDEBUGGER
   nsresult rv = NS_OK;
   nsCOMPtr<jsdIDebuggerService> jsd =
     do_GetService("@mozilla.org/js/jsd/debugger-service;1", &rv);
   NS_ENSURE_SUCCESS(rv, NS_OK);
 
   bool isOn = false;
   jsd->GetIsOn(&isOn);
   NS_ENSURE_TRUE(isOn, NS_OK);
 
   AutoSafeJSContext cx;
-  mozilla::Maybe<JSAutoCompartment> ac;
+  Maybe<JSAutoCompartment> ac;
   JS::Rooted<JS::Value> v(cx);
   if (GetJSVal(cx, ac, &v)) {
     nsCOMPtr<jsdIValue> jsdValue;
     rv = jsd->WrapValue(v, getter_AddRefs(jsdValue));
     NS_ENSURE_SUCCESS(rv, rv);
     jsdValue.forget(aRetVal);
   }
 #endif
 
   return NS_OK;
 }
 
 NS_IMETHODIMP
-nsEventListenerService::GetListenerInfoFor(nsIDOMEventTarget* aEventTarget,
-                                           uint32_t* aCount,
-                                           nsIEventListenerInfo*** aOutArray)
+EventListenerService::GetListenerInfoFor(nsIDOMEventTarget* aEventTarget,
+                                         uint32_t* aCount,
+                                         nsIEventListenerInfo*** aOutArray)
 {
   NS_ENSURE_ARG_POINTER(aEventTarget);
   *aCount = 0;
   *aOutArray = nullptr;
   nsCOMArray<nsIEventListenerInfo> listenerInfos;
 
   nsCOMPtr<EventTarget> eventTarget = do_QueryInterface(aEventTarget);
   NS_ENSURE_TRUE(eventTarget, NS_ERROR_NO_INTERFACE);
@@ -184,19 +193,19 @@ nsEventListenerService::GetListenerInfoF
   for (int32_t i = 0; i < count; ++i) {
     NS_ADDREF((*aOutArray)[i] = listenerInfos[i]);
   }
   *aCount = count;
   return NS_OK;
 }
 
 NS_IMETHODIMP
-nsEventListenerService::GetEventTargetChainFor(nsIDOMEventTarget* aEventTarget,
-                                               uint32_t* aCount,
-                                               nsIDOMEventTarget*** aOutArray)
+EventListenerService::GetEventTargetChainFor(nsIDOMEventTarget* aEventTarget,
+                                             uint32_t* aCount,
+                                             nsIDOMEventTarget*** aOutArray)
 {
   *aCount = 0;
   *aOutArray = nullptr;
   NS_ENSURE_ARG(aEventTarget);
   WidgetEvent event(true, NS_EVENT_NULL);
   nsCOMArray<EventTarget> targets;
   nsresult rv = nsEventDispatcher::Dispatch(aEventTarget, nullptr, &event,
                                             nullptr, nullptr, nullptr, &targets);
@@ -215,33 +224,33 @@ nsEventListenerService::GetEventTargetCh
     NS_ADDREF((*aOutArray)[i] = targets[i]);
   }
   *aCount = count;
 
   return NS_OK;
 }
 
 NS_IMETHODIMP
-nsEventListenerService::HasListenersFor(nsIDOMEventTarget* aEventTarget,
-                                        const nsAString& aType,
-                                        bool* aRetVal)
+EventListenerService::HasListenersFor(nsIDOMEventTarget* aEventTarget,
+                                      const nsAString& aType,
+                                      bool* aRetVal)
 {
   nsCOMPtr<EventTarget> eventTarget = do_QueryInterface(aEventTarget);
   NS_ENSURE_TRUE(eventTarget, NS_ERROR_NO_INTERFACE);
 
   nsEventListenerManager* elm = eventTarget->GetExistingListenerManager();
   *aRetVal = elm && elm->HasListenersFor(aType);
   return NS_OK;
 }
 
 NS_IMETHODIMP
-nsEventListenerService::AddSystemEventListener(nsIDOMEventTarget *aTarget,
-                                               const nsAString& aType,
-                                               nsIDOMEventListener* aListener,
-                                               bool aUseCapture)
+EventListenerService::AddSystemEventListener(nsIDOMEventTarget *aTarget,
+                                             const nsAString& aType,
+                                             nsIDOMEventListener* aListener,
+                                             bool aUseCapture)
 {
   NS_PRECONDITION(aTarget, "Missing target");
   NS_PRECONDITION(aListener, "Missing listener");
 
   nsCOMPtr<EventTarget> eventTarget = do_QueryInterface(aTarget);
   NS_ENSURE_TRUE(eventTarget, NS_ERROR_NO_INTERFACE);
 
   nsEventListenerManager* manager = eventTarget->GetOrCreateListenerManager();
@@ -250,20 +259,20 @@ nsEventListenerService::AddSystemEventLi
   EventListenerFlags flags =
     aUseCapture ? TrustedEventsAtSystemGroupCapture() :
                   TrustedEventsAtSystemGroupBubble();
   manager->AddEventListenerByType(aListener, aType, flags);
   return NS_OK;
 }
 
 NS_IMETHODIMP
-nsEventListenerService::RemoveSystemEventListener(nsIDOMEventTarget *aTarget,
-                                                  const nsAString& aType,
-                                                  nsIDOMEventListener* aListener,
-                                                  bool aUseCapture)
+EventListenerService::RemoveSystemEventListener(nsIDOMEventTarget *aTarget,
+                                                const nsAString& aType,
+                                                nsIDOMEventListener* aListener,
+                                                bool aUseCapture)
 {
   NS_PRECONDITION(aTarget, "Missing target");
   NS_PRECONDITION(aListener, "Missing listener");
 
   nsCOMPtr<EventTarget> eventTarget = do_QueryInterface(aTarget);
   NS_ENSURE_TRUE(eventTarget, NS_ERROR_NO_INTERFACE);
 
   nsEventListenerManager* manager = eventTarget->GetExistingListenerManager();
@@ -273,51 +282,53 @@ nsEventListenerService::RemoveSystemEven
                     TrustedEventsAtSystemGroupBubble();
     manager->RemoveEventListenerByType(aListener, aType, flags);
   }
 
   return NS_OK;
 }
 
 NS_IMETHODIMP
-nsEventListenerService::AddListenerForAllEvents(nsIDOMEventTarget* aTarget,
-                                                nsIDOMEventListener* aListener,
-                                                bool aUseCapture,
-                                                bool aWantsUntrusted,
-                                                bool aSystemEventGroup)
+EventListenerService::AddListenerForAllEvents(nsIDOMEventTarget* aTarget,
+                                              nsIDOMEventListener* aListener,
+                                              bool aUseCapture,
+                                              bool aWantsUntrusted,
+                                              bool aSystemEventGroup)
 {
   NS_ENSURE_STATE(aTarget && aListener);
 
   nsCOMPtr<EventTarget> eventTarget = do_QueryInterface(aTarget);
   NS_ENSURE_TRUE(eventTarget, NS_ERROR_NO_INTERFACE);
 
   nsEventListenerManager* manager = eventTarget->GetOrCreateListenerManager();
   NS_ENSURE_STATE(manager);
   manager->AddListenerForAllEvents(aListener, aUseCapture, aWantsUntrusted,
                                aSystemEventGroup);
   return NS_OK;
 }
 
 NS_IMETHODIMP
-nsEventListenerService::RemoveListenerForAllEvents(nsIDOMEventTarget* aTarget,
-                                                   nsIDOMEventListener* aListener,
-                                                   bool aUseCapture,
-                                                   bool aSystemEventGroup)
+EventListenerService::RemoveListenerForAllEvents(nsIDOMEventTarget* aTarget,
+                                                 nsIDOMEventListener* aListener,
+                                                 bool aUseCapture,
+                                                 bool aSystemEventGroup)
 {
   NS_ENSURE_STATE(aTarget && aListener);
 
   nsCOMPtr<EventTarget> eventTarget = do_QueryInterface(aTarget);
   NS_ENSURE_TRUE(eventTarget, NS_ERROR_NO_INTERFACE);
 
   nsEventListenerManager* manager = eventTarget->GetExistingListenerManager();
   if (manager) {
     manager->RemoveListenerForAllEvents(aListener, aUseCapture, aSystemEventGroup);
   }
   return NS_OK;
 }
 
+} // namespace mozilla
+
 nsresult
 NS_NewEventListenerService(nsIEventListenerService** aResult)
 {
-  *aResult = new nsEventListenerService();
+  *aResult = new mozilla::EventListenerService();
   NS_ADDREF(*aResult);
   return NS_OK;
 }
rename from dom/events/nsEventListenerService.h
rename to dom/events/EventListenerService.h
--- a/dom/events/nsEventListenerService.h
+++ b/dom/events/EventListenerService.h
@@ -1,53 +1,66 @@
 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
-#ifndef nsEventListenerService_h__
-#define nsEventListenerService_h__
-#include "nsIEventListenerService.h"
-#include "nsAutoPtr.h"
-#include "nsIDOMEventListener.h"
-#include "nsString.h"
-#include "nsCycleCollectionParticipant.h"
+#ifndef mozilla_EventListenerService_h_
+#define mozilla_EventListenerService_h_
+
 #include "jsapi.h"
 #include "mozilla/Attributes.h"
+#include "nsAutoPtr.h"
+#include "nsCycleCollectionParticipant.h"
+#include "nsIDOMEventListener.h"
+#include "nsIEventListenerService.h"
+#include "nsString.h"
 
 namespace mozilla {
+
 template<typename T>
 class Maybe;
-} // namespace mozilla
 
-class nsEventListenerInfo : public nsIEventListenerInfo
+class EventListenerInfo MOZ_FINAL : public nsIEventListenerInfo
 {
 public:
-  nsEventListenerInfo(const nsAString& aType,
-                      already_AddRefed<nsIDOMEventListener> aListener,
-                      bool aCapturing, bool aAllowsUntrusted,
-                      bool aInSystemEventGroup)
-  : mType(aType), mListener(aListener), mCapturing(aCapturing),
-    mAllowsUntrusted(aAllowsUntrusted),
-    mInSystemEventGroup(aInSystemEventGroup) {}
-  virtual ~nsEventListenerInfo() {}
+  EventListenerInfo(const nsAString& aType,
+                    already_AddRefed<nsIDOMEventListener> aListener,
+                    bool aCapturing,
+                    bool aAllowsUntrusted,
+                    bool aInSystemEventGroup)
+    : mType(aType)
+    , mListener(aListener)
+    , mCapturing(aCapturing)
+    , mAllowsUntrusted(aAllowsUntrusted)
+    , mInSystemEventGroup(aInSystemEventGroup)
+  {
+  }
+
+  virtual ~EventListenerInfo() {}
+
   NS_DECL_CYCLE_COLLECTING_ISUPPORTS
-  NS_DECL_CYCLE_COLLECTION_CLASS(nsEventListenerInfo)
+  NS_DECL_CYCLE_COLLECTION_CLASS(EventListenerInfo)
   NS_DECL_NSIEVENTLISTENERINFO
+
 protected:
-  bool GetJSVal(JSContext* aCx, mozilla::Maybe<JSAutoCompartment>& aAc,
+  bool GetJSVal(JSContext* aCx,
+                Maybe<JSAutoCompartment>& aAc,
                 JS::MutableHandle<JS::Value> aJSVal);
 
-  nsString                      mType;
+  nsString mType;
   // nsReftPtr because that is what nsListenerStruct uses too.
   nsRefPtr<nsIDOMEventListener> mListener;
-  bool                          mCapturing;
-  bool                          mAllowsUntrusted;
-  bool                          mInSystemEventGroup;
+  bool mCapturing;
+  bool mAllowsUntrusted;
+  bool mInSystemEventGroup;
 };
 
-class nsEventListenerService MOZ_FINAL : public nsIEventListenerService
+class EventListenerService MOZ_FINAL : public nsIEventListenerService
 {
 public:
   NS_DECL_ISUPPORTS
   NS_DECL_NSIEVENTLISTENERSERVICE
 };
-#endif
+
+} // namespace mozilla
+
+#endif // mozilla_EventListenerService_h_
--- a/dom/events/moz.build
+++ b/dom/events/moz.build
@@ -72,32 +72,32 @@ UNIFIED_SOURCES += [
     'CommandEvent.cpp',
     'CompositionEvent.cpp',
     'ContentEventHandler.cpp',
     'DataContainerEvent.cpp',
     'DataTransfer.cpp',
     'DeviceMotionEvent.cpp',
     'DragEvent.cpp',
     'Event.cpp',
+    'EventListenerService.cpp',
     'EventTarget.cpp',
     'FocusEvent.cpp',
     'IMEContentObserver.cpp',
     'IMEStateManager.cpp',
     'KeyboardEvent.cpp',
     'MessageEvent.cpp',
     'MouseEvent.cpp',
     'MouseScrollEvent.cpp',
     'MutationEvent.cpp',
     'NotifyAudioAvailableEvent.cpp',
     'NotifyPaintEvent.cpp',
     'nsAsyncDOMEvent.cpp',
     'nsDOMEventTargetHelper.cpp',
     'nsEventDispatcher.cpp',
     'nsEventListenerManager.cpp',
-    'nsEventListenerService.cpp',
     'nsJSEventListener.cpp',
     'nsPaintRequest.cpp',
     'PointerEvent.cpp',
     'ScrollAreaEvent.cpp',
     'SimpleGestureEvent.cpp',
     'TextComposition.cpp',
     'Touch.cpp',
     'TouchEvent.cpp',
--- a/dom/events/nsEventListenerManager.cpp
+++ b/dom/events/nsEventListenerManager.cpp
@@ -28,17 +28,17 @@
 #include "nsIDocument.h"
 #include "mozilla/InternalMutationEvent.h"
 #include "nsIXPConnect.h"
 #include "nsDOMCID.h"
 #include "nsContentUtils.h"
 #include "nsJSUtils.h"
 #include "nsEventDispatcher.h"
 #include "nsCOMArray.h"
-#include "nsEventListenerService.h"
+#include "EventListenerService.h"
 #include "nsIContentSecurityPolicy.h"
 #include "xpcpublic.h"
 #include "nsSandboxFlags.h"
 #include "mozilla/dom/Element.h"
 #include "mozilla/dom/BindingUtils.h"
 
 using namespace mozilla;
 using namespace mozilla::dom;
@@ -1185,21 +1185,21 @@ nsEventListenerManager::GetListenerInfo(
     nsAutoString eventType;
     if (ls.mAllEvents) {
       eventType.SetIsVoid(true);
     } else {
       eventType.Assign(Substring(nsDependentAtomString(ls.mTypeAtom), 2));
     }
     // EventListenerInfo is defined in XPCOM, so we have to go ahead
     // and convert to an XPCOM callback here...
-    nsRefPtr<nsEventListenerInfo> info =
-      new nsEventListenerInfo(eventType, ls.mListener.ToXPCOMCallback(),
-                              ls.mFlags.mCapture,
-                              ls.mFlags.mAllowUntrustedEvents,
-                              ls.mFlags.mInSystemGroup);
+    nsRefPtr<EventListenerInfo> info =
+      new EventListenerInfo(eventType, ls.mListener.ToXPCOMCallback(),
+                            ls.mFlags.mCapture,
+                            ls.mFlags.mAllowUntrustedEvents,
+                            ls.mFlags.mInSystemGroup);
     aList->AppendObject(info);
   }
   return NS_OK;
 }
 
 bool
 nsEventListenerManager::HasUnloadListeners()
 {