Bug 821850 - Pass nsXBLBinding instead of nsIContent during implementation installation. r=bz
authorBobby Holley <bobbyholley@gmail.com>
Fri, 08 Feb 2013 14:24:20 +0000
changeset 131185 34bc18d21cc556dd8b2033f59f7da21111cbf539
parent 131184 dd78d9d83bddc2405437c78d905f94cdf06dd147
child 131186 bbad14489645eef304dd338dde264388d782d5f0
push id2323
push userbbajaj@mozilla.com
push dateMon, 01 Apr 2013 19:47:02 +0000
treeherdermozilla-beta@7712be144d91 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbz
bugs821850
milestone21.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 821850 - Pass nsXBLBinding instead of nsIContent during implementation installation. r=bz This lets us hook up the binding to the JSClass.
content/xbl/src/nsXBLBinding.cpp
content/xbl/src/nsXBLProtoImpl.cpp
content/xbl/src/nsXBLProtoImpl.h
content/xbl/src/nsXBLPrototypeBinding.cpp
content/xbl/src/nsXBLPrototypeBinding.h
--- a/content/xbl/src/nsXBLBinding.cpp
+++ b/content/xbl/src/nsXBLBinding.cpp
@@ -1064,17 +1064,17 @@ nsXBLBinding::InstallImplementation()
 
   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(mBoundElement);
+    return mPrototypeBinding->InstallImplementation(this);
 
   return NS_OK;
 }
 
 nsIAtom*
 nsXBLBinding::GetBaseTag(int32_t* aNameSpaceID)
 {
   nsIAtom *tag = mPrototypeBinding->GetBaseTag(aNameSpaceID);
--- a/content/xbl/src/nsXBLProtoImpl.cpp
+++ b/content/xbl/src/nsXBLProtoImpl.cpp
@@ -37,57 +37,59 @@ public:
 #ifdef DEBUG
     JSVersion versionAfter = JS_GetVersion(cx);
     NS_ABORT_IF_FALSE(versionAfter == versionBefore, "version must not change");
 #endif
   }
 };
 
 nsresult
