Bug 855411 - Root various things. r=bz,terrence
authorTom Schuster <evilpies@gmail.com>
Fri, 05 Apr 2013 15:21:03 +0200
changeset 127831 aee8610885274e97901696193c40ceba8c3e70e2
parent 127830 1766922c611f729467f667de29447dad896e9978
child 127832 969674821d1ae13ccf3e7b7a4fe995f2f98dcb62
push id24512
push userryanvm@gmail.com
push dateFri, 05 Apr 2013 20:13:49 +0000
treeherderautoland@139b6ba547fa [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbz, terrence
bugs855411
milestone23.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 855411 - Root various things. r=bz,terrence
content/xbl/src/nsXBLBinding.cpp
content/xbl/src/nsXBLBinding.h
content/xbl/src/nsXBLProtoImpl.cpp
content/xbl/src/nsXBLProtoImpl.h
content/xbl/src/nsXBLPrototypeBinding.h
--- a/content/xbl/src/nsXBLBinding.cpp
+++ b/content/xbl/src/nsXBLBinding.cpp
@@ -789,17 +789,17 @@ nsXBLBinding::InstallImplementation()
 {
   // Always install the base class properties first, so that
   // derived classes can reference the base class properties.
 
   if (mNextBinding) {
     nsresult rv = mNextBinding->InstallImplementation();
     NS_ENSURE_SUCCESS(rv, rv);
   }
-  
+
   // iterate through each property in the prototype's list and install the property.
   if (AllowScripts())
     return mPrototypeBinding->InstallImplementation(this);
 
   return NS_OK;
 }
 
 nsIAtom*
@@ -1392,17 +1392,17 @@ nsXBLBinding::GetFirstStyleBinding()
 {
   if (mIsStyleBinding)
     return this;
 
   return mNextBinding ? mNextBinding->GetFirstStyleBinding() : nullptr;
 }
 
 bool
-nsXBLBinding::ResolveAllFields(JSContext *cx, JSObject *obj) const
+nsXBLBinding::ResolveAllFields(JSContext *cx, JS::Handle<JSObject*> obj) const
 {
   if (!mPrototypeBinding->ResolveAllFields(cx, obj)) {
     return false;
   }
 
   if (mNextBinding) {
     return mNextBinding->ResolveAllFields(cx, obj);
   }
--- a/content/xbl/src/nsXBLBinding.h
+++ b/content/xbl/src/nsXBLBinding.h
@@ -113,17 +113,17 @@ public:
   void UnhookEventHandlers();
 
   nsIAtom* GetBaseTag(int32_t* aNameSpaceID);
   nsXBLBinding* RootBinding();
   nsXBLBinding* GetFirstStyleBinding();
 
   // Resolve all the fields for this binding and all ancestor bindings on the
   // object |obj|.  False return means a JS exception was set.
-  bool ResolveAllFields(JSContext *cx, JSObject *obj) const;
+  bool ResolveAllFields(JSContext *cx, JS::Handle<JSObject*> obj) const;
 
   // Get the list of insertion points for aParent. The nsInsertionPointList
   // is owned by the binding, you should not delete it.
   void GetInsertionPointsFor(nsIContent* aParent,
                              nsInsertionPointList** aResult);
 
   nsInsertionPointList* GetExistingInsertionPointsFor(nsIContent* aParent);
 
--- a/content/xbl/src/nsXBLProtoImpl.cpp
+++ b/content/xbl/src/nsXBLProtoImpl.cpp
@@ -142,17 +142,17 @@ nsXBLProtoImpl::InstallImplementation(ns
   return NS_OK;
 }
 
 nsresult 
 nsXBLProtoImpl::InitTargetObjects(nsXBLPrototypeBinding* aBinding,
                                   nsIScriptContext* aContext, 
                                   nsIContent* aBoundElement, 
                                   nsIXPConnectJSObjectHolder** aScriptObjectHolder, 
-                                  JSObject** aTargetClassObject,
+                                  JS::MutableHandle<JSObject*> aTargetClassObject,
                                   bool* aTargetIsNew)
 {
   nsresult rv = NS_OK;
   *aScriptObjectHolder = nullptr;
   
   if (!mClassObject) {
     rv = CompilePrototypeMembers(aBinding); // This is the first time we've ever installed this binding on an element.
                                  // We need to go ahead and compile all methods and properties on a class
@@ -176,30 +176,26 @@ nsXBLProtoImpl::InitTargetObjects(nsXBLP
   JS::Rooted<JSObject*> global(cx, sgo->GetGlobalJSObject());
   nsCOMPtr<nsIXPConnectJSObjectHolder> wrapper;
   JS::Value v;
   rv = nsContentUtils::WrapNative(cx, global, aBoundElement, &v,
                                   getter_AddRefs(wrapper));
   NS_ENSURE_SUCCESS(rv, rv);
 
   JS::Rooted<JSObject*> value(cx, &v.toObject());
-  JS::Rooted<JSObject*> targetClassObject(cx, *aTargetClassObject);
 
   // All of the above code was just obtaining the bound element's script object and its immediate
   // concrete base class.  We need to alter the object so that our concrete class is interposed
   // between the object and its base class.  We become the new base class of the object, and the
   // object's old base class becomes the new class' base class.
-  rv = aBinding->InitClass(mClassName, cx, global, value,
-                           &targetClassObject, aTargetIsNew);
+  rv = aBinding->InitClass(mClassName, cx, global, value, aTargetClassObject, aTargetIsNew);
   if (NS_FAILED(rv)) {
     return rv;
   }
 
-  *aTargetClassObject = targetClassObject;
-
   nsContentUtils::PreserveWrapper(aBoundElement, aBoundElement);
 
   wrapper.swap(*aScriptObjectHolder);
   
   return rv;
 }
 
 nsresult
@@ -294,48 +290,48 @@ nsXBLProtoImpl::FindField(const nsString
       return f;
     }
   }
 
   return nullptr;
 }
 
 bool
-nsXBLProtoImpl::ResolveAllFields(JSContext *cx, JSObject *obj) const
+nsXBLProtoImpl::ResolveAllFields(JSContext *cx, JS::Handle<JSObject*> obj) const
 {
   AutoVersionChecker avc(cx);
   for (nsXBLProtoImplField* f = mFields; f; f = f->GetNext()) {
     // Using OBJ_LOOKUP_PROPERTY is a pain, since what we have is a
     // PRUnichar* for the property name.  Let's just use the public API and
     // all.
     nsDependentString name(f->GetName());
-    JS::Value dummy;
+    JS::Rooted<JS::Value> dummy(cx);
     if (!::JS_LookupUCProperty(cx, obj,
                                reinterpret_cast<const jschar*>(name.get()),
-                               name.Length(), &dummy)) {
+                               name.Length(), dummy.address())) {
       return false;
     }
   }
 
   return true;
 }
 
 void
-nsXBLProtoImpl::UndefineFields(JSContext *cx, JSObject *obj) const
+nsXBLProtoImpl::UndefineFields(JSContext *cx, JS::Handle<JSObject*> obj) const
 {
   JSAutoRequest ar(cx);
   for (nsXBLProtoImplField* f = mFields; f; f = f->GetNext()) {
     nsDependentString name(f->GetName());
 
     const jschar* s = reinterpret_cast<const jschar*>(name.get());
     JSBool hasProp;
     if (::JS_AlreadyHasOwnUCProperty(cx, obj, s, name.Length(), &hasProp) &&
         hasProp) {
-      JS::Value dummy;
-      ::JS_DeleteUCProperty2(cx, obj, s, name.Length(), &dummy);
+      JS::Rooted<JS::Value> dummy(cx);
+      ::JS_DeleteUCProperty2(cx, obj, s, name.Length(), dummy.address());
     }
   }
 }
 
 void
 nsXBLProtoImpl::DestroyMembers()
 {
   NS_ASSERTION(mClassObject, "This should never be called when there is no class object");
--- a/content/xbl/src/nsXBLProtoImpl.h
+++ b/content/xbl/src/nsXBLProtoImpl.h
@@ -36,17 +36,17 @@ public:
     delete mMembers;
     delete mFields;
   }
   
   nsresult InstallImplementation(nsXBLPrototypeBinding* aPrototypeBinding, nsXBLBinding* aBinding);
   nsresult InitTargetObjects(nsXBLPrototypeBinding* aBinding, nsIScriptContext* aContext, 
                              nsIContent* aBoundElement, 
                              nsIXPConnectJSObjectHolder** aScriptObjectHolder,
-                             JSObject** aTargetClassObject,
+                             JS::MutableHandle<JSObject*> aTargetClassObject,
                              bool* aTargetIsNew);
   nsresult CompilePrototypeMembers(nsXBLPrototypeBinding* aBinding);
 
   bool LookupMember(JSContext* aCx, nsString& aName, JS::HandleId aNameAsId,
                     JSPropertyDescriptor* aDesc, JSObject* aClassObject);
 
   void SetMemberList(nsXBLProtoImplMember* aMemberList)
   {
@@ -62,21 +62,21 @@ public:
 
   void Trace(TraceCallback aCallback, void *aClosure) const;
   void UnlinkJSObjects();
 
   nsXBLProtoImplField* FindField(const nsString& aFieldName) const;
 
   // Resolve all the fields for this implementation on the object |obj| False
   // return means a JS exception was set.
-  bool ResolveAllFields(JSContext *cx, JSObject *obj) const;
+  bool ResolveAllFields(JSContext *cx, JS::Handle<JSObject*> obj) const;
 
   // Undefine all our fields from object |obj| (which should be a
   // JSObject for a bound element).
-  void UndefineFields(JSContext* cx, JSObject* obj) const;
+  void UndefineFields(JSContext* cx, JS::Handle<JSObject*> obj) const;
 
   bool CompiledMembers() const {
     return mClassObject != nullptr;
   }
 
   nsresult Read(nsIScriptContext* aContext,
                 nsIObjectInputStream* aStream,
                 nsXBLPrototypeBinding* aBinding,
--- a/content/xbl/src/nsXBLPrototypeBinding.h
+++ b/content/xbl/src/nsXBLPrototypeBinding.h
@@ -96,24 +96,24 @@ public:
 
   nsXBLProtoImplField* FindField(const nsString& aFieldName) const
   {
     return mImplementation ? mImplementation->FindField(aFieldName) : nullptr;
   }
 
   // Resolve all the fields for this binding on the object |obj|.
   // False return means a JS exception was set.
-  bool ResolveAllFields(JSContext* cx, JSObject* obj) const
+  bool ResolveAllFields(JSContext* cx, JS::Handle<JSObject*> obj) const
   {
     return !mImplementation || mImplementation->ResolveAllFields(cx, obj);
   }
 
   // Undefine all our fields from object |obj| (which should be a
   // JSObject for a bound element).
-  void UndefineFields(JSContext* cx, JSObject* obj) const {
+  void UndefineFields(JSContext* cx, JS::Handle<JSObject*> obj) const {
     if (mImplementation) {
       mImplementation->UndefineFields(cx, obj);
     }
   }
 
   const nsCString& ClassName() const {
     return mImplementation ? mImplementation->mClassName : EmptyCString();
   }