if (content) { nsCOMPtr<nsIDOMEventTarget> receiver(do_QueryInterface(content)); if (receiver) { nsCOMPtr<nsIDOMContextMenuListener> cxMenuListener; QueryInterface(NS_GET_IID(nsIDOMContextMenuListener), getter_AddRefs(cxMenuListener)); if (cxMenuListener) { receiver->AddEventListener(NS_LITERAL_STRING("contextmenu"), cxMenuListener, PR_TRUE); return NS_OK; } }
mCXMenuListener = new nsPluginDOMContextMenuListener(); if (mCXMenuListener) { NS_ADDREF(mCXMenuListener); mCXMenuListener->Init(aFrame);
nsresult nsPluginDOMContextMenuListener::Init(nsObjectFrame *aFrame){  nsIContent* content = aFrame->GetContent();  // Register context menu listener  if (content) {    nsCOMPtr<nsIDOMEventTarget> receiver(do_QueryInterface(content));    if (receiver) {      nsCOMPtr<nsIDOMContextMenuListener> cxMenuListener;      QueryInterface(NS_GET_IID(nsIDOMContextMenuListener), getter_AddRefs(cxMenuListener));      if (cxMenuListener) {        receiver->AddEventListener(NS_LITERAL_STRING("contextmenu"), cxMenuListener, PR_TRUE);        return NS_OK;      }    }  }  return NS_ERROR_NO_INTERFACE;}