nsString tagName; GetTagName(tagName); if (tagName == "menu" || tagName == "menuitem" || tagName == "menubar") { nsCOMPtr<nsIEventListenerManager> listenerManager; if (NS_FAILED(ret = GetListenerManager(getter_AddRefs(listenerManager)))) { NS_ERROR("Unable to instantiate a listener manager on a menu event."); return ret; } if (NS_FAILED(ret = listenerManager->CreateEvent(aPresContext, aEvent, aDOMEvent))) { NS_ERROR("Menu event will fail without the ability to create the event early."); return ret; } domEvent->SetTarget(this); }
RDFElementImpl::HandleDOMEvent(nsIPresContext& aPresContext,                                       nsEvent* aEvent,                                       nsIDOMEvent** aDOMEvent,                                       PRUint32 aFlags,                                       nsEventStatus& aEventStatus){    nsresult ret = NS_OK;      nsIDOMEvent* domEvent = nsnull;    if (DOM_EVENT_INIT == aFlags) {        aDOMEvent = &domEvent;    }      //Capturing stage      //Local handling stage    if (nsnull != mListenerManager) {        mListenerManager->HandleEvent(aPresContext, aEvent, aDOMEvent, aEventStatus);    }    //Bubbling stage    if ((DOM_EVENT_CAPTURE != aFlags) && (mParent != nsnull)) {        ret = mParent->HandleDOMEvent(aPresContext, aEvent, aDOMEvent,                                      DOM_EVENT_BUBBLE, aEventStatus);    }    if (DOM_EVENT_INIT == aFlags) {        // We're leaving the DOM event loop so if we created a DOM event,        // release here.        if (nsnull != *aDOMEvent) {            nsrefcnt rc;            NS_RELEASE2(*aDOMEvent, rc);            if (0 != rc) {                // Okay, so someone in the DOM loop (a listener, JS object)                // still has a ref to the DOM Event but the internal data                // hasn't been malloc'd.  Force a copy of the data here so the                // DOM Event is still valid.                nsIPrivateDOMEvent *privateEvent;                if (NS_OK == (*aDOMEvent)->QueryInterface(kIPrivateDOMEventIID, (void**)&privateEvent)) {                    privateEvent->DuplicatePrivateData();                    NS_RELEASE(privateEvent);                }            }        }        aDOMEvent = nsnull;    }    return ret;}