NS_RELEASE(handler); } else {  nsAutoString value; child->GetAttribute(kNameSpaceID_None, kValueAtom, value); AddScriptEventListener(mBoundElement, eventAtom, value, iid); }
nsXBLEventHandler* handler = nsnull;  nsAutoString type; eventAtom->ToString(type);   if (iid.Equals(NS_GET_IID(nsIDOMMouseListener))) { nsXBLMouseHandler* mouseHandler; NS_NewXBLMouseHandler(receiver, curr, &mouseHandler); receiver->AddEventListener(type, (nsIDOMMouseListener*)mouseHandler, useCapture); handler = mouseHandler; } else if(iid.Equals(NS_GET_IID(nsIDOMKeyListener))) { nsXBLKeyHandler* keyHandler; NS_NewXBLKeyHandler(receiver, curr, &keyHandler); receiver->AddEventListener(type, (nsIDOMKeyListener*)keyHandler, useCapture); handler = keyHandler; } else if (iid.Equals(NS_GET_IID(nsIDOMMouseMotionListener))) { nsXBLMouseMotionHandler* mouseHandler; NS_NewXBLMouseMotionHandler(receiver, curr, &mouseHandler); receiver->AddEventListener(type, (nsIDOMMouseListener*)mouseHandler, useCapture); handler = mouseHandler; } else if(iid.Equals(NS_GET_IID(nsIDOMFocusListener))) { nsXBLFocusHandler* focusHandler; NS_NewXBLFocusHandler(receiver, curr, &focusHandler); receiver->AddEventListener(type, (nsIDOMFocusListener*)focusHandler, useCapture); handler = focusHandler; } else if (iid.Equals(NS_GET_IID(nsIDOMXULListener))) { nsXBLXULHandler* xulHandler; NS_NewXBLXULHandler(receiver, curr, &xulHandler); receiver->AddEventListener(type, (nsIDOMXULListener*)xulHandler, useCapture); handler = xulHandler; } else if (iid.Equals(NS_GET_IID(nsIDOMScrollListener))) { nsXBLScrollHandler* scrollHandler; NS_NewXBLScrollHandler(receiver, curr, &scrollHandler); receiver->AddEventListener(type, (nsIDOMScrollListener*)scrollHandler, useCapture); handler = scrollHandler; } else if (iid.Equals(NS_GET_IID(nsIDOMFormListener))) { nsXBLFormHandler* formHandler; NS_NewXBLFormHandler(receiver, curr, &formHandler); receiver->AddEventListener(type, (nsIDOMFormListener*)formHandler, useCapture); handler = formHandler; } else if(iid.Equals(NS_GET_IID(nsIDOMDragListener))) { nsXBLDragHandler* dragHandler; NS_NewXBLDragHandler(receiver, curr, &dragHandler); receiver->AddEventListener(type, (nsIDOMDragListener*)dragHandler, useCapture); handler = dragHandler; } else if(iid.Equals(NS_GET_IID(nsIDOMLoadListener))) { nsXBLLoadHandler* loadHandler; NS_NewXBLLoadHandler(receiver, curr, &loadHandler); receiver->AddEventListener(type, (nsIDOMLoadListener*)loadHandler, useCapture); handler = loadHandler; } else if(iid.Equals(NS_GET_IID(nsIDOMMutationListener))) { nsXBLMutationHandler* mutationHandler; NS_NewXBLMutationHandler(receiver, curr, &mutationHandler); receiver->AddEventListener(type, (nsIDOMMutationListener*)mutationHandler, useCapture); handler = mutationHandler; } else if(iid.Equals(NS_GET_IID(nsIDOMContextMenuListener))) { nsXBLContextMenuHandler* menuHandler; NS_NewXBLContextMenuHandler(receiver, curr, &menuHandler); receiver->AddEventListener(type, (nsIDOMContextMenuListener*)menuHandler, useCapture); handler = menuHandler; } else { NS_WARNING("***** Non-compliant XBL event listener attached! *****"); nsAutoString value; child->GetAttr(kNameSpaceID_None, kActionAtom, value); if (value.IsEmpty()) GetTextData(child, value); AddScriptEventListener(mBoundElement, eventAtom, value); }    if (handler) { if (!currHandler) mFirstHandler = handler; else currHandler->SetNextHandler(handler);  currHandler = handler;   NS_RELEASE(handler);
nsXBLBinding::InstallEventHandlers(nsIContent* aBoundElement){  // Fetch the handlers element for this binding.  nsCOMPtr<nsIContent> handlers;  GetImmediateChild(kHandlersAtom, getter_AddRefs(handlers));  if (handlers) {    // Now walk the handlers and add event listeners to the bound    // element.    PRInt32 childCount;    handlers->ChildCount(childCount);    for (PRInt32 i = 0; i < childCount; i++) {      nsCOMPtr<nsIContent> child;      handlers->ChildAt(i, *getter_AddRefs(child));      // Fetch the type attribute.      // XXX Deal with a comma-separated list of types      nsAutoString type;      child->GetAttribute(kNameSpaceID_None, kTypeAtom, type);          if (!type.IsEmpty()) {        nsCOMPtr<nsIAtom> eventAtom = getter_AddRefs(NS_NewAtom(type));        PRBool found = PR_FALSE;        nsIID iid;        GetEventHandlerIID(eventAtom, &iid, &found);        if (found) {          // Add an event listener for mouse and key events only.          PRBool mouse = IsMouseHandler(type);          PRBool key = IsKeyHandler(type);          PRBool xul = IsXULHandler(type);          nsCOMPtr<nsIDOMEventReceiver> receiver = do_QueryInterface(mBoundElement);                      if (mouse || key || xul) {            // Create a new nsXBLEventHandler.            nsXBLEventHandler* handler;            NS_NewXBLEventHandler(mBoundElement, child, type, &handler);            // Figure out if we're using capturing or not.            PRBool useCapture = PR_FALSE;            nsAutoString capturer;            child->GetAttribute(kNameSpaceID_None, kCapturerAtom, capturer);            if (capturer.Equals("true"))              useCapture = PR_TRUE;            // Add the event listener.            if (mouse)              receiver->AddEventListener(type, (nsIDOMMouseListener*)handler, useCapture);            else if(key)              receiver->AddEventListener(type, (nsIDOMKeyListener*)handler, useCapture);            else              receiver->AddEventListener(type, (nsIDOMMenuListener*)handler, useCapture);            NS_RELEASE(handler);          }          else {            // Call AddScriptEventListener for other IID types            nsAutoString value;            child->GetAttribute(kNameSpaceID_None, kValueAtom, value);            AddScriptEventListener(mBoundElement, eventAtom, value, iid);          }        }      }    }  }  if (mNextBinding)    mNextBinding->InstallEventHandlers(aBoundElement);  return NS_OK;}