Bug 961490 - More exact rooting in nsEventListenerService. r=terrence,smaug
authorTom Schuster <evilpies@gmail.com>
Thu, 23 Jan 2014 20:49:40 +0100
changeset 180960 7c3b5796373b70ce075ac8a3587ff0822e69282e
parent 180959 7095fa5eeb21aec93854228ea6a95f4423348fc4
child 180961 2a93f0989941b661802123666a4d927c0b62ef48
push id3343
push userffxbld
push dateMon, 17 Mar 2014 21:55:32 +0000
treeherdermozilla-beta@2f7d3415f79f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersterrence, smaug
bugs961490
milestone29.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 961490 - More exact rooting in nsEventListenerService. r=terrence,smaug
dom/events/nsEventListenerService.cpp
dom/events/nsEventListenerService.h
--- a/dom/events/nsEventListenerService.cpp
+++ b/dom/events/nsEventListenerService.cpp
@@ -64,61 +64,60 @@ nsEventListenerInfo::GetInSystemEventGro
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsEventListenerInfo::GetListenerObject(JSContext* aCx,
                                        JS::MutableHandle<JS::Value> aObject)
 {
   mozilla::Maybe<JSAutoCompartment> ac;
-  GetJSVal(aCx, ac, aObject.address());
+  GetJSVal(aCx, ac, aObject);
   return NS_OK;
 }
 
 NS_IMPL_ISUPPORTS1(nsEventListenerService, nsIEventListenerService)
 
-// Caller must root *aJSVal!
 bool
 nsEventListenerInfo::GetJSVal(JSContext* aCx,
                               mozilla::Maybe<JSAutoCompartment>& aAc,
-                              JS::Value* aJSVal)
+                              JS::MutableHandle<JS::Value> aJSVal)
 {
-  *aJSVal = JSVAL_NULL;
+  aJSVal.setNull();
   nsCOMPtr<nsIXPConnectWrappedJS> wrappedJS = do_QueryInterface(mListener);
   if (wrappedJS) {
     JS::Rooted<JSObject*> object(aCx, wrappedJS->GetJSObject());
     if (!object) {
       return false;
     }
     aAc.construct(aCx, object);
-    *aJSVal = OBJECT_TO_JSVAL(object);
+    aJSVal.setObject(*object);
     return true;
   }
 
   nsCOMPtr<nsIJSEventListener> jsl = do_QueryInterface(mListener);
   if (jsl && jsl->GetHandler().HasEventHandler()) {
     JS::Handle<JSObject*> handler(jsl->GetHandler().Ptr()->Callable());
     if (handler) {
       aAc.construct(aCx, handler);
-      *aJSVal = OBJECT_TO_JSVAL(handler);
+      aJSVal.setObject(*handler);
       return true;
     }
   }
   return false;
 }
 
 NS_IMETHODIMP
 nsEventListenerInfo::ToSource(nsAString& aResult)
 {
   aResult.SetIsVoid(true);
 
   AutoSafeJSContext cx;
   mozilla::Maybe<JSAutoCompartment> ac;
-  JS::Rooted<JS::Value> v(cx, JSVAL_NULL);
-  if (GetJSVal(cx, ac, v.address())) {
+  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);
       }
     }
   }
@@ -137,18 +136,18 @@ nsEventListenerInfo::GetDebugObject(nsIS
   NS_ENSURE_SUCCESS(rv, NS_OK);
 
   bool isOn = false;
   jsd->GetIsOn(&isOn);
   NS_ENSURE_TRUE(isOn, NS_OK);
 
   AutoSafeJSContext cx;
   mozilla::Maybe<JSAutoCompartment> ac;
-  JS::Rooted<JS::Value> v(cx, JSVAL_NULL);
-  if (GetJSVal(cx, ac, v.address())) {
+  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;
--- a/dom/events/nsEventListenerService.h
+++ b/dom/events/nsEventListenerService.h
@@ -29,17 +29,17 @@ public:
     mAllowsUntrusted(aAllowsUntrusted),
     mInSystemEventGroup(aInSystemEventGroup) {}
   virtual ~nsEventListenerInfo() {}
   NS_DECL_CYCLE_COLLECTING_ISUPPORTS
   NS_DECL_CYCLE_COLLECTION_CLASS(nsEventListenerInfo)
   NS_DECL_NSIEVENTLISTENERINFO
 protected:
   bool GetJSVal(JSContext* aCx, mozilla::Maybe<JSAutoCompartment>& aAc,
-                JS::Value* aJSVal);
+                JS::MutableHandle<JS::Value> aJSVal);
 
   nsString                      mType;
   // nsReftPtr because that is what nsListenerStruct uses too.
   nsRefPtr<nsIDOMEventListener> mListener;
   bool                          mCapturing;
   bool                          mAllowsUntrusted;
   bool                          mInSystemEventGroup;
 };