-nsXBLProtoImpl::InstallImplementation(nsXBLPrototypeBinding* aBinding, nsIContent* aBoundElement)
+nsXBLProtoImpl::InstallImplementation(nsXBLPrototypeBinding* aPrototypeBinding,
+                                      nsXBLBinding* aBinding)
 {
   // This function is called to install a concrete implementation on a bound element using
   // this prototype implementation as a guide.  The prototype implementation is compiled lazily,
   // so for the first bound element that needs a concrete implementation, we also build the
   // prototype implementation.
   if (!mMembers && !mFields)  // Constructor and destructor also live in mMembers
     return NS_OK; // Nothing to do, so let's not waste time.
 
   // If the way this gets the script context changes, fix
   // nsXBLProtoImplAnonymousMethod::Execute
-  nsIDocument* document = aBoundElement->OwnerDoc();
+  nsIDocument* document = aBinding->GetBoundElement()->OwnerDoc();
                                               
   nsIScriptGlobalObject *global = document->GetScopeObject();
   if (!global) return NS_OK;
 
   nsCOMPtr<nsIScriptContext> context = global->GetContext();
   if (!context) return NS_OK;
 
   // InitTarget objects gives us back the JS object that represents the bound element and the
   // class object in the bound document that represents the concrete version of this implementation.
   // This function also has the side effect of building up the prototype implementation if it has
   // not been built already.
   nsCOMPtr<nsIXPConnectJSObjectHolder> holder;
   JSObject* targetClassObject = nullptr;
-  nsresult rv = InitTargetObjects(aBinding, context, aBoundElement,
+  nsresult rv = InitTargetObjects(aPrototypeBinding, context,
+                                  aBinding->GetBoundElement(),
                                   getter_AddRefs(holder), &targetClassObject);
   NS_ENSURE_SUCCESS(rv, rv); // kick out if we were unable to properly intialize our target objects
 
   JSObject * targetScriptObject;
   holder->GetJSObject(&targetScriptObject);
 
   JSContext *cx = context->GetNativeContext();
 
   AutoVersionChecker avc(cx);
   
   // Walk our member list and install each one in turn.
   for (nsXBLProtoImplMember* curr = mMembers;
        curr;
        curr = curr->GetNext())
-    curr->InstallMember(context, aBoundElement, targetScriptObject,
+    curr->InstallMember(context, aBinding->GetBoundElement(), targetScriptObject,
                         targetClassObject, mClassName);
 
   return NS_OK;
 }
 
 nsresult 
 nsXBLProtoImpl::InitTargetObjects(nsXBLPrototypeBinding* aBinding,
                                   nsIScriptContext* aContext, 
--- a/content/xbl/src/nsXBLProtoImpl.h
+++ b/content/xbl/src/nsXBLProtoImpl.h
@@ -5,16 +5,17 @@
 
 #ifndef nsXBLProtoImpl_h__
 #define nsXBLProtoImpl_h__
 
 #include "nsMemory.h"
 #include "nsXBLPrototypeHandler.h"
 #include "nsXBLProtoImplMember.h"
 #include "nsXBLProtoImplField.h"
+#include "nsXBLBinding.h"
 
 class nsIXPConnectJSObjectHolder;
 class nsXBLPrototypeBinding;
 class nsXBLProtoImplAnonymousMethod;
 
 class nsXBLProtoImpl
 {
 public:
@@ -31,17 +32,17 @@ public:
   { 
     MOZ_COUNT_DTOR(nsXBLProtoImpl);
     // Note: the constructor and destructor are in mMembers, so we'll
     // clean them up automatically.
     delete mMembers;
     delete mFields;
   }
   
-  nsresult InstallImplementation(nsXBLPrototypeBinding* aBinding, nsIContent* aBoundElement);
+  nsresult InstallImplementation(nsXBLPrototypeBinding* aPrototypeBinding, nsXBLBinding* aBinding);
   nsresult InitTargetObjects(nsXBLPrototypeBinding* aBinding, nsIScriptContext* aContext, 
                              nsIContent* aBoundElement, 
                              nsIXPConnectJSObjectHolder** aScriptObjectHolder,
                              JSObject** aTargetClassObject);
   nsresult CompilePrototypeMembers(nsXBLPrototypeBinding* aBinding);
 
   void SetMemberList(nsXBLProtoImplMember* aMemberList)
   {
--- a/content/xbl/src/nsXBLPrototypeBinding.cpp
+++ b/content/xbl/src/nsXBLPrototypeBinding.cpp
@@ -536,20 +536,20 @@ nsXBLPrototypeBinding::SetDestructor(nsX
 {
   if (!mImplementation)
     return NS_ERROR_FAILURE;
   mImplementation->mDestructor = aMethod;
   return NS_OK;
 }
 
 nsresult
-nsXBLPrototypeBinding::InstallImplementation(nsIContent* aBoundElement)
+nsXBLPrototypeBinding::InstallImplementation(nsXBLBinding* aBinding)
 {
   if (mImplementation)
-    return mImplementation->InstallImplementation(this, aBoundElement);
+    return mImplementation->InstallImplementation(this, aBinding);
   return NS_OK;
 }
 
 // XXXbz this duplicates lots of SetAttrs
 void
 nsXBLPrototypeBinding::AttributeChanged(nsIAtom* aAttribute,
                                         int32_t aNameSpaceID,
                                         bool aRemoveFlag, 
--- a/content/xbl/src/nsXBLPrototypeBinding.h
+++ b/content/xbl/src/nsXBLPrototypeBinding.h
@@ -121,17 +121,17 @@ public:
 
   nsresult InitClass(const nsCString& aClassName, JSContext * aContext,
                      JSObject * aGlobal, JSObject * aScriptObject,
                      JSObject** aClassObject);
 
   nsresult ConstructInterfaceTable(const nsAString& aImpls);
   
   void SetImplementation(nsXBLProtoImpl* aImpl) { mImplementation = aImpl; }
-  nsresult InstallImplementation(nsIContent* aBoundElement);
+  nsresult InstallImplementation(nsXBLBinding* aBinding);
   bool HasImplementation() const { return mImplementation != nullptr; }
 
   void AttributeChanged(nsIAtom* aAttribute, int32_t aNameSpaceID,
                         bool aRemoveFlag, nsIContent* aChangedElement,
                         nsIContent* aAnonymousContent, bool aNotify);
 
   void SetBasePrototype(nsXBLPrototypeBinding* aBinding);
   nsXBLPrototypeBinding* GetBasePrototype() { return mBaseBinding; }