author Dave Townsend <>
Sun, 13 Jan 2019 17:44:29 -0800
changeset 453676 edca8877b0505cd1c31beaf6d907ca32e022aa52
parent 448947 6f3709b3878117466168c40affa7bca0b60cf75b
permissions -rw-r--r--
Backing out Bug 1518799 (changeset eace4709948c) because the target page is not yet available. a=backout

/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at */

 * This is the popup listener implementation for popup menus and context menus.

#ifndef nsXULPopupListener_h___
#define nsXULPopupListener_h___

#include "nsCOMPtr.h"

#include "mozilla/dom/Element.h"
#include "nsIDOMEventListener.h"
#include "nsCycleCollectionParticipant.h"

namespace mozilla {
namespace dom {
class MouseEvent;
}  // namespace dom
}  // namespace mozilla

class nsXULPopupListener : public nsIDOMEventListener {
  // aElement is the element that the popup is attached to. If aIsContext is
  // false, the popup opens on left click on aElement or a descendant. If
  // aIsContext is true, the popup is a context menu which opens on a
  // context menu event.
  nsXULPopupListener(mozilla::dom::Element* aElement, bool aIsContext);

  // nsISupports

  virtual ~nsXULPopupListener(void);

  // open the popup. aEvent is the event that triggered the popup such as
  // a mouse click and aTargetContent is the target of this event.
  virtual nsresult LaunchPopup(mozilla::dom::MouseEvent* aEvent);

  // close the popup when the listener goes away
  virtual void ClosePopup();

  // When a context menu is opened, focus the target of the contextmenu event.
  nsresult FireFocusOnTargetContent(nsIContent* aTargetContent, bool aIsTouch);

  // |mElement| is the node to which this listener is attached.
  RefPtr<mozilla::dom::Element> mElement;

  // The popup that is getting shown on top of mElement.
  RefPtr<mozilla::dom::Element> mPopupContent;

  // true if a context popup
  bool mIsContext;

#endif  // nsXULPopupListener_h___