list = item.next;
nsBindingManager::GetBindingImplementation(nsIContent* aContent, REFNSIID aIID,                                           void** aResult){  *aResult = nsnull;  nsCOMPtr<nsIXBLBinding> binding;  GetBinding(aContent, getter_AddRefs(binding));  if (binding) {    PRBool supportsInterface;    binding->ImplementsInterface(aIID, &supportsInterface);    if (supportsInterface) {      nsCOMPtr<nsIXPConnectWrappedJS> wrappedJS;      GetWrappedJS(aContent, getter_AddRefs(wrappedJS));      if (wrappedJS) {        nsresult rv = wrappedJS->AggregatedQueryInterface(aIID, aResult);        if (*aResult)          return rv;                // No result was found, so this must be another XBL interface.        // Fall through to create a new wrapper.      }      // We have never made a wrapper for this implementation.      // Create an XPC wrapper for the script object and hand it back.      nsCOMPtr<nsIDocument> doc;      aContent->GetDocument(*getter_AddRefs(doc));      if (!doc)        return NS_NOINTERFACE;      nsCOMPtr<nsIScriptGlobalObject> global;      doc->GetScriptGlobalObject(getter_AddRefs(global));      if (!global)        return NS_NOINTERFACE;      nsCOMPtr<nsIScriptContext> context;      global->GetContext(getter_AddRefs(context));      if (!context)        return NS_NOINTERFACE;      JSContext* jscontext = (JSContext*)context->GetNativeContext();      if (!jscontext)        return NS_NOINTERFACE;      nsCOMPtr<nsIXPConnect> xpConnect = do_GetService("@mozilla.org/js/xpc/XPConnect;1");      if (!xpConnect)        return NS_NOINTERFACE;      nsCOMPtr<nsIXPConnectWrappedNative> wrapper;      xpConnect->GetWrappedNativeOfNativeObject(jscontext,                                                JS_GetGlobalObject(jscontext),                                                aContent,                                                NS_GET_IID(nsISupports),                                                getter_AddRefs(wrapper));      NS_ENSURE_TRUE(wrapper, NS_NOINTERFACE);      JSObject* jsobj = nsnull;      wrapper->GetJSObject(&jsobj);      NS_ENSURE_TRUE(jsobj, NS_NOINTERFACE);      nsresult rv = xpConnect->WrapJSAggregatedToNative(aContent, jscontext,                                                        jsobj, aIID, aResult);      if (NS_FAILED(rv))        return rv;      // We successfully created a wrapper.  We will own this wrapper for as long as the binding remains      // alive.  At the time the binding is cleared out of the bindingManager, we will remove the wrapper      // from the bindingManager as well.      nsISupports* supp = NS_STATIC_CAST(nsISupports*, *aResult);      wrappedJS = do_QueryInterface(supp);      SetWrappedJS(aContent, wrappedJS);      return rv;    }  }    *aResult = nsnull;  return NS_NOINTERFACE;